diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e70df25..aaa162af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,29 @@ +- fix(禁則処理): ルビ・縦中横・傍点関連への禁則処理を修正 + - ぶら下げ領域にはみ出す場合 + - 追い出しになる場合 +- fix(文字レイヤ): クリック待ちが[tcy]の二文字目直下に行ってしまう件(safari以外) +- fix(CSS): いつの間にか Safari も縦中横(text-combine-upright)対応していたので、-webkit-text-combine(Firefox以外) の設定を削除 + - "text-combine" | Can I use... Support tables for HTML5, CSS3, etc https://caniuse.com/?search=text-combine +- test(禁則処理): ルビのテストデータ修正 + - ルビと改行状態のさまざまなケースでのテスト導入 +- test(禁則処理): 「犬神使いと少年」スクリプト+ debugHtm スイッチによりテスト + - 既知の問題:fn=ss_050 line=739 において一文字(広いルビ)がぶら下げ領域にはみ出す + ```scheme + の明治二 + ・井上圓《えん》了《りょう》 + の + ``` + - 既知の問題:以下のような「。で終わらない非ぶら下げ文字」で、ぶら下げ領域にはみ出す不具合あり。ただ通常の使用ではまずない&見た目的にそんな気にならないので保留。 + ```scheme +  こいつが無邪気なのか、強いのかは俺には分から口《☀》ビ《☂》末《⛈》[r] ;ok +  こいつが無邪気なのか、強いのかは俺には分からな口末頭。[r] ;ok +  こいつが無邪気なのか、強いのかは俺には分からな口《☀》末頭[r] ;ng +  こいつが無邪気なのか、強いのかは俺には分からな口《☀》末《☂》頭[r] ;ng +  こいつが無邪気なのか、強いのかは俺には分からな口末頭\ ;ng + ``` +- fix: リファクタリングなど + + # [1.55.0](https://github.com/famibee/SKYNovel/compare/v1.54.1...v1.55.0) (2024-06-27) diff --git a/dist/app.js b/dist/app.js index aea6df7a..6c8992b3 100644 --- a/dist/app.js +++ b/dist/app.js @@ -20881,7 +20881,7 @@ class u0 { continue; } let p = h - 1; - for (; o[p].elm.tagName === "RT"; ) --p; + o[p].elm.parentElement?.tagName === "RUBY" && --p; const { elm: v, rect: y, ch: _ } = o[p]; if (!this.break_fixed) { this.break_fixed_left = y.x, this.break_fixed_top = y.y; @@ -20936,15 +20936,15 @@ class u0 { hyph_alg(t, e, i, n, s) { if (!this.#s.test(i)) { if (this.#r.test(s)) - for (; n > 0; ) { - const { elm: o, ch: a } = t[--n]; + for (; --n >= 0; ) { + const { elm: o, ch: a } = t[n]; if (o.tagName !== "RT" && !this.#r.test(a)) break; } else if (!(i === s && this.#a.test(i))) return { cont: !0, ins: n + 1 }; } - for (n = e; n > 0; ) { - const { elm: o, ch: a } = t[--n]; + for (n = e; --n >= 0; ) { + const { elm: o, ch: a } = t[n]; if (o.tagName !== "RT" && !this.#s.test(a)) break; } @@ -20962,35 +20962,36 @@ class u0 { * @return {number} result.ins - 手前に改行を挿入すべき要素の添字 */ hyph_alg_bura(t, e, i, n) { - const s = n - 2, { ch: o } = t[s]; + const s = t[e - 1].elm.tagName === "RT" ? e - 2 : e - 1, { ch: o } = t[s]; if (this.#f.test(o) || this.#r.test(o)) { - let h = s + 1; - (this.#f.test(i) || this.#r.test(i)) && (h = e + 1); + let h = e; + (this.#f.test(i) || this.#r.test(i)) && ++h; const { ch: l } = t[h - 1], { ch: u } = t[h]; if (l === u && this.#a.test(u)) return { cont: !1, ins: h - 1 }; if (!this.#s.test(l)) return { cont: !1, ins: h }; - for (n = h - 1; n > 0; ) { - const { elm: c, ch: f } = t[--n]; + for (; --h >= 0; ) { + const { elm: c, ch: f } = t[h]; if (c.tagName !== "RT" && !this.#s.test(f)) break; } - return { cont: !1, ins: n + 1 }; + return { cont: !1, ins: h + 1 }; } - const a = n - 3; + const a = s - 1; if (n >= 3) { const { ch: h } = t[a]; if (this.#a.test(o) && h === o) return { cont: !1, ins: a }; if (this.#s.test(h)) { - for (n = a; --n > 0; ) { - const { elm: l, ch: u } = t[n]; - if (l.tagName !== "RT" && !this.#s.test(u)) + let l = a; + for (; --l >= 0; ) { + const { elm: u, ch: c } = t[l]; + if (u.tagName !== "RT" && !this.#s.test(c)) break; } - return { cont: !1, ins: n + 1 }; + return ++l, { cont: !1, ins: l }; } } - return { cont: !1, ins: n - 2 }; + return { cont: !1, ins: s }; } } class ht extends Nt { @@ -22171,9 +22172,7 @@ class ot extends jt { const { t: h, r: l = "", wait: u = null, style: c = "", r_style: f = "" } = JSON.parse(a); ot.#t.doRecLog() && (this.#it += t + (e ? `《${e}》` : ""), this.#Q += h); const d = k.isSafari ? l.replaceAll(/[A-Za-z0-9]/g, (y) => String.fromCharCode(y.charCodeAt(0) + 65248)) : l, { cl: m, sty: p, lnk: v } = this.#z(!0, u); - n = `${h}${h} -1 && length <= maxSafeInteger) {\n while (++index < length) {\n callback(object[index], index, object);\n }\n } else {\n forOwn(object, callback);\n }\n }\n\n /**\n * Trim and conditionally capitalize string values.\n *\n * @private\n * @param {string} string The string to format.\n * @returns {string} The formatted string.\n */\n function format(string) {\n string = trim(string);\n return /^(?:webOS|i(?:OS|P))/.test(string)\n ? string\n : capitalize(string);\n }\n\n /**\n * Iterates over an object's own properties, executing the `callback` for each.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} callback The function executed per own property.\n */\n function forOwn(object, callback) {\n for (var key in object) {\n if (hasOwnProperty.call(object, key)) {\n callback(object[key], key, object);\n }\n }\n }\n\n /**\n * Gets the internal `[[Class]]` of a value.\n *\n * @private\n * @param {*} value The value.\n * @returns {string} The `[[Class]]`.\n */\n function getClassOf(value) {\n return value == null\n ? capitalize(value)\n : toString.call(value).slice(8, -1);\n }\n\n /**\n * Host objects can return type values that are different from their actual\n * data type. The objects we are concerned with usually return non-primitive\n * types of \"object\", \"function\", or \"unknown\".\n *\n * @private\n * @param {*} object The owner of the property.\n * @param {string} property The property to check.\n * @returns {boolean} Returns `true` if the property value is a non-primitive, else `false`.\n */\n function isHostType(object, property) {\n var type = object != null ? typeof object[property] : 'number';\n return !/^(?:boolean|number|string|undefined)$/.test(type) &&\n (type == 'object' ? !!object[property] : true);\n }\n\n /**\n * Prepares a string for use in a `RegExp` by making hyphens and spaces optional.\n *\n * @private\n * @param {string} string The string to qualify.\n * @returns {string} The qualified string.\n */\n function qualify(string) {\n return String(string).replace(/([ -])(?!$)/g, '$1?');\n }\n\n /**\n * A bare-bones `Array#reduce` like utility function.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} callback The function called per iteration.\n * @returns {*} The accumulated result.\n */\n function reduce(array, callback) {\n var accumulator = null;\n each(array, function(value, index) {\n accumulator = callback(accumulator, value, index, array);\n });\n return accumulator;\n }\n\n /**\n * Removes leading and trailing whitespace from a string.\n *\n * @private\n * @param {string} string The string to trim.\n * @returns {string} The trimmed string.\n */\n function trim(string) {\n return String(string).replace(/^ +| +$/g, '');\n }\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * Creates a new platform object.\n *\n * @memberOf platform\n * @param {Object|string} [ua=navigator.userAgent] The user agent string or\n * context object.\n * @returns {Object} A platform object.\n */\n function parse(ua) {\n\n /** The environment context object. */\n var context = root;\n\n /** Used to flag when a custom context is provided. */\n var isCustomContext = ua && typeof ua == 'object' && getClassOf(ua) != 'String';\n\n // Juggle arguments.\n if (isCustomContext) {\n context = ua;\n ua = null;\n }\n\n /** Browser navigator object. */\n var nav = context.navigator || {};\n\n /** Browser user agent string. */\n var userAgent = nav.userAgent || '';\n\n ua || (ua = userAgent);\n\n /** Used to flag when `thisBinding` is the [ModuleScope]. */\n var isModuleScope = isCustomContext || thisBinding == oldRoot;\n\n /** Used to detect if browser is like Chrome. */\n var likeChrome = isCustomContext\n ? !!nav.likeChrome\n : /\\bChrome\\b/.test(ua) && !/internal|\\n/i.test(toString.toString());\n\n /** Internal `[[Class]]` value shortcuts. */\n var objectClass = 'Object',\n airRuntimeClass = isCustomContext ? objectClass : 'ScriptBridgingProxyObject',\n enviroClass = isCustomContext ? objectClass : 'Environment',\n javaClass = (isCustomContext && context.java) ? 'JavaPackage' : getClassOf(context.java),\n phantomClass = isCustomContext ? objectClass : 'RuntimeObject';\n\n /** Detect Java environments. */\n var java = /\\bJava/.test(javaClass) && context.java;\n\n /** Detect Rhino. */\n var rhino = java && getClassOf(context.environment) == enviroClass;\n\n /** A character to represent alpha. */\n var alpha = java ? 'a' : '\\u03b1';\n\n /** A character to represent beta. */\n var beta = java ? 'b' : '\\u03b2';\n\n /** Browser document object. */\n var doc = context.document || {};\n\n /**\n * Detect Opera browser (Presto-based).\n * http://www.howtocreate.co.uk/operaStuff/operaObject.html\n * http://dev.opera.com/articles/view/opera-mini-web-content-authoring-guidelines/#operamini\n */\n var opera = context.operamini || context.opera;\n\n /** Opera `[[Class]]`. */\n var operaClass = reOpera.test(operaClass = (isCustomContext && opera) ? opera['[[Class]]'] : getClassOf(opera))\n ? operaClass\n : (opera = null);\n\n /*------------------------------------------------------------------------*/\n\n /** Temporary variable used over the script's lifetime. */\n var data;\n\n /** The CPU architecture. */\n var arch = ua;\n\n /** Platform description array. */\n var description = [];\n\n /** Platform alpha/beta indicator. */\n var prerelease = null;\n\n /** A flag to indicate that environment features should be used to resolve the platform. */\n var useFeatures = ua == userAgent;\n\n /** The browser/environment version. */\n var version = useFeatures && opera && typeof opera.version == 'function' && opera.version();\n\n /** A flag to indicate if the OS ends with \"/ Version\" */\n var isSpecialCasedOS;\n\n /* Detectable layout engines (order is important). */\n var layout = getLayout([\n { 'label': 'EdgeHTML', 'pattern': 'Edge' },\n 'Trident',\n { 'label': 'WebKit', 'pattern': 'AppleWebKit' },\n 'iCab',\n 'Presto',\n 'NetFront',\n 'Tasman',\n 'KHTML',\n 'Gecko'\n ]);\n\n /* Detectable browser names (order is important). */\n var name = getName([\n 'Adobe AIR',\n 'Arora',\n 'Avant Browser',\n 'Breach',\n 'Camino',\n 'Electron',\n 'Epiphany',\n 'Fennec',\n 'Flock',\n 'Galeon',\n 'GreenBrowser',\n 'iCab',\n 'Iceweasel',\n 'K-Meleon',\n 'Konqueror',\n 'Lunascape',\n 'Maxthon',\n { 'label': 'Microsoft Edge', 'pattern': '(?:Edge|Edg|EdgA|EdgiOS)' },\n 'Midori',\n 'Nook Browser',\n 'PaleMoon',\n 'PhantomJS',\n 'Raven',\n 'Rekonq',\n 'RockMelt',\n { 'label': 'Samsung Internet', 'pattern': 'SamsungBrowser' },\n 'SeaMonkey',\n { 'label': 'Silk', 'pattern': '(?:Cloud9|Silk-Accelerated)' },\n 'Sleipnir',\n 'SlimBrowser',\n { 'label': 'SRWare Iron', 'pattern': 'Iron' },\n 'Sunrise',\n 'Swiftfox',\n 'Vivaldi',\n 'Waterfox',\n 'WebPositive',\n { 'label': 'Yandex Browser', 'pattern': 'YaBrowser' },\n { 'label': 'UC Browser', 'pattern': 'UCBrowser' },\n 'Opera Mini',\n { 'label': 'Opera Mini', 'pattern': 'OPiOS' },\n 'Opera',\n { 'label': 'Opera', 'pattern': 'OPR' },\n 'Chromium',\n 'Chrome',\n { 'label': 'Chrome', 'pattern': '(?:HeadlessChrome)' },\n { 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' },\n { 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' },\n { 'label': 'Firefox for iOS', 'pattern': 'FxiOS' },\n { 'label': 'IE', 'pattern': 'IEMobile' },\n { 'label': 'IE', 'pattern': 'MSIE' },\n 'Safari'\n ]);\n\n /* Detectable products (order is important). */\n var product = getProduct([\n { 'label': 'BlackBerry', 'pattern': 'BB10' },\n 'BlackBerry',\n { 'label': 'Galaxy S', 'pattern': 'GT-I9000' },\n { 'label': 'Galaxy S2', 'pattern': 'GT-I9100' },\n { 'label': 'Galaxy S3', 'pattern': 'GT-I9300' },\n { 'label': 'Galaxy S4', 'pattern': 'GT-I9500' },\n { 'label': 'Galaxy S5', 'pattern': 'SM-G900' },\n { 'label': 'Galaxy S6', 'pattern': 'SM-G920' },\n { 'label': 'Galaxy S6 Edge', 'pattern': 'SM-G925' },\n { 'label': 'Galaxy S7', 'pattern': 'SM-G930' },\n { 'label': 'Galaxy S7 Edge', 'pattern': 'SM-G935' },\n 'Google TV',\n 'Lumia',\n 'iPad',\n 'iPod',\n 'iPhone',\n 'Kindle',\n { 'label': 'Kindle Fire', 'pattern': '(?:Cloud9|Silk-Accelerated)' },\n 'Nexus',\n 'Nook',\n 'PlayBook',\n 'PlayStation Vita',\n 'PlayStation',\n 'TouchPad',\n 'Transformer',\n { 'label': 'Wii U', 'pattern': 'WiiU' },\n 'Wii',\n 'Xbox One',\n { 'label': 'Xbox 360', 'pattern': 'Xbox' },\n 'Xoom'\n ]);\n\n /* Detectable manufacturers. */\n var manufacturer = getManufacturer({\n 'Apple': { 'iPad': 1, 'iPhone': 1, 'iPod': 1 },\n 'Alcatel': {},\n 'Archos': {},\n 'Amazon': { 'Kindle': 1, 'Kindle Fire': 1 },\n 'Asus': { 'Transformer': 1 },\n 'Barnes & Noble': { 'Nook': 1 },\n 'BlackBerry': { 'PlayBook': 1 },\n 'Google': { 'Google TV': 1, 'Nexus': 1 },\n 'HP': { 'TouchPad': 1 },\n 'HTC': {},\n 'Huawei': {},\n 'Lenovo': {},\n 'LG': {},\n 'Microsoft': { 'Xbox': 1, 'Xbox One': 1 },\n 'Motorola': { 'Xoom': 1 },\n 'Nintendo': { 'Wii U': 1, 'Wii': 1 },\n 'Nokia': { 'Lumia': 1 },\n 'Oppo': {},\n 'Samsung': { 'Galaxy S': 1, 'Galaxy S2': 1, 'Galaxy S3': 1, 'Galaxy S4': 1 },\n 'Sony': { 'PlayStation': 1, 'PlayStation Vita': 1 },\n 'Xiaomi': { 'Mi': 1, 'Redmi': 1 }\n });\n\n /* Detectable operating systems (order is important). */\n var os = getOS([\n 'Windows Phone',\n 'KaiOS',\n 'Android',\n 'CentOS',\n { 'label': 'Chrome OS', 'pattern': 'CrOS' },\n 'Debian',\n { 'label': 'DragonFly BSD', 'pattern': 'DragonFly' },\n 'Fedora',\n 'FreeBSD',\n 'Gentoo',\n 'Haiku',\n 'Kubuntu',\n 'Linux Mint',\n 'OpenBSD',\n 'Red Hat',\n 'SuSE',\n 'Ubuntu',\n 'Xubuntu',\n 'Cygwin',\n 'Symbian OS',\n 'hpwOS',\n 'webOS ',\n 'webOS',\n 'Tablet OS',\n 'Tizen',\n 'Linux',\n 'Mac OS X',\n 'Macintosh',\n 'Mac',\n 'Windows 98;',\n 'Windows '\n ]);\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Picks the layout engine from an array of guesses.\n *\n * @private\n * @param {Array} guesses An array of guesses.\n * @returns {null|string} The detected layout engine.\n */\n function getLayout(guesses) {\n return reduce(guesses, function(result, guess) {\n return result || RegExp('\\\\b' + (\n guess.pattern || qualify(guess)\n ) + '\\\\b', 'i').exec(ua) && (guess.label || guess);\n });\n }\n\n /**\n * Picks the manufacturer from an array of guesses.\n *\n * @private\n * @param {Array} guesses An object of guesses.\n * @returns {null|string} The detected manufacturer.\n */\n function getManufacturer(guesses) {\n return reduce(guesses, function(result, value, key) {\n // Lookup the manufacturer by product or scan the UA for the manufacturer.\n return result || (\n value[product] ||\n value[/^[a-z]+(?: +[a-z]+\\b)*/i.exec(product)] ||\n RegExp('\\\\b' + qualify(key) + '(?:\\\\b|\\\\w*\\\\d)', 'i').exec(ua)\n ) && key;\n });\n }\n\n /**\n * Picks the browser name from an array of guesses.\n *\n * @private\n * @param {Array} guesses An array of guesses.\n * @returns {null|string} The detected browser name.\n */\n function getName(guesses) {\n return reduce(guesses, function(result, guess) {\n return result || RegExp('\\\\b' + (\n guess.pattern || qualify(guess)\n ) + '\\\\b', 'i').exec(ua) && (guess.label || guess);\n });\n }\n\n /**\n * Picks the OS name from an array of guesses.\n *\n * @private\n * @param {Array} guesses An array of guesses.\n * @returns {null|string} The detected OS name.\n */\n function getOS(guesses) {\n return reduce(guesses, function(result, guess) {\n var pattern = guess.pattern || qualify(guess);\n if (!result && (result =\n RegExp('\\\\b' + pattern + '(?:/[\\\\d.]+|[ \\\\w.]*)', 'i').exec(ua)\n )) {\n result = cleanupOS(result, pattern, guess.label || guess);\n }\n return result;\n });\n }\n\n /**\n * Picks the product name from an array of guesses.\n *\n * @private\n * @param {Array} guesses An array of guesses.\n * @returns {null|string} The detected product name.\n */\n function getProduct(guesses) {\n return reduce(guesses, function(result, guess) {\n var pattern = guess.pattern || qualify(guess);\n if (!result && (result =\n RegExp('\\\\b' + pattern + ' *\\\\d+[.\\\\w_]*', 'i').exec(ua) ||\n RegExp('\\\\b' + pattern + ' *\\\\w+-[\\\\w]*', 'i').exec(ua) ||\n RegExp('\\\\b' + pattern + '(?:; *(?:[a-z]+[_-])?[a-z]+\\\\d+|[^ ();-]*)', 'i').exec(ua)\n )) {\n // Split by forward slash and append product version if needed.\n if ((result = String((guess.label && !RegExp(pattern, 'i').test(guess.label)) ? guess.label : result).split('/'))[1] && !/[\\d.]+/.test(result[0])) {\n result[0] += ' ' + result[1];\n }\n // Correct character case and cleanup string.\n guess = guess.label || guess;\n result = format(result[0]\n .replace(RegExp(pattern, 'i'), guess)\n .replace(RegExp('; *(?:' + guess + '[_-])?', 'i'), ' ')\n .replace(RegExp('(' + guess + ')[-_.]?(\\\\w)', 'i'), '$1 $2'));\n }\n return result;\n });\n }\n\n /**\n * Resolves the version using an array of UA patterns.\n *\n * @private\n * @param {Array} patterns An array of UA patterns.\n * @returns {null|string} The detected version.\n */\n function getVersion(patterns) {\n return reduce(patterns, function(result, pattern) {\n return result || (RegExp(pattern +\n '(?:-[\\\\d.]+/|(?: for [\\\\w-]+)?[ /-])([\\\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null;\n });\n }\n\n /**\n * Returns `platform.description` when the platform object is coerced to a string.\n *\n * @name toString\n * @memberOf platform\n * @returns {string} Returns `platform.description` if available, else an empty string.\n */\n function toStringPlatform() {\n return this.description || '';\n }\n\n /*------------------------------------------------------------------------*/\n\n // Convert layout to an array so we can add extra details.\n layout && (layout = [layout]);\n\n // Detect Android products.\n // Browsers on Android devices typically provide their product IDS after \"Android;\"\n // up to \"Build\" or \") AppleWebKit\".\n // Example:\n // \"Mozilla/5.0 (Linux; Android 8.1.0; Moto G (5) Plus) AppleWebKit/537.36\n // (KHTML, like Gecko) Chrome/70.0.3538.80 Mobile Safari/537.36\"\n if (/\\bAndroid\\b/.test(os) && !product &&\n (data = /\\bAndroid[^;]*;(.*?)(?:Build|\\) AppleWebKit)\\b/i.exec(ua))) {\n product = trim(data[1])\n // Replace any language codes (eg. \"en-US\").\n .replace(/^[a-z]{2}-[a-z]{2};\\s*/i, '')\n || null;\n }\n // Detect product names that contain their manufacturer's name.\n if (manufacturer && !product) {\n product = getProduct([manufacturer]);\n } else if (manufacturer && product) {\n product = product\n .replace(RegExp('^(' + qualify(manufacturer) + ')[-_.\\\\s]', 'i'), manufacturer + ' ')\n .replace(RegExp('^(' + qualify(manufacturer) + ')[-_.]?(\\\\w)', 'i'), manufacturer + ' $2');\n }\n // Clean up Google TV.\n if ((data = /\\bGoogle TV\\b/.exec(product))) {\n product = data[0];\n }\n // Detect simulators.\n if (/\\bSimulator\\b/i.test(ua)) {\n product = (product ? product + ' ' : '') + 'Simulator';\n }\n // Detect Opera Mini 8+ running in Turbo/Uncompressed mode on iOS.\n if (name == 'Opera Mini' && /\\bOPiOS\\b/.test(ua)) {\n description.push('running in Turbo/Uncompressed mode');\n }\n // Detect IE Mobile 11.\n if (name == 'IE' && /\\blike iPhone OS\\b/.test(ua)) {\n data = parse(ua.replace(/like iPhone OS/, ''));\n manufacturer = data.manufacturer;\n product = data.product;\n }\n // Detect iOS.\n else if (/^iP/.test(product)) {\n name || (name = 'Safari');\n os = 'iOS' + ((data = / OS ([\\d_]+)/i.exec(ua))\n ? ' ' + data[1].replace(/_/g, '.')\n : '');\n }\n // Detect Kubuntu.\n else if (name == 'Konqueror' && /^Linux\\b/i.test(os)) {\n os = 'Kubuntu';\n }\n // Detect Android browsers.\n else if ((manufacturer && manufacturer != 'Google' &&\n ((/Chrome/.test(name) && !/\\bMobile Safari\\b/i.test(ua)) || /\\bVita\\b/.test(product))) ||\n (/\\bAndroid\\b/.test(os) && /^Chrome/.test(name) && /\\bVersion\\//i.test(ua))) {\n name = 'Android Browser';\n os = /\\bAndroid\\b/.test(os) ? os : 'Android';\n }\n // Detect Silk desktop/accelerated modes.\n else if (name == 'Silk') {\n if (!/\\bMobi/i.test(ua)) {\n os = 'Android';\n description.unshift('desktop mode');\n }\n if (/Accelerated *= *true/i.test(ua)) {\n description.unshift('accelerated');\n }\n }\n // Detect UC Browser speed mode.\n else if (name == 'UC Browser' && /\\bUCWEB\\b/.test(ua)) {\n description.push('speed mode');\n }\n // Detect PaleMoon identifying as Firefox.\n else if (name == 'PaleMoon' && (data = /\\bFirefox\\/([\\d.]+)\\b/.exec(ua))) {\n description.push('identifying as Firefox ' + data[1]);\n }\n // Detect Firefox OS and products running Firefox.\n else if (name == 'Firefox' && (data = /\\b(Mobile|Tablet|TV)\\b/i.exec(ua))) {\n os || (os = 'Firefox OS');\n product || (product = data[1]);\n }\n // Detect false positives for Firefox/Safari.\n else if (!name || (data = !/\\bMinefield\\b/i.test(ua) && /\\b(?:Firefox|Safari)\\b/.exec(name))) {\n // Escape the `/` for Firefox 1.\n if (name && !product && /[\\/,]|^[^(]+?\\)/.test(ua.slice(ua.indexOf(data + '/') + 8))) {\n // Clear name of false positives.\n name = null;\n }\n // Reassign a generic name.\n if ((data = product || manufacturer || os) &&\n (product || manufacturer || /\\b(?:Android|Symbian OS|Tablet OS|webOS)\\b/.test(os))) {\n name = /[a-z]+(?: Hat)?/i.exec(/\\bAndroid\\b/.test(os) ? os : data) + ' Browser';\n }\n }\n // Add Chrome version to description for Electron.\n else if (name == 'Electron' && (data = (/\\bChrome\\/([\\d.]+)\\b/.exec(ua) || 0)[1])) {\n description.push('Chromium ' + data);\n }\n // Detect non-Opera (Presto-based) versions (order is important).\n if (!version) {\n version = getVersion([\n '(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\\\d.]+$)|UCBrowser|YaBrowser)',\n 'Version',\n qualify(name),\n '(?:Firefox|Minefield|NetFront)'\n ]);\n }\n // Detect stubborn layout engines.\n if ((data =\n layout == 'iCab' && parseFloat(version) > 3 && 'WebKit' ||\n /\\bOpera\\b/.test(name) && (/\\bOPR\\b/.test(ua) ? 'Blink' : 'Presto') ||\n /\\b(?:Midori|Nook|Safari)\\b/i.test(ua) && !/^(?:Trident|EdgeHTML)$/.test(layout) && 'WebKit' ||\n !layout && /\\bMSIE\\b/i.test(ua) && (os == 'Mac OS' ? 'Tasman' : 'Trident') ||\n layout == 'WebKit' && /\\bPlayStation\\b(?! Vita\\b)/i.test(name) && 'NetFront'\n )) {\n layout = [data];\n }\n // Detect Windows Phone 7 desktop mode.\n if (name == 'IE' && (data = (/; *(?:XBLWP|ZuneWP)(\\d+)/i.exec(ua) || 0)[1])) {\n name += ' Mobile';\n os = 'Windows Phone ' + (/\\+$/.test(data) ? data : data + '.x');\n description.unshift('desktop mode');\n }\n // Detect Windows Phone 8.x desktop mode.\n else if (/\\bWPDesktop\\b/i.test(ua)) {\n name = 'IE Mobile';\n os = 'Windows Phone 8.x';\n description.unshift('desktop mode');\n version || (version = (/\\brv:([\\d.]+)/.exec(ua) || 0)[1]);\n }\n // Detect IE 11 identifying as other browsers.\n else if (name != 'IE' && layout == 'Trident' && (data = /\\brv:([\\d.]+)/.exec(ua))) {\n if (name) {\n description.push('identifying as ' + name + (version ? ' ' + version : ''));\n }\n name = 'IE';\n version = data[1];\n }\n // Leverage environment features.\n if (useFeatures) {\n // Detect server-side environments.\n // Rhino has a global function while others have a global object.\n if (isHostType(context, 'global')) {\n if (java) {\n data = java.lang.System;\n arch = data.getProperty('os.arch');\n os = os || data.getProperty('os.name') + ' ' + data.getProperty('os.version');\n }\n if (rhino) {\n try {\n version = context.require('ringo/engine').version.join('.');\n name = 'RingoJS';\n } catch(e) {\n if ((data = context.system) && data.global.system == context.system) {\n name = 'Narwhal';\n os || (os = data[0].os || null);\n }\n }\n if (!name) {\n name = 'Rhino';\n }\n }\n else if (\n typeof context.process == 'object' && !context.process.browser &&\n (data = context.process)\n ) {\n if (typeof data.versions == 'object') {\n if (typeof data.versions.electron == 'string') {\n description.push('Node ' + data.versions.node);\n name = 'Electron';\n version = data.versions.electron;\n } else if (typeof data.versions.nw == 'string') {\n description.push('Chromium ' + version, 'Node ' + data.versions.node);\n name = 'NW.js';\n version = data.versions.nw;\n }\n }\n if (!name) {\n name = 'Node.js';\n arch = data.arch;\n os = data.platform;\n version = /[\\d.]+/.exec(data.version);\n version = version ? version[0] : null;\n }\n }\n }\n // Detect Adobe AIR.\n else if (getClassOf((data = context.runtime)) == airRuntimeClass) {\n name = 'Adobe AIR';\n os = data.flash.system.Capabilities.os;\n }\n // Detect PhantomJS.\n else if (getClassOf((data = context.phantom)) == phantomClass) {\n name = 'PhantomJS';\n version = (data = data.version || null) && (data.major + '.' + data.minor + '.' + data.patch);\n }\n // Detect IE compatibility modes.\n else if (typeof doc.documentMode == 'number' && (data = /\\bTrident\\/(\\d+)/i.exec(ua))) {\n // We're in compatibility mode when the Trident version + 4 doesn't\n // equal the document mode.\n version = [version, doc.documentMode];\n if ((data = +data[1] + 4) != version[1]) {\n description.push('IE ' + version[1] + ' mode');\n layout && (layout[1] = '');\n version[1] = data;\n }\n version = name == 'IE' ? String(version[1].toFixed(1)) : version[0];\n }\n // Detect IE 11 masking as other browsers.\n else if (typeof doc.documentMode == 'number' && /^(?:Chrome|Firefox)\\b/.test(name)) {\n description.push('masking as ' + name + ' ' + version);\n name = 'IE';\n version = '11.0';\n layout = ['Trident'];\n os = 'Windows';\n }\n os = os && format(os);\n }\n // Detect prerelease phases.\n if (version && (data =\n /(?:[ab]|dp|pre|[ab]\\d+pre)(?:\\d+\\+?)?$/i.exec(version) ||\n /(?:alpha|beta)(?: ?\\d)?/i.exec(ua + ';' + (useFeatures && nav.appMinorVersion)) ||\n /\\bMinefield\\b/i.test(ua) && 'a'\n )) {\n prerelease = /b/i.test(data) ? 'beta' : 'alpha';\n version = version.replace(RegExp(data + '\\\\+?$'), '') +\n (prerelease == 'beta' ? beta : alpha) + (/\\d+\\+?/.exec(data) || '');\n }\n // Detect Firefox Mobile.\n if (name == 'Fennec' || name == 'Firefox' && /\\b(?:Android|Firefox OS|KaiOS)\\b/.test(os)) {\n name = 'Firefox Mobile';\n }\n // Obscure Maxthon's unreliable version.\n else if (name == 'Maxthon' && version) {\n version = version.replace(/\\.[\\d.]+/, '.x');\n }\n // Detect Xbox 360 and Xbox One.\n else if (/\\bXbox\\b/i.test(product)) {\n if (product == 'Xbox 360') {\n os = null;\n }\n if (product == 'Xbox 360' && /\\bIEMobile\\b/.test(ua)) {\n description.unshift('mobile mode');\n }\n }\n // Add mobile postfix.\n else if ((/^(?:Chrome|IE|Opera)$/.test(name) || name && !product && !/Browser|Mobi/.test(name)) &&\n (os == 'Windows CE' || /Mobi/i.test(ua))) {\n name += ' Mobile';\n }\n // Detect IE platform preview.\n else if (name == 'IE' && useFeatures) {\n try {\n if (context.external === null) {\n description.unshift('platform preview');\n }\n } catch(e) {\n description.unshift('embedded');\n }\n }\n // Detect BlackBerry OS version.\n // http://docs.blackberry.com/en/developers/deliverables/18169/HTTP_headers_sent_by_BB_Browser_1234911_11.jsp\n else if ((/\\bBlackBerry\\b/.test(product) || /\\bBB10\\b/.test(ua)) && (data =\n (RegExp(product.replace(/ +/g, ' *') + '/([.\\\\d]+)', 'i').exec(ua) || 0)[1] ||\n version\n )) {\n data = [data, /BB10/.test(ua)];\n os = (data[1] ? (product = null, manufacturer = 'BlackBerry') : 'Device Software') + ' ' + data[0];\n version = null;\n }\n // Detect Opera identifying/masking itself as another browser.\n // http://www.opera.com/support/kb/view/843/\n else if (this != forOwn && product != 'Wii' && (\n (useFeatures && opera) ||\n (/Opera/.test(name) && /\\b(?:MSIE|Firefox)\\b/i.test(ua)) ||\n (name == 'Firefox' && /\\bOS X (?:\\d+\\.){2,}/.test(os)) ||\n (name == 'IE' && (\n (os && !/^Win/.test(os) && version > 5.5) ||\n /\\bWindows XP\\b/.test(os) && version > 8 ||\n version == 8 && !/\\bTrident\\b/.test(ua)\n ))\n ) && !reOpera.test((data = parse.call(forOwn, ua.replace(reOpera, '') + ';'))) && data.name) {\n // When \"identifying\", the UA contains both Opera and the other browser's name.\n data = 'ing as ' + data.name + ((data = data.version) ? ' ' + data : '');\n if (reOpera.test(name)) {\n if (/\\bIE\\b/.test(data) && os == 'Mac OS') {\n os = null;\n }\n data = 'identify' + data;\n }\n // When \"masking\", the UA contains only the other browser's name.\n else {\n data = 'mask' + data;\n if (operaClass) {\n name = format(operaClass.replace(/([a-z])([A-Z])/g, '$1 $2'));\n } else {\n name = 'Opera';\n }\n if (/\\bIE\\b/.test(data)) {\n os = null;\n }\n if (!useFeatures) {\n version = null;\n }\n }\n layout = ['Presto'];\n description.push(data);\n }\n // Detect WebKit Nightly and approximate Chrome/Safari versions.\n if ((data = (/\\bAppleWebKit\\/([\\d.]+\\+?)/i.exec(ua) || 0)[1])) {\n // Correct build number for numeric comparison.\n // (e.g. \"532.5\" becomes \"532.05\")\n data = [parseFloat(data.replace(/\\.(\\d)$/, '.0$1')), data];\n // Nightly builds are postfixed with a \"+\".\n if (name == 'Safari' && data[1].slice(-1) == '+') {\n name = 'WebKit Nightly';\n prerelease = 'alpha';\n version = data[1].slice(0, -1);\n }\n // Clear incorrect browser versions.\n else if (version == data[1] ||\n version == (data[2] = (/\\bSafari\\/([\\d.]+\\+?)/i.exec(ua) || 0)[1])) {\n version = null;\n }\n // Use the full Chrome version when available.\n data[1] = (/\\b(?:Headless)?Chrome\\/([\\d.]+)/i.exec(ua) || 0)[1];\n // Detect Blink layout engine.\n if (data[0] == 537.36 && data[2] == 537.36 && parseFloat(data[1]) >= 28 && layout == 'WebKit') {\n layout = ['Blink'];\n }\n // Detect JavaScriptCore.\n // http://stackoverflow.com/questions/6768474/how-can-i-detect-which-javascript-engine-v8-or-jsc-is-used-at-runtime-in-androi\n if (!useFeatures || (!likeChrome && !data[1])) {\n layout && (layout[1] = 'like Safari');\n data = (data = data[0], data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : data < 534 ? '4+' : data < 535 ? 5 : data < 537 ? 6 : data < 538 ? 7 : data < 601 ? 8 : data < 602 ? 9 : data < 604 ? 10 : data < 606 ? 11 : data < 608 ? 12 : '12');\n } else {\n layout && (layout[1] = 'like Chrome');\n data = data[1] || (data = data[0], data < 530 ? 1 : data < 532 ? 2 : data < 532.05 ? 3 : data < 533 ? 4 : data < 534.03 ? 5 : data < 534.07 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : data < 534.24 ? 10 : data < 534.30 ? 11 : data < 535.01 ? 12 : data < 535.02 ? '13+' : data < 535.07 ? 15 : data < 535.11 ? 16 : data < 535.19 ? 17 : data < 536.05 ? 18 : data < 536.10 ? 19 : data < 537.01 ? 20 : data < 537.11 ? '21+' : data < 537.13 ? 23 : data < 537.18 ? 24 : data < 537.24 ? 25 : data < 537.36 ? 26 : layout != 'Blink' ? '27' : '28');\n }\n // Add the postfix of \".x\" or \"+\" for approximate versions.\n layout && (layout[1] += ' ' + (data += typeof data == 'number' ? '.x' : /[.+]/.test(data) ? '' : '+'));\n // Obscure version for some Safari 1-2 releases.\n if (name == 'Safari' && (!version || parseInt(version) > 45)) {\n version = data;\n } else if (name == 'Chrome' && /\\bHeadlessChrome/i.test(ua)) {\n description.unshift('headless');\n }\n }\n // Detect Opera desktop modes.\n if (name == 'Opera' && (data = /\\bzbov|zvav$/.exec(os))) {\n name += ' ';\n description.unshift('desktop mode');\n if (data == 'zvav') {\n name += 'Mini';\n version = null;\n } else {\n name += 'Mobile';\n }\n os = os.replace(RegExp(' *' + data + '$'), '');\n }\n // Detect Chrome desktop mode.\n else if (name == 'Safari' && /\\bChrome\\b/.exec(layout && layout[1])) {\n description.unshift('desktop mode');\n name = 'Chrome Mobile';\n version = null;\n\n if (/\\bOS X\\b/.test(os)) {\n manufacturer = 'Apple';\n os = 'iOS 4.3+';\n } else {\n os = null;\n }\n }\n // Newer versions of SRWare Iron uses the Chrome tag to indicate its version number.\n else if (/\\bSRWare Iron\\b/.test(name) && !version) {\n version = getVersion('Chrome');\n }\n // Strip incorrect OS versions.\n if (version && version.indexOf((data = /[\\d.]+$/.exec(os))) == 0 &&\n ua.indexOf('/' + data + '-') > -1) {\n os = trim(os.replace(data, ''));\n }\n // Ensure OS does not include the browser name.\n if (os && os.indexOf(name) != -1 && !RegExp(name + ' OS').test(os)) {\n os = os.replace(RegExp(' *' + qualify(name) + ' *'), '');\n }\n // Add layout engine.\n if (layout && !/\\b(?:Avant|Nook)\\b/.test(name) && (\n /Browser|Lunascape|Maxthon/.test(name) ||\n name != 'Safari' && /^iOS/.test(os) && /\\bSafari\\b/.test(layout[1]) ||\n /^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(name) && layout[1])) {\n // Don't add layout details to description if they are falsey.\n (data = layout[layout.length - 1]) && description.push(data);\n }\n // Combine contextual information.\n if (description.length) {\n description = ['(' + description.join('; ') + ')'];\n }\n // Append manufacturer to description.\n if (manufacturer && product && product.indexOf(manufacturer) < 0) {\n description.push('on ' + manufacturer);\n }\n // Append product to description.\n if (product) {\n description.push((/^on /.test(description[description.length - 1]) ? '' : 'on ') + product);\n }\n // Parse the OS into an object.\n if (os) {\n data = / ([\\d.+]+)$/.exec(os);\n isSpecialCasedOS = data && os.charAt(os.length - data[0].length - 1) == '/';\n os = {\n 'architecture': 32,\n 'family': (data && !isSpecialCasedOS) ? os.replace(data[0], '') : os,\n 'version': data ? data[1] : null,\n 'toString': function() {\n var version = this.version;\n return this.family + ((version && !isSpecialCasedOS) ? ' ' + version : '') + (this.architecture == 64 ? ' 64-bit' : '');\n }\n };\n }\n // Add browser/OS architecture.\n if ((data = /\\b(?:AMD|IA|Win|WOW|x86_|x)64\\b/i.exec(arch)) && !/\\bi686\\b/i.test(arch)) {\n if (os) {\n os.architecture = 64;\n os.family = os.family.replace(RegExp(' *' + data), '');\n }\n if (\n name && (/\\bWOW64\\b/i.test(ua) ||\n (useFeatures && /\\w(?:86|32)$/.test(nav.cpuClass || nav.platform) && !/\\bWin64; x64\\b/i.test(ua)))\n ) {\n description.unshift('32-bit');\n }\n }\n // Chrome 39 and above on OS X is always 64-bit.\n else if (\n os && /^OS X/.test(os.family) &&\n name == 'Chrome' && parseFloat(version) >= 39\n ) {\n os.architecture = 64;\n }\n\n ua || (ua = null);\n\n /*------------------------------------------------------------------------*/\n\n /**\n * The platform object.\n *\n * @name platform\n * @type Object\n */\n var platform = {};\n\n /**\n * The platform description.\n *\n * @memberOf platform\n * @type string|null\n */\n platform.description = ua;\n\n /**\n * The name of the browser's layout engine.\n *\n * The list of common layout engines include:\n * \"Blink\", \"EdgeHTML\", \"Gecko\", \"Trident\" and \"WebKit\"\n *\n * @memberOf platform\n * @type string|null\n */\n platform.layout = layout && layout[0];\n\n /**\n * The name of the product's manufacturer.\n *\n * The list of manufacturers include:\n * \"Apple\", \"Archos\", \"Amazon\", \"Asus\", \"Barnes & Noble\", \"BlackBerry\",\n * \"Google\", \"HP\", \"HTC\", \"LG\", \"Microsoft\", \"Motorola\", \"Nintendo\",\n * \"Nokia\", \"Samsung\" and \"Sony\"\n *\n * @memberOf platform\n * @type string|null\n */\n platform.manufacturer = manufacturer;\n\n /**\n * The name of the browser/environment.\n *\n * The list of common browser names include:\n * \"Chrome\", \"Electron\", \"Firefox\", \"Firefox for iOS\", \"IE\",\n * \"Microsoft Edge\", \"PhantomJS\", \"Safari\", \"SeaMonkey\", \"Silk\",\n * \"Opera Mini\" and \"Opera\"\n *\n * Mobile versions of some browsers have \"Mobile\" appended to their name:\n * eg. \"Chrome Mobile\", \"Firefox Mobile\", \"IE Mobile\" and \"Opera Mobile\"\n *\n * @memberOf platform\n * @type string|null\n */\n platform.name = name;\n\n /**\n * The alpha/beta release indicator.\n *\n * @memberOf platform\n * @type string|null\n */\n platform.prerelease = prerelease;\n\n /**\n * The name of the product hosting the browser.\n *\n * The list of common products include:\n *\n * \"BlackBerry\", \"Galaxy S4\", \"Lumia\", \"iPad\", \"iPod\", \"iPhone\", \"Kindle\",\n * \"Kindle Fire\", \"Nexus\", \"Nook\", \"PlayBook\", \"TouchPad\" and \"Transformer\"\n *\n * @memberOf platform\n * @type string|null\n */\n platform.product = product;\n\n /**\n * The browser's user agent string.\n *\n * @memberOf platform\n * @type string|null\n */\n platform.ua = ua;\n\n /**\n * The browser/environment version.\n *\n * @memberOf platform\n * @type string|null\n */\n platform.version = name && version;\n\n /**\n * The name of the operating system.\n *\n * @memberOf platform\n * @type Object\n */\n platform.os = os || {\n\n /**\n * The CPU architecture the OS is built for.\n *\n * @memberOf platform.os\n * @type number|null\n */\n 'architecture': null,\n\n /**\n * The family of the OS.\n *\n * Common values include:\n * \"Windows\", \"Windows Server 2008 R2 / 7\", \"Windows Server 2008 / Vista\",\n * \"Windows XP\", \"OS X\", \"Linux\", \"Ubuntu\", \"Debian\", \"Fedora\", \"Red Hat\",\n * \"SuSE\", \"Android\", \"iOS\" and \"Windows Phone\"\n *\n * @memberOf platform.os\n * @type string|null\n */\n 'family': null,\n\n /**\n * The version of the OS.\n *\n * @memberOf platform.os\n * @type string|null\n */\n 'version': null,\n\n /**\n * Returns the OS string.\n *\n * @memberOf platform.os\n * @returns {string} The OS string.\n */\n 'toString': function() { return 'null'; }\n };\n\n platform.parse = parse;\n platform.toString = toStringPlatform;\n\n if (platform.version) {\n description.unshift(version);\n }\n if (platform.name) {\n description.unshift(name);\n }\n if (os && name && !(os == String(os).split(' ')[0] && (os == name.split(' ')[0] || product))) {\n description.push(product ? '(' + os + ')' : 'on ' + os);\n }\n if (description.length) {\n platform.description = description.join(' ');\n }\n return platform;\n }\n\n /*--------------------------------------------------------------------------*/\n\n // Export platform.\n var platform = parse();\n\n // Some AMD build optimizers, like r.js, check for condition patterns like the following:\n if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {\n // Expose platform on the global object to prevent errors when platform is\n // loaded by a script tag in the presence of an AMD loader.\n // See http://requirejs.org/docs/errors.html#mismatch for more details.\n root.platform = platform;\n\n // Define as an anonymous module so platform can be aliased through path mapping.\n define(function() {\n return platform;\n });\n }\n // Check for `exports` after `define` in case a build optimizer adds an `exports` object.\n else if (freeExports && freeModule) {\n // Export for CommonJS support.\n forOwn(platform, function(value, key) {\n freeExports[key] = value;\n });\n }\n else {\n // Export to the global object.\n root.platform = platform;\n }\n}.call(this));\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2018-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {HArg} from './Grammar';\nimport {IHEvt2Fnc} from './CmnInterface';\n\n// =============== Global\nexport function int(o: any): number {return parseInt(String(o), 10)}\nexport function uint(o: any): number {\n\tconst v = parseInt(String(o), 10);\n\treturn v < 0 ? -v : v;\n}\nif (! ('toInt' in String.prototype)) {\n\t(String.prototype as any).toInt = function () { return int(this); };\n}\nif (! ('toUint' in String.prototype)) {\n\t(String.prototype as any).toUint = function () {\n\t\tconst v = int(this);\n\t\treturn v < 0 ? -v : v;\n\t};\n}\n\nexport function getDateStr(spl_dd = '/', spl_dt = ' ', spl_tt = ':', spl_ms = ''): string {\n\tconst now = new Date;\n\treturn now.getFullYear()\n\t\t+ spl_dd+ String(100 +now.getMonth() +1).slice(1, 3)\n\t\t+ spl_dd+ String(100 +now.getDate()).slice(1, 3)\n\t\t+ spl_dt+ String(100 +now.getHours()).slice(1, 3)\n\t\t+ spl_tt+ String(100 +now.getMinutes()).slice(1, 3)\n\t\t+ (spl_ms === '' ?'' :spl_ms+ String(now.getMilliseconds()));\n}\n\n\nconst\tcss_key4del\t= '/* SKYNovel */';\nexport function initStyle() {\n\tconst he = document.getElementsByTagName('head')[0];\n\tconst len = he.children.length;\n\tfor (let i=len -1; i>=0; --i) {\n\t\tconst v = he.children[i];\n\t\tif (! (v instanceof HTMLStyleElement)) continue;\n\t\tif (v.innerText.slice(0, 14) !== css_key4del) continue;\n\t\the.removeChild(v);\n\t}\n}\nexport function addStyle(style: string) {\n\tconst gs = document.createElement('style');\n\tgs.innerHTML = css_key4del + style;\n\tdocument.getElementsByTagName('head')[0].appendChild(gs);\n}\n\n\n\n// =============== EventMng\nimport {Container} from 'pixi.js';\nexport interface IEvtMng {\n\tbutton(hArg: HArg, ctnBtn: Container, normal: ()=> void, hover: ()=> boolean, clicked: ()=> void): void;\n\tunButton(em: Container): void;\n\tget\tisSkipping(): boolean;\n\tpopLocalEvts(): IHEvt2Fnc;\n\tpushLocalEvts(a: IHEvt2Fnc): void;\n\twaitEvent(evnm: string, hArg: HArg, onFire: ()=> void): boolean;\n\tbreakEvent(evnm: string): void;\n\thideHint(): void;\n\tcvsResize(): void;\n\n\tresvFlameEvent(win: Window): void;\n}\n\nexport\tfunction argChk_Num(hash: any, name: string, def: number): number {\n\tconst v = hash[name];\n\tif (! (name in hash)) {\n\t\tif (isNaN(def)) throw `[${hash[':タグ名']}]属性 ${name} は必須です`;\n\n\t\thash[name] = def;\n\t\treturn def;\n\t}\n\n\tconst n = (String(v).slice(0, 2) === '0x')\n\t\t? parseInt(v)\n\t\t: parseFloat(v);\n\tif (isNaN(n)) throw `[${hash[':タグ名']}]属性 ${name} の値【${v}】が数値ではありません`;\n\n\treturn hash[name] = n;\n}\n\n/*\n\tそれぞれの型を Boolean 型に変換した場合の値は以下のようになります。\n\n\tUndefiend \tfalse\n\tNull \t\tfalse\n\tBoolean \t変換前のオブジェクトと同じ\n\tNumber \t\t0 または NaN は false それ以外の値は true\n\tString \t\t空文字列は false それ以外の値は true\n\tObject \t\ttrue\n*/\nexport\tfunction argChk_Boolean(hash: any, name: string, def: boolean): boolean {\n\t//\tt-r-a-c-e(Boolean(null),Boolean(\"\"),Boolean(undefined),Boolean(\"0\"),Boolean(\"1\"),Boolean(\"true\"),Boolean(\"false\"),Boolean(\"あい\"));\n\t//\t[exec] false false false true true true true true\n\t/*console.log('%o %o %o %o %o %o %o %o',\n\t\tBoolean(null), Boolean(\"\"), Boolean(undefined), Boolean(\"0\"), Boolean(\"1\"),\n\t\tBoolean(\"true\"), Boolean(\"false\"), Boolean(\"あい\"));\n\t*/\n\n\t//if (! hArg[name]) return hArg[name] = def;\n\tif (! (name in hash)) return hash[name] = def;\n\n\tconst v = hash[name];\n\tif (v === null) return false;\n\n\tconst v2 = String(v);\n\treturn hash[name] = (v2 === 'false')? false : Boolean(v2);\n}\n\n\nexport function parseColor(v: string): number {\n\tif (v.at(0) === '#') return parseInt(v.slice(1), 16);\n\tconst n = Number(v);\n\tif (! isNaN(n)) return n;\t// 0, 0xffffff\n\n\tif (v === 'black') return 0;\n\tCmnLib.cc4ColorName.fillStyle = v;\n\tconst cc = CmnLib.cc4ColorName.fillStyle;\n\tif (cc === '#000000') throw `色名前 ${v} が異常です`;\n\n\treturn parseInt(cc.slice(1), 16);\n}\nexport\tfunction argChk_Color(hash: any, name: string, def: number): number {\n\tconst v = hash[name];\n\tif (! v) return hash[name] = def;\n\n\treturn hash[name] = parseColor(String(v));\n}\n\n\nconst REG_ERRMES_JSON = /JSON at position (\\d+)$/;\n\t// Unexpected number in JSON at position \nexport\tfunction mesErrJSON(hArg: HArg, nm = '', mes = ''): string {\n\tconst col = (mes.match(REG_ERRMES_JSON) ?? ['',''])[1];\n\treturn `[${hArg[':タグ名']}] ${nm} 属性の解析エラー : ${mes}\n${(hArg)[nm]}${col ?`\n${'^'.padStart(Number(col))}` :``}`;\n}\n\n\nconst REG_FN\t= /^[^\\/\\.]+$|[^\\/]+(?=\\.)/;\n\t// https://regex101.com/r/8sltIm/1\nexport\tfunction getFn(p: string) {return (p.match(REG_FN) ?? [''])[0]}\nconst REG_EXT\t= /\\.([^\\.]+)$/;\n\t// https://regex101.com/r/IULqII/3\nexport \tfunction getExt(p: string) {return (p.match(REG_EXT) ?? ['',''])[1]}\n\nimport {name, os} from 'platform';\nexport class CmnLib {\n\tstatic\tstageW\t\t= 0;\n\tstatic\tstageH\t\t= 0;\n\tstatic\tdebugLog\t= false;\n\tstatic\treadonly\tisSafari\t= name === 'Safari';\n\tstatic\treadonly\tisFirefox\t= name === 'Firefox';\n\tstatic\treadonly\tisMac\t\t= new RegExp('OS X').test(os?.family ?? '');\n\tstatic\treadonly\tisMobile\t= ! new RegExp('(Windows|OS X)').test(os?.family ?? '');\n\tstatic\thDip\t\t: {[name: string]: string}\t= {};\n\tstatic\tisDbg\t\t= false;\n\tstatic\tisPackaged\t= false;\n\n\tstatic\tisDarkMode\t= false;\n\n\tstatic\tcc4ColorName: CanvasRenderingContext2D;\n\n}\n","/**\n * @this {Promise}\n */\nfunction finallyConstructor(callback) {\n var constructor = this.constructor;\n return this.then(\n function(value) {\n // @ts-ignore\n return constructor.resolve(callback()).then(function() {\n return value;\n });\n },\n function(reason) {\n // @ts-ignore\n return constructor.resolve(callback()).then(function() {\n // @ts-ignore\n return constructor.reject(reason);\n });\n }\n );\n}\n\nexport default finallyConstructor;\n","function allSettled(arr) {\n var P = this;\n return new P(function(resolve, reject) {\n if (!(arr && typeof arr.length !== 'undefined')) {\n return reject(\n new TypeError(\n typeof arr +\n ' ' +\n arr +\n ' is not iterable(cannot read property Symbol(Symbol.iterator))'\n )\n );\n }\n var args = Array.prototype.slice.call(arr);\n if (args.length === 0) return resolve([]);\n var remaining = args.length;\n\n function res(i, val) {\n if (val && (typeof val === 'object' || typeof val === 'function')) {\n var then = val.then;\n if (typeof then === 'function') {\n then.call(\n val,\n function(val) {\n res(i, val);\n },\n function(e) {\n args[i] = { status: 'rejected', reason: e };\n if (--remaining === 0) {\n resolve(args);\n }\n }\n );\n return;\n }\n }\n args[i] = { status: 'fulfilled', value: val };\n if (--remaining === 0) {\n resolve(args);\n }\n }\n\n for (var i = 0; i < args.length; i++) {\n res(i, args[i]);\n }\n });\n}\n\nexport default allSettled;\n","/**\n * @constructor\n */\nfunction AggregateError(errors, message) {\n (this.name = 'AggregateError'), (this.errors = errors);\n this.message = message || '';\n}\nAggregateError.prototype = Error.prototype;\n\nfunction any(arr) {\n var P = this;\n return new P(function(resolve, reject) {\n if (!(arr && typeof arr.length !== 'undefined')) {\n return reject(new TypeError('Promise.any accepts an array'));\n }\n\n var args = Array.prototype.slice.call(arr);\n if (args.length === 0) return reject();\n\n var rejectionReasons = [];\n for (var i = 0; i < args.length; i++) {\n try {\n P.resolve(args[i])\n .then(resolve)\n .catch(function(error) {\n rejectionReasons.push(error);\n if (rejectionReasons.length === args.length) {\n reject(\n new AggregateError(\n rejectionReasons,\n 'All promises were rejected'\n )\n );\n }\n });\n } catch (ex) {\n reject(ex);\n }\n }\n });\n}\n\nexport default any;\n","import promiseFinally from './finally';\nimport allSettled from './allSettled';\nimport any from './any';\n\n// Store setTimeout reference so promise-polyfill will be unaffected by\n// other code modifying setTimeout (like sinon.useFakeTimers())\nvar setTimeoutFunc = setTimeout;\n\nfunction isArray(x) {\n return Boolean(x && typeof x.length !== 'undefined');\n}\n\nfunction noop() {}\n\n// Polyfill for Function.prototype.bind\nfunction bind(fn, thisArg) {\n return function() {\n fn.apply(thisArg, arguments);\n };\n}\n\n/**\n * @constructor\n * @param {Function} fn\n */\nfunction Promise(fn) {\n if (!(this instanceof Promise))\n throw new TypeError('Promises must be constructed via new');\n if (typeof fn !== 'function') throw new TypeError('not a function');\n /** @type {!number} */\n this._state = 0;\n /** @type {!boolean} */\n this._handled = false;\n /** @type {Promise|undefined} */\n this._value = undefined;\n /** @type {!Array} */\n this._deferreds = [];\n\n doResolve(fn, this);\n}\n\nfunction handle(self, deferred) {\n while (self._state === 3) {\n self = self._value;\n }\n if (self._state === 0) {\n self._deferreds.push(deferred);\n return;\n }\n self._handled = true;\n Promise._immediateFn(function() {\n var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;\n if (cb === null) {\n (self._state === 1 ? resolve : reject)(deferred.promise, self._value);\n return;\n }\n var ret;\n try {\n ret = cb(self._value);\n } catch (e) {\n reject(deferred.promise, e);\n return;\n }\n resolve(deferred.promise, ret);\n });\n}\n\nfunction resolve(self, newValue) {\n try {\n // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure\n if (newValue === self)\n throw new TypeError('A promise cannot be resolved with itself.');\n if (\n newValue &&\n (typeof newValue === 'object' || typeof newValue === 'function')\n ) {\n var then = newValue.then;\n if (newValue instanceof Promise) {\n self._state = 3;\n self._value = newValue;\n finale(self);\n return;\n } else if (typeof then === 'function') {\n doResolve(bind(then, newValue), self);\n return;\n }\n }\n self._state = 1;\n self._value = newValue;\n finale(self);\n } catch (e) {\n reject(self, e);\n }\n}\n\nfunction reject(self, newValue) {\n self._state = 2;\n self._value = newValue;\n finale(self);\n}\n\nfunction finale(self) {\n if (self._state === 2 && self._deferreds.length === 0) {\n Promise._immediateFn(function() {\n if (!self._handled) {\n Promise._unhandledRejectionFn(self._value);\n }\n });\n }\n\n for (var i = 0, len = self._deferreds.length; i < len; i++) {\n handle(self, self._deferreds[i]);\n }\n self._deferreds = null;\n}\n\n/**\n * @constructor\n */\nfunction Handler(onFulfilled, onRejected, promise) {\n this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;\n this.onRejected = typeof onRejected === 'function' ? onRejected : null;\n this.promise = promise;\n}\n\n/**\n * Take a potentially misbehaving resolver function and make sure\n * onFulfilled and onRejected are only called once.\n *\n * Makes no guarantees about asynchrony.\n */\nfunction doResolve(fn, self) {\n var done = false;\n try {\n fn(\n function(value) {\n if (done) return;\n done = true;\n resolve(self, value);\n },\n function(reason) {\n if (done) return;\n done = true;\n reject(self, reason);\n }\n );\n } catch (ex) {\n if (done) return;\n done = true;\n reject(self, ex);\n }\n}\n\nPromise.prototype['catch'] = function(onRejected) {\n return this.then(null, onRejected);\n};\n\nPromise.prototype.then = function(onFulfilled, onRejected) {\n // @ts-ignore\n var prom = new this.constructor(noop);\n\n handle(this, new Handler(onFulfilled, onRejected, prom));\n return prom;\n};\n\nPromise.prototype['finally'] = promiseFinally;\n\nPromise.all = function(arr) {\n return new Promise(function(resolve, reject) {\n if (!isArray(arr)) {\n return reject(new TypeError('Promise.all accepts an array'));\n }\n\n var args = Array.prototype.slice.call(arr);\n if (args.length === 0) return resolve([]);\n var remaining = args.length;\n\n function res(i, val) {\n try {\n if (val && (typeof val === 'object' || typeof val === 'function')) {\n var then = val.then;\n if (typeof then === 'function') {\n then.call(\n val,\n function(val) {\n res(i, val);\n },\n reject\n );\n return;\n }\n }\n args[i] = val;\n if (--remaining === 0) {\n resolve(args);\n }\n } catch (ex) {\n reject(ex);\n }\n }\n\n for (var i = 0; i < args.length; i++) {\n res(i, args[i]);\n }\n });\n};\n\nPromise.any = any;\n\nPromise.allSettled = allSettled;\n\nPromise.resolve = function(value) {\n if (value && typeof value === 'object' && value.constructor === Promise) {\n return value;\n }\n\n return new Promise(function(resolve) {\n resolve(value);\n });\n};\n\nPromise.reject = function(value) {\n return new Promise(function(resolve, reject) {\n reject(value);\n });\n};\n\nPromise.race = function(arr) {\n return new Promise(function(resolve, reject) {\n if (!isArray(arr)) {\n return reject(new TypeError('Promise.race accepts an array'));\n }\n\n for (var i = 0, len = arr.length; i < len; i++) {\n Promise.resolve(arr[i]).then(resolve, reject);\n }\n });\n};\n\n// Use polyfill for setImmediate for performance gains\nPromise._immediateFn =\n // @ts-ignore\n (typeof setImmediate === 'function' &&\n function(fn) {\n // @ts-ignore\n setImmediate(fn);\n }) ||\n function(fn) {\n setTimeoutFunc(fn, 0);\n };\n\nPromise._unhandledRejectionFn = function _unhandledRejectionFn(err) {\n if (typeof console !== 'undefined' && console) {\n console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console\n }\n};\n\nexport default Promise;\n","/*\nobject-assign\n(c) Sindre Sorhus\n@license MIT\n*/\n\n'use strict';\n/* eslint-disable no-unused-vars */\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar propIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nfunction toObject(val) {\n\tif (val === null || val === undefined) {\n\t\tthrow new TypeError('Object.assign cannot be called with null or undefined');\n\t}\n\n\treturn Object(val);\n}\n\nfunction shouldUseNative() {\n\ttry {\n\t\tif (!Object.assign) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Detect buggy property enumeration order in older V8 versions.\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=4118\n\t\tvar test1 = new String('abc'); // eslint-disable-line no-new-wrappers\n\t\ttest1[5] = 'de';\n\t\tif (Object.getOwnPropertyNames(test1)[0] === '5') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test2 = {};\n\t\tfor (var i = 0; i < 10; i++) {\n\t\t\ttest2['_' + String.fromCharCode(i)] = i;\n\t\t}\n\t\tvar order2 = Object.getOwnPropertyNames(test2).map(function (n) {\n\t\t\treturn test2[n];\n\t\t});\n\t\tif (order2.join('') !== '0123456789') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test3 = {};\n\t\t'abcdefghijklmnopqrst'.split('').forEach(function (letter) {\n\t\t\ttest3[letter] = letter;\n\t\t});\n\t\tif (Object.keys(Object.assign({}, test3)).join('') !==\n\t\t\t\t'abcdefghijklmnopqrst') {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (err) {\n\t\t// We don't expect any of the above to throw, but better to be safe.\n\t\treturn false;\n\t}\n}\n\nmodule.exports = shouldUseNative() ? Object.assign : function (target, source) {\n\tvar from;\n\tvar to = toObject(target);\n\tvar symbols;\n\n\tfor (var s = 1; s < arguments.length; s++) {\n\t\tfrom = Object(arguments[s]);\n\n\t\tfor (var key in from) {\n\t\t\tif (hasOwnProperty.call(from, key)) {\n\t\t\t\tto[key] = from[key];\n\t\t\t}\n\t\t}\n\n\t\tif (getOwnPropertySymbols) {\n\t\t\tsymbols = getOwnPropertySymbols(from);\n\t\t\tfor (var i = 0; i < symbols.length; i++) {\n\t\t\t\tif (propIsEnumerable.call(from, symbols[i])) {\n\t\t\t\t\tto[symbols[i]] = from[symbols[i]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn to;\n};\n","/*!\n * @pixi/polyfill - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/polyfill is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport Polyfill from 'promise-polyfill';\nimport objectAssign from 'object-assign';\n\nif (typeof globalThis === 'undefined') {\n if (typeof self !== 'undefined') {\n // covers browsers\n // @ts-expect-error not-writable ts(2540) error only on node\n self.globalThis = self;\n }\n else if (typeof global !== 'undefined') {\n // covers versions of Node < 12\n // @ts-expect-error not-writable ts(2540) error only on node\n global.globalThis = global;\n }\n}\n\n// Support for IE 9 - 11 which does not include Promises\nif (!globalThis.Promise) {\n globalThis.Promise = Polyfill;\n}\n\n// References:\nif (!Object.assign) {\n Object.assign = objectAssign;\n}\n\n// References:\n// http://paulirish.com/2011/requestanimationframe-for-smart-animating/\n// https://gist.github.com/1579671\n// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision\n// https://gist.github.com/timhall/4078614\n// https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame\n// Expected to be used with Browserfiy\n// Browserify automatically detects the use of `global` and passes the\n// correct reference of `global`, `globalThis`, and finally `window`\nvar ONE_FRAME_TIME = 16;\n// Date.now\nif (!(Date.now && Date.prototype.getTime)) {\n Date.now = function now() {\n return new Date().getTime();\n };\n}\n// performance.now\nif (!(globalThis.performance && globalThis.performance.now)) {\n var startTime_1 = Date.now();\n if (!globalThis.performance) {\n globalThis.performance = {};\n }\n globalThis.performance.now = function () { return Date.now() - startTime_1; };\n}\n// requestAnimationFrame\nvar lastTime = Date.now();\nvar vendors = ['ms', 'moz', 'webkit', 'o'];\nfor (var x = 0; x < vendors.length && !globalThis.requestAnimationFrame; ++x) {\n var p = vendors[x];\n globalThis.requestAnimationFrame = globalThis[p + \"RequestAnimationFrame\"];\n globalThis.cancelAnimationFrame = globalThis[p + \"CancelAnimationFrame\"]\n || globalThis[p + \"CancelRequestAnimationFrame\"];\n}\nif (!globalThis.requestAnimationFrame) {\n globalThis.requestAnimationFrame = function (callback) {\n if (typeof callback !== 'function') {\n throw new TypeError(callback + \"is not a function\");\n }\n var currentTime = Date.now();\n var delay = ONE_FRAME_TIME + lastTime - currentTime;\n if (delay < 0) {\n delay = 0;\n }\n lastTime = currentTime;\n return globalThis.self.setTimeout(function () {\n lastTime = Date.now();\n callback(performance.now());\n }, delay);\n };\n}\nif (!globalThis.cancelAnimationFrame) {\n globalThis.cancelAnimationFrame = function (id) { return clearTimeout(id); };\n}\n\n// References:\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign\nif (!Math.sign) {\n Math.sign = function mathSign(x) {\n x = Number(x);\n if (x === 0 || isNaN(x)) {\n return x;\n }\n return x > 0 ? 1 : -1;\n };\n}\n\n// References:\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger\nif (!Number.isInteger) {\n Number.isInteger = function numberIsInteger(value) {\n return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;\n };\n}\n\nif (!globalThis.ArrayBuffer) {\n globalThis.ArrayBuffer = Array;\n}\nif (!globalThis.Float32Array) {\n globalThis.Float32Array = Array;\n}\nif (!globalThis.Uint32Array) {\n globalThis.Uint32Array = Array;\n}\nif (!globalThis.Uint16Array) {\n globalThis.Uint16Array = Array;\n}\nif (!globalThis.Uint8Array) {\n globalThis.Uint8Array = Array;\n}\nif (!globalThis.Int32Array) {\n globalThis.Int32Array = Array;\n}\n//# sourceMappingURL=polyfill.mjs.map\n","/*!\n * @pixi/constants - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/constants is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\n/**\n * Different types of environments for WebGL.\n * @static\n * @memberof PIXI\n * @name ENV\n * @enum {number}\n * @property {number} WEBGL_LEGACY - Used for older v1 WebGL devices. PixiJS will aim to ensure compatibility\n * with older / less advanced devices. If you experience unexplained flickering prefer this environment.\n * @property {number} WEBGL - Version 1 of WebGL\n * @property {number} WEBGL2 - Version 2 of WebGL\n */\nvar ENV;\n(function (ENV) {\n ENV[ENV[\"WEBGL_LEGACY\"] = 0] = \"WEBGL_LEGACY\";\n ENV[ENV[\"WEBGL\"] = 1] = \"WEBGL\";\n ENV[ENV[\"WEBGL2\"] = 2] = \"WEBGL2\";\n})(ENV || (ENV = {}));\n/**\n * Constant to identify the Renderer Type.\n * @static\n * @memberof PIXI\n * @name RENDERER_TYPE\n * @enum {number}\n * @property {number} UNKNOWN - Unknown render type.\n * @property {number} WEBGL - WebGL render type.\n * @property {number} CANVAS - Canvas render type.\n */\nvar RENDERER_TYPE;\n(function (RENDERER_TYPE) {\n RENDERER_TYPE[RENDERER_TYPE[\"UNKNOWN\"] = 0] = \"UNKNOWN\";\n RENDERER_TYPE[RENDERER_TYPE[\"WEBGL\"] = 1] = \"WEBGL\";\n RENDERER_TYPE[RENDERER_TYPE[\"CANVAS\"] = 2] = \"CANVAS\";\n})(RENDERER_TYPE || (RENDERER_TYPE = {}));\n/**\n * Bitwise OR of masks that indicate the buffers to be cleared.\n * @static\n * @memberof PIXI\n * @name BUFFER_BITS\n * @enum {number}\n * @property {number} COLOR - Indicates the buffers currently enabled for color writing.\n * @property {number} DEPTH - Indicates the depth buffer.\n * @property {number} STENCIL - Indicates the stencil buffer.\n */\nvar BUFFER_BITS;\n(function (BUFFER_BITS) {\n BUFFER_BITS[BUFFER_BITS[\"COLOR\"] = 16384] = \"COLOR\";\n BUFFER_BITS[BUFFER_BITS[\"DEPTH\"] = 256] = \"DEPTH\";\n BUFFER_BITS[BUFFER_BITS[\"STENCIL\"] = 1024] = \"STENCIL\";\n})(BUFFER_BITS || (BUFFER_BITS = {}));\n/**\n * Various blend modes supported by PIXI.\n *\n * IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes.\n * Anything else will silently act like NORMAL.\n * @memberof PIXI\n * @name BLEND_MODES\n * @enum {number}\n * @property {number} NORMAL -\n * @property {number} ADD -\n * @property {number} MULTIPLY -\n * @property {number} SCREEN -\n * @property {number} OVERLAY -\n * @property {number} DARKEN -\n * @property {number} LIGHTEN -\n * @property {number} COLOR_DODGE -\n * @property {number} COLOR_BURN -\n * @property {number} HARD_LIGHT -\n * @property {number} SOFT_LIGHT -\n * @property {number} DIFFERENCE -\n * @property {number} EXCLUSION -\n * @property {number} HUE -\n * @property {number} SATURATION -\n * @property {number} COLOR -\n * @property {number} LUMINOSITY -\n * @property {number} NORMAL_NPM -\n * @property {number} ADD_NPM -\n * @property {number} SCREEN_NPM -\n * @property {number} NONE -\n * @property {number} SRC_IN -\n * @property {number} SRC_OUT -\n * @property {number} SRC_ATOP -\n * @property {number} DST_OVER -\n * @property {number} DST_IN -\n * @property {number} DST_OUT -\n * @property {number} DST_ATOP -\n * @property {number} SUBTRACT -\n * @property {number} SRC_OVER -\n * @property {number} ERASE -\n * @property {number} XOR -\n */\nvar BLEND_MODES;\n(function (BLEND_MODES) {\n BLEND_MODES[BLEND_MODES[\"NORMAL\"] = 0] = \"NORMAL\";\n BLEND_MODES[BLEND_MODES[\"ADD\"] = 1] = \"ADD\";\n BLEND_MODES[BLEND_MODES[\"MULTIPLY\"] = 2] = \"MULTIPLY\";\n BLEND_MODES[BLEND_MODES[\"SCREEN\"] = 3] = \"SCREEN\";\n BLEND_MODES[BLEND_MODES[\"OVERLAY\"] = 4] = \"OVERLAY\";\n BLEND_MODES[BLEND_MODES[\"DARKEN\"] = 5] = \"DARKEN\";\n BLEND_MODES[BLEND_MODES[\"LIGHTEN\"] = 6] = \"LIGHTEN\";\n BLEND_MODES[BLEND_MODES[\"COLOR_DODGE\"] = 7] = \"COLOR_DODGE\";\n BLEND_MODES[BLEND_MODES[\"COLOR_BURN\"] = 8] = \"COLOR_BURN\";\n BLEND_MODES[BLEND_MODES[\"HARD_LIGHT\"] = 9] = \"HARD_LIGHT\";\n BLEND_MODES[BLEND_MODES[\"SOFT_LIGHT\"] = 10] = \"SOFT_LIGHT\";\n BLEND_MODES[BLEND_MODES[\"DIFFERENCE\"] = 11] = \"DIFFERENCE\";\n BLEND_MODES[BLEND_MODES[\"EXCLUSION\"] = 12] = \"EXCLUSION\";\n BLEND_MODES[BLEND_MODES[\"HUE\"] = 13] = \"HUE\";\n BLEND_MODES[BLEND_MODES[\"SATURATION\"] = 14] = \"SATURATION\";\n BLEND_MODES[BLEND_MODES[\"COLOR\"] = 15] = \"COLOR\";\n BLEND_MODES[BLEND_MODES[\"LUMINOSITY\"] = 16] = \"LUMINOSITY\";\n BLEND_MODES[BLEND_MODES[\"NORMAL_NPM\"] = 17] = \"NORMAL_NPM\";\n BLEND_MODES[BLEND_MODES[\"ADD_NPM\"] = 18] = \"ADD_NPM\";\n BLEND_MODES[BLEND_MODES[\"SCREEN_NPM\"] = 19] = \"SCREEN_NPM\";\n BLEND_MODES[BLEND_MODES[\"NONE\"] = 20] = \"NONE\";\n BLEND_MODES[BLEND_MODES[\"SRC_OVER\"] = 0] = \"SRC_OVER\";\n BLEND_MODES[BLEND_MODES[\"SRC_IN\"] = 21] = \"SRC_IN\";\n BLEND_MODES[BLEND_MODES[\"SRC_OUT\"] = 22] = \"SRC_OUT\";\n BLEND_MODES[BLEND_MODES[\"SRC_ATOP\"] = 23] = \"SRC_ATOP\";\n BLEND_MODES[BLEND_MODES[\"DST_OVER\"] = 24] = \"DST_OVER\";\n BLEND_MODES[BLEND_MODES[\"DST_IN\"] = 25] = \"DST_IN\";\n BLEND_MODES[BLEND_MODES[\"DST_OUT\"] = 26] = \"DST_OUT\";\n BLEND_MODES[BLEND_MODES[\"DST_ATOP\"] = 27] = \"DST_ATOP\";\n BLEND_MODES[BLEND_MODES[\"ERASE\"] = 26] = \"ERASE\";\n BLEND_MODES[BLEND_MODES[\"SUBTRACT\"] = 28] = \"SUBTRACT\";\n BLEND_MODES[BLEND_MODES[\"XOR\"] = 29] = \"XOR\";\n})(BLEND_MODES || (BLEND_MODES = {}));\n/**\n * Various webgl draw modes. These can be used to specify which GL drawMode to use\n * under certain situations and renderers.\n * @memberof PIXI\n * @static\n * @name DRAW_MODES\n * @enum {number}\n * @property {number} POINTS -\n * @property {number} LINES -\n * @property {number} LINE_LOOP -\n * @property {number} LINE_STRIP -\n * @property {number} TRIANGLES -\n * @property {number} TRIANGLE_STRIP -\n * @property {number} TRIANGLE_FAN -\n */\nvar DRAW_MODES;\n(function (DRAW_MODES) {\n DRAW_MODES[DRAW_MODES[\"POINTS\"] = 0] = \"POINTS\";\n DRAW_MODES[DRAW_MODES[\"LINES\"] = 1] = \"LINES\";\n DRAW_MODES[DRAW_MODES[\"LINE_LOOP\"] = 2] = \"LINE_LOOP\";\n DRAW_MODES[DRAW_MODES[\"LINE_STRIP\"] = 3] = \"LINE_STRIP\";\n DRAW_MODES[DRAW_MODES[\"TRIANGLES\"] = 4] = \"TRIANGLES\";\n DRAW_MODES[DRAW_MODES[\"TRIANGLE_STRIP\"] = 5] = \"TRIANGLE_STRIP\";\n DRAW_MODES[DRAW_MODES[\"TRIANGLE_FAN\"] = 6] = \"TRIANGLE_FAN\";\n})(DRAW_MODES || (DRAW_MODES = {}));\n/**\n * Various GL texture/resources formats.\n * @memberof PIXI\n * @static\n * @name FORMATS\n * @enum {number}\n * @property {number} [RGBA=6408] -\n * @property {number} [RGB=6407] -\n * @property {number} [RG=33319] -\n * @property {number} [RED=6403] -\n * @property {number} [RGBA_INTEGER=36249] -\n * @property {number} [RGB_INTEGER=36248] -\n * @property {number} [RG_INTEGER=33320] -\n * @property {number} [RED_INTEGER=36244] -\n * @property {number} [ALPHA=6406] -\n * @property {number} [LUMINANCE=6409] -\n * @property {number} [LUMINANCE_ALPHA=6410] -\n * @property {number} [DEPTH_COMPONENT=6402] -\n * @property {number} [DEPTH_STENCIL=34041] -\n */\nvar FORMATS;\n(function (FORMATS) {\n FORMATS[FORMATS[\"RGBA\"] = 6408] = \"RGBA\";\n FORMATS[FORMATS[\"RGB\"] = 6407] = \"RGB\";\n FORMATS[FORMATS[\"RG\"] = 33319] = \"RG\";\n FORMATS[FORMATS[\"RED\"] = 6403] = \"RED\";\n FORMATS[FORMATS[\"RGBA_INTEGER\"] = 36249] = \"RGBA_INTEGER\";\n FORMATS[FORMATS[\"RGB_INTEGER\"] = 36248] = \"RGB_INTEGER\";\n FORMATS[FORMATS[\"RG_INTEGER\"] = 33320] = \"RG_INTEGER\";\n FORMATS[FORMATS[\"RED_INTEGER\"] = 36244] = \"RED_INTEGER\";\n FORMATS[FORMATS[\"ALPHA\"] = 6406] = \"ALPHA\";\n FORMATS[FORMATS[\"LUMINANCE\"] = 6409] = \"LUMINANCE\";\n FORMATS[FORMATS[\"LUMINANCE_ALPHA\"] = 6410] = \"LUMINANCE_ALPHA\";\n FORMATS[FORMATS[\"DEPTH_COMPONENT\"] = 6402] = \"DEPTH_COMPONENT\";\n FORMATS[FORMATS[\"DEPTH_STENCIL\"] = 34041] = \"DEPTH_STENCIL\";\n})(FORMATS || (FORMATS = {}));\n/**\n * Various GL target types.\n * @memberof PIXI\n * @static\n * @name TARGETS\n * @enum {number}\n * @property {number} [TEXTURE_2D=3553] -\n * @property {number} [TEXTURE_CUBE_MAP=34067] -\n * @property {number} [TEXTURE_2D_ARRAY=35866] -\n * @property {number} [TEXTURE_CUBE_MAP_POSITIVE_X=34069] -\n * @property {number} [TEXTURE_CUBE_MAP_NEGATIVE_X=34070] -\n * @property {number} [TEXTURE_CUBE_MAP_POSITIVE_Y=34071] -\n * @property {number} [TEXTURE_CUBE_MAP_NEGATIVE_Y=34072] -\n * @property {number} [TEXTURE_CUBE_MAP_POSITIVE_Z=34073] -\n * @property {number} [TEXTURE_CUBE_MAP_NEGATIVE_Z=34074] -\n */\nvar TARGETS;\n(function (TARGETS) {\n TARGETS[TARGETS[\"TEXTURE_2D\"] = 3553] = \"TEXTURE_2D\";\n TARGETS[TARGETS[\"TEXTURE_CUBE_MAP\"] = 34067] = \"TEXTURE_CUBE_MAP\";\n TARGETS[TARGETS[\"TEXTURE_2D_ARRAY\"] = 35866] = \"TEXTURE_2D_ARRAY\";\n TARGETS[TARGETS[\"TEXTURE_CUBE_MAP_POSITIVE_X\"] = 34069] = \"TEXTURE_CUBE_MAP_POSITIVE_X\";\n TARGETS[TARGETS[\"TEXTURE_CUBE_MAP_NEGATIVE_X\"] = 34070] = \"TEXTURE_CUBE_MAP_NEGATIVE_X\";\n TARGETS[TARGETS[\"TEXTURE_CUBE_MAP_POSITIVE_Y\"] = 34071] = \"TEXTURE_CUBE_MAP_POSITIVE_Y\";\n TARGETS[TARGETS[\"TEXTURE_CUBE_MAP_NEGATIVE_Y\"] = 34072] = \"TEXTURE_CUBE_MAP_NEGATIVE_Y\";\n TARGETS[TARGETS[\"TEXTURE_CUBE_MAP_POSITIVE_Z\"] = 34073] = \"TEXTURE_CUBE_MAP_POSITIVE_Z\";\n TARGETS[TARGETS[\"TEXTURE_CUBE_MAP_NEGATIVE_Z\"] = 34074] = \"TEXTURE_CUBE_MAP_NEGATIVE_Z\";\n})(TARGETS || (TARGETS = {}));\n/**\n * Various GL data format types.\n * @memberof PIXI\n * @static\n * @name TYPES\n * @enum {number}\n * @property {number} [UNSIGNED_BYTE=5121] -\n * @property {number} [UNSIGNED_SHORT=5123] -\n * @property {number} [UNSIGNED_SHORT_5_6_5=33635] -\n * @property {number} [UNSIGNED_SHORT_4_4_4_4=32819] -\n * @property {number} [UNSIGNED_SHORT_5_5_5_1=32820] -\n * @property {number} [UNSIGNED_INT=5125] -\n * @property {number} [UNSIGNED_INT_10F_11F_11F_REV=35899] -\n * @property {number} [UNSIGNED_INT_2_10_10_10_REV=33640] -\n * @property {number} [UNSIGNED_INT_24_8=34042] -\n * @property {number} [UNSIGNED_INT_5_9_9_9_REV=35902] -\n * @property {number} [BYTE=5120] -\n * @property {number} [SHORT=5122] -\n * @property {number} [INT=5124] -\n * @property {number} [FLOAT=5126] -\n * @property {number} [FLOAT_32_UNSIGNED_INT_24_8_REV=36269] -\n * @property {number} [HALF_FLOAT=36193] -\n */\nvar TYPES;\n(function (TYPES) {\n TYPES[TYPES[\"UNSIGNED_BYTE\"] = 5121] = \"UNSIGNED_BYTE\";\n TYPES[TYPES[\"UNSIGNED_SHORT\"] = 5123] = \"UNSIGNED_SHORT\";\n TYPES[TYPES[\"UNSIGNED_SHORT_5_6_5\"] = 33635] = \"UNSIGNED_SHORT_5_6_5\";\n TYPES[TYPES[\"UNSIGNED_SHORT_4_4_4_4\"] = 32819] = \"UNSIGNED_SHORT_4_4_4_4\";\n TYPES[TYPES[\"UNSIGNED_SHORT_5_5_5_1\"] = 32820] = \"UNSIGNED_SHORT_5_5_5_1\";\n TYPES[TYPES[\"UNSIGNED_INT\"] = 5125] = \"UNSIGNED_INT\";\n TYPES[TYPES[\"UNSIGNED_INT_10F_11F_11F_REV\"] = 35899] = \"UNSIGNED_INT_10F_11F_11F_REV\";\n TYPES[TYPES[\"UNSIGNED_INT_2_10_10_10_REV\"] = 33640] = \"UNSIGNED_INT_2_10_10_10_REV\";\n TYPES[TYPES[\"UNSIGNED_INT_24_8\"] = 34042] = \"UNSIGNED_INT_24_8\";\n TYPES[TYPES[\"UNSIGNED_INT_5_9_9_9_REV\"] = 35902] = \"UNSIGNED_INT_5_9_9_9_REV\";\n TYPES[TYPES[\"BYTE\"] = 5120] = \"BYTE\";\n TYPES[TYPES[\"SHORT\"] = 5122] = \"SHORT\";\n TYPES[TYPES[\"INT\"] = 5124] = \"INT\";\n TYPES[TYPES[\"FLOAT\"] = 5126] = \"FLOAT\";\n TYPES[TYPES[\"FLOAT_32_UNSIGNED_INT_24_8_REV\"] = 36269] = \"FLOAT_32_UNSIGNED_INT_24_8_REV\";\n TYPES[TYPES[\"HALF_FLOAT\"] = 36193] = \"HALF_FLOAT\";\n})(TYPES || (TYPES = {}));\n/**\n * Various sampler types. Correspond to `sampler`, `isampler`, `usampler` GLSL types respectively.\n * WebGL1 works only with FLOAT.\n * @memberof PIXI\n * @static\n * @name SAMPLER_TYPES\n * @enum {number}\n * @property {number} [FLOAT=0] -\n * @property {number} [INT=1] -\n * @property {number} [UINT=2] -\n */\nvar SAMPLER_TYPES;\n(function (SAMPLER_TYPES) {\n SAMPLER_TYPES[SAMPLER_TYPES[\"FLOAT\"] = 0] = \"FLOAT\";\n SAMPLER_TYPES[SAMPLER_TYPES[\"INT\"] = 1] = \"INT\";\n SAMPLER_TYPES[SAMPLER_TYPES[\"UINT\"] = 2] = \"UINT\";\n})(SAMPLER_TYPES || (SAMPLER_TYPES = {}));\n/**\n * The scale modes that are supported by pixi.\n *\n * The {@link PIXI.settings.SCALE_MODE} scale mode affects the default scaling mode of future operations.\n * It can be re-assigned to either LINEAR or NEAREST, depending upon suitability.\n * @memberof PIXI\n * @static\n * @name SCALE_MODES\n * @enum {number}\n * @property {number} LINEAR Smooth scaling\n * @property {number} NEAREST Pixelating scaling\n */\nvar SCALE_MODES;\n(function (SCALE_MODES) {\n SCALE_MODES[SCALE_MODES[\"NEAREST\"] = 0] = \"NEAREST\";\n SCALE_MODES[SCALE_MODES[\"LINEAR\"] = 1] = \"LINEAR\";\n})(SCALE_MODES || (SCALE_MODES = {}));\n/**\n * The wrap modes that are supported by pixi.\n *\n * The {@link PIXI.settings.WRAP_MODE} wrap mode affects the default wrapping mode of future operations.\n * It can be re-assigned to either CLAMP or REPEAT, depending upon suitability.\n * If the texture is non power of two then clamp will be used regardless as WebGL can\n * only use REPEAT if the texture is po2.\n *\n * This property only affects WebGL.\n * @name WRAP_MODES\n * @memberof PIXI\n * @static\n * @enum {number}\n * @property {number} CLAMP - The textures uvs are clamped\n * @property {number} REPEAT - The texture uvs tile and repeat\n * @property {number} MIRRORED_REPEAT - The texture uvs tile and repeat with mirroring\n */\nvar WRAP_MODES;\n(function (WRAP_MODES) {\n WRAP_MODES[WRAP_MODES[\"CLAMP\"] = 33071] = \"CLAMP\";\n WRAP_MODES[WRAP_MODES[\"REPEAT\"] = 10497] = \"REPEAT\";\n WRAP_MODES[WRAP_MODES[\"MIRRORED_REPEAT\"] = 33648] = \"MIRRORED_REPEAT\";\n})(WRAP_MODES || (WRAP_MODES = {}));\n/**\n * Mipmap filtering modes that are supported by pixi.\n *\n * The {@link PIXI.settings.MIPMAP_TEXTURES} affects default texture filtering.\n * Mipmaps are generated for a baseTexture if its `mipmap` field is `ON`,\n * or its `POW2` and texture dimensions are powers of 2.\n * Due to platform restriction, `ON` option will work like `POW2` for webgl-1.\n *\n * This property only affects WebGL.\n * @name MIPMAP_MODES\n * @memberof PIXI\n * @static\n * @enum {number}\n * @property {number} OFF - No mipmaps\n * @property {number} POW2 - Generate mipmaps if texture dimensions are pow2\n * @property {number} ON - Always generate mipmaps\n * @property {number} ON_MANUAL - Use mipmaps, but do not auto-generate them; this is used with a resource\n * that supports buffering each level-of-detail.\n */\nvar MIPMAP_MODES;\n(function (MIPMAP_MODES) {\n MIPMAP_MODES[MIPMAP_MODES[\"OFF\"] = 0] = \"OFF\";\n MIPMAP_MODES[MIPMAP_MODES[\"POW2\"] = 1] = \"POW2\";\n MIPMAP_MODES[MIPMAP_MODES[\"ON\"] = 2] = \"ON\";\n MIPMAP_MODES[MIPMAP_MODES[\"ON_MANUAL\"] = 3] = \"ON_MANUAL\";\n})(MIPMAP_MODES || (MIPMAP_MODES = {}));\n/**\n * How to treat textures with premultiplied alpha\n * @name ALPHA_MODES\n * @memberof PIXI\n * @static\n * @enum {number}\n * @property {number} NO_PREMULTIPLIED_ALPHA - Source is not premultiplied, leave it like that.\n * Option for compressed and data textures that are created from typed arrays.\n * @property {number} PREMULTIPLY_ON_UPLOAD - Source is not premultiplied, premultiply on upload.\n * Default option, used for all loaded images.\n * @property {number} PREMULTIPLIED_ALPHA - Source is already premultiplied\n * Example: spine atlases with `_pma` suffix.\n * @property {number} NPM - Alias for NO_PREMULTIPLIED_ALPHA.\n * @property {number} UNPACK - Default option, alias for PREMULTIPLY_ON_UPLOAD.\n * @property {number} PMA - Alias for PREMULTIPLIED_ALPHA.\n */\nvar ALPHA_MODES;\n(function (ALPHA_MODES) {\n ALPHA_MODES[ALPHA_MODES[\"NPM\"] = 0] = \"NPM\";\n ALPHA_MODES[ALPHA_MODES[\"UNPACK\"] = 1] = \"UNPACK\";\n ALPHA_MODES[ALPHA_MODES[\"PMA\"] = 2] = \"PMA\";\n ALPHA_MODES[ALPHA_MODES[\"NO_PREMULTIPLIED_ALPHA\"] = 0] = \"NO_PREMULTIPLIED_ALPHA\";\n ALPHA_MODES[ALPHA_MODES[\"PREMULTIPLY_ON_UPLOAD\"] = 1] = \"PREMULTIPLY_ON_UPLOAD\";\n ALPHA_MODES[ALPHA_MODES[\"PREMULTIPLY_ALPHA\"] = 2] = \"PREMULTIPLY_ALPHA\";\n ALPHA_MODES[ALPHA_MODES[\"PREMULTIPLIED_ALPHA\"] = 2] = \"PREMULTIPLIED_ALPHA\";\n})(ALPHA_MODES || (ALPHA_MODES = {}));\n/**\n * Configure whether filter textures are cleared after binding.\n *\n * Filter textures need not be cleared if the filter does not use pixel blending. {@link CLEAR_MODES.BLIT} will detect\n * this and skip clearing as an optimization.\n * @name CLEAR_MODES\n * @memberof PIXI\n * @static\n * @enum {number}\n * @property {number} BLEND - Do not clear the filter texture. The filter's output will blend on top of the output texture.\n * @property {number} CLEAR - Always clear the filter texture.\n * @property {number} BLIT - Clear only if {@link FilterSystem.forceClear} is set or if the filter uses pixel blending.\n * @property {number} NO - Alias for BLEND, same as `false` in earlier versions\n * @property {number} YES - Alias for CLEAR, same as `true` in earlier versions\n * @property {number} AUTO - Alias for BLIT\n */\nvar CLEAR_MODES;\n(function (CLEAR_MODES) {\n CLEAR_MODES[CLEAR_MODES[\"NO\"] = 0] = \"NO\";\n CLEAR_MODES[CLEAR_MODES[\"YES\"] = 1] = \"YES\";\n CLEAR_MODES[CLEAR_MODES[\"AUTO\"] = 2] = \"AUTO\";\n CLEAR_MODES[CLEAR_MODES[\"BLEND\"] = 0] = \"BLEND\";\n CLEAR_MODES[CLEAR_MODES[\"CLEAR\"] = 1] = \"CLEAR\";\n CLEAR_MODES[CLEAR_MODES[\"BLIT\"] = 2] = \"BLIT\";\n})(CLEAR_MODES || (CLEAR_MODES = {}));\n/**\n * The gc modes that are supported by pixi.\n *\n * The {@link PIXI.settings.GC_MODE} Garbage Collection mode for PixiJS textures is AUTO\n * If set to GC_MODE, the renderer will occasionally check textures usage. If they are not\n * used for a specified period of time they will be removed from the GPU. They will of course\n * be uploaded again when they are required. This is a silent behind the scenes process that\n * should ensure that the GPU does not get filled up.\n *\n * Handy for mobile devices!\n * This property only affects WebGL.\n * @name GC_MODES\n * @enum {number}\n * @static\n * @memberof PIXI\n * @property {number} AUTO - Garbage collection will happen periodically automatically\n * @property {number} MANUAL - Garbage collection will need to be called manually\n */\nvar GC_MODES;\n(function (GC_MODES) {\n GC_MODES[GC_MODES[\"AUTO\"] = 0] = \"AUTO\";\n GC_MODES[GC_MODES[\"MANUAL\"] = 1] = \"MANUAL\";\n})(GC_MODES || (GC_MODES = {}));\n/**\n * Constants that specify float precision in shaders.\n * @name PRECISION\n * @memberof PIXI\n * @constant\n * @static\n * @enum {string}\n * @property {string} [LOW='lowp'] -\n * @property {string} [MEDIUM='mediump'] -\n * @property {string} [HIGH='highp'] -\n */\nvar PRECISION;\n(function (PRECISION) {\n PRECISION[\"LOW\"] = \"lowp\";\n PRECISION[\"MEDIUM\"] = \"mediump\";\n PRECISION[\"HIGH\"] = \"highp\";\n})(PRECISION || (PRECISION = {}));\n/**\n * Constants for mask implementations.\n * We use `type` suffix because it leads to very different behaviours\n * @name MASK_TYPES\n * @memberof PIXI\n * @static\n * @enum {number}\n * @property {number} NONE - Mask is ignored\n * @property {number} SCISSOR - Scissor mask, rectangle on screen, cheap\n * @property {number} STENCIL - Stencil mask, 1-bit, medium, works only if renderer supports stencil\n * @property {number} SPRITE - Mask that uses SpriteMaskFilter, uses temporary RenderTexture\n * @property {number} COLOR - Color mask (RGBA)\n */\nvar MASK_TYPES;\n(function (MASK_TYPES) {\n MASK_TYPES[MASK_TYPES[\"NONE\"] = 0] = \"NONE\";\n MASK_TYPES[MASK_TYPES[\"SCISSOR\"] = 1] = \"SCISSOR\";\n MASK_TYPES[MASK_TYPES[\"STENCIL\"] = 2] = \"STENCIL\";\n MASK_TYPES[MASK_TYPES[\"SPRITE\"] = 3] = \"SPRITE\";\n MASK_TYPES[MASK_TYPES[\"COLOR\"] = 4] = \"COLOR\";\n})(MASK_TYPES || (MASK_TYPES = {}));\n/**\n * Bitwise OR of masks that indicate the color channels that are rendered to.\n * @static\n * @memberof PIXI\n * @name COLOR_MASK_BITS\n * @enum {number}\n * @property {number} RED - Red channel.\n * @property {number} GREEN - Green channel\n * @property {number} BLUE - Blue channel.\n * @property {number} ALPHA - Alpha channel.\n */\nvar COLOR_MASK_BITS;\n(function (COLOR_MASK_BITS) {\n COLOR_MASK_BITS[COLOR_MASK_BITS[\"RED\"] = 1] = \"RED\";\n COLOR_MASK_BITS[COLOR_MASK_BITS[\"GREEN\"] = 2] = \"GREEN\";\n COLOR_MASK_BITS[COLOR_MASK_BITS[\"BLUE\"] = 4] = \"BLUE\";\n COLOR_MASK_BITS[COLOR_MASK_BITS[\"ALPHA\"] = 8] = \"ALPHA\";\n})(COLOR_MASK_BITS || (COLOR_MASK_BITS = {}));\n/**\n * Constants for multi-sampling antialiasing.\n * @see PIXI.Framebuffer#multisample\n * @name MSAA_QUALITY\n * @memberof PIXI\n * @static\n * @enum {number}\n * @property {number} NONE - No multisampling for this renderTexture\n * @property {number} LOW - Try 2 samples\n * @property {number} MEDIUM - Try 4 samples\n * @property {number} HIGH - Try 8 samples\n */\nvar MSAA_QUALITY;\n(function (MSAA_QUALITY) {\n MSAA_QUALITY[MSAA_QUALITY[\"NONE\"] = 0] = \"NONE\";\n MSAA_QUALITY[MSAA_QUALITY[\"LOW\"] = 2] = \"LOW\";\n MSAA_QUALITY[MSAA_QUALITY[\"MEDIUM\"] = 4] = \"MEDIUM\";\n MSAA_QUALITY[MSAA_QUALITY[\"HIGH\"] = 8] = \"HIGH\";\n})(MSAA_QUALITY || (MSAA_QUALITY = {}));\n/**\n * Constants for various buffer types in Pixi\n * @see PIXI.BUFFER_TYPE\n * @name BUFFER_TYPE\n * @memberof PIXI\n * @static\n * @enum {number}\n * @property {number} ELEMENT_ARRAY_BUFFER - buffer type for using as an index buffer\n * @property {number} ARRAY_BUFFER - buffer type for using attribute data\n * @property {number} UNIFORM_BUFFER - the buffer type is for uniform buffer objects\n */\nvar BUFFER_TYPE;\n(function (BUFFER_TYPE) {\n BUFFER_TYPE[BUFFER_TYPE[\"ELEMENT_ARRAY_BUFFER\"] = 34963] = \"ELEMENT_ARRAY_BUFFER\";\n BUFFER_TYPE[BUFFER_TYPE[\"ARRAY_BUFFER\"] = 34962] = \"ARRAY_BUFFER\";\n // NOT YET SUPPORTED\n BUFFER_TYPE[BUFFER_TYPE[\"UNIFORM_BUFFER\"] = 35345] = \"UNIFORM_BUFFER\";\n})(BUFFER_TYPE || (BUFFER_TYPE = {}));\n\nexport { ALPHA_MODES, BLEND_MODES, BUFFER_BITS, BUFFER_TYPE, CLEAR_MODES, COLOR_MASK_BITS, DRAW_MODES, ENV, FORMATS, GC_MODES, MASK_TYPES, MIPMAP_MODES, MSAA_QUALITY, PRECISION, RENDERER_TYPE, SAMPLER_TYPES, SCALE_MODES, TARGETS, TYPES, WRAP_MODES };\n//# sourceMappingURL=constants.mjs.map\n","/*!\n * @pixi/settings - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/settings is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { MIPMAP_MODES, MSAA_QUALITY, GC_MODES, WRAP_MODES, SCALE_MODES, PRECISION } from '@pixi/constants';\n\nvar BrowserAdapter = {\n /**\n * Creates a canvas element of the given size.\n * This canvas is created using the browser's native canvas element.\n * @param width - width of the canvas\n * @param height - height of the canvas\n */\n createCanvas: function (width, height) {\n var canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n return canvas;\n },\n getWebGLRenderingContext: function () { return WebGLRenderingContext; },\n getNavigator: function () { return navigator; },\n getBaseUrl: function () { var _a; return ((_a = document.baseURI) !== null && _a !== void 0 ? _a : window.location.href); },\n fetch: function (url, options) { return fetch(url, options); },\n};\n\nvar appleIphone = /iPhone/i;\nvar appleIpod = /iPod/i;\nvar appleTablet = /iPad/i;\nvar appleUniversal = /\\biOS-universal(?:.+)Mac\\b/i;\nvar androidPhone = /\\bAndroid(?:.+)Mobile\\b/i;\nvar androidTablet = /Android/i;\nvar amazonPhone = /(?:SD4930UR|\\bSilk(?:.+)Mobile\\b)/i;\nvar amazonTablet = /Silk/i;\nvar windowsPhone = /Windows Phone/i;\nvar windowsTablet = /\\bWindows(?:.+)ARM\\b/i;\nvar otherBlackBerry = /BlackBerry/i;\nvar otherBlackBerry10 = /BB10/i;\nvar otherOpera = /Opera Mini/i;\nvar otherChrome = /\\b(CriOS|Chrome)(?:.+)Mobile/i;\nvar otherFirefox = /Mobile(?:.+)Firefox\\b/i;\nvar isAppleTabletOnIos13 = function (navigator) {\n return (typeof navigator !== 'undefined' &&\n navigator.platform === 'MacIntel' &&\n typeof navigator.maxTouchPoints === 'number' &&\n navigator.maxTouchPoints > 1 &&\n typeof MSStream === 'undefined');\n};\nfunction createMatch(userAgent) {\n return function (regex) { return regex.test(userAgent); };\n}\nfunction isMobile$1(param) {\n var nav = {\n userAgent: '',\n platform: '',\n maxTouchPoints: 0\n };\n if (!param && typeof navigator !== 'undefined') {\n nav = {\n userAgent: navigator.userAgent,\n platform: navigator.platform,\n maxTouchPoints: navigator.maxTouchPoints || 0\n };\n }\n else if (typeof param === 'string') {\n nav.userAgent = param;\n }\n else if (param && param.userAgent) {\n nav = {\n userAgent: param.userAgent,\n platform: param.platform,\n maxTouchPoints: param.maxTouchPoints || 0\n };\n }\n var userAgent = nav.userAgent;\n var tmp = userAgent.split('[FBAN');\n if (typeof tmp[1] !== 'undefined') {\n userAgent = tmp[0];\n }\n tmp = userAgent.split('Twitter');\n if (typeof tmp[1] !== 'undefined') {\n userAgent = tmp[0];\n }\n var match = createMatch(userAgent);\n var result = {\n apple: {\n phone: match(appleIphone) && !match(windowsPhone),\n ipod: match(appleIpod),\n tablet: !match(appleIphone) &&\n (match(appleTablet) || isAppleTabletOnIos13(nav)) &&\n !match(windowsPhone),\n universal: match(appleUniversal),\n device: (match(appleIphone) ||\n match(appleIpod) ||\n match(appleTablet) ||\n match(appleUniversal) ||\n isAppleTabletOnIos13(nav)) &&\n !match(windowsPhone)\n },\n amazon: {\n phone: match(amazonPhone),\n tablet: !match(amazonPhone) && match(amazonTablet),\n device: match(amazonPhone) || match(amazonTablet)\n },\n android: {\n phone: (!match(windowsPhone) && match(amazonPhone)) ||\n (!match(windowsPhone) && match(androidPhone)),\n tablet: !match(windowsPhone) &&\n !match(amazonPhone) &&\n !match(androidPhone) &&\n (match(amazonTablet) || match(androidTablet)),\n device: (!match(windowsPhone) &&\n (match(amazonPhone) ||\n match(amazonTablet) ||\n match(androidPhone) ||\n match(androidTablet))) ||\n match(/\\bokhttp\\b/i)\n },\n windows: {\n phone: match(windowsPhone),\n tablet: match(windowsTablet),\n device: match(windowsPhone) || match(windowsTablet)\n },\n other: {\n blackberry: match(otherBlackBerry),\n blackberry10: match(otherBlackBerry10),\n opera: match(otherOpera),\n firefox: match(otherFirefox),\n chrome: match(otherChrome),\n device: match(otherBlackBerry) ||\n match(otherBlackBerry10) ||\n match(otherOpera) ||\n match(otherFirefox) ||\n match(otherChrome)\n },\n any: false,\n phone: false,\n tablet: false\n };\n result.any =\n result.apple.device ||\n result.android.device ||\n result.windows.device ||\n result.other.device;\n result.phone =\n result.apple.phone || result.android.phone || result.windows.phone;\n result.tablet =\n result.apple.tablet || result.android.tablet || result.windows.tablet;\n return result;\n}\n\nvar isMobile = isMobile$1(globalThis.navigator);\n\n/**\n * Uploading the same buffer multiple times in a single frame can cause performance issues.\n * Apparent on iOS so only check for that at the moment\n * This check may become more complex if this issue pops up elsewhere.\n * @private\n * @returns {boolean} `true` if the same buffer may be uploaded more than once.\n */\nfunction canUploadSameBuffer() {\n return !isMobile.apple.device;\n}\n\n/**\n * The maximum recommended texture units to use.\n * In theory the bigger the better, and for desktop we'll use as many as we can.\n * But some mobile devices slow down if there is to many branches in the shader.\n * So in practice there seems to be a sweet spot size that varies depending on the device.\n *\n * In v4, all mobile devices were limited to 4 texture units because for this.\n * In v5, we allow all texture units to be used on modern Apple or Android devices.\n * @private\n * @param {number} max\n * @returns {number} The maximum recommended texture units to use.\n */\nfunction maxRecommendedTextures(max) {\n var allowMax = true;\n if (isMobile.tablet || isMobile.phone) {\n if (isMobile.apple.device) {\n var match = (navigator.userAgent).match(/OS (\\d+)_(\\d+)?/);\n if (match) {\n var majorVersion = parseInt(match[1], 10);\n // Limit texture units on devices below iOS 11, which will be older hardware\n if (majorVersion < 11) {\n allowMax = false;\n }\n }\n }\n if (isMobile.android.device) {\n var match = (navigator.userAgent).match(/Android\\s([0-9.]*)/);\n if (match) {\n var majorVersion = parseInt(match[1], 10);\n // Limit texture units on devices below Android 7 (Nougat), which will be older hardware\n if (majorVersion < 7) {\n allowMax = false;\n }\n }\n }\n }\n return allowMax ? max : 4;\n}\n\n/**\n * User's customizable globals for overriding the default PIXI settings, such\n * as a renderer's default resolution, framerate, float precision, etc.\n * @example\n * // Use the native window resolution as the default resolution\n * // will support high-density displays when rendering\n * PIXI.settings.RESOLUTION = window.devicePixelRatio;\n *\n * // Disable interpolation when scaling, will make texture be pixelated\n * PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST;\n * @namespace PIXI.settings\n */\nvar settings = {\n /**\n * This adapter is used to call methods that are platform dependent.\n * For example `document.createElement` only runs on the web but fails in node environments.\n * This allows us to support more platforms by abstracting away specific implementations per platform.\n *\n * By default the adapter is set to work in the browser. However you can create your own\n * by implementing the `IAdapter` interface. See `IAdapter` for more information.\n * @name ADAPTER\n * @memberof PIXI.settings\n * @type {PIXI.IAdapter}\n * @default PIXI.BrowserAdapter\n */\n ADAPTER: BrowserAdapter,\n /**\n * If set to true WebGL will attempt make textures mimpaped by default.\n * Mipmapping will only succeed if the base texture uploaded has power of two dimensions.\n * @static\n * @name MIPMAP_TEXTURES\n * @memberof PIXI.settings\n * @type {PIXI.MIPMAP_MODES}\n * @default PIXI.MIPMAP_MODES.POW2\n */\n MIPMAP_TEXTURES: MIPMAP_MODES.POW2,\n /**\n * Default anisotropic filtering level of textures.\n * Usually from 0 to 16\n * @static\n * @name ANISOTROPIC_LEVEL\n * @memberof PIXI.settings\n * @type {number}\n * @default 0\n */\n ANISOTROPIC_LEVEL: 0,\n /**\n * Default resolution / device pixel ratio of the renderer.\n * @static\n * @name RESOLUTION\n * @memberof PIXI.settings\n * @type {number}\n * @default 1\n */\n RESOLUTION: 1,\n /**\n * Default filter resolution.\n * @static\n * @name FILTER_RESOLUTION\n * @memberof PIXI.settings\n * @type {number}\n * @default 1\n */\n FILTER_RESOLUTION: 1,\n /**\n * Default filter samples.\n * @static\n * @name FILTER_MULTISAMPLE\n * @memberof PIXI.settings\n * @type {PIXI.MSAA_QUALITY}\n * @default PIXI.MSAA_QUALITY.NONE\n */\n FILTER_MULTISAMPLE: MSAA_QUALITY.NONE,\n /**\n * The maximum textures that this device supports.\n * @static\n * @name SPRITE_MAX_TEXTURES\n * @memberof PIXI.settings\n * @type {number}\n * @default 32\n */\n SPRITE_MAX_TEXTURES: maxRecommendedTextures(32),\n // TODO: maybe change to SPRITE.BATCH_SIZE: 2000\n // TODO: maybe add PARTICLE.BATCH_SIZE: 15000\n /**\n * The default sprite batch size.\n *\n * The default aims to balance desktop and mobile devices.\n * @static\n * @name SPRITE_BATCH_SIZE\n * @memberof PIXI.settings\n * @type {number}\n * @default 4096\n */\n SPRITE_BATCH_SIZE: 4096,\n /**\n * The default render options if none are supplied to {@link PIXI.Renderer}\n * or {@link PIXI.CanvasRenderer}.\n * @static\n * @name RENDER_OPTIONS\n * @memberof PIXI.settings\n * @type {object}\n * @property {boolean} [antialias=false] - {@link PIXI.IRendererOptions.antialias}\n * @property {boolean} [autoDensity=false] - {@link PIXI.IRendererOptions.autoDensity}\n * @property {number} [backgroundAlpha=1] - {@link PIXI.IRendererOptions.backgroundAlpha}\n * @property {number} [backgroundColor=0x000000] - {@link PIXI.IRendererOptions.backgroundColor}\n * @property {boolean} [clearBeforeRender=true] - {@link PIXI.IRendererOptions.clearBeforeRender}\n * @property {number} [height=600] - {@link PIXI.IRendererOptions.height}\n * @property {boolean} [preserveDrawingBuffer=false] - {@link PIXI.IRendererOptions.preserveDrawingBuffer}\n * @property {boolean|'notMultiplied'} [useContextAlpha=true] - {@link PIXI.IRendererOptions.useContextAlpha}\n * @property {HTMLCanvasElement} [view=null] - {@link PIXI.IRendererOptions.view}\n * @property {number} [width=800] - {@link PIXI.IRendererOptions.width}\n */\n RENDER_OPTIONS: {\n view: null,\n width: 800,\n height: 600,\n autoDensity: false,\n backgroundColor: 0x000000,\n backgroundAlpha: 1,\n useContextAlpha: true,\n clearBeforeRender: true,\n antialias: false,\n preserveDrawingBuffer: false,\n },\n /**\n * Default Garbage Collection mode.\n * @static\n * @name GC_MODE\n * @memberof PIXI.settings\n * @type {PIXI.GC_MODES}\n * @default PIXI.GC_MODES.AUTO\n */\n GC_MODE: GC_MODES.AUTO,\n /**\n * Default Garbage Collection max idle.\n * @static\n * @name GC_MAX_IDLE\n * @memberof PIXI.settings\n * @type {number}\n * @default 3600\n */\n GC_MAX_IDLE: 60 * 60,\n /**\n * Default Garbage Collection maximum check count.\n * @static\n * @name GC_MAX_CHECK_COUNT\n * @memberof PIXI.settings\n * @type {number}\n * @default 600\n */\n GC_MAX_CHECK_COUNT: 60 * 10,\n /**\n * Default wrap modes that are supported by pixi.\n * @static\n * @name WRAP_MODE\n * @memberof PIXI.settings\n * @type {PIXI.WRAP_MODES}\n * @default PIXI.WRAP_MODES.CLAMP\n */\n WRAP_MODE: WRAP_MODES.CLAMP,\n /**\n * Default scale mode for textures.\n * @static\n * @name SCALE_MODE\n * @memberof PIXI.settings\n * @type {PIXI.SCALE_MODES}\n * @default PIXI.SCALE_MODES.LINEAR\n */\n SCALE_MODE: SCALE_MODES.LINEAR,\n /**\n * Default specify float precision in vertex shader.\n * @static\n * @name PRECISION_VERTEX\n * @memberof PIXI.settings\n * @type {PIXI.PRECISION}\n * @default PIXI.PRECISION.HIGH\n */\n PRECISION_VERTEX: PRECISION.HIGH,\n /**\n * Default specify float precision in fragment shader.\n * iOS is best set at highp due to https://github.com/pixijs/pixi.js/issues/3742\n * @static\n * @name PRECISION_FRAGMENT\n * @memberof PIXI.settings\n * @type {PIXI.PRECISION}\n * @default PIXI.PRECISION.MEDIUM\n */\n PRECISION_FRAGMENT: isMobile.apple.device ? PRECISION.HIGH : PRECISION.MEDIUM,\n /**\n * Can we upload the same buffer in a single frame?\n * @static\n * @name CAN_UPLOAD_SAME_BUFFER\n * @memberof PIXI.settings\n * @type {boolean}\n */\n CAN_UPLOAD_SAME_BUFFER: canUploadSameBuffer(),\n /**\n * Enables bitmap creation before image load. This feature is experimental.\n * @static\n * @name CREATE_IMAGE_BITMAP\n * @memberof PIXI.settings\n * @type {boolean}\n * @default false\n */\n CREATE_IMAGE_BITMAP: false,\n /**\n * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation.\n * Advantages can include sharper image quality (like text) and faster rendering on canvas.\n * The main disadvantage is movement of objects may appear less smooth.\n * @static\n * @constant\n * @memberof PIXI.settings\n * @type {boolean}\n * @default false\n */\n ROUND_PIXELS: false,\n};\n\nexport { BrowserAdapter, isMobile, settings };\n//# sourceMappingURL=settings.mjs.map\n","'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */\nfunction addListener(emitter, event, fn, context, once) {\n if (typeof fn !== 'function') {\n throw new TypeError('The listener must be a function');\n }\n\n var listener = new EE(fn, context || emitter, once)\n , evt = prefix ? prefix + event : event;\n\n if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n else emitter._events[evt] = [emitter._events[evt], listener];\n\n return emitter;\n}\n\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */\nfunction clearEvent(emitter, evt) {\n if (--emitter._eventsCount === 0) emitter._events = new Events();\n else delete emitter._events[evt];\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */\nEventEmitter.prototype.listeners = function listeners(event) {\n var evt = prefix ? prefix + event : event\n , handlers = this._events[evt];\n\n if (!handlers) return [];\n if (handlers.fn) return [handlers.fn];\n\n for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {\n ee[i] = handlers[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */\nEventEmitter.prototype.listenerCount = function listenerCount(event) {\n var evt = prefix ? prefix + event : event\n , listeners = this._events[evt];\n\n if (!listeners) return 0;\n if (listeners.fn) return 1;\n return listeners.length;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n return addListener(this, event, fn, context, false);\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n return addListener(this, event, fn, context, true);\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n clearEvent(this, evt);\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn &&\n (!once || listeners.once) &&\n (!context || listeners.context === context)\n ) {\n clearEvent(this, evt);\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn ||\n (once && !listeners[i].once) ||\n (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else clearEvent(this, evt);\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) clearEvent(this, evt);\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n module.exports = EventEmitter;\n}\n","'use strict';\n\nmodule.exports = earcut;\nmodule.exports.default = earcut;\n\nfunction earcut(data, holeIndices, dim) {\n\n dim = dim || 2;\n\n var hasHoles = holeIndices && holeIndices.length,\n outerLen = hasHoles ? holeIndices[0] * dim : data.length,\n outerNode = linkedList(data, 0, outerLen, dim, true),\n triangles = [];\n\n if (!outerNode || outerNode.next === outerNode.prev) return triangles;\n\n var minX, minY, maxX, maxY, x, y, invSize;\n\n if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);\n\n // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox\n if (data.length > 80 * dim) {\n minX = maxX = data[0];\n minY = maxY = data[1];\n\n for (var i = dim; i < outerLen; i += dim) {\n x = data[i];\n y = data[i + 1];\n if (x < minX) minX = x;\n if (y < minY) minY = y;\n if (x > maxX) maxX = x;\n if (y > maxY) maxY = y;\n }\n\n // minX, minY and invSize are later used to transform coords into integers for z-order calculation\n invSize = Math.max(maxX - minX, maxY - minY);\n invSize = invSize !== 0 ? 32767 / invSize : 0;\n }\n\n earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);\n\n return triangles;\n}\n\n// create a circular doubly linked list from polygon points in the specified winding order\nfunction linkedList(data, start, end, dim, clockwise) {\n var i, last;\n\n if (clockwise === (signedArea(data, start, end, dim) > 0)) {\n for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);\n } else {\n for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);\n }\n\n if (last && equals(last, last.next)) {\n removeNode(last);\n last = last.next;\n }\n\n return last;\n}\n\n// eliminate colinear or duplicate points\nfunction filterPoints(start, end) {\n if (!start) return start;\n if (!end) end = start;\n\n var p = start,\n again;\n do {\n again = false;\n\n if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {\n removeNode(p);\n p = end = p.prev;\n if (p === p.next) break;\n again = true;\n\n } else {\n p = p.next;\n }\n } while (again || p !== end);\n\n return end;\n}\n\n// main ear slicing loop which triangulates a polygon (given as a linked list)\nfunction earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {\n if (!ear) return;\n\n // interlink polygon nodes in z-order\n if (!pass && invSize) indexCurve(ear, minX, minY, invSize);\n\n var stop = ear,\n prev, next;\n\n // iterate through ears, slicing them one by one\n while (ear.prev !== ear.next) {\n prev = ear.prev;\n next = ear.next;\n\n if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {\n // cut off the triangle\n triangles.push(prev.i / dim | 0);\n triangles.push(ear.i / dim | 0);\n triangles.push(next.i / dim | 0);\n\n removeNode(ear);\n\n // skipping the next vertex leads to less sliver triangles\n ear = next.next;\n stop = next.next;\n\n continue;\n }\n\n ear = next;\n\n // if we looped through the whole remaining polygon and can't find any more ears\n if (ear === stop) {\n // try filtering points and slicing again\n if (!pass) {\n earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);\n\n // if this didn't work, try curing all small self-intersections locally\n } else if (pass === 1) {\n ear = cureLocalIntersections(filterPoints(ear), triangles, dim);\n earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);\n\n // as a last resort, try splitting the remaining polygon into two\n } else if (pass === 2) {\n splitEarcut(ear, triangles, dim, minX, minY, invSize);\n }\n\n break;\n }\n }\n}\n\n// check whether a polygon node forms a valid ear with adjacent nodes\nfunction isEar(ear) {\n var a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n // now make sure we don't have other points inside the potential ear\n var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox; min & max are calculated like this for speed\n var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),\n y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),\n x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),\n y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);\n\n var p = c.next;\n while (p !== a) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&\n area(p.prev, p, p.next) >= 0) return false;\n p = p.next;\n }\n\n return true;\n}\n\nfunction isEarHashed(ear, minX, minY, invSize) {\n var a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox; min & max are calculated like this for speed\n var x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),\n y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),\n x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),\n y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);\n\n // z-order range for the current triangle bbox;\n var minZ = zOrder(x0, y0, minX, minY, invSize),\n maxZ = zOrder(x1, y1, minX, minY, invSize);\n\n var p = ear.prevZ,\n n = ear.nextZ;\n\n // look for points inside the triangle in both directions\n while (p && p.z >= minZ && n && n.z <= maxZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n // look for remaining points in decreasing z-order\n while (p && p.z >= minZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n }\n\n // look for remaining points in increasing z-order\n while (n && n.z <= maxZ) {\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n return true;\n}\n\n// go through all polygon nodes and cure small local self-intersections\nfunction cureLocalIntersections(start, triangles, dim) {\n var p = start;\n do {\n var a = p.prev,\n b = p.next.next;\n\n if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {\n\n triangles.push(a.i / dim | 0);\n triangles.push(p.i / dim | 0);\n triangles.push(b.i / dim | 0);\n\n // remove two nodes involved\n removeNode(p);\n removeNode(p.next);\n\n p = start = b;\n }\n p = p.next;\n } while (p !== start);\n\n return filterPoints(p);\n}\n\n// try splitting polygon into two and triangulate them independently\nfunction splitEarcut(start, triangles, dim, minX, minY, invSize) {\n // look for a valid diagonal that divides the polygon into two\n var a = start;\n do {\n var b = a.next.next;\n while (b !== a.prev) {\n if (a.i !== b.i && isValidDiagonal(a, b)) {\n // split the polygon in two by the diagonal\n var c = splitPolygon(a, b);\n\n // filter colinear points around the cuts\n a = filterPoints(a, a.next);\n c = filterPoints(c, c.next);\n\n // run earcut on each half\n earcutLinked(a, triangles, dim, minX, minY, invSize, 0);\n earcutLinked(c, triangles, dim, minX, minY, invSize, 0);\n return;\n }\n b = b.next;\n }\n a = a.next;\n } while (a !== start);\n}\n\n// link every hole into the outer loop, producing a single-ring polygon without holes\nfunction eliminateHoles(data, holeIndices, outerNode, dim) {\n var queue = [],\n i, len, start, end, list;\n\n for (i = 0, len = holeIndices.length; i < len; i++) {\n start = holeIndices[i] * dim;\n end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n list = linkedList(data, start, end, dim, false);\n if (list === list.next) list.steiner = true;\n queue.push(getLeftmost(list));\n }\n\n queue.sort(compareX);\n\n // process holes from left to right\n for (i = 0; i < queue.length; i++) {\n outerNode = eliminateHole(queue[i], outerNode);\n }\n\n return outerNode;\n}\n\nfunction compareX(a, b) {\n return a.x - b.x;\n}\n\n// find a bridge between vertices that connects hole with an outer ring and and link it\nfunction eliminateHole(hole, outerNode) {\n var bridge = findHoleBridge(hole, outerNode);\n if (!bridge) {\n return outerNode;\n }\n\n var bridgeReverse = splitPolygon(bridge, hole);\n\n // filter collinear points around the cuts\n filterPoints(bridgeReverse, bridgeReverse.next);\n return filterPoints(bridge, bridge.next);\n}\n\n// David Eberly's algorithm for finding a bridge between hole and outer polygon\nfunction findHoleBridge(hole, outerNode) {\n var p = outerNode,\n hx = hole.x,\n hy = hole.y,\n qx = -Infinity,\n m;\n\n // find a segment intersected by a ray from the hole's leftmost point to the left;\n // segment's endpoint with lesser x will be potential connection point\n do {\n if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {\n var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);\n if (x <= hx && x > qx) {\n qx = x;\n m = p.x < p.next.x ? p : p.next;\n if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint\n }\n }\n p = p.next;\n } while (p !== outerNode);\n\n if (!m) return null;\n\n // look for points inside the triangle of hole point, segment intersection and endpoint;\n // if there are no points found, we have a valid connection;\n // otherwise choose the point of the minimum angle with the ray as connection point\n\n var stop = m,\n mx = m.x,\n my = m.y,\n tanMin = Infinity,\n tan;\n\n p = m;\n\n do {\n if (hx >= p.x && p.x >= mx && hx !== p.x &&\n pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {\n\n tan = Math.abs(hy - p.y) / (hx - p.x); // tangential\n\n if (locallyInside(p, hole) &&\n (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {\n m = p;\n tanMin = tan;\n }\n }\n\n p = p.next;\n } while (p !== stop);\n\n return m;\n}\n\n// whether sector in vertex m contains sector in vertex p in the same coordinates\nfunction sectorContainsSector(m, p) {\n return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;\n}\n\n// interlink polygon nodes in z-order\nfunction indexCurve(start, minX, minY, invSize) {\n var p = start;\n do {\n if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);\n p.prevZ = p.prev;\n p.nextZ = p.next;\n p = p.next;\n } while (p !== start);\n\n p.prevZ.nextZ = null;\n p.prevZ = null;\n\n sortLinked(p);\n}\n\n// Simon Tatham's linked list merge sort algorithm\n// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html\nfunction sortLinked(list) {\n var i, p, q, e, tail, numMerges, pSize, qSize,\n inSize = 1;\n\n do {\n p = list;\n list = null;\n tail = null;\n numMerges = 0;\n\n while (p) {\n numMerges++;\n q = p;\n pSize = 0;\n for (i = 0; i < inSize; i++) {\n pSize++;\n q = q.nextZ;\n if (!q) break;\n }\n qSize = inSize;\n\n while (pSize > 0 || (qSize > 0 && q)) {\n\n if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {\n e = p;\n p = p.nextZ;\n pSize--;\n } else {\n e = q;\n q = q.nextZ;\n qSize--;\n }\n\n if (tail) tail.nextZ = e;\n else list = e;\n\n e.prevZ = tail;\n tail = e;\n }\n\n p = q;\n }\n\n tail.nextZ = null;\n inSize *= 2;\n\n } while (numMerges > 1);\n\n return list;\n}\n\n// z-order of a point given coords and inverse of the longer side of data bbox\nfunction zOrder(x, y, minX, minY, invSize) {\n // coords are transformed into non-negative 15-bit integer range\n x = (x - minX) * invSize | 0;\n y = (y - minY) * invSize | 0;\n\n x = (x | (x << 8)) & 0x00FF00FF;\n x = (x | (x << 4)) & 0x0F0F0F0F;\n x = (x | (x << 2)) & 0x33333333;\n x = (x | (x << 1)) & 0x55555555;\n\n y = (y | (y << 8)) & 0x00FF00FF;\n y = (y | (y << 4)) & 0x0F0F0F0F;\n y = (y | (y << 2)) & 0x33333333;\n y = (y | (y << 1)) & 0x55555555;\n\n return x | (y << 1);\n}\n\n// find the leftmost node of a polygon ring\nfunction getLeftmost(start) {\n var p = start,\n leftmost = start;\n do {\n if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;\n p = p.next;\n } while (p !== start);\n\n return leftmost;\n}\n\n// check if a point lies within a convex triangle\nfunction pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {\n return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&\n (ax - px) * (by - py) >= (bx - px) * (ay - py) &&\n (bx - px) * (cy - py) >= (cx - px) * (by - py);\n}\n\n// check if a diagonal between two polygon nodes is valid (lies in polygon interior)\nfunction isValidDiagonal(a, b) {\n return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges\n (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible\n (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors\n equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case\n}\n\n// signed area of a triangle\nfunction area(p, q, r) {\n return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);\n}\n\n// check if two points are equal\nfunction equals(p1, p2) {\n return p1.x === p2.x && p1.y === p2.y;\n}\n\n// check if two segments intersect\nfunction intersects(p1, q1, p2, q2) {\n var o1 = sign(area(p1, q1, p2));\n var o2 = sign(area(p1, q1, q2));\n var o3 = sign(area(p2, q2, p1));\n var o4 = sign(area(p2, q2, q1));\n\n if (o1 !== o2 && o3 !== o4) return true; // general case\n\n if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1\n if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1\n if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2\n if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2\n\n return false;\n}\n\n// for collinear points p, q, r, check if point q lies on segment pr\nfunction onSegment(p, q, r) {\n return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);\n}\n\nfunction sign(num) {\n return num > 0 ? 1 : num < 0 ? -1 : 0;\n}\n\n// check if a polygon diagonal intersects any polygon segments\nfunction intersectsPolygon(a, b) {\n var p = a;\n do {\n if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&\n intersects(p, p.next, a, b)) return true;\n p = p.next;\n } while (p !== a);\n\n return false;\n}\n\n// check if a polygon diagonal is locally inside the polygon\nfunction locallyInside(a, b) {\n return area(a.prev, a, a.next) < 0 ?\n area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :\n area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;\n}\n\n// check if the middle point of a polygon diagonal is inside the polygon\nfunction middleInside(a, b) {\n var p = a,\n inside = false,\n px = (a.x + b.x) / 2,\n py = (a.y + b.y) / 2;\n do {\n if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&\n (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))\n inside = !inside;\n p = p.next;\n } while (p !== a);\n\n return inside;\n}\n\n// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;\n// if one belongs to the outer ring and another to a hole, it merges it into a single ring\nfunction splitPolygon(a, b) {\n var a2 = new Node(a.i, a.x, a.y),\n b2 = new Node(b.i, b.x, b.y),\n an = a.next,\n bp = b.prev;\n\n a.next = b;\n b.prev = a;\n\n a2.next = an;\n an.prev = a2;\n\n b2.next = a2;\n a2.prev = b2;\n\n bp.next = b2;\n b2.prev = bp;\n\n return b2;\n}\n\n// create a node and optionally link it with previous one (in a circular doubly linked list)\nfunction insertNode(i, x, y, last) {\n var p = new Node(i, x, y);\n\n if (!last) {\n p.prev = p;\n p.next = p;\n\n } else {\n p.next = last.next;\n p.prev = last;\n last.next.prev = p;\n last.next = p;\n }\n return p;\n}\n\nfunction removeNode(p) {\n p.next.prev = p.prev;\n p.prev.next = p.next;\n\n if (p.prevZ) p.prevZ.nextZ = p.nextZ;\n if (p.nextZ) p.nextZ.prevZ = p.prevZ;\n}\n\nfunction Node(i, x, y) {\n // vertex index in coordinates array\n this.i = i;\n\n // vertex coordinates\n this.x = x;\n this.y = y;\n\n // previous and next vertex nodes in a polygon ring\n this.prev = null;\n this.next = null;\n\n // z-order curve value\n this.z = 0;\n\n // previous and next nodes in z-order\n this.prevZ = null;\n this.nextZ = null;\n\n // indicates whether this is a steiner point\n this.steiner = false;\n}\n\n// return a percentage difference between the polygon area and its triangulation area;\n// used to verify correctness of triangulation\nearcut.deviation = function (data, holeIndices, dim, triangles) {\n var hasHoles = holeIndices && holeIndices.length;\n var outerLen = hasHoles ? holeIndices[0] * dim : data.length;\n\n var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));\n if (hasHoles) {\n for (var i = 0, len = holeIndices.length; i < len; i++) {\n var start = holeIndices[i] * dim;\n var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n polygonArea -= Math.abs(signedArea(data, start, end, dim));\n }\n }\n\n var trianglesArea = 0;\n for (i = 0; i < triangles.length; i += 3) {\n var a = triangles[i] * dim;\n var b = triangles[i + 1] * dim;\n var c = triangles[i + 2] * dim;\n trianglesArea += Math.abs(\n (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -\n (data[a] - data[b]) * (data[c + 1] - data[a + 1]));\n }\n\n return polygonArea === 0 && trianglesArea === 0 ? 0 :\n Math.abs((trianglesArea - polygonArea) / polygonArea);\n};\n\nfunction signedArea(data, start, end, dim) {\n var sum = 0;\n for (var i = start, j = end - dim; i < end; i += dim) {\n sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);\n j = i;\n }\n return sum;\n}\n\n// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts\nearcut.flatten = function (data) {\n var dim = data[0][0].length,\n result = {vertices: [], holes: [], dimensions: dim},\n holeIndex = 0;\n\n for (var i = 0; i < data.length; i++) {\n for (var j = 0; j < data[i].length; j++) {\n for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);\n }\n if (i > 0) {\n holeIndex += data[i - 1].length;\n result.holes.push(holeIndex);\n }\n }\n return result;\n};\n","/*!\n * @pixi/utils - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/utils is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { settings } from '@pixi/settings';\nexport { isMobile } from '@pixi/settings';\nexport { default as EventEmitter } from 'eventemitter3';\nexport { default as earcut } from 'earcut';\nimport { parse, format, resolve } from 'url';\nimport { BLEND_MODES } from '@pixi/constants';\n\n/**\n * This file contains redeclared types for Node `url` and `querystring` modules. These modules\n * don't provide their own typings but instead are a part of the full Node typings. The purpose of\n * this file is to redeclare the required types to avoid having the whole Node types as a\n * dependency.\n */\nvar url = {\n parse: parse,\n format: format,\n resolve: resolve,\n};\n\nfunction assertPath(path) {\n if (typeof path !== 'string') {\n throw new TypeError(\"Path must be a string. Received \" + JSON.stringify(path));\n }\n}\nfunction removeUrlParams(url) {\n var re = url.split('?')[0];\n return re.split('#')[0];\n}\nfunction escapeRegExp(string) {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n}\nfunction replaceAll(str, find, replace) {\n return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);\n}\n// Resolves . and .. elements in a path with directory names\nfunction normalizeStringPosix(path, allowAboveRoot) {\n var res = '';\n var lastSegmentLength = 0;\n var lastSlash = -1;\n var dots = 0;\n var code;\n for (var i = 0; i <= path.length; ++i) {\n if (i < path.length) {\n code = path.charCodeAt(i);\n }\n else if (code === 47) {\n break;\n }\n else {\n code = 47;\n }\n if (code === 47) {\n if (lastSlash === i - 1 || dots === 1) ;\n else if (lastSlash !== i - 1 && dots === 2) {\n if (res.length < 2\n || lastSegmentLength !== 2\n || res.charCodeAt(res.length - 1) !== 46\n || res.charCodeAt(res.length - 2) !== 46) {\n if (res.length > 2) {\n var lastSlashIndex = res.lastIndexOf('/');\n if (lastSlashIndex !== res.length - 1) {\n if (lastSlashIndex === -1) {\n res = '';\n lastSegmentLength = 0;\n }\n else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf('/');\n }\n lastSlash = i;\n dots = 0;\n continue;\n }\n }\n else if (res.length === 2 || res.length === 1) {\n res = '';\n lastSegmentLength = 0;\n lastSlash = i;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n if (res.length > 0) {\n res += '/..';\n }\n else {\n res = '..';\n }\n lastSegmentLength = 2;\n }\n }\n else {\n if (res.length > 0) {\n res += \"/\" + path.slice(lastSlash + 1, i);\n }\n else {\n res = path.slice(lastSlash + 1, i);\n }\n lastSegmentLength = i - lastSlash - 1;\n }\n lastSlash = i;\n dots = 0;\n }\n else if (code === 46 && dots !== -1) {\n ++dots;\n }\n else {\n dots = -1;\n }\n }\n return res;\n}\nvar path = {\n /**\n * Converts a path to posix format.\n * @param path - The path to convert to posix\n */\n toPosix: function (path) { return replaceAll(path, '\\\\', '/'); },\n /**\n * Checks if the path is a URL\n * @param path - The path to check\n */\n isUrl: function (path) { return (/^https?:/).test(this.toPosix(path)); },\n /**\n * Checks if the path is a data URL\n * @param path - The path to check\n */\n isDataUrl: function (path) {\n // eslint-disable-next-line max-len\n return (/^data:([a-z]+\\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\\-._~:@\\/?%\\s<>]*?)$/i)\n .test(path);\n },\n /**\n * Checks if the path has a protocol e.g. http://\n * This will return true for windows file paths\n * @param path - The path to check\n */\n hasProtocol: function (path) { return (/^[^/:]+:\\//).test(this.toPosix(path)); },\n /**\n * Returns the protocol of the path e.g. http://, C:/, file:///\n * @param path - The path to get the protocol from\n */\n getProtocol: function (path) {\n assertPath(path);\n path = this.toPosix(path);\n var protocol = '';\n var isFile = (/^file:\\/\\/\\//).exec(path);\n var isHttp = (/^[^/:]+:\\/\\//).exec(path);\n var isWindows = (/^[^/:]+:\\//).exec(path);\n if (isFile || isHttp || isWindows) {\n var arr = (isFile === null || isFile === void 0 ? void 0 : isFile[0]) || (isHttp === null || isHttp === void 0 ? void 0 : isHttp[0]) || (isWindows === null || isWindows === void 0 ? void 0 : isWindows[0]);\n protocol = arr;\n path = path.slice(arr.length);\n }\n return protocol;\n },\n /**\n * Converts URL to an absolute path.\n * When loading from a Web Worker, we must use absolute paths.\n * If the URL is already absolute we return it as is\n * If it's not, we convert it\n * @param url - The URL to test\n * @param customBaseUrl - The base URL to use\n * @param customRootUrl - The root URL to use\n */\n toAbsolute: function (url, customBaseUrl, customRootUrl) {\n if (this.isDataUrl(url))\n { return url; }\n var baseUrl = removeUrlParams(this.toPosix(customBaseUrl !== null && customBaseUrl !== void 0 ? customBaseUrl : settings.ADAPTER.getBaseUrl()));\n var rootUrl = removeUrlParams(this.toPosix(customRootUrl !== null && customRootUrl !== void 0 ? customRootUrl : this.rootname(baseUrl)));\n assertPath(url);\n url = this.toPosix(url);\n // root relative url\n if (url.startsWith('/')) {\n return path.join(rootUrl, url.slice(1));\n }\n var absolutePath = this.isAbsolute(url) ? url : this.join(baseUrl, url);\n return absolutePath;\n },\n /**\n * Normalizes the given path, resolving '..' and '.' segments\n * @param path - The path to normalize\n */\n normalize: function (path) {\n path = this.toPosix(path);\n assertPath(path);\n if (path.length === 0)\n { return '.'; }\n var protocol = '';\n var isAbsolute = path.startsWith('/');\n if (this.hasProtocol(path)) {\n protocol = this.rootname(path);\n path = path.slice(protocol.length);\n }\n var trailingSeparator = path.endsWith('/');\n // Normalize the path\n path = normalizeStringPosix(path, false);\n if (path.length > 0 && trailingSeparator)\n { path += '/'; }\n if (isAbsolute)\n { return \"/\" + path; }\n return protocol + path;\n },\n /**\n * Determines if path is an absolute path.\n * Absolute paths can be urls, data urls, or paths on disk\n * @param path - The path to test\n */\n isAbsolute: function (path) {\n assertPath(path);\n path = this.toPosix(path);\n if (this.hasProtocol(path))\n { return true; }\n return path.startsWith('/');\n },\n /**\n * Joins all given path segments together using the platform-specific separator as a delimiter,\n * then normalizes the resulting path\n * @param segments - The segments of the path to join\n */\n join: function () {\n var arguments$1 = arguments;\n\n var _a;\n var segments = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n segments[_i] = arguments$1[_i];\n }\n if (segments.length === 0) {\n return '.';\n }\n var joined;\n for (var i = 0; i < segments.length; ++i) {\n var arg = segments[i];\n assertPath(arg);\n if (arg.length > 0) {\n if (joined === undefined)\n { joined = arg; }\n else {\n var prevArg = (_a = segments[i - 1]) !== null && _a !== void 0 ? _a : '';\n if (this.extname(prevArg)) {\n joined += \"/../\" + arg;\n }\n else {\n joined += \"/\" + arg;\n }\n }\n }\n }\n if (joined === undefined) {\n return '.';\n }\n return this.normalize(joined);\n },\n /**\n * Returns the directory name of a path\n * @param path - The path to parse\n */\n dirname: function (path) {\n assertPath(path);\n if (path.length === 0)\n { return '.'; }\n path = this.toPosix(path);\n var code = path.charCodeAt(0);\n var hasRoot = code === 47;\n var end = -1;\n var matchedSlash = true;\n var proto = this.getProtocol(path);\n var origpath = path;\n path = path.slice(proto.length);\n for (var i = path.length - 1; i >= 1; --i) {\n code = path.charCodeAt(i);\n if (code === 47) {\n if (!matchedSlash) {\n end = i;\n break;\n }\n }\n else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n // if end is -1 and its a url then we need to add the path back\n // eslint-disable-next-line no-nested-ternary\n if (end === -1)\n { return hasRoot ? '/' : this.isUrl(origpath) ? proto + path : proto; }\n if (hasRoot && end === 1)\n { return '//'; }\n return proto + path.slice(0, end);\n },\n /**\n * Returns the root of the path e.g. /, C:/, file:///, http://domain.com/\n * @param path - The path to parse\n */\n rootname: function (path) {\n assertPath(path);\n path = this.toPosix(path);\n var root = '';\n if (path.startsWith('/'))\n { root = '/'; }\n else {\n root = this.getProtocol(path);\n }\n if (this.isUrl(path)) {\n // need to find the first path separator\n var index = path.indexOf('/', root.length);\n if (index !== -1) {\n root = path.slice(0, index);\n }\n else\n { root = path; }\n if (!root.endsWith('/'))\n { root += '/'; }\n }\n return root;\n },\n /**\n * Returns the last portion of a path\n * @param path - The path to test\n * @param ext - Optional extension to remove\n */\n basename: function (path, ext) {\n assertPath(path);\n if (ext)\n { assertPath(ext); }\n path = this.toPosix(path);\n var start = 0;\n var end = -1;\n var matchedSlash = true;\n var i;\n if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {\n if (ext.length === path.length && ext === path)\n { return ''; }\n var extIdx = ext.length - 1;\n var firstNonSlashEnd = -1;\n for (i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n }\n else {\n if (firstNonSlashEnd === -1) {\n // We saw the first non-path separator, remember this index in case\n // we need it if the extension ends up not matching\n matchedSlash = false;\n firstNonSlashEnd = i + 1;\n }\n if (extIdx >= 0) {\n // Try to match the explicit extension\n if (code === ext.charCodeAt(extIdx)) {\n if (--extIdx === -1) {\n // We matched the extension, so mark this as the end of our path\n // component\n end = i;\n }\n }\n else {\n // Extension does not match, so our result is the entire path\n // component\n extIdx = -1;\n end = firstNonSlashEnd;\n }\n }\n }\n }\n if (start === end)\n { end = firstNonSlashEnd; }\n else if (end === -1)\n { end = path.length; }\n return path.slice(start, end);\n }\n for (i = path.length - 1; i >= 0; --i) {\n if (path.charCodeAt(i) === 47) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n }\n else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n if (end === -1)\n { return ''; }\n return path.slice(start, end);\n },\n /**\n * Returns the extension of the path, from the last occurrence of the . (period) character to end of string in the last\n * portion of the path. If there is no . in the last portion of the path, or if there are no . characters other than\n * the first character of the basename of path, an empty string is returned.\n * @param path - The path to parse\n */\n extname: function (path) {\n assertPath(path);\n path = this.toPosix(path);\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n for (var i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n { startDot = i; }\n else if (preDotState !== 1)\n { preDotState = 1; }\n }\n else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n if (startDot === -1 || end === -1\n // We saw a non-dot character immediately before the dot\n || preDotState === 0\n // The (right-most) trimmed path component is exactly '..'\n // eslint-disable-next-line no-mixed-operators\n || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n return '';\n }\n return path.slice(startDot, end);\n },\n /**\n * Parses a path into an object containing the 'root', `dir`, `base`, `ext`, and `name` properties.\n * @param path - The path to parse\n */\n parse: function (path) {\n assertPath(path);\n var ret = { root: '', dir: '', base: '', ext: '', name: '' };\n if (path.length === 0)\n { return ret; }\n path = this.toPosix(path);\n var code = path.charCodeAt(0);\n var isAbsolute = this.isAbsolute(path);\n var start;\n ret.root = this.rootname(path);\n if (isAbsolute || this.hasProtocol(path)) {\n start = 1;\n }\n else {\n start = 0;\n }\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n var i = path.length - 1;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n // Get non-dir info\n for (; i >= start; --i) {\n code = path.charCodeAt(i);\n if (code === 47) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n { startDot = i; }\n else if (preDotState !== 1)\n { preDotState = 1; }\n }\n else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n if (startDot === -1 || end === -1\n // We saw a non-dot character immediately before the dot\n || preDotState === 0\n // The (right-most) trimmed path component is exactly '..'\n // eslint-disable-next-line no-mixed-operators\n || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n if (end !== -1) {\n if (startPart === 0 && isAbsolute)\n { ret.base = ret.name = path.slice(1, end); }\n else\n { ret.base = ret.name = path.slice(startPart, end); }\n }\n }\n else {\n if (startPart === 0 && isAbsolute) {\n ret.name = path.slice(1, startDot);\n ret.base = path.slice(1, end);\n }\n else {\n ret.name = path.slice(startPart, startDot);\n ret.base = path.slice(startPart, end);\n }\n ret.ext = path.slice(startDot, end);\n }\n ret.dir = this.dirname(path);\n return ret;\n },\n sep: '/',\n delimiter: ':'\n};\n\n/**\n * The prefix that denotes a URL is for a retina asset.\n * @static\n * @name RETINA_PREFIX\n * @memberof PIXI.settings\n * @type {RegExp}\n * @default /@([0-9\\.]+)x/\n * @example `@2x`\n */\nsettings.RETINA_PREFIX = /@([0-9\\.]+)x/;\n/**\n * Should the `failIfMajorPerformanceCaveat` flag be enabled as a context option used in the `isWebGLSupported` function.\n * If set to true, a WebGL renderer can fail to be created if the browser thinks there could be performance issues when\n * using WebGL.\n *\n * In PixiJS v6 this has changed from true to false by default, to allow WebGL to work in as many scenarios as possible.\n * However, some users may have a poor experience, for example, if a user has a gpu or driver version blacklisted by the\n * browser.\n *\n * If your application requires high performance rendering, you may wish to set this to false.\n * We recommend one of two options if you decide to set this flag to false:\n *\n * 1: Use the `pixi.js-legacy` package, which includes a Canvas renderer as a fallback in case high performance WebGL is\n * not supported.\n *\n * 2: Call `isWebGLSupported` (which if found in the PIXI.utils package) in your code before attempting to create a PixiJS\n * renderer, and show an error message to the user if the function returns false, explaining that their device & browser\n * combination does not support high performance WebGL.\n * This is a much better strategy than trying to create a PixiJS renderer and finding it then fails.\n * @static\n * @name FAIL_IF_MAJOR_PERFORMANCE_CAVEAT\n * @memberof PIXI.settings\n * @type {boolean}\n * @default false\n */\nsettings.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT = false;\n\nvar saidHello = false;\nvar VERSION = '6.5.10';\n/**\n * Skips the hello message of renderers that are created after this is run.\n * @function skipHello\n * @memberof PIXI.utils\n */\nfunction skipHello() {\n saidHello = true;\n}\n/**\n * Logs out the version and renderer information for this running instance of PIXI.\n * If you don't want to see this message you can run `PIXI.utils.skipHello()` before\n * creating your renderer. Keep in mind that doing that will forever make you a jerk face.\n * @static\n * @function sayHello\n * @memberof PIXI.utils\n * @param {string} type - The string renderer type to log.\n */\nfunction sayHello(type) {\n var _a;\n if (saidHello) {\n return;\n }\n if (settings.ADAPTER.getNavigator().userAgent.toLowerCase().indexOf('chrome') > -1) {\n var args = [\n \"\\n %c %c %c PixiJS \" + VERSION + \" - \\u2730 \" + type + \" \\u2730 %c %c http://www.pixijs.com/ %c %c \\u2665%c\\u2665%c\\u2665 \\n\\n\",\n 'background: #ff66a5; padding:5px 0;',\n 'background: #ff66a5; padding:5px 0;',\n 'color: #ff66a5; background: #030307; padding:5px 0;',\n 'background: #ff66a5; padding:5px 0;',\n 'background: #ffc3dc; padding:5px 0;',\n 'background: #ff66a5; padding:5px 0;',\n 'color: #ff2424; background: #fff; padding:5px 0;',\n 'color: #ff2424; background: #fff; padding:5px 0;',\n 'color: #ff2424; background: #fff; padding:5px 0;' ];\n (_a = globalThis.console).log.apply(_a, args);\n }\n else if (globalThis.console) {\n globalThis.console.log(\"PixiJS \" + VERSION + \" - \" + type + \" - http://www.pixijs.com/\");\n }\n saidHello = true;\n}\n\nvar supported;\n/**\n * Helper for checking for WebGL support.\n * @memberof PIXI.utils\n * @function isWebGLSupported\n * @returns {boolean} Is WebGL supported.\n */\nfunction isWebGLSupported() {\n if (typeof supported === 'undefined') {\n supported = (function supported() {\n var contextOptions = {\n stencil: true,\n failIfMajorPerformanceCaveat: settings.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT,\n };\n try {\n if (!settings.ADAPTER.getWebGLRenderingContext()) {\n return false;\n }\n var canvas = settings.ADAPTER.createCanvas();\n var gl = (canvas.getContext('webgl', contextOptions)\n || canvas.getContext('experimental-webgl', contextOptions));\n var success = !!(gl && gl.getContextAttributes().stencil);\n if (gl) {\n var loseContext = gl.getExtension('WEBGL_lose_context');\n if (loseContext) {\n loseContext.loseContext();\n }\n }\n gl = null;\n return success;\n }\n catch (e) {\n return false;\n }\n })();\n }\n return supported;\n}\n\nvar aliceblue = \"#f0f8ff\";\nvar antiquewhite = \"#faebd7\";\nvar aqua = \"#00ffff\";\nvar aquamarine = \"#7fffd4\";\nvar azure = \"#f0ffff\";\nvar beige = \"#f5f5dc\";\nvar bisque = \"#ffe4c4\";\nvar black = \"#000000\";\nvar blanchedalmond = \"#ffebcd\";\nvar blue = \"#0000ff\";\nvar blueviolet = \"#8a2be2\";\nvar brown = \"#a52a2a\";\nvar burlywood = \"#deb887\";\nvar cadetblue = \"#5f9ea0\";\nvar chartreuse = \"#7fff00\";\nvar chocolate = \"#d2691e\";\nvar coral = \"#ff7f50\";\nvar cornflowerblue = \"#6495ed\";\nvar cornsilk = \"#fff8dc\";\nvar crimson = \"#dc143c\";\nvar cyan = \"#00ffff\";\nvar darkblue = \"#00008b\";\nvar darkcyan = \"#008b8b\";\nvar darkgoldenrod = \"#b8860b\";\nvar darkgray = \"#a9a9a9\";\nvar darkgreen = \"#006400\";\nvar darkgrey = \"#a9a9a9\";\nvar darkkhaki = \"#bdb76b\";\nvar darkmagenta = \"#8b008b\";\nvar darkolivegreen = \"#556b2f\";\nvar darkorange = \"#ff8c00\";\nvar darkorchid = \"#9932cc\";\nvar darkred = \"#8b0000\";\nvar darksalmon = \"#e9967a\";\nvar darkseagreen = \"#8fbc8f\";\nvar darkslateblue = \"#483d8b\";\nvar darkslategray = \"#2f4f4f\";\nvar darkslategrey = \"#2f4f4f\";\nvar darkturquoise = \"#00ced1\";\nvar darkviolet = \"#9400d3\";\nvar deeppink = \"#ff1493\";\nvar deepskyblue = \"#00bfff\";\nvar dimgray = \"#696969\";\nvar dimgrey = \"#696969\";\nvar dodgerblue = \"#1e90ff\";\nvar firebrick = \"#b22222\";\nvar floralwhite = \"#fffaf0\";\nvar forestgreen = \"#228b22\";\nvar fuchsia = \"#ff00ff\";\nvar gainsboro = \"#dcdcdc\";\nvar ghostwhite = \"#f8f8ff\";\nvar goldenrod = \"#daa520\";\nvar gold = \"#ffd700\";\nvar gray = \"#808080\";\nvar green = \"#008000\";\nvar greenyellow = \"#adff2f\";\nvar grey = \"#808080\";\nvar honeydew = \"#f0fff0\";\nvar hotpink = \"#ff69b4\";\nvar indianred = \"#cd5c5c\";\nvar indigo = \"#4b0082\";\nvar ivory = \"#fffff0\";\nvar khaki = \"#f0e68c\";\nvar lavenderblush = \"#fff0f5\";\nvar lavender = \"#e6e6fa\";\nvar lawngreen = \"#7cfc00\";\nvar lemonchiffon = \"#fffacd\";\nvar lightblue = \"#add8e6\";\nvar lightcoral = \"#f08080\";\nvar lightcyan = \"#e0ffff\";\nvar lightgoldenrodyellow = \"#fafad2\";\nvar lightgray = \"#d3d3d3\";\nvar lightgreen = \"#90ee90\";\nvar lightgrey = \"#d3d3d3\";\nvar lightpink = \"#ffb6c1\";\nvar lightsalmon = \"#ffa07a\";\nvar lightseagreen = \"#20b2aa\";\nvar lightskyblue = \"#87cefa\";\nvar lightslategray = \"#778899\";\nvar lightslategrey = \"#778899\";\nvar lightsteelblue = \"#b0c4de\";\nvar lightyellow = \"#ffffe0\";\nvar lime = \"#00ff00\";\nvar limegreen = \"#32cd32\";\nvar linen = \"#faf0e6\";\nvar magenta = \"#ff00ff\";\nvar maroon = \"#800000\";\nvar mediumaquamarine = \"#66cdaa\";\nvar mediumblue = \"#0000cd\";\nvar mediumorchid = \"#ba55d3\";\nvar mediumpurple = \"#9370db\";\nvar mediumseagreen = \"#3cb371\";\nvar mediumslateblue = \"#7b68ee\";\nvar mediumspringgreen = \"#00fa9a\";\nvar mediumturquoise = \"#48d1cc\";\nvar mediumvioletred = \"#c71585\";\nvar midnightblue = \"#191970\";\nvar mintcream = \"#f5fffa\";\nvar mistyrose = \"#ffe4e1\";\nvar moccasin = \"#ffe4b5\";\nvar navajowhite = \"#ffdead\";\nvar navy = \"#000080\";\nvar oldlace = \"#fdf5e6\";\nvar olive = \"#808000\";\nvar olivedrab = \"#6b8e23\";\nvar orange = \"#ffa500\";\nvar orangered = \"#ff4500\";\nvar orchid = \"#da70d6\";\nvar palegoldenrod = \"#eee8aa\";\nvar palegreen = \"#98fb98\";\nvar paleturquoise = \"#afeeee\";\nvar palevioletred = \"#db7093\";\nvar papayawhip = \"#ffefd5\";\nvar peachpuff = \"#ffdab9\";\nvar peru = \"#cd853f\";\nvar pink = \"#ffc0cb\";\nvar plum = \"#dda0dd\";\nvar powderblue = \"#b0e0e6\";\nvar purple = \"#800080\";\nvar rebeccapurple = \"#663399\";\nvar red = \"#ff0000\";\nvar rosybrown = \"#bc8f8f\";\nvar royalblue = \"#4169e1\";\nvar saddlebrown = \"#8b4513\";\nvar salmon = \"#fa8072\";\nvar sandybrown = \"#f4a460\";\nvar seagreen = \"#2e8b57\";\nvar seashell = \"#fff5ee\";\nvar sienna = \"#a0522d\";\nvar silver = \"#c0c0c0\";\nvar skyblue = \"#87ceeb\";\nvar slateblue = \"#6a5acd\";\nvar slategray = \"#708090\";\nvar slategrey = \"#708090\";\nvar snow = \"#fffafa\";\nvar springgreen = \"#00ff7f\";\nvar steelblue = \"#4682b4\";\nvar tan = \"#d2b48c\";\nvar teal = \"#008080\";\nvar thistle = \"#d8bfd8\";\nvar tomato = \"#ff6347\";\nvar turquoise = \"#40e0d0\";\nvar violet = \"#ee82ee\";\nvar wheat = \"#f5deb3\";\nvar white = \"#ffffff\";\nvar whitesmoke = \"#f5f5f5\";\nvar yellow = \"#ffff00\";\nvar yellowgreen = \"#9acd32\";\nvar cssColorNames = {\n\taliceblue: aliceblue,\n\tantiquewhite: antiquewhite,\n\taqua: aqua,\n\taquamarine: aquamarine,\n\tazure: azure,\n\tbeige: beige,\n\tbisque: bisque,\n\tblack: black,\n\tblanchedalmond: blanchedalmond,\n\tblue: blue,\n\tblueviolet: blueviolet,\n\tbrown: brown,\n\tburlywood: burlywood,\n\tcadetblue: cadetblue,\n\tchartreuse: chartreuse,\n\tchocolate: chocolate,\n\tcoral: coral,\n\tcornflowerblue: cornflowerblue,\n\tcornsilk: cornsilk,\n\tcrimson: crimson,\n\tcyan: cyan,\n\tdarkblue: darkblue,\n\tdarkcyan: darkcyan,\n\tdarkgoldenrod: darkgoldenrod,\n\tdarkgray: darkgray,\n\tdarkgreen: darkgreen,\n\tdarkgrey: darkgrey,\n\tdarkkhaki: darkkhaki,\n\tdarkmagenta: darkmagenta,\n\tdarkolivegreen: darkolivegreen,\n\tdarkorange: darkorange,\n\tdarkorchid: darkorchid,\n\tdarkred: darkred,\n\tdarksalmon: darksalmon,\n\tdarkseagreen: darkseagreen,\n\tdarkslateblue: darkslateblue,\n\tdarkslategray: darkslategray,\n\tdarkslategrey: darkslategrey,\n\tdarkturquoise: darkturquoise,\n\tdarkviolet: darkviolet,\n\tdeeppink: deeppink,\n\tdeepskyblue: deepskyblue,\n\tdimgray: dimgray,\n\tdimgrey: dimgrey,\n\tdodgerblue: dodgerblue,\n\tfirebrick: firebrick,\n\tfloralwhite: floralwhite,\n\tforestgreen: forestgreen,\n\tfuchsia: fuchsia,\n\tgainsboro: gainsboro,\n\tghostwhite: ghostwhite,\n\tgoldenrod: goldenrod,\n\tgold: gold,\n\tgray: gray,\n\tgreen: green,\n\tgreenyellow: greenyellow,\n\tgrey: grey,\n\thoneydew: honeydew,\n\thotpink: hotpink,\n\tindianred: indianred,\n\tindigo: indigo,\n\tivory: ivory,\n\tkhaki: khaki,\n\tlavenderblush: lavenderblush,\n\tlavender: lavender,\n\tlawngreen: lawngreen,\n\tlemonchiffon: lemonchiffon,\n\tlightblue: lightblue,\n\tlightcoral: lightcoral,\n\tlightcyan: lightcyan,\n\tlightgoldenrodyellow: lightgoldenrodyellow,\n\tlightgray: lightgray,\n\tlightgreen: lightgreen,\n\tlightgrey: lightgrey,\n\tlightpink: lightpink,\n\tlightsalmon: lightsalmon,\n\tlightseagreen: lightseagreen,\n\tlightskyblue: lightskyblue,\n\tlightslategray: lightslategray,\n\tlightslategrey: lightslategrey,\n\tlightsteelblue: lightsteelblue,\n\tlightyellow: lightyellow,\n\tlime: lime,\n\tlimegreen: limegreen,\n\tlinen: linen,\n\tmagenta: magenta,\n\tmaroon: maroon,\n\tmediumaquamarine: mediumaquamarine,\n\tmediumblue: mediumblue,\n\tmediumorchid: mediumorchid,\n\tmediumpurple: mediumpurple,\n\tmediumseagreen: mediumseagreen,\n\tmediumslateblue: mediumslateblue,\n\tmediumspringgreen: mediumspringgreen,\n\tmediumturquoise: mediumturquoise,\n\tmediumvioletred: mediumvioletred,\n\tmidnightblue: midnightblue,\n\tmintcream: mintcream,\n\tmistyrose: mistyrose,\n\tmoccasin: moccasin,\n\tnavajowhite: navajowhite,\n\tnavy: navy,\n\toldlace: oldlace,\n\tolive: olive,\n\tolivedrab: olivedrab,\n\torange: orange,\n\torangered: orangered,\n\torchid: orchid,\n\tpalegoldenrod: palegoldenrod,\n\tpalegreen: palegreen,\n\tpaleturquoise: paleturquoise,\n\tpalevioletred: palevioletred,\n\tpapayawhip: papayawhip,\n\tpeachpuff: peachpuff,\n\tperu: peru,\n\tpink: pink,\n\tplum: plum,\n\tpowderblue: powderblue,\n\tpurple: purple,\n\trebeccapurple: rebeccapurple,\n\tred: red,\n\trosybrown: rosybrown,\n\troyalblue: royalblue,\n\tsaddlebrown: saddlebrown,\n\tsalmon: salmon,\n\tsandybrown: sandybrown,\n\tseagreen: seagreen,\n\tseashell: seashell,\n\tsienna: sienna,\n\tsilver: silver,\n\tskyblue: skyblue,\n\tslateblue: slateblue,\n\tslategray: slategray,\n\tslategrey: slategrey,\n\tsnow: snow,\n\tspringgreen: springgreen,\n\tsteelblue: steelblue,\n\ttan: tan,\n\tteal: teal,\n\tthistle: thistle,\n\ttomato: tomato,\n\tturquoise: turquoise,\n\tviolet: violet,\n\twheat: wheat,\n\twhite: white,\n\twhitesmoke: whitesmoke,\n\tyellow: yellow,\n\tyellowgreen: yellowgreen\n};\n\n/**\n * Converts a hexadecimal color number to an [R, G, B] array of normalized floats (numbers from 0.0 to 1.0).\n * @example\n * PIXI.utils.hex2rgb(0xffffff); // returns [1, 1, 1]\n * @memberof PIXI.utils\n * @function hex2rgb\n * @param {number} hex - The hexadecimal number to convert\n * @param {number[]} [out=[]] - If supplied, this array will be used rather than returning a new one\n * @returns {number[]} An array representing the [R, G, B] of the color where all values are floats.\n */\nfunction hex2rgb(hex, out) {\n if (out === void 0) { out = []; }\n out[0] = ((hex >> 16) & 0xFF) / 255;\n out[1] = ((hex >> 8) & 0xFF) / 255;\n out[2] = (hex & 0xFF) / 255;\n return out;\n}\n/**\n * Converts a hexadecimal color number to a string.\n * @example\n * PIXI.utils.hex2string(0xffffff); // returns \"#ffffff\"\n * @memberof PIXI.utils\n * @function hex2string\n * @param {number} hex - Number in hex (e.g., `0xffffff`)\n * @returns {string} The string color (e.g., `\"#ffffff\"`).\n */\nfunction hex2string(hex) {\n var hexString = hex.toString(16);\n hexString = '000000'.substring(0, 6 - hexString.length) + hexString;\n return \"#\" + hexString;\n}\n/**\n * Converts a string to a hexadecimal color number.\n * It can handle:\n * hex strings starting with #: \"#ffffff\"\n * hex strings starting with 0x: \"0xffffff\"\n * hex strings without prefix: \"ffffff\"\n * css colors: \"black\"\n * @example\n * PIXI.utils.string2hex(\"#ffffff\"); // returns 0xffffff, which is 16777215 as an integer\n * @memberof PIXI.utils\n * @function string2hex\n * @param {string} string - The string color (e.g., `\"#ffffff\"`)\n * @returns {number} Number in hexadecimal.\n */\nfunction string2hex(string) {\n if (typeof string === 'string') {\n string = cssColorNames[string.toLowerCase()] || string;\n if (string[0] === '#') {\n string = string.slice(1);\n }\n }\n return parseInt(string, 16);\n}\n/**\n * Converts a color as an [R, G, B] array of normalized floats to a hexadecimal number.\n * @example\n * PIXI.utils.rgb2hex([1, 1, 1]); // returns 0xffffff, which is 16777215 as an integer\n * @memberof PIXI.utils\n * @function rgb2hex\n * @param {number[]} rgb - Array of numbers where all values are normalized floats from 0.0 to 1.0.\n * @returns {number} Number in hexadecimal.\n */\nfunction rgb2hex(rgb) {\n return (((rgb[0] * 255) << 16) + ((rgb[1] * 255) << 8) + (rgb[2] * 255 | 0));\n}\n\n/**\n * Corrects PixiJS blend, takes premultiplied alpha into account\n * @memberof PIXI.utils\n * @function mapPremultipliedBlendModes\n * @private\n * @returns {Array} Mapped modes.\n */\nfunction mapPremultipliedBlendModes() {\n var pm = [];\n var npm = [];\n for (var i = 0; i < 32; i++) {\n pm[i] = i;\n npm[i] = i;\n }\n pm[BLEND_MODES.NORMAL_NPM] = BLEND_MODES.NORMAL;\n pm[BLEND_MODES.ADD_NPM] = BLEND_MODES.ADD;\n pm[BLEND_MODES.SCREEN_NPM] = BLEND_MODES.SCREEN;\n npm[BLEND_MODES.NORMAL] = BLEND_MODES.NORMAL_NPM;\n npm[BLEND_MODES.ADD] = BLEND_MODES.ADD_NPM;\n npm[BLEND_MODES.SCREEN] = BLEND_MODES.SCREEN_NPM;\n var array = [];\n array.push(npm);\n array.push(pm);\n return array;\n}\n/**\n * maps premultiply flag and blendMode to adjusted blendMode\n * @memberof PIXI.utils\n * @constant premultiplyBlendMode\n * @type {Array}\n */\nvar premultiplyBlendMode = mapPremultipliedBlendModes();\n/**\n * changes blendMode according to texture format\n * @memberof PIXI.utils\n * @function correctBlendMode\n * @param {number} blendMode - supposed blend mode\n * @param {boolean} premultiplied - whether source is premultiplied\n * @returns {number} true blend mode for this texture\n */\nfunction correctBlendMode(blendMode, premultiplied) {\n return premultiplyBlendMode[premultiplied ? 1 : 0][blendMode];\n}\n/**\n * combines rgb and alpha to out array\n * @memberof PIXI.utils\n * @function premultiplyRgba\n * @param {Float32Array|number[]} rgb - input rgb\n * @param {number} alpha - alpha param\n * @param {Float32Array} [out] - output\n * @param {boolean} [premultiply=true] - do premultiply it\n * @returns {Float32Array} vec4 rgba\n */\nfunction premultiplyRgba(rgb, alpha, out, premultiply) {\n out = out || new Float32Array(4);\n if (premultiply || premultiply === undefined) {\n out[0] = rgb[0] * alpha;\n out[1] = rgb[1] * alpha;\n out[2] = rgb[2] * alpha;\n }\n else {\n out[0] = rgb[0];\n out[1] = rgb[1];\n out[2] = rgb[2];\n }\n out[3] = alpha;\n return out;\n}\n/**\n * premultiplies tint\n * @memberof PIXI.utils\n * @function premultiplyTint\n * @param {number} tint - integer RGB\n * @param {number} alpha - floating point alpha (0.0-1.0)\n * @returns {number} tint multiplied by alpha\n */\nfunction premultiplyTint(tint, alpha) {\n if (alpha === 1.0) {\n return (alpha * 255 << 24) + tint;\n }\n if (alpha === 0.0) {\n return 0;\n }\n var R = ((tint >> 16) & 0xFF);\n var G = ((tint >> 8) & 0xFF);\n var B = (tint & 0xFF);\n R = ((R * alpha) + 0.5) | 0;\n G = ((G * alpha) + 0.5) | 0;\n B = ((B * alpha) + 0.5) | 0;\n return (alpha * 255 << 24) + (R << 16) + (G << 8) + B;\n}\n/**\n * converts integer tint and float alpha to vec4 form, premultiplies by default\n * @memberof PIXI.utils\n * @function premultiplyTintToRgba\n * @param {number} tint - input tint\n * @param {number} alpha - alpha param\n * @param {Float32Array} [out] - output\n * @param {boolean} [premultiply=true] - do premultiply it\n * @returns {Float32Array} vec4 rgba\n */\nfunction premultiplyTintToRgba(tint, alpha, out, premultiply) {\n out = out || new Float32Array(4);\n out[0] = ((tint >> 16) & 0xFF) / 255.0;\n out[1] = ((tint >> 8) & 0xFF) / 255.0;\n out[2] = (tint & 0xFF) / 255.0;\n if (premultiply || premultiply === undefined) {\n out[0] *= alpha;\n out[1] *= alpha;\n out[2] *= alpha;\n }\n out[3] = alpha;\n return out;\n}\n\n/**\n * Generic Mask Stack data structure\n * @memberof PIXI.utils\n * @function createIndicesForQuads\n * @param {number} size - Number of quads\n * @param {Uint16Array|Uint32Array} [outBuffer] - Buffer for output, length has to be `6 * size`\n * @returns {Uint16Array|Uint32Array} - Resulting index buffer\n */\nfunction createIndicesForQuads(size, outBuffer) {\n if (outBuffer === void 0) { outBuffer = null; }\n // the total number of indices in our array, there are 6 points per quad.\n var totalIndices = size * 6;\n outBuffer = outBuffer || new Uint16Array(totalIndices);\n if (outBuffer.length !== totalIndices) {\n throw new Error(\"Out buffer length is incorrect, got \" + outBuffer.length + \" and expected \" + totalIndices);\n }\n // fill the indices with the quads to draw\n for (var i = 0, j = 0; i < totalIndices; i += 6, j += 4) {\n outBuffer[i + 0] = j + 0;\n outBuffer[i + 1] = j + 1;\n outBuffer[i + 2] = j + 2;\n outBuffer[i + 3] = j + 0;\n outBuffer[i + 4] = j + 2;\n outBuffer[i + 5] = j + 3;\n }\n return outBuffer;\n}\n\nfunction getBufferType(array) {\n if (array.BYTES_PER_ELEMENT === 4) {\n if (array instanceof Float32Array) {\n return 'Float32Array';\n }\n else if (array instanceof Uint32Array) {\n return 'Uint32Array';\n }\n return 'Int32Array';\n }\n else if (array.BYTES_PER_ELEMENT === 2) {\n if (array instanceof Uint16Array) {\n return 'Uint16Array';\n }\n }\n else if (array.BYTES_PER_ELEMENT === 1) {\n if (array instanceof Uint8Array) {\n return 'Uint8Array';\n }\n }\n // TODO map out the rest of the array elements!\n return null;\n}\n\n/* eslint-disable object-shorthand */\nvar map = { Float32Array: Float32Array, Uint32Array: Uint32Array, Int32Array: Int32Array, Uint8Array: Uint8Array };\nfunction interleaveTypedArrays(arrays, sizes) {\n var outSize = 0;\n var stride = 0;\n var views = {};\n for (var i = 0; i < arrays.length; i++) {\n stride += sizes[i];\n outSize += arrays[i].length;\n }\n var buffer = new ArrayBuffer(outSize * 4);\n var out = null;\n var littleOffset = 0;\n for (var i = 0; i < arrays.length; i++) {\n var size = sizes[i];\n var array = arrays[i];\n /*\n @todo This is unsafe casting but consistent with how the code worked previously. Should it stay this way\n or should and `getBufferTypeUnsafe` function be exposed that throws an Error if unsupported type is passed?\n */\n var type = getBufferType(array);\n if (!views[type]) {\n views[type] = new map[type](buffer);\n }\n out = views[type];\n for (var j = 0; j < array.length; j++) {\n var indexStart = ((j / size | 0) * stride) + littleOffset;\n var index = j % size;\n out[indexStart + index] = array[j];\n }\n littleOffset += size;\n }\n return new Float32Array(buffer);\n}\n\n// Taken from the bit-twiddle package\n/**\n * Rounds to next power of two.\n * @function nextPow2\n * @memberof PIXI.utils\n * @param {number} v - input value\n * @returns {number} - next rounded power of two\n */\nfunction nextPow2(v) {\n v += v === 0 ? 1 : 0;\n --v;\n v |= v >>> 1;\n v |= v >>> 2;\n v |= v >>> 4;\n v |= v >>> 8;\n v |= v >>> 16;\n return v + 1;\n}\n/**\n * Checks if a number is a power of two.\n * @function isPow2\n * @memberof PIXI.utils\n * @param {number} v - input value\n * @returns {boolean} `true` if value is power of two\n */\nfunction isPow2(v) {\n return !(v & (v - 1)) && (!!v);\n}\n/**\n * Computes ceil of log base 2\n * @function log2\n * @memberof PIXI.utils\n * @param {number} v - input value\n * @returns {number} logarithm base 2\n */\nfunction log2(v) {\n var r = (v > 0xFFFF ? 1 : 0) << 4;\n v >>>= r;\n var shift = (v > 0xFF ? 1 : 0) << 3;\n v >>>= shift;\n r |= shift;\n shift = (v > 0xF ? 1 : 0) << 2;\n v >>>= shift;\n r |= shift;\n shift = (v > 0x3 ? 1 : 0) << 1;\n v >>>= shift;\n r |= shift;\n return r | (v >> 1);\n}\n\n/**\n * Remove items from a javascript array without generating garbage\n * @function removeItems\n * @memberof PIXI.utils\n * @param {Array} arr - Array to remove elements from\n * @param {number} startIdx - starting index\n * @param {number} removeCount - how many to remove\n */\nfunction removeItems(arr, startIdx, removeCount) {\n var length = arr.length;\n var i;\n if (startIdx >= length || removeCount === 0) {\n return;\n }\n removeCount = (startIdx + removeCount > length ? length - startIdx : removeCount);\n var len = length - removeCount;\n for (i = startIdx; i < len; ++i) {\n arr[i] = arr[i + removeCount];\n }\n arr.length = len;\n}\n\n/**\n * Returns sign of number\n * @memberof PIXI.utils\n * @function sign\n * @param {number} n - the number to check the sign of\n * @returns {number} 0 if `n` is 0, -1 if `n` is negative, 1 if `n` is positive\n */\nfunction sign(n) {\n if (n === 0)\n { return 0; }\n return n < 0 ? -1 : 1;\n}\n\nvar nextUid = 0;\n/**\n * Gets the next unique identifier\n * @memberof PIXI.utils\n * @function uid\n * @returns {number} The next unique identifier to use.\n */\nfunction uid() {\n return ++nextUid;\n}\n\n// A map of warning messages already fired\nvar warnings = {};\n/**\n * Helper for warning developers about deprecated features & settings.\n * A stack track for warnings is given; useful for tracking-down where\n * deprecated methods/properties/classes are being used within the code.\n * @memberof PIXI.utils\n * @function deprecation\n * @param {string} version - The version where the feature became deprecated\n * @param {string} message - Message should include what is deprecated, where, and the new solution\n * @param {number} [ignoreDepth=3] - The number of steps to ignore at the top of the error stack\n * this is mostly to ignore internal deprecation calls.\n */\nfunction deprecation(version, message, ignoreDepth) {\n if (ignoreDepth === void 0) { ignoreDepth = 3; }\n // Ignore duplicat\n if (warnings[message]) {\n return;\n }\n /* eslint-disable no-console */\n var stack = new Error().stack;\n // Handle IE < 10 and Safari < 6\n if (typeof stack === 'undefined') {\n console.warn('PixiJS Deprecation Warning: ', message + \"\\nDeprecated since v\" + version);\n }\n else {\n // chop off the stack trace which includes PixiJS internal calls\n stack = stack.split('\\n').splice(ignoreDepth).join('\\n');\n if (console.groupCollapsed) {\n console.groupCollapsed('%cPixiJS Deprecation Warning: %c%s', 'color:#614108;background:#fffbe6', 'font-weight:normal;color:#614108;background:#fffbe6', message + \"\\nDeprecated since v\" + version);\n console.warn(stack);\n console.groupEnd();\n }\n else {\n console.warn('PixiJS Deprecation Warning: ', message + \"\\nDeprecated since v\" + version);\n console.warn(stack);\n }\n }\n /* eslint-enable no-console */\n warnings[message] = true;\n}\n\n/**\n * @todo Describe property usage\n * @static\n * @name ProgramCache\n * @memberof PIXI.utils\n * @type {object}\n */\nvar ProgramCache = {};\n/**\n * @todo Describe property usage\n * @static\n * @name TextureCache\n * @memberof PIXI.utils\n * @type {object}\n */\nvar TextureCache = Object.create(null);\n/**\n * @todo Describe property usage\n * @static\n * @name BaseTextureCache\n * @memberof PIXI.utils\n * @type {object}\n */\nvar BaseTextureCache = Object.create(null);\n/**\n * Destroys all texture in the cache\n * @memberof PIXI.utils\n * @function destroyTextureCache\n */\nfunction destroyTextureCache() {\n var key;\n for (key in TextureCache) {\n TextureCache[key].destroy();\n }\n for (key in BaseTextureCache) {\n BaseTextureCache[key].destroy();\n }\n}\n/**\n * Removes all textures from cache, but does not destroy them\n * @memberof PIXI.utils\n * @function clearTextureCache\n */\nfunction clearTextureCache() {\n var key;\n for (key in TextureCache) {\n delete TextureCache[key];\n }\n for (key in BaseTextureCache) {\n delete BaseTextureCache[key];\n }\n}\n\n/**\n * Creates a Canvas element of the given size to be used as a target for rendering to.\n * @class\n * @memberof PIXI.utils\n */\nvar CanvasRenderTarget = /** @class */ (function () {\n /**\n * @param width - the width for the newly created canvas\n * @param height - the height for the newly created canvas\n * @param {number} [resolution=PIXI.settings.RESOLUTION] - The resolution / device pixel ratio of the canvas\n */\n function CanvasRenderTarget(width, height, resolution) {\n this.canvas = settings.ADAPTER.createCanvas();\n this.context = this.canvas.getContext('2d');\n this.resolution = resolution || settings.RESOLUTION;\n this.resize(width, height);\n }\n /**\n * Clears the canvas that was created by the CanvasRenderTarget class.\n * @private\n */\n CanvasRenderTarget.prototype.clear = function () {\n this.context.setTransform(1, 0, 0, 1, 0, 0);\n this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);\n };\n /**\n * Resizes the canvas to the specified width and height.\n * @param desiredWidth - the desired width of the canvas\n * @param desiredHeight - the desired height of the canvas\n */\n CanvasRenderTarget.prototype.resize = function (desiredWidth, desiredHeight) {\n this.canvas.width = Math.round(desiredWidth * this.resolution);\n this.canvas.height = Math.round(desiredHeight * this.resolution);\n };\n /** Destroys this canvas. */\n CanvasRenderTarget.prototype.destroy = function () {\n this.context = null;\n this.canvas = null;\n };\n Object.defineProperty(CanvasRenderTarget.prototype, \"width\", {\n /**\n * The width of the canvas buffer in pixels.\n * @member {number}\n */\n get: function () {\n return this.canvas.width;\n },\n set: function (val) {\n this.canvas.width = Math.round(val);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(CanvasRenderTarget.prototype, \"height\", {\n /**\n * The height of the canvas buffer in pixels.\n * @member {number}\n */\n get: function () {\n return this.canvas.height;\n },\n set: function (val) {\n this.canvas.height = Math.round(val);\n },\n enumerable: false,\n configurable: true\n });\n return CanvasRenderTarget;\n}());\n\n/**\n * Trim transparent borders from a canvas\n * @memberof PIXI.utils\n * @function trimCanvas\n * @param {HTMLCanvasElement} canvas - the canvas to trim\n * @returns {object} Trim data\n */\nfunction trimCanvas(canvas) {\n // https://gist.github.com/remy/784508\n var width = canvas.width;\n var height = canvas.height;\n var context = canvas.getContext('2d', {\n willReadFrequently: true,\n });\n var imageData = context.getImageData(0, 0, width, height);\n var pixels = imageData.data;\n var len = pixels.length;\n var bound = {\n top: null,\n left: null,\n right: null,\n bottom: null,\n };\n var data = null;\n var i;\n var x;\n var y;\n for (i = 0; i < len; i += 4) {\n if (pixels[i + 3] !== 0) {\n x = (i / 4) % width;\n y = ~~((i / 4) / width);\n if (bound.top === null) {\n bound.top = y;\n }\n if (bound.left === null) {\n bound.left = x;\n }\n else if (x < bound.left) {\n bound.left = x;\n }\n if (bound.right === null) {\n bound.right = x + 1;\n }\n else if (bound.right < x) {\n bound.right = x + 1;\n }\n if (bound.bottom === null) {\n bound.bottom = y;\n }\n else if (bound.bottom < y) {\n bound.bottom = y;\n }\n }\n }\n if (bound.top !== null) {\n width = bound.right - bound.left;\n height = bound.bottom - bound.top + 1;\n data = context.getImageData(bound.left, bound.top, width, height);\n }\n return {\n height: height,\n width: width,\n data: data,\n };\n}\n\n/**\n * Regexp for data URI.\n * Based on: {@link https://github.com/ragingwind/data-uri-regex}\n * @static\n * @constant {RegExp|string} DATA_URI\n * @memberof PIXI\n * @example data:image/png;base64\n */\nvar DATA_URI = /^\\s*data:(?:([\\w-]+)\\/([\\w+.-]+))?(?:;charset=([\\w-]+))?(?:;(base64))?,(.*)/i;\n\n/**\n * @memberof PIXI.utils\n * @interface DecomposedDataUri\n */\n/**\n * type, eg. `image`\n * @memberof PIXI.utils.DecomposedDataUri#\n * @member {string} mediaType\n */\n/**\n * Sub type, eg. `png`\n * @memberof PIXI.utils.DecomposedDataUri#\n * @member {string} subType\n */\n/**\n * @memberof PIXI.utils.DecomposedDataUri#\n * @member {string} charset\n */\n/**\n * Data encoding, eg. `base64`\n * @memberof PIXI.utils.DecomposedDataUri#\n * @member {string} encoding\n */\n/**\n * The actual data\n * @memberof PIXI.utils.DecomposedDataUri#\n * @member {string} data\n */\n/**\n * Split a data URI into components. Returns undefined if\n * parameter `dataUri` is not a valid data URI.\n * @memberof PIXI.utils\n * @function decomposeDataUri\n * @param {string} dataUri - the data URI to check\n * @returns {PIXI.utils.DecomposedDataUri|undefined} The decomposed data uri or undefined\n */\nfunction decomposeDataUri(dataUri) {\n var dataUriMatch = DATA_URI.exec(dataUri);\n if (dataUriMatch) {\n return {\n mediaType: dataUriMatch[1] ? dataUriMatch[1].toLowerCase() : undefined,\n subType: dataUriMatch[2] ? dataUriMatch[2].toLowerCase() : undefined,\n charset: dataUriMatch[3] ? dataUriMatch[3].toLowerCase() : undefined,\n encoding: dataUriMatch[4] ? dataUriMatch[4].toLowerCase() : undefined,\n data: dataUriMatch[5],\n };\n }\n return undefined;\n}\n\nvar tempAnchor;\n/**\n * Sets the `crossOrigin` property for this resource based on if the url\n * for this resource is cross-origin. If crossOrigin was manually set, this\n * function does nothing.\n * Nipped from the resource loader!\n * @ignore\n * @param {string} url - The url to test.\n * @param {object} [loc=window.location] - The location object to test against.\n * @returns {string} The crossOrigin value to use (or empty string for none).\n */\nfunction determineCrossOrigin(url$1, loc) {\n if (loc === void 0) { loc = globalThis.location; }\n // data: and javascript: urls are considered same-origin\n if (url$1.indexOf('data:') === 0) {\n return '';\n }\n // default is window.location\n loc = loc || globalThis.location;\n if (!tempAnchor) {\n tempAnchor = document.createElement('a');\n }\n // let the browser determine the full href for the url of this resource and then\n // parse with the node url lib, we can't use the properties of the anchor element\n // because they don't work in IE9 :(\n tempAnchor.href = url$1;\n var parsedUrl = url.parse(tempAnchor.href);\n var samePort = (!parsedUrl.port && loc.port === '') || (parsedUrl.port === loc.port);\n // if cross origin\n if (parsedUrl.hostname !== loc.hostname || !samePort || parsedUrl.protocol !== loc.protocol) {\n return 'anonymous';\n }\n return '';\n}\n\n/**\n * get the resolution / device pixel ratio of an asset by looking for the prefix\n * used by spritesheets and image urls\n * @memberof PIXI.utils\n * @function getResolutionOfUrl\n * @param {string} url - the image path\n * @param {number} [defaultValue=1] - the defaultValue if no filename prefix is set.\n * @returns {number} resolution / device pixel ratio of an asset\n */\nfunction getResolutionOfUrl(url, defaultValue) {\n var resolution = settings.RETINA_PREFIX.exec(url);\n if (resolution) {\n return parseFloat(resolution[1]);\n }\n return defaultValue !== undefined ? defaultValue : 1;\n}\n\nexport { BaseTextureCache, CanvasRenderTarget, DATA_URI, ProgramCache, TextureCache, clearTextureCache, correctBlendMode, createIndicesForQuads, decomposeDataUri, deprecation, destroyTextureCache, determineCrossOrigin, getBufferType, getResolutionOfUrl, hex2rgb, hex2string, interleaveTypedArrays, isPow2, isWebGLSupported, log2, nextPow2, path, premultiplyBlendMode, premultiplyRgba, premultiplyTint, premultiplyTintToRgba, removeItems, rgb2hex, sayHello, sign, skipHello, string2hex, trimCanvas, uid, url };\n//# sourceMappingURL=utils.mjs.map\n","/*!\n * @pixi/math - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/math is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\n/**\n * Two Pi.\n * @static\n * @member {number}\n * @memberof PIXI\n */\nvar PI_2 = Math.PI * 2;\n/**\n * Conversion factor for converting radians to degrees.\n * @static\n * @member {number} RAD_TO_DEG\n * @memberof PIXI\n */\nvar RAD_TO_DEG = 180 / Math.PI;\n/**\n * Conversion factor for converting degrees to radians.\n * @static\n * @member {number}\n * @memberof PIXI\n */\nvar DEG_TO_RAD = Math.PI / 180;\n/**\n * Constants that identify shapes, mainly to prevent `instanceof` calls.\n * @static\n * @memberof PIXI\n * @enum {number}\n * @property {number} POLY Polygon\n * @property {number} RECT Rectangle\n * @property {number} CIRC Circle\n * @property {number} ELIP Ellipse\n * @property {number} RREC Rounded Rectangle\n */\nvar SHAPES;\n(function (SHAPES) {\n SHAPES[SHAPES[\"POLY\"] = 0] = \"POLY\";\n SHAPES[SHAPES[\"RECT\"] = 1] = \"RECT\";\n SHAPES[SHAPES[\"CIRC\"] = 2] = \"CIRC\";\n SHAPES[SHAPES[\"ELIP\"] = 3] = \"ELIP\";\n SHAPES[SHAPES[\"RREC\"] = 4] = \"RREC\";\n})(SHAPES || (SHAPES = {}));\n\n/**\n * The Point object represents a location in a two-dimensional coordinate system, where `x` represents\n * the position on the horizontal axis and `y` represents the position on the vertical axis\n * @class\n * @memberof PIXI\n * @implements {IPoint}\n */\nvar Point = /** @class */ (function () {\n /**\n * Creates a new `Point`\n * @param {number} [x=0] - position of the point on the x axis\n * @param {number} [y=0] - position of the point on the y axis\n */\n function Point(x, y) {\n if (x === void 0) { x = 0; }\n if (y === void 0) { y = 0; }\n /** Position of the point on the x axis */\n this.x = 0;\n /** Position of the point on the y axis */\n this.y = 0;\n this.x = x;\n this.y = y;\n }\n /**\n * Creates a clone of this point\n * @returns A clone of this point\n */\n Point.prototype.clone = function () {\n return new Point(this.x, this.y);\n };\n /**\n * Copies `x` and `y` from the given point into this point\n * @param p - The point to copy from\n * @returns The point instance itself\n */\n Point.prototype.copyFrom = function (p) {\n this.set(p.x, p.y);\n return this;\n };\n /**\n * Copies this point's x and y into the given point (`p`).\n * @param p - The point to copy to. Can be any of type that is or extends `IPointData`\n * @returns The point (`p`) with values updated\n */\n Point.prototype.copyTo = function (p) {\n p.set(this.x, this.y);\n return p;\n };\n /**\n * Accepts another point (`p`) and returns `true` if the given point is equal to this point\n * @param p - The point to check\n * @returns Returns `true` if both `x` and `y` are equal\n */\n Point.prototype.equals = function (p) {\n return (p.x === this.x) && (p.y === this.y);\n };\n /**\n * Sets the point to a new `x` and `y` position.\n * If `y` is omitted, both `x` and `y` will be set to `x`.\n * @param {number} [x=0] - position of the point on the `x` axis\n * @param {number} [y=x] - position of the point on the `y` axis\n * @returns The point instance itself\n */\n Point.prototype.set = function (x, y) {\n if (x === void 0) { x = 0; }\n if (y === void 0) { y = x; }\n this.x = x;\n this.y = y;\n return this;\n };\n Point.prototype.toString = function () {\n return \"[@pixi/math:Point x=\" + this.x + \" y=\" + this.y + \"]\";\n };\n return Point;\n}());\n\nvar tempPoints = [new Point(), new Point(), new Point(), new Point()];\n/**\n * Size object, contains width and height\n * @memberof PIXI\n * @typedef {object} ISize\n * @property {number} width - Width component\n * @property {number} height - Height component\n */\n/**\n * Rectangle object is an area defined by its position, as indicated by its top-left corner\n * point (x, y) and by its width and its height.\n * @memberof PIXI\n */\nvar Rectangle = /** @class */ (function () {\n /**\n * @param x - The X coordinate of the upper-left corner of the rectangle\n * @param y - The Y coordinate of the upper-left corner of the rectangle\n * @param width - The overall width of the rectangle\n * @param height - The overall height of the rectangle\n */\n function Rectangle(x, y, width, height) {\n if (x === void 0) { x = 0; }\n if (y === void 0) { y = 0; }\n if (width === void 0) { width = 0; }\n if (height === void 0) { height = 0; }\n this.x = Number(x);\n this.y = Number(y);\n this.width = Number(width);\n this.height = Number(height);\n this.type = SHAPES.RECT;\n }\n Object.defineProperty(Rectangle.prototype, \"left\", {\n /** Returns the left edge of the rectangle. */\n get: function () {\n return this.x;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Rectangle.prototype, \"right\", {\n /** Returns the right edge of the rectangle. */\n get: function () {\n return this.x + this.width;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Rectangle.prototype, \"top\", {\n /** Returns the top edge of the rectangle. */\n get: function () {\n return this.y;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Rectangle.prototype, \"bottom\", {\n /** Returns the bottom edge of the rectangle. */\n get: function () {\n return this.y + this.height;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Rectangle, \"EMPTY\", {\n /** A constant empty rectangle. */\n get: function () {\n return new Rectangle(0, 0, 0, 0);\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Creates a clone of this Rectangle\n * @returns a copy of the rectangle\n */\n Rectangle.prototype.clone = function () {\n return new Rectangle(this.x, this.y, this.width, this.height);\n };\n /**\n * Copies another rectangle to this one.\n * @param rectangle - The rectangle to copy from.\n * @returns Returns itself.\n */\n Rectangle.prototype.copyFrom = function (rectangle) {\n this.x = rectangle.x;\n this.y = rectangle.y;\n this.width = rectangle.width;\n this.height = rectangle.height;\n return this;\n };\n /**\n * Copies this rectangle to another one.\n * @param rectangle - The rectangle to copy to.\n * @returns Returns given parameter.\n */\n Rectangle.prototype.copyTo = function (rectangle) {\n rectangle.x = this.x;\n rectangle.y = this.y;\n rectangle.width = this.width;\n rectangle.height = this.height;\n return rectangle;\n };\n /**\n * Checks whether the x and y coordinates given are contained within this Rectangle\n * @param x - The X coordinate of the point to test\n * @param y - The Y coordinate of the point to test\n * @returns Whether the x/y coordinates are within this Rectangle\n */\n Rectangle.prototype.contains = function (x, y) {\n if (this.width <= 0 || this.height <= 0) {\n return false;\n }\n if (x >= this.x && x < this.x + this.width) {\n if (y >= this.y && y < this.y + this.height) {\n return true;\n }\n }\n return false;\n };\n /**\n * Determines whether the `other` Rectangle transformed by `transform` intersects with `this` Rectangle object.\n * Returns true only if the area of the intersection is >0, this means that Rectangles\n * sharing a side are not overlapping. Another side effect is that an arealess rectangle\n * (width or height equal to zero) can't intersect any other rectangle.\n * @param {Rectangle} other - The Rectangle to intersect with `this`.\n * @param {Matrix} transform - The transformation matrix of `other`.\n * @returns {boolean} A value of `true` if the transformed `other` Rectangle intersects with `this`; otherwise `false`.\n */\n Rectangle.prototype.intersects = function (other, transform) {\n if (!transform) {\n var x0_1 = this.x < other.x ? other.x : this.x;\n var x1_1 = this.right > other.right ? other.right : this.right;\n if (x1_1 <= x0_1) {\n return false;\n }\n var y0_1 = this.y < other.y ? other.y : this.y;\n var y1_1 = this.bottom > other.bottom ? other.bottom : this.bottom;\n return y1_1 > y0_1;\n }\n var x0 = this.left;\n var x1 = this.right;\n var y0 = this.top;\n var y1 = this.bottom;\n if (x1 <= x0 || y1 <= y0) {\n return false;\n }\n var lt = tempPoints[0].set(other.left, other.top);\n var lb = tempPoints[1].set(other.left, other.bottom);\n var rt = tempPoints[2].set(other.right, other.top);\n var rb = tempPoints[3].set(other.right, other.bottom);\n if (rt.x <= lt.x || lb.y <= lt.y) {\n return false;\n }\n var s = Math.sign((transform.a * transform.d) - (transform.b * transform.c));\n if (s === 0) {\n return false;\n }\n transform.apply(lt, lt);\n transform.apply(lb, lb);\n transform.apply(rt, rt);\n transform.apply(rb, rb);\n if (Math.max(lt.x, lb.x, rt.x, rb.x) <= x0\n || Math.min(lt.x, lb.x, rt.x, rb.x) >= x1\n || Math.max(lt.y, lb.y, rt.y, rb.y) <= y0\n || Math.min(lt.y, lb.y, rt.y, rb.y) >= y1) {\n return false;\n }\n var nx = s * (lb.y - lt.y);\n var ny = s * (lt.x - lb.x);\n var n00 = (nx * x0) + (ny * y0);\n var n10 = (nx * x1) + (ny * y0);\n var n01 = (nx * x0) + (ny * y1);\n var n11 = (nx * x1) + (ny * y1);\n if (Math.max(n00, n10, n01, n11) <= (nx * lt.x) + (ny * lt.y)\n || Math.min(n00, n10, n01, n11) >= (nx * rb.x) + (ny * rb.y)) {\n return false;\n }\n var mx = s * (lt.y - rt.y);\n var my = s * (rt.x - lt.x);\n var m00 = (mx * x0) + (my * y0);\n var m10 = (mx * x1) + (my * y0);\n var m01 = (mx * x0) + (my * y1);\n var m11 = (mx * x1) + (my * y1);\n if (Math.max(m00, m10, m01, m11) <= (mx * lt.x) + (my * lt.y)\n || Math.min(m00, m10, m01, m11) >= (mx * rb.x) + (my * rb.y)) {\n return false;\n }\n return true;\n };\n /**\n * Pads the rectangle making it grow in all directions.\n * If paddingY is omitted, both paddingX and paddingY will be set to paddingX.\n * @param paddingX - The horizontal padding amount.\n * @param paddingY - The vertical padding amount.\n * @returns Returns itself.\n */\n Rectangle.prototype.pad = function (paddingX, paddingY) {\n if (paddingX === void 0) { paddingX = 0; }\n if (paddingY === void 0) { paddingY = paddingX; }\n this.x -= paddingX;\n this.y -= paddingY;\n this.width += paddingX * 2;\n this.height += paddingY * 2;\n return this;\n };\n /**\n * Fits this rectangle around the passed one.\n * @param rectangle - The rectangle to fit.\n * @returns Returns itself.\n */\n Rectangle.prototype.fit = function (rectangle) {\n var x1 = Math.max(this.x, rectangle.x);\n var x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width);\n var y1 = Math.max(this.y, rectangle.y);\n var y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height);\n this.x = x1;\n this.width = Math.max(x2 - x1, 0);\n this.y = y1;\n this.height = Math.max(y2 - y1, 0);\n return this;\n };\n /**\n * Enlarges rectangle that way its corners lie on grid\n * @param resolution - resolution\n * @param eps - precision\n * @returns Returns itself.\n */\n Rectangle.prototype.ceil = function (resolution, eps) {\n if (resolution === void 0) { resolution = 1; }\n if (eps === void 0) { eps = 0.001; }\n var x2 = Math.ceil((this.x + this.width - eps) * resolution) / resolution;\n var y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution;\n this.x = Math.floor((this.x + eps) * resolution) / resolution;\n this.y = Math.floor((this.y + eps) * resolution) / resolution;\n this.width = x2 - this.x;\n this.height = y2 - this.y;\n return this;\n };\n /**\n * Enlarges this rectangle to include the passed rectangle.\n * @param rectangle - The rectangle to include.\n * @returns Returns itself.\n */\n Rectangle.prototype.enlarge = function (rectangle) {\n var x1 = Math.min(this.x, rectangle.x);\n var x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width);\n var y1 = Math.min(this.y, rectangle.y);\n var y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height);\n this.x = x1;\n this.width = x2 - x1;\n this.y = y1;\n this.height = y2 - y1;\n return this;\n };\n Rectangle.prototype.toString = function () {\n return \"[@pixi/math:Rectangle x=\" + this.x + \" y=\" + this.y + \" width=\" + this.width + \" height=\" + this.height + \"]\";\n };\n return Rectangle;\n}());\n\n/**\n * The Circle object is used to help draw graphics and can also be used to specify a hit area for displayObjects.\n * @memberof PIXI\n */\nvar Circle = /** @class */ (function () {\n /**\n * @param x - The X coordinate of the center of this circle\n * @param y - The Y coordinate of the center of this circle\n * @param radius - The radius of the circle\n */\n function Circle(x, y, radius) {\n if (x === void 0) { x = 0; }\n if (y === void 0) { y = 0; }\n if (radius === void 0) { radius = 0; }\n this.x = x;\n this.y = y;\n this.radius = radius;\n this.type = SHAPES.CIRC;\n }\n /**\n * Creates a clone of this Circle instance\n * @returns A copy of the Circle\n */\n Circle.prototype.clone = function () {\n return new Circle(this.x, this.y, this.radius);\n };\n /**\n * Checks whether the x and y coordinates given are contained within this circle\n * @param x - The X coordinate of the point to test\n * @param y - The Y coordinate of the point to test\n * @returns Whether the x/y coordinates are within this Circle\n */\n Circle.prototype.contains = function (x, y) {\n if (this.radius <= 0) {\n return false;\n }\n var r2 = this.radius * this.radius;\n var dx = (this.x - x);\n var dy = (this.y - y);\n dx *= dx;\n dy *= dy;\n return (dx + dy <= r2);\n };\n /**\n * Returns the framing rectangle of the circle as a Rectangle object\n * @returns The framing rectangle\n */\n Circle.prototype.getBounds = function () {\n return new Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2);\n };\n Circle.prototype.toString = function () {\n return \"[@pixi/math:Circle x=\" + this.x + \" y=\" + this.y + \" radius=\" + this.radius + \"]\";\n };\n return Circle;\n}());\n\n/**\n * The Ellipse object is used to help draw graphics and can also be used to specify a hit area for displayObjects.\n * @memberof PIXI\n */\nvar Ellipse = /** @class */ (function () {\n /**\n * @param x - The X coordinate of the center of this ellipse\n * @param y - The Y coordinate of the center of this ellipse\n * @param halfWidth - The half width of this ellipse\n * @param halfHeight - The half height of this ellipse\n */\n function Ellipse(x, y, halfWidth, halfHeight) {\n if (x === void 0) { x = 0; }\n if (y === void 0) { y = 0; }\n if (halfWidth === void 0) { halfWidth = 0; }\n if (halfHeight === void 0) { halfHeight = 0; }\n this.x = x;\n this.y = y;\n this.width = halfWidth;\n this.height = halfHeight;\n this.type = SHAPES.ELIP;\n }\n /**\n * Creates a clone of this Ellipse instance\n * @returns {PIXI.Ellipse} A copy of the ellipse\n */\n Ellipse.prototype.clone = function () {\n return new Ellipse(this.x, this.y, this.width, this.height);\n };\n /**\n * Checks whether the x and y coordinates given are contained within this ellipse\n * @param x - The X coordinate of the point to test\n * @param y - The Y coordinate of the point to test\n * @returns Whether the x/y coords are within this ellipse\n */\n Ellipse.prototype.contains = function (x, y) {\n if (this.width <= 0 || this.height <= 0) {\n return false;\n }\n // normalize the coords to an ellipse with center 0,0\n var normx = ((x - this.x) / this.width);\n var normy = ((y - this.y) / this.height);\n normx *= normx;\n normy *= normy;\n return (normx + normy <= 1);\n };\n /**\n * Returns the framing rectangle of the ellipse as a Rectangle object\n * @returns The framing rectangle\n */\n Ellipse.prototype.getBounds = function () {\n return new Rectangle(this.x - this.width, this.y - this.height, this.width, this.height);\n };\n Ellipse.prototype.toString = function () {\n return \"[@pixi/math:Ellipse x=\" + this.x + \" y=\" + this.y + \" width=\" + this.width + \" height=\" + this.height + \"]\";\n };\n return Ellipse;\n}());\n\n/**\n * A class to define a shape via user defined coordinates.\n * @memberof PIXI\n */\nvar Polygon = /** @class */ (function () {\n /**\n * @param {PIXI.IPointData[]|number[]} points - This can be an array of Points\n * that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...], or\n * the arguments passed can be all the points of the polygon e.g.\n * `new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...)`, or the arguments passed can be flat\n * x,y values e.g. `new Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are Numbers.\n */\n function Polygon() {\n var arguments$1 = arguments;\n\n var points = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n points[_i] = arguments$1[_i];\n }\n var flat = Array.isArray(points[0]) ? points[0] : points;\n // if this is an array of points, convert it to a flat array of numbers\n if (typeof flat[0] !== 'number') {\n var p = [];\n for (var i = 0, il = flat.length; i < il; i++) {\n p.push(flat[i].x, flat[i].y);\n }\n flat = p;\n }\n this.points = flat;\n this.type = SHAPES.POLY;\n this.closeStroke = true;\n }\n /**\n * Creates a clone of this polygon.\n * @returns - A copy of the polygon.\n */\n Polygon.prototype.clone = function () {\n var points = this.points.slice();\n var polygon = new Polygon(points);\n polygon.closeStroke = this.closeStroke;\n return polygon;\n };\n /**\n * Checks whether the x and y coordinates passed to this function are contained within this polygon.\n * @param x - The X coordinate of the point to test.\n * @param y - The Y coordinate of the point to test.\n * @returns - Whether the x/y coordinates are within this polygon.\n */\n Polygon.prototype.contains = function (x, y) {\n var inside = false;\n // use some raycasting to test hits\n // https://github.com/substack/point-in-polygon/blob/master/index.js\n var length = this.points.length / 2;\n for (var i = 0, j = length - 1; i < length; j = i++) {\n var xi = this.points[i * 2];\n var yi = this.points[(i * 2) + 1];\n var xj = this.points[j * 2];\n var yj = this.points[(j * 2) + 1];\n var intersect = ((yi > y) !== (yj > y)) && (x < ((xj - xi) * ((y - yi) / (yj - yi))) + xi);\n if (intersect) {\n inside = !inside;\n }\n }\n return inside;\n };\n Polygon.prototype.toString = function () {\n return \"[@pixi/math:Polygon\"\n + (\"closeStroke=\" + this.closeStroke)\n + (\"points=\" + this.points.reduce(function (pointsDesc, currentPoint) { return pointsDesc + \", \" + currentPoint; }, '') + \"]\");\n };\n return Polygon;\n}());\n\n/**\n * The Rounded Rectangle object is an area that has nice rounded corners, as indicated by its\n * top-left corner point (x, y) and by its width and its height and its radius.\n * @memberof PIXI\n */\nvar RoundedRectangle = /** @class */ (function () {\n /**\n * @param x - The X coordinate of the upper-left corner of the rounded rectangle\n * @param y - The Y coordinate of the upper-left corner of the rounded rectangle\n * @param width - The overall width of this rounded rectangle\n * @param height - The overall height of this rounded rectangle\n * @param radius - Controls the radius of the rounded corners\n */\n function RoundedRectangle(x, y, width, height, radius) {\n if (x === void 0) { x = 0; }\n if (y === void 0) { y = 0; }\n if (width === void 0) { width = 0; }\n if (height === void 0) { height = 0; }\n if (radius === void 0) { radius = 20; }\n this.x = x;\n this.y = y;\n this.width = width;\n this.height = height;\n this.radius = radius;\n this.type = SHAPES.RREC;\n }\n /**\n * Creates a clone of this Rounded Rectangle.\n * @returns - A copy of the rounded rectangle.\n */\n RoundedRectangle.prototype.clone = function () {\n return new RoundedRectangle(this.x, this.y, this.width, this.height, this.radius);\n };\n /**\n * Checks whether the x and y coordinates given are contained within this Rounded Rectangle\n * @param x - The X coordinate of the point to test.\n * @param y - The Y coordinate of the point to test.\n * @returns - Whether the x/y coordinates are within this Rounded Rectangle.\n */\n RoundedRectangle.prototype.contains = function (x, y) {\n if (this.width <= 0 || this.height <= 0) {\n return false;\n }\n if (x >= this.x && x <= this.x + this.width) {\n if (y >= this.y && y <= this.y + this.height) {\n var radius = Math.max(0, Math.min(this.radius, Math.min(this.width, this.height) / 2));\n if ((y >= this.y + radius && y <= this.y + this.height - radius)\n || (x >= this.x + radius && x <= this.x + this.width - radius)) {\n return true;\n }\n var dx = x - (this.x + radius);\n var dy = y - (this.y + radius);\n var radius2 = radius * radius;\n if ((dx * dx) + (dy * dy) <= radius2) {\n return true;\n }\n dx = x - (this.x + this.width - radius);\n if ((dx * dx) + (dy * dy) <= radius2) {\n return true;\n }\n dy = y - (this.y + this.height - radius);\n if ((dx * dx) + (dy * dy) <= radius2) {\n return true;\n }\n dx = x - (this.x + radius);\n if ((dx * dx) + (dy * dy) <= radius2) {\n return true;\n }\n }\n }\n return false;\n };\n RoundedRectangle.prototype.toString = function () {\n return \"[@pixi/math:RoundedRectangle x=\" + this.x + \" y=\" + this.y\n + (\"width=\" + this.width + \" height=\" + this.height + \" radius=\" + this.radius + \"]\");\n };\n return RoundedRectangle;\n}());\n\n/**\n * The ObservablePoint object represents a location in a two-dimensional coordinate system, where `x` represents\n * the position on the horizontal axis and `y` represents the position on the vertical axis.\n *\n * An `ObservablePoint` is a point that triggers a callback when the point's position is changed.\n * @memberof PIXI\n */\nvar ObservablePoint = /** @class */ (function () {\n /**\n * Creates a new `ObservablePoint`\n * @param cb - callback function triggered when `x` and/or `y` are changed\n * @param scope - owner of callback\n * @param {number} [x=0] - position of the point on the x axis\n * @param {number} [y=0] - position of the point on the y axis\n */\n function ObservablePoint(cb, scope, x, y) {\n if (x === void 0) { x = 0; }\n if (y === void 0) { y = 0; }\n this._x = x;\n this._y = y;\n this.cb = cb;\n this.scope = scope;\n }\n /**\n * Creates a clone of this point.\n * The callback and scope params can be overridden otherwise they will default\n * to the clone object's values.\n * @override\n * @param cb - The callback function triggered when `x` and/or `y` are changed\n * @param scope - The owner of the callback\n * @returns a copy of this observable point\n */\n ObservablePoint.prototype.clone = function (cb, scope) {\n if (cb === void 0) { cb = this.cb; }\n if (scope === void 0) { scope = this.scope; }\n return new ObservablePoint(cb, scope, this._x, this._y);\n };\n /**\n * Sets the point to a new `x` and `y` position.\n * If `y` is omitted, both `x` and `y` will be set to `x`.\n * @param {number} [x=0] - position of the point on the x axis\n * @param {number} [y=x] - position of the point on the y axis\n * @returns The observable point instance itself\n */\n ObservablePoint.prototype.set = function (x, y) {\n if (x === void 0) { x = 0; }\n if (y === void 0) { y = x; }\n if (this._x !== x || this._y !== y) {\n this._x = x;\n this._y = y;\n this.cb.call(this.scope);\n }\n return this;\n };\n /**\n * Copies x and y from the given point (`p`)\n * @param p - The point to copy from. Can be any of type that is or extends `IPointData`\n * @returns The observable point instance itself\n */\n ObservablePoint.prototype.copyFrom = function (p) {\n if (this._x !== p.x || this._y !== p.y) {\n this._x = p.x;\n this._y = p.y;\n this.cb.call(this.scope);\n }\n return this;\n };\n /**\n * Copies this point's x and y into that of the given point (`p`)\n * @param p - The point to copy to. Can be any of type that is or extends `IPointData`\n * @returns The point (`p`) with values updated\n */\n ObservablePoint.prototype.copyTo = function (p) {\n p.set(this._x, this._y);\n return p;\n };\n /**\n * Accepts another point (`p`) and returns `true` if the given point is equal to this point\n * @param p - The point to check\n * @returns Returns `true` if both `x` and `y` are equal\n */\n ObservablePoint.prototype.equals = function (p) {\n return (p.x === this._x) && (p.y === this._y);\n };\n ObservablePoint.prototype.toString = function () {\n return \"[@pixi/math:ObservablePoint x=\" + 0 + \" y=\" + 0 + \" scope=\" + this.scope + \"]\";\n };\n Object.defineProperty(ObservablePoint.prototype, \"x\", {\n /** Position of the observable point on the x axis. */\n get: function () {\n return this._x;\n },\n set: function (value) {\n if (this._x !== value) {\n this._x = value;\n this.cb.call(this.scope);\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(ObservablePoint.prototype, \"y\", {\n /** Position of the observable point on the y axis. */\n get: function () {\n return this._y;\n },\n set: function (value) {\n if (this._y !== value) {\n this._y = value;\n this.cb.call(this.scope);\n }\n },\n enumerable: false,\n configurable: true\n });\n return ObservablePoint;\n}());\n\n/**\n * The PixiJS Matrix as a class makes it a lot faster.\n *\n * Here is a representation of it:\n * ```js\n * | a | c | tx|\n * | b | d | ty|\n * | 0 | 0 | 1 |\n * ```\n * @memberof PIXI\n */\nvar Matrix = /** @class */ (function () {\n /**\n * @param a - x scale\n * @param b - y skew\n * @param c - x skew\n * @param d - y scale\n * @param tx - x translation\n * @param ty - y translation\n */\n function Matrix(a, b, c, d, tx, ty) {\n if (a === void 0) { a = 1; }\n if (b === void 0) { b = 0; }\n if (c === void 0) { c = 0; }\n if (d === void 0) { d = 1; }\n if (tx === void 0) { tx = 0; }\n if (ty === void 0) { ty = 0; }\n this.array = null;\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.tx = tx;\n this.ty = ty;\n }\n /**\n * Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:\n *\n * a = array[0]\n * b = array[1]\n * c = array[3]\n * d = array[4]\n * tx = array[2]\n * ty = array[5]\n * @param array - The array that the matrix will be populated from.\n */\n Matrix.prototype.fromArray = function (array) {\n this.a = array[0];\n this.b = array[1];\n this.c = array[3];\n this.d = array[4];\n this.tx = array[2];\n this.ty = array[5];\n };\n /**\n * Sets the matrix properties.\n * @param a - Matrix component\n * @param b - Matrix component\n * @param c - Matrix component\n * @param d - Matrix component\n * @param tx - Matrix component\n * @param ty - Matrix component\n * @returns This matrix. Good for chaining method calls.\n */\n Matrix.prototype.set = function (a, b, c, d, tx, ty) {\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.tx = tx;\n this.ty = ty;\n return this;\n };\n /**\n * Creates an array from the current Matrix object.\n * @param transpose - Whether we need to transpose the matrix or not\n * @param [out=new Float32Array(9)] - If provided the array will be assigned to out\n * @returns The newly created array which contains the matrix\n */\n Matrix.prototype.toArray = function (transpose, out) {\n if (!this.array) {\n this.array = new Float32Array(9);\n }\n var array = out || this.array;\n if (transpose) {\n array[0] = this.a;\n array[1] = this.b;\n array[2] = 0;\n array[3] = this.c;\n array[4] = this.d;\n array[5] = 0;\n array[6] = this.tx;\n array[7] = this.ty;\n array[8] = 1;\n }\n else {\n array[0] = this.a;\n array[1] = this.c;\n array[2] = this.tx;\n array[3] = this.b;\n array[4] = this.d;\n array[5] = this.ty;\n array[6] = 0;\n array[7] = 0;\n array[8] = 1;\n }\n return array;\n };\n /**\n * Get a new position with the current transformation applied.\n * Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering)\n * @param pos - The origin\n * @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)\n * @returns {PIXI.Point} The new point, transformed through this matrix\n */\n Matrix.prototype.apply = function (pos, newPos) {\n newPos = (newPos || new Point());\n var x = pos.x;\n var y = pos.y;\n newPos.x = (this.a * x) + (this.c * y) + this.tx;\n newPos.y = (this.b * x) + (this.d * y) + this.ty;\n return newPos;\n };\n /**\n * Get a new position with the inverse of the current transformation applied.\n * Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input)\n * @param pos - The origin\n * @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)\n * @returns {PIXI.Point} The new point, inverse-transformed through this matrix\n */\n Matrix.prototype.applyInverse = function (pos, newPos) {\n newPos = (newPos || new Point());\n var id = 1 / ((this.a * this.d) + (this.c * -this.b));\n var x = pos.x;\n var y = pos.y;\n newPos.x = (this.d * id * x) + (-this.c * id * y) + (((this.ty * this.c) - (this.tx * this.d)) * id);\n newPos.y = (this.a * id * y) + (-this.b * id * x) + (((-this.ty * this.a) + (this.tx * this.b)) * id);\n return newPos;\n };\n /**\n * Translates the matrix on the x and y.\n * @param x - How much to translate x by\n * @param y - How much to translate y by\n * @returns This matrix. Good for chaining method calls.\n */\n Matrix.prototype.translate = function (x, y) {\n this.tx += x;\n this.ty += y;\n return this;\n };\n /**\n * Applies a scale transformation to the matrix.\n * @param x - The amount to scale horizontally\n * @param y - The amount to scale vertically\n * @returns This matrix. Good for chaining method calls.\n */\n Matrix.prototype.scale = function (x, y) {\n this.a *= x;\n this.d *= y;\n this.c *= x;\n this.b *= y;\n this.tx *= x;\n this.ty *= y;\n return this;\n };\n /**\n * Applies a rotation transformation to the matrix.\n * @param angle - The angle in radians.\n * @returns This matrix. Good for chaining method calls.\n */\n Matrix.prototype.rotate = function (angle) {\n var cos = Math.cos(angle);\n var sin = Math.sin(angle);\n var a1 = this.a;\n var c1 = this.c;\n var tx1 = this.tx;\n this.a = (a1 * cos) - (this.b * sin);\n this.b = (a1 * sin) + (this.b * cos);\n this.c = (c1 * cos) - (this.d * sin);\n this.d = (c1 * sin) + (this.d * cos);\n this.tx = (tx1 * cos) - (this.ty * sin);\n this.ty = (tx1 * sin) + (this.ty * cos);\n return this;\n };\n /**\n * Appends the given Matrix to this Matrix.\n * @param matrix - The matrix to append.\n * @returns This matrix. Good for chaining method calls.\n */\n Matrix.prototype.append = function (matrix) {\n var a1 = this.a;\n var b1 = this.b;\n var c1 = this.c;\n var d1 = this.d;\n this.a = (matrix.a * a1) + (matrix.b * c1);\n this.b = (matrix.a * b1) + (matrix.b * d1);\n this.c = (matrix.c * a1) + (matrix.d * c1);\n this.d = (matrix.c * b1) + (matrix.d * d1);\n this.tx = (matrix.tx * a1) + (matrix.ty * c1) + this.tx;\n this.ty = (matrix.tx * b1) + (matrix.ty * d1) + this.ty;\n return this;\n };\n /**\n * Sets the matrix based on all the available properties\n * @param x - Position on the x axis\n * @param y - Position on the y axis\n * @param pivotX - Pivot on the x axis\n * @param pivotY - Pivot on the y axis\n * @param scaleX - Scale on the x axis\n * @param scaleY - Scale on the y axis\n * @param rotation - Rotation in radians\n * @param skewX - Skew on the x axis\n * @param skewY - Skew on the y axis\n * @returns This matrix. Good for chaining method calls.\n */\n Matrix.prototype.setTransform = function (x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY) {\n this.a = Math.cos(rotation + skewY) * scaleX;\n this.b = Math.sin(rotation + skewY) * scaleX;\n this.c = -Math.sin(rotation - skewX) * scaleY;\n this.d = Math.cos(rotation - skewX) * scaleY;\n this.tx = x - ((pivotX * this.a) + (pivotY * this.c));\n this.ty = y - ((pivotX * this.b) + (pivotY * this.d));\n return this;\n };\n /**\n * Prepends the given Matrix to this Matrix.\n * @param matrix - The matrix to prepend\n * @returns This matrix. Good for chaining method calls.\n */\n Matrix.prototype.prepend = function (matrix) {\n var tx1 = this.tx;\n if (matrix.a !== 1 || matrix.b !== 0 || matrix.c !== 0 || matrix.d !== 1) {\n var a1 = this.a;\n var c1 = this.c;\n this.a = (a1 * matrix.a) + (this.b * matrix.c);\n this.b = (a1 * matrix.b) + (this.b * matrix.d);\n this.c = (c1 * matrix.a) + (this.d * matrix.c);\n this.d = (c1 * matrix.b) + (this.d * matrix.d);\n }\n this.tx = (tx1 * matrix.a) + (this.ty * matrix.c) + matrix.tx;\n this.ty = (tx1 * matrix.b) + (this.ty * matrix.d) + matrix.ty;\n return this;\n };\n /**\n * Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.\n * @param transform - The transform to apply the properties to.\n * @returns The transform with the newly applied properties\n */\n Matrix.prototype.decompose = function (transform) {\n // sort out rotation / skew..\n var a = this.a;\n var b = this.b;\n var c = this.c;\n var d = this.d;\n var pivot = transform.pivot;\n var skewX = -Math.atan2(-c, d);\n var skewY = Math.atan2(b, a);\n var delta = Math.abs(skewX + skewY);\n if (delta < 0.00001 || Math.abs(PI_2 - delta) < 0.00001) {\n transform.rotation = skewY;\n transform.skew.x = transform.skew.y = 0;\n }\n else {\n transform.rotation = 0;\n transform.skew.x = skewX;\n transform.skew.y = skewY;\n }\n // next set scale\n transform.scale.x = Math.sqrt((a * a) + (b * b));\n transform.scale.y = Math.sqrt((c * c) + (d * d));\n // next set position\n transform.position.x = this.tx + ((pivot.x * a) + (pivot.y * c));\n transform.position.y = this.ty + ((pivot.x * b) + (pivot.y * d));\n return transform;\n };\n /**\n * Inverts this matrix\n * @returns This matrix. Good for chaining method calls.\n */\n Matrix.prototype.invert = function () {\n var a1 = this.a;\n var b1 = this.b;\n var c1 = this.c;\n var d1 = this.d;\n var tx1 = this.tx;\n var n = (a1 * d1) - (b1 * c1);\n this.a = d1 / n;\n this.b = -b1 / n;\n this.c = -c1 / n;\n this.d = a1 / n;\n this.tx = ((c1 * this.ty) - (d1 * tx1)) / n;\n this.ty = -((a1 * this.ty) - (b1 * tx1)) / n;\n return this;\n };\n /**\n * Resets this Matrix to an identity (default) matrix.\n * @returns This matrix. Good for chaining method calls.\n */\n Matrix.prototype.identity = function () {\n this.a = 1;\n this.b = 0;\n this.c = 0;\n this.d = 1;\n this.tx = 0;\n this.ty = 0;\n return this;\n };\n /**\n * Creates a new Matrix object with the same values as this one.\n * @returns A copy of this matrix. Good for chaining method calls.\n */\n Matrix.prototype.clone = function () {\n var matrix = new Matrix();\n matrix.a = this.a;\n matrix.b = this.b;\n matrix.c = this.c;\n matrix.d = this.d;\n matrix.tx = this.tx;\n matrix.ty = this.ty;\n return matrix;\n };\n /**\n * Changes the values of the given matrix to be the same as the ones in this matrix\n * @param matrix - The matrix to copy to.\n * @returns The matrix given in parameter with its values updated.\n */\n Matrix.prototype.copyTo = function (matrix) {\n matrix.a = this.a;\n matrix.b = this.b;\n matrix.c = this.c;\n matrix.d = this.d;\n matrix.tx = this.tx;\n matrix.ty = this.ty;\n return matrix;\n };\n /**\n * Changes the values of the matrix to be the same as the ones in given matrix\n * @param {PIXI.Matrix} matrix - The matrix to copy from.\n * @returns {PIXI.Matrix} this\n */\n Matrix.prototype.copyFrom = function (matrix) {\n this.a = matrix.a;\n this.b = matrix.b;\n this.c = matrix.c;\n this.d = matrix.d;\n this.tx = matrix.tx;\n this.ty = matrix.ty;\n return this;\n };\n Matrix.prototype.toString = function () {\n return \"[@pixi/math:Matrix a=\" + this.a + \" b=\" + this.b + \" c=\" + this.c + \" d=\" + this.d + \" tx=\" + this.tx + \" ty=\" + this.ty + \"]\";\n };\n Object.defineProperty(Matrix, \"IDENTITY\", {\n /**\n * A default (identity) matrix\n * @readonly\n */\n get: function () {\n return new Matrix();\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Matrix, \"TEMP_MATRIX\", {\n /**\n * A temp matrix\n * @readonly\n */\n get: function () {\n return new Matrix();\n },\n enumerable: false,\n configurable: true\n });\n return Matrix;\n}());\n\n// Your friendly neighbour https://en.wikipedia.org/wiki/Dihedral_group\n/*\n * Transform matrix for operation n is:\n * | ux | vx |\n * | uy | vy |\n */\nvar ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1];\nvar uy = [0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1];\nvar vx = [0, -1, -1, -1, 0, 1, 1, 1, 0, 1, 1, 1, 0, -1, -1, -1];\nvar vy = [1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, 1, 1, 1, 0, -1];\n/**\n * [Cayley Table]{@link https://en.wikipedia.org/wiki/Cayley_table}\n * for the composition of each rotation in the dihederal group D8.\n * @type {number[][]}\n * @private\n */\nvar rotationCayley = [];\n/**\n * Matrices for each `GD8Symmetry` rotation.\n * @type {PIXI.Matrix[]}\n * @private\n */\nvar rotationMatrices = [];\n/*\n * Alias for {@code Math.sign}.\n */\nvar signum = Math.sign;\n/*\n * Initializes `rotationCayley` and `rotationMatrices`. It is called\n * only once below.\n */\nfunction init() {\n for (var i = 0; i < 16; i++) {\n var row = [];\n rotationCayley.push(row);\n for (var j = 0; j < 16; j++) {\n /* Multiplies rotation matrices i and j. */\n var _ux = signum((ux[i] * ux[j]) + (vx[i] * uy[j]));\n var _uy = signum((uy[i] * ux[j]) + (vy[i] * uy[j]));\n var _vx = signum((ux[i] * vx[j]) + (vx[i] * vy[j]));\n var _vy = signum((uy[i] * vx[j]) + (vy[i] * vy[j]));\n /* Finds rotation matrix matching the product and pushes it. */\n for (var k = 0; k < 16; k++) {\n if (ux[k] === _ux && uy[k] === _uy\n && vx[k] === _vx && vy[k] === _vy) {\n row.push(k);\n break;\n }\n }\n }\n }\n for (var i = 0; i < 16; i++) {\n var mat = new Matrix();\n mat.set(ux[i], uy[i], vx[i], vy[i], 0, 0);\n rotationMatrices.push(mat);\n }\n}\ninit();\n/**\n * @memberof PIXI\n * @typedef {number} GD8Symmetry\n * @see PIXI.groupD8\n */\n/**\n * Implements the dihedral group D8, which is similar to\n * [group D4]{@link http://mathworld.wolfram.com/DihedralGroupD4.html};\n * D8 is the same but with diagonals, and it is used for texture\n * rotations.\n *\n * The directions the U- and V- axes after rotation\n * of an angle of `a: GD8Constant` are the vectors `(uX(a), uY(a))`\n * and `(vX(a), vY(a))`. These aren't necessarily unit vectors.\n *\n * **Origin:**
\n * This is the small part of gameofbombs.com portal system. It works.\n * @see PIXI.groupD8.E\n * @see PIXI.groupD8.SE\n * @see PIXI.groupD8.S\n * @see PIXI.groupD8.SW\n * @see PIXI.groupD8.W\n * @see PIXI.groupD8.NW\n * @see PIXI.groupD8.N\n * @see PIXI.groupD8.NE\n * @author Ivan @ivanpopelyshev\n * @namespace PIXI.groupD8\n * @memberof PIXI\n */\nvar groupD8 = {\n /**\n * | Rotation | Direction |\n * |----------|-----------|\n * | 0° | East |\n * @memberof PIXI.groupD8\n * @constant {PIXI.GD8Symmetry}\n */\n E: 0,\n /**\n * | Rotation | Direction |\n * |----------|-----------|\n * | 45°↻ | Southeast |\n * @memberof PIXI.groupD8\n * @constant {PIXI.GD8Symmetry}\n */\n SE: 1,\n /**\n * | Rotation | Direction |\n * |----------|-----------|\n * | 90°↻ | South |\n * @memberof PIXI.groupD8\n * @constant {PIXI.GD8Symmetry}\n */\n S: 2,\n /**\n * | Rotation | Direction |\n * |----------|-----------|\n * | 135°↻ | Southwest |\n * @memberof PIXI.groupD8\n * @constant {PIXI.GD8Symmetry}\n */\n SW: 3,\n /**\n * | Rotation | Direction |\n * |----------|-----------|\n * | 180° | West |\n * @memberof PIXI.groupD8\n * @constant {PIXI.GD8Symmetry}\n */\n W: 4,\n /**\n * | Rotation | Direction |\n * |-------------|--------------|\n * | -135°/225°↻ | Northwest |\n * @memberof PIXI.groupD8\n * @constant {PIXI.GD8Symmetry}\n */\n NW: 5,\n /**\n * | Rotation | Direction |\n * |-------------|--------------|\n * | -90°/270°↻ | North |\n * @memberof PIXI.groupD8\n * @constant {PIXI.GD8Symmetry}\n */\n N: 6,\n /**\n * | Rotation | Direction |\n * |-------------|--------------|\n * | -45°/315°↻ | Northeast |\n * @memberof PIXI.groupD8\n * @constant {PIXI.GD8Symmetry}\n */\n NE: 7,\n /**\n * Reflection about Y-axis.\n * @memberof PIXI.groupD8\n * @constant {PIXI.GD8Symmetry}\n */\n MIRROR_VERTICAL: 8,\n /**\n * Reflection about the main diagonal.\n * @memberof PIXI.groupD8\n * @constant {PIXI.GD8Symmetry}\n */\n MAIN_DIAGONAL: 10,\n /**\n * Reflection about X-axis.\n * @memberof PIXI.groupD8\n * @constant {PIXI.GD8Symmetry}\n */\n MIRROR_HORIZONTAL: 12,\n /**\n * Reflection about reverse diagonal.\n * @memberof PIXI.groupD8\n * @constant {PIXI.GD8Symmetry}\n */\n REVERSE_DIAGONAL: 14,\n /**\n * @memberof PIXI.groupD8\n * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.\n * @returns {PIXI.GD8Symmetry} The X-component of the U-axis\n * after rotating the axes.\n */\n uX: function (ind) { return ux[ind]; },\n /**\n * @memberof PIXI.groupD8\n * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.\n * @returns {PIXI.GD8Symmetry} The Y-component of the U-axis\n * after rotating the axes.\n */\n uY: function (ind) { return uy[ind]; },\n /**\n * @memberof PIXI.groupD8\n * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.\n * @returns {PIXI.GD8Symmetry} The X-component of the V-axis\n * after rotating the axes.\n */\n vX: function (ind) { return vx[ind]; },\n /**\n * @memberof PIXI.groupD8\n * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.\n * @returns {PIXI.GD8Symmetry} The Y-component of the V-axis\n * after rotating the axes.\n */\n vY: function (ind) { return vy[ind]; },\n /**\n * @memberof PIXI.groupD8\n * @param {PIXI.GD8Symmetry} rotation - symmetry whose opposite\n * is needed. Only rotations have opposite symmetries while\n * reflections don't.\n * @returns {PIXI.GD8Symmetry} The opposite symmetry of `rotation`\n */\n inv: function (rotation) {\n if (rotation & 8) // true only if between 8 & 15 (reflections)\n {\n return rotation & 15; // or rotation % 16\n }\n return (-rotation) & 7; // or (8 - rotation) % 8\n },\n /**\n * Composes the two D8 operations.\n *\n * Taking `^` as reflection:\n *\n * | | E=0 | S=2 | W=4 | N=6 | E^=8 | S^=10 | W^=12 | N^=14 |\n * |-------|-----|-----|-----|-----|------|-------|-------|-------|\n * | E=0 | E | S | W | N | E^ | S^ | W^ | N^ |\n * | S=2 | S | W | N | E | S^ | W^ | N^ | E^ |\n * | W=4 | W | N | E | S | W^ | N^ | E^ | S^ |\n * | N=6 | N | E | S | W | N^ | E^ | S^ | W^ |\n * | E^=8 | E^ | N^ | W^ | S^ | E | N | W | S |\n * | S^=10 | S^ | E^ | N^ | W^ | S | E | N | W |\n * | W^=12 | W^ | S^ | E^ | N^ | W | S | E | N |\n * | N^=14 | N^ | W^ | S^ | E^ | N | W | S | E |\n *\n * [This is a Cayley table]{@link https://en.wikipedia.org/wiki/Cayley_table}\n * @memberof PIXI.groupD8\n * @param {PIXI.GD8Symmetry} rotationSecond - Second operation, which\n * is the row in the above cayley table.\n * @param {PIXI.GD8Symmetry} rotationFirst - First operation, which\n * is the column in the above cayley table.\n * @returns {PIXI.GD8Symmetry} Composed operation\n */\n add: function (rotationSecond, rotationFirst) { return (rotationCayley[rotationSecond][rotationFirst]); },\n /**\n * Reverse of `add`.\n * @memberof PIXI.groupD8\n * @param {PIXI.GD8Symmetry} rotationSecond - Second operation\n * @param {PIXI.GD8Symmetry} rotationFirst - First operation\n * @returns {PIXI.GD8Symmetry} Result\n */\n sub: function (rotationSecond, rotationFirst) { return (rotationCayley[rotationSecond][groupD8.inv(rotationFirst)]); },\n /**\n * Adds 180 degrees to rotation, which is a commutative\n * operation.\n * @memberof PIXI.groupD8\n * @param {number} rotation - The number to rotate.\n * @returns {number} Rotated number\n */\n rotate180: function (rotation) { return rotation ^ 4; },\n /**\n * Checks if the rotation angle is vertical, i.e. south\n * or north. It doesn't work for reflections.\n * @memberof PIXI.groupD8\n * @param {PIXI.GD8Symmetry} rotation - The number to check.\n * @returns {boolean} Whether or not the direction is vertical\n */\n isVertical: function (rotation) { return (rotation & 3) === 2; },\n /**\n * Approximates the vector `V(dx,dy)` into one of the\n * eight directions provided by `groupD8`.\n * @memberof PIXI.groupD8\n * @param {number} dx - X-component of the vector\n * @param {number} dy - Y-component of the vector\n * @returns {PIXI.GD8Symmetry} Approximation of the vector into\n * one of the eight symmetries.\n */\n byDirection: function (dx, dy) {\n if (Math.abs(dx) * 2 <= Math.abs(dy)) {\n if (dy >= 0) {\n return groupD8.S;\n }\n return groupD8.N;\n }\n else if (Math.abs(dy) * 2 <= Math.abs(dx)) {\n if (dx > 0) {\n return groupD8.E;\n }\n return groupD8.W;\n }\n else if (dy > 0) {\n if (dx > 0) {\n return groupD8.SE;\n }\n return groupD8.SW;\n }\n else if (dx > 0) {\n return groupD8.NE;\n }\n return groupD8.NW;\n },\n /**\n * Helps sprite to compensate texture packer rotation.\n * @memberof PIXI.groupD8\n * @param {PIXI.Matrix} matrix - sprite world matrix\n * @param {PIXI.GD8Symmetry} rotation - The rotation factor to use.\n * @param {number} tx - sprite anchoring\n * @param {number} ty - sprite anchoring\n */\n matrixAppendRotationInv: function (matrix, rotation, tx, ty) {\n if (tx === void 0) { tx = 0; }\n if (ty === void 0) { ty = 0; }\n // Packer used \"rotation\", we use \"inv(rotation)\"\n var mat = rotationMatrices[groupD8.inv(rotation)];\n mat.tx = tx;\n mat.ty = ty;\n matrix.append(mat);\n },\n};\n\n/**\n * Transform that takes care about its versions.\n * @memberof PIXI\n */\nvar Transform = /** @class */ (function () {\n function Transform() {\n this.worldTransform = new Matrix();\n this.localTransform = new Matrix();\n this.position = new ObservablePoint(this.onChange, this, 0, 0);\n this.scale = new ObservablePoint(this.onChange, this, 1, 1);\n this.pivot = new ObservablePoint(this.onChange, this, 0, 0);\n this.skew = new ObservablePoint(this.updateSkew, this, 0, 0);\n this._rotation = 0;\n this._cx = 1;\n this._sx = 0;\n this._cy = 0;\n this._sy = 1;\n this._localID = 0;\n this._currentLocalID = 0;\n this._worldID = 0;\n this._parentID = 0;\n }\n /** Called when a value changes. */\n Transform.prototype.onChange = function () {\n this._localID++;\n };\n /** Called when the skew or the rotation changes. */\n Transform.prototype.updateSkew = function () {\n this._cx = Math.cos(this._rotation + this.skew.y);\n this._sx = Math.sin(this._rotation + this.skew.y);\n this._cy = -Math.sin(this._rotation - this.skew.x); // cos, added PI/2\n this._sy = Math.cos(this._rotation - this.skew.x); // sin, added PI/2\n this._localID++;\n };\n Transform.prototype.toString = function () {\n return \"[@pixi/math:Transform \"\n + (\"position=(\" + this.position.x + \", \" + this.position.y + \") \")\n + (\"rotation=\" + this.rotation + \" \")\n + (\"scale=(\" + this.scale.x + \", \" + this.scale.y + \") \")\n + (\"skew=(\" + this.skew.x + \", \" + this.skew.y + \") \")\n + \"]\";\n };\n /** Updates the local transformation matrix. */\n Transform.prototype.updateLocalTransform = function () {\n var lt = this.localTransform;\n if (this._localID !== this._currentLocalID) {\n // get the matrix values of the displayobject based on its transform properties..\n lt.a = this._cx * this.scale.x;\n lt.b = this._sx * this.scale.x;\n lt.c = this._cy * this.scale.y;\n lt.d = this._sy * this.scale.y;\n lt.tx = this.position.x - ((this.pivot.x * lt.a) + (this.pivot.y * lt.c));\n lt.ty = this.position.y - ((this.pivot.x * lt.b) + (this.pivot.y * lt.d));\n this._currentLocalID = this._localID;\n // force an update..\n this._parentID = -1;\n }\n };\n /**\n * Updates the local and the world transformation matrices.\n * @param parentTransform - The parent transform\n */\n Transform.prototype.updateTransform = function (parentTransform) {\n var lt = this.localTransform;\n if (this._localID !== this._currentLocalID) {\n // get the matrix values of the displayobject based on its transform properties..\n lt.a = this._cx * this.scale.x;\n lt.b = this._sx * this.scale.x;\n lt.c = this._cy * this.scale.y;\n lt.d = this._sy * this.scale.y;\n lt.tx = this.position.x - ((this.pivot.x * lt.a) + (this.pivot.y * lt.c));\n lt.ty = this.position.y - ((this.pivot.x * lt.b) + (this.pivot.y * lt.d));\n this._currentLocalID = this._localID;\n // force an update..\n this._parentID = -1;\n }\n if (this._parentID !== parentTransform._worldID) {\n // concat the parent matrix with the objects transform.\n var pt = parentTransform.worldTransform;\n var wt = this.worldTransform;\n wt.a = (lt.a * pt.a) + (lt.b * pt.c);\n wt.b = (lt.a * pt.b) + (lt.b * pt.d);\n wt.c = (lt.c * pt.a) + (lt.d * pt.c);\n wt.d = (lt.c * pt.b) + (lt.d * pt.d);\n wt.tx = (lt.tx * pt.a) + (lt.ty * pt.c) + pt.tx;\n wt.ty = (lt.tx * pt.b) + (lt.ty * pt.d) + pt.ty;\n this._parentID = parentTransform._worldID;\n // update the id of the transform..\n this._worldID++;\n }\n };\n /**\n * Decomposes a matrix and sets the transforms properties based on it.\n * @param matrix - The matrix to decompose\n */\n Transform.prototype.setFromMatrix = function (matrix) {\n matrix.decompose(this);\n this._localID++;\n };\n Object.defineProperty(Transform.prototype, \"rotation\", {\n /** The rotation of the object in radians. */\n get: function () {\n return this._rotation;\n },\n set: function (value) {\n if (this._rotation !== value) {\n this._rotation = value;\n this.updateSkew();\n }\n },\n enumerable: false,\n configurable: true\n });\n /** A default (identity) transform. */\n Transform.IDENTITY = new Transform();\n return Transform;\n}());\n\nexport { Circle, DEG_TO_RAD, Ellipse, Matrix, ObservablePoint, PI_2, Point, Polygon, RAD_TO_DEG, Rectangle, RoundedRectangle, SHAPES, Transform, groupD8 };\n//# sourceMappingURL=math.mjs.map\n","/*!\n * @pixi/display - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/display is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { settings } from '@pixi/settings';\nimport { Rectangle, RAD_TO_DEG, DEG_TO_RAD, Transform } from '@pixi/math';\nimport { EventEmitter, removeItems } from '@pixi/utils';\nimport { MASK_TYPES } from '@pixi/constants';\n\n/**\n * Sets the default value for the container property 'sortableChildren'.\n * If set to true, the container will sort its children by zIndex value\n * when updateTransform() is called, or manually if sortChildren() is called.\n *\n * This actually changes the order of elements in the array, so should be treated\n * as a basic solution that is not performant compared to other solutions,\n * such as @link https://github.com/pixijs/pixi-display\n *\n * Also be aware of that this may not work nicely with the addChildAt() function,\n * as the zIndex sorting may cause the child to automatically sorted to another position.\n * @static\n * @constant\n * @name SORTABLE_CHILDREN\n * @memberof PIXI.settings\n * @type {boolean}\n * @default false\n */\nsettings.SORTABLE_CHILDREN = false;\n\n/**\n * 'Builder' pattern for bounds rectangles.\n *\n * This could be called an Axis-Aligned Bounding Box.\n * It is not an actual shape. It is a mutable thing; no 'EMPTY' or those kind of problems.\n * @memberof PIXI\n */\nvar Bounds = /** @class */ (function () {\n function Bounds() {\n this.minX = Infinity;\n this.minY = Infinity;\n this.maxX = -Infinity;\n this.maxY = -Infinity;\n this.rect = null;\n this.updateID = -1;\n }\n /**\n * Checks if bounds are empty.\n * @returns - True if empty.\n */\n Bounds.prototype.isEmpty = function () {\n return this.minX > this.maxX || this.minY > this.maxY;\n };\n /** Clears the bounds and resets. */\n Bounds.prototype.clear = function () {\n this.minX = Infinity;\n this.minY = Infinity;\n this.maxX = -Infinity;\n this.maxY = -Infinity;\n };\n /**\n * Can return Rectangle.EMPTY constant, either construct new rectangle, either use your rectangle\n * It is not guaranteed that it will return tempRect\n * @param rect - Temporary object will be used if AABB is not empty\n * @returns - A rectangle of the bounds\n */\n Bounds.prototype.getRectangle = function (rect) {\n if (this.minX > this.maxX || this.minY > this.maxY) {\n return Rectangle.EMPTY;\n }\n rect = rect || new Rectangle(0, 0, 1, 1);\n rect.x = this.minX;\n rect.y = this.minY;\n rect.width = this.maxX - this.minX;\n rect.height = this.maxY - this.minY;\n return rect;\n };\n /**\n * This function should be inlined when its possible.\n * @param point - The point to add.\n */\n Bounds.prototype.addPoint = function (point) {\n this.minX = Math.min(this.minX, point.x);\n this.maxX = Math.max(this.maxX, point.x);\n this.minY = Math.min(this.minY, point.y);\n this.maxY = Math.max(this.maxY, point.y);\n };\n /**\n * Adds a point, after transformed. This should be inlined when its possible.\n * @param matrix\n * @param point\n */\n Bounds.prototype.addPointMatrix = function (matrix, point) {\n var a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d, tx = matrix.tx, ty = matrix.ty;\n var x = (a * point.x) + (c * point.y) + tx;\n var y = (b * point.x) + (d * point.y) + ty;\n this.minX = Math.min(this.minX, x);\n this.maxX = Math.max(this.maxX, x);\n this.minY = Math.min(this.minY, y);\n this.maxY = Math.max(this.maxY, y);\n };\n /**\n * Adds a quad, not transformed\n * @param vertices - The verts to add.\n */\n Bounds.prototype.addQuad = function (vertices) {\n var minX = this.minX;\n var minY = this.minY;\n var maxX = this.maxX;\n var maxY = this.maxY;\n var x = vertices[0];\n var y = vertices[1];\n minX = x < minX ? x : minX;\n minY = y < minY ? y : minY;\n maxX = x > maxX ? x : maxX;\n maxY = y > maxY ? y : maxY;\n x = vertices[2];\n y = vertices[3];\n minX = x < minX ? x : minX;\n minY = y < minY ? y : minY;\n maxX = x > maxX ? x : maxX;\n maxY = y > maxY ? y : maxY;\n x = vertices[4];\n y = vertices[5];\n minX = x < minX ? x : minX;\n minY = y < minY ? y : minY;\n maxX = x > maxX ? x : maxX;\n maxY = y > maxY ? y : maxY;\n x = vertices[6];\n y = vertices[7];\n minX = x < minX ? x : minX;\n minY = y < minY ? y : minY;\n maxX = x > maxX ? x : maxX;\n maxY = y > maxY ? y : maxY;\n this.minX = minX;\n this.minY = minY;\n this.maxX = maxX;\n this.maxY = maxY;\n };\n /**\n * Adds sprite frame, transformed.\n * @param transform - transform to apply\n * @param x0 - left X of frame\n * @param y0 - top Y of frame\n * @param x1 - right X of frame\n * @param y1 - bottom Y of frame\n */\n Bounds.prototype.addFrame = function (transform, x0, y0, x1, y1) {\n this.addFrameMatrix(transform.worldTransform, x0, y0, x1, y1);\n };\n /**\n * Adds sprite frame, multiplied by matrix\n * @param matrix - matrix to apply\n * @param x0 - left X of frame\n * @param y0 - top Y of frame\n * @param x1 - right X of frame\n * @param y1 - bottom Y of frame\n */\n Bounds.prototype.addFrameMatrix = function (matrix, x0, y0, x1, y1) {\n var a = matrix.a;\n var b = matrix.b;\n var c = matrix.c;\n var d = matrix.d;\n var tx = matrix.tx;\n var ty = matrix.ty;\n var minX = this.minX;\n var minY = this.minY;\n var maxX = this.maxX;\n var maxY = this.maxY;\n var x = (a * x0) + (c * y0) + tx;\n var y = (b * x0) + (d * y0) + ty;\n minX = x < minX ? x : minX;\n minY = y < minY ? y : minY;\n maxX = x > maxX ? x : maxX;\n maxY = y > maxY ? y : maxY;\n x = (a * x1) + (c * y0) + tx;\n y = (b * x1) + (d * y0) + ty;\n minX = x < minX ? x : minX;\n minY = y < minY ? y : minY;\n maxX = x > maxX ? x : maxX;\n maxY = y > maxY ? y : maxY;\n x = (a * x0) + (c * y1) + tx;\n y = (b * x0) + (d * y1) + ty;\n minX = x < minX ? x : minX;\n minY = y < minY ? y : minY;\n maxX = x > maxX ? x : maxX;\n maxY = y > maxY ? y : maxY;\n x = (a * x1) + (c * y1) + tx;\n y = (b * x1) + (d * y1) + ty;\n minX = x < minX ? x : minX;\n minY = y < minY ? y : minY;\n maxX = x > maxX ? x : maxX;\n maxY = y > maxY ? y : maxY;\n this.minX = minX;\n this.minY = minY;\n this.maxX = maxX;\n this.maxY = maxY;\n };\n /**\n * Adds screen vertices from array\n * @param vertexData - calculated vertices\n * @param beginOffset - begin offset\n * @param endOffset - end offset, excluded\n */\n Bounds.prototype.addVertexData = function (vertexData, beginOffset, endOffset) {\n var minX = this.minX;\n var minY = this.minY;\n var maxX = this.maxX;\n var maxY = this.maxY;\n for (var i = beginOffset; i < endOffset; i += 2) {\n var x = vertexData[i];\n var y = vertexData[i + 1];\n minX = x < minX ? x : minX;\n minY = y < minY ? y : minY;\n maxX = x > maxX ? x : maxX;\n maxY = y > maxY ? y : maxY;\n }\n this.minX = minX;\n this.minY = minY;\n this.maxX = maxX;\n this.maxY = maxY;\n };\n /**\n * Add an array of mesh vertices\n * @param transform - mesh transform\n * @param vertices - mesh coordinates in array\n * @param beginOffset - begin offset\n * @param endOffset - end offset, excluded\n */\n Bounds.prototype.addVertices = function (transform, vertices, beginOffset, endOffset) {\n this.addVerticesMatrix(transform.worldTransform, vertices, beginOffset, endOffset);\n };\n /**\n * Add an array of mesh vertices.\n * @param matrix - mesh matrix\n * @param vertices - mesh coordinates in array\n * @param beginOffset - begin offset\n * @param endOffset - end offset, excluded\n * @param padX - x padding\n * @param padY - y padding\n */\n Bounds.prototype.addVerticesMatrix = function (matrix, vertices, beginOffset, endOffset, padX, padY) {\n if (padX === void 0) { padX = 0; }\n if (padY === void 0) { padY = padX; }\n var a = matrix.a;\n var b = matrix.b;\n var c = matrix.c;\n var d = matrix.d;\n var tx = matrix.tx;\n var ty = matrix.ty;\n var minX = this.minX;\n var minY = this.minY;\n var maxX = this.maxX;\n var maxY = this.maxY;\n for (var i = beginOffset; i < endOffset; i += 2) {\n var rawX = vertices[i];\n var rawY = vertices[i + 1];\n var x = (a * rawX) + (c * rawY) + tx;\n var y = (d * rawY) + (b * rawX) + ty;\n minX = Math.min(minX, x - padX);\n maxX = Math.max(maxX, x + padX);\n minY = Math.min(minY, y - padY);\n maxY = Math.max(maxY, y + padY);\n }\n this.minX = minX;\n this.minY = minY;\n this.maxX = maxX;\n this.maxY = maxY;\n };\n /**\n * Adds other {@link Bounds}.\n * @param bounds - The Bounds to be added\n */\n Bounds.prototype.addBounds = function (bounds) {\n var minX = this.minX;\n var minY = this.minY;\n var maxX = this.maxX;\n var maxY = this.maxY;\n this.minX = bounds.minX < minX ? bounds.minX : minX;\n this.minY = bounds.minY < minY ? bounds.minY : minY;\n this.maxX = bounds.maxX > maxX ? bounds.maxX : maxX;\n this.maxY = bounds.maxY > maxY ? bounds.maxY : maxY;\n };\n /**\n * Adds other Bounds, masked with Bounds.\n * @param bounds - The Bounds to be added.\n * @param mask - TODO\n */\n Bounds.prototype.addBoundsMask = function (bounds, mask) {\n var _minX = bounds.minX > mask.minX ? bounds.minX : mask.minX;\n var _minY = bounds.minY > mask.minY ? bounds.minY : mask.minY;\n var _maxX = bounds.maxX < mask.maxX ? bounds.maxX : mask.maxX;\n var _maxY = bounds.maxY < mask.maxY ? bounds.maxY : mask.maxY;\n if (_minX <= _maxX && _minY <= _maxY) {\n var minX = this.minX;\n var minY = this.minY;\n var maxX = this.maxX;\n var maxY = this.maxY;\n this.minX = _minX < minX ? _minX : minX;\n this.minY = _minY < minY ? _minY : minY;\n this.maxX = _maxX > maxX ? _maxX : maxX;\n this.maxY = _maxY > maxY ? _maxY : maxY;\n }\n };\n /**\n * Adds other Bounds, multiplied by matrix. Bounds shouldn't be empty.\n * @param bounds - other bounds\n * @param matrix - multiplicator\n */\n Bounds.prototype.addBoundsMatrix = function (bounds, matrix) {\n this.addFrameMatrix(matrix, bounds.minX, bounds.minY, bounds.maxX, bounds.maxY);\n };\n /**\n * Adds other Bounds, masked with Rectangle.\n * @param bounds - TODO\n * @param area - TODO\n */\n Bounds.prototype.addBoundsArea = function (bounds, area) {\n var _minX = bounds.minX > area.x ? bounds.minX : area.x;\n var _minY = bounds.minY > area.y ? bounds.minY : area.y;\n var _maxX = bounds.maxX < area.x + area.width ? bounds.maxX : (area.x + area.width);\n var _maxY = bounds.maxY < area.y + area.height ? bounds.maxY : (area.y + area.height);\n if (_minX <= _maxX && _minY <= _maxY) {\n var minX = this.minX;\n var minY = this.minY;\n var maxX = this.maxX;\n var maxY = this.maxY;\n this.minX = _minX < minX ? _minX : minX;\n this.minY = _minY < minY ? _minY : minY;\n this.maxX = _maxX > maxX ? _maxX : maxX;\n this.maxY = _maxY > maxY ? _maxY : maxY;\n }\n };\n /**\n * Pads bounds object, making it grow in all directions.\n * If paddingY is omitted, both paddingX and paddingY will be set to paddingX.\n * @param paddingX - The horizontal padding amount.\n * @param paddingY - The vertical padding amount.\n */\n Bounds.prototype.pad = function (paddingX, paddingY) {\n if (paddingX === void 0) { paddingX = 0; }\n if (paddingY === void 0) { paddingY = paddingX; }\n if (!this.isEmpty()) {\n this.minX -= paddingX;\n this.maxX += paddingX;\n this.minY -= paddingY;\n this.maxY += paddingY;\n }\n };\n /**\n * Adds padded frame. (x0, y0) should be strictly less than (x1, y1)\n * @param x0 - left X of frame\n * @param y0 - top Y of frame\n * @param x1 - right X of frame\n * @param y1 - bottom Y of frame\n * @param padX - padding X\n * @param padY - padding Y\n */\n Bounds.prototype.addFramePad = function (x0, y0, x1, y1, padX, padY) {\n x0 -= padX;\n y0 -= padY;\n x1 += padX;\n y1 += padY;\n this.minX = this.minX < x0 ? this.minX : x0;\n this.maxX = this.maxX > x1 ? this.maxX : x1;\n this.minY = this.minY < y0 ? this.minY : y0;\n this.maxY = this.maxY > y1 ? this.maxY : y1;\n };\n return Bounds;\n}());\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\n/**\n * The base class for all objects that are rendered on the screen.\n *\n * This is an abstract class and can not be used on its own; rather it should be extended.\n *\n * ## Display objects implemented in PixiJS\n *\n * | Display Object | Description |\n * | ------------------------------- | --------------------------------------------------------------------- |\n * | {@link PIXI.Container} | Adds support for `children` to DisplayObject |\n * | {@link PIXI.Graphics} | Shape-drawing display object similar to the Canvas API |\n * | {@link PIXI.Sprite} | Draws textures (i.e. images) |\n * | {@link PIXI.Text} | Draws text using the Canvas API internally |\n * | {@link PIXI.BitmapText} | More scaleable solution for text rendering, reusing glyph textures |\n * | {@link PIXI.TilingSprite} | Draws textures/images in a tiled fashion |\n * | {@link PIXI.AnimatedSprite} | Draws an animation of multiple images |\n * | {@link PIXI.Mesh} | Provides a lower-level API for drawing meshes with custom data |\n * | {@link PIXI.NineSlicePlane} | Mesh-related |\n * | {@link PIXI.SimpleMesh} | v4-compatible mesh |\n * | {@link PIXI.SimplePlane} | Mesh-related |\n * | {@link PIXI.SimpleRope} | Mesh-related |\n *\n * ## Transforms\n *\n * The [transform]{@link DisplayObject#transform} of a display object describes the projection from its\n * local coordinate space to its parent's local coordinate space. The following properties are derived\n * from the transform:\n *\n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n *
PropertyDescription
[pivot]{@link PIXI.DisplayObject#pivot}\n * Invariant under rotation, scaling, and skewing. The projection of into the parent's space of the pivot\n * is equal to position, regardless of the other three transformations. In other words, It is the center of\n * rotation, scaling, and skewing.\n *
[position]{@link PIXI.DisplayObject#position}\n * Translation. This is the position of the [pivot]{@link PIXI.DisplayObject#pivot} in the parent's local\n * space. The default value of the pivot is the origin (0,0). If the top-left corner of your display object\n * is (0,0) in its local space, then the position will be its top-left corner in the parent's local space.\n *
[scale]{@link PIXI.DisplayObject#scale}\n * Scaling. This will stretch (or compress) the display object's projection. The scale factors are along the\n * local coordinate axes. In other words, the display object is scaled before rotated or skewed. The center\n * of scaling is the [pivot]{@link PIXI.DisplayObject#pivot}.\n *
[rotation]{@link PIXI.DisplayObject#rotation}\n * Rotation. This will rotate the display object's projection by this angle (in radians).\n *
[skew]{@link PIXI.DisplayObject#skew}\n *

Skewing. This can be used to deform a rectangular display object into a parallelogram.

\n *

\n * In PixiJS, skew has a slightly different behaviour than the conventional meaning. It can be\n * thought of the net rotation applied to the coordinate axes (separately). For example, if \"skew.x\" is\n * ⍺ and \"skew.y\" is β, then the line x = 0 will be rotated by ⍺ (y = -x*cot⍺) and the line y = 0 will be\n * rotated by β (y = x*tanβ). A line y = x*tanϴ (i.e. a line at angle ϴ to the x-axis in local-space) will\n * be rotated by an angle between ⍺ and β.\n *

\n *

\n * It can be observed that if skew is applied equally to both axes, then it will be equivalent to applying\n * a rotation. Indeed, if \"skew.x\" = -ϴ and \"skew.y\" = ϴ, it will produce an equivalent of \"rotation\" = ϴ.\n *

\n *

\n * Another quite interesting observation is that \"skew.x\", \"skew.y\", rotation are communtative operations. Indeed,\n * because rotation is essentially a careful combination of the two.\n *

\n *
angleRotation. This is an alias for [rotation]{@link PIXI.DisplayObject#rotation}, but in degrees.
xTranslation. This is an alias for position.x!
yTranslation. This is an alias for position.y!
width\n * Implemented in [Container]{@link PIXI.Container}. Scaling. The width property calculates scale.x by dividing\n * the \"requested\" width by the local bounding box width. It is indirectly an abstraction over scale.x, and there\n * is no concept of user-defined width.\n *
height\n * Implemented in [Container]{@link PIXI.Container}. Scaling. The height property calculates scale.y by dividing\n * the \"requested\" height by the local bounding box height. It is indirectly an abstraction over scale.y, and there\n * is no concept of user-defined height.\n *
\n *\n * ## Bounds\n *\n * The bounds of a display object is defined by the minimum axis-aligned rectangle in world space that can fit\n * around it. The abstract `calculateBounds` method is responsible for providing it (and it should use the\n * `worldTransform` to calculate in world space).\n *\n * There are a few additional types of bounding boxes:\n *\n * | Bounds | Description |\n * | --------------------- | ---------------------------------------------------------------------------------------- |\n * | World Bounds | This is synonymous is the regular bounds described above. See `getBounds()`. |\n * | Local Bounds | This the axis-aligned bounding box in the parent's local space. See `getLocalBounds()`. |\n * | Render Bounds | The bounds, but including extra rendering effects like filter padding. |\n * | Projected Bounds | The bounds of the projected display object onto the screen. Usually equals world bounds. |\n * | Relative Bounds | The bounds of a display object when projected onto a ancestor's (or parent's) space. |\n * | Natural Bounds | The bounds of an object in its own local space (not parent's space, like in local bounds)|\n * | Content Bounds | The natural bounds when excluding all children of a `Container`. |\n *\n * ### calculateBounds\n *\n * [Container]{@link Container} already implements `calculateBounds` in a manner that includes children.\n *\n * But for a non-Container display object, the `calculateBounds` method must be overridden in order for `getBounds` and\n * `getLocalBounds` to work. This method must write the bounds into `this._bounds`.\n *\n * Generally, the following technique works for most simple cases: take the list of points\n * forming the \"hull\" of the object (i.e. outline of the object's shape), and then add them\n * using {@link PIXI.Bounds#addPointMatrix}.\n *\n * ```js\n * calculateBounds(): void\n * {\n * const points = [...];\n *\n * for (let i = 0, j = points.length; i < j; i++)\n * {\n * this._bounds.addPointMatrix(this.worldTransform, points[i]);\n * }\n * }\n * ```\n *\n * You can optimize this for a large number of points by using {@link PIXI.Bounds#addVerticesMatrix} to pass them\n * in one array together.\n *\n * ## Alpha\n *\n * This alpha sets a display object's **relative opacity** w.r.t its parent. For example, if the alpha of a display\n * object is 0.5 and its parent's alpha is 0.5, then it will be rendered with 25% opacity (assuming alpha is not\n * applied on any ancestor further up the chain).\n *\n * The alpha with which the display object will be rendered is called the [worldAlpha]{@link PIXI.DisplayObject#worldAlpha}.\n *\n * ## Renderable vs Visible\n *\n * The `renderable` and `visible` properties can be used to prevent a display object from being rendered to the\n * screen. However, there is a subtle difference between the two. When using `renderable`, the transforms of the display\n * object (and its children subtree) will continue to be calculated. When using `visible`, the transforms will not\n * be calculated.\n *\n * It is recommended that applications use the `renderable` property for culling. See\n * [@pixi-essentials/cull]{@link https://www.npmjs.com/package/@pixi-essentials/cull} or\n * [pixi-cull]{@link https://www.npmjs.com/package/pixi-cull} for more details.\n *\n * Otherwise, to prevent an object from rendering in the general-purpose sense - `visible` is the property to use. This\n * one is also better in terms of performance.\n * @memberof PIXI\n */\nvar DisplayObject = /** @class */ (function (_super) {\n __extends(DisplayObject, _super);\n function DisplayObject() {\n var _this = _super.call(this) || this;\n _this.tempDisplayObjectParent = null;\n // TODO: need to create Transform from factory\n _this.transform = new Transform();\n _this.alpha = 1;\n _this.visible = true;\n _this.renderable = true;\n _this.cullable = false;\n _this.cullArea = null;\n _this.parent = null;\n _this.worldAlpha = 1;\n _this._lastSortedIndex = 0;\n _this._zIndex = 0;\n _this.filterArea = null;\n _this.filters = null;\n _this._enabledFilters = null;\n _this._bounds = new Bounds();\n _this._localBounds = null;\n _this._boundsID = 0;\n _this._boundsRect = null;\n _this._localBoundsRect = null;\n _this._mask = null;\n _this._maskRefCount = 0;\n _this._destroyed = false;\n _this.isSprite = false;\n _this.isMask = false;\n return _this;\n }\n /**\n * Mixes all enumerable properties and methods from a source object to DisplayObject.\n * @param source - The source of properties and methods to mix in.\n */\n DisplayObject.mixin = function (source) {\n // in ES8/ES2017, this would be really easy:\n // Object.defineProperties(DisplayObject.prototype, Object.getOwnPropertyDescriptors(source));\n // get all the enumerable property keys\n var keys = Object.keys(source);\n // loop through properties\n for (var i = 0; i < keys.length; ++i) {\n var propertyName = keys[i];\n // Set the property using the property descriptor - this works for accessors and normal value properties\n Object.defineProperty(DisplayObject.prototype, propertyName, Object.getOwnPropertyDescriptor(source, propertyName));\n }\n };\n Object.defineProperty(DisplayObject.prototype, \"destroyed\", {\n /**\n * Fired when this DisplayObject is added to a Container.\n * @instance\n * @event added\n * @param {PIXI.Container} container - The container added to.\n */\n /**\n * Fired when this DisplayObject is removed from a Container.\n * @instance\n * @event removed\n * @param {PIXI.Container} container - The container removed from.\n */\n /**\n * Fired when this DisplayObject is destroyed. This event is emitted once\n * destroy is finished.\n * @instance\n * @event destroyed\n */\n /** Readonly flag for destroyed display objects. */\n get: function () {\n return this._destroyed;\n },\n enumerable: false,\n configurable: true\n });\n /** Recursively updates transform of all objects from the root to this one internal function for toLocal() */\n DisplayObject.prototype._recursivePostUpdateTransform = function () {\n if (this.parent) {\n this.parent._recursivePostUpdateTransform();\n this.transform.updateTransform(this.parent.transform);\n }\n else {\n this.transform.updateTransform(this._tempDisplayObjectParent.transform);\n }\n };\n /** Updates the object transform for rendering. TODO - Optimization pass! */\n DisplayObject.prototype.updateTransform = function () {\n this._boundsID++;\n this.transform.updateTransform(this.parent.transform);\n // multiply the alphas..\n this.worldAlpha = this.alpha * this.parent.worldAlpha;\n };\n /**\n * Calculates and returns the (world) bounds of the display object as a [Rectangle]{@link PIXI.Rectangle}.\n *\n * This method is expensive on containers with a large subtree (like the stage). This is because the bounds\n * of a container depend on its children's bounds, which recursively causes all bounds in the subtree to\n * be recalculated. The upside, however, is that calling `getBounds` once on a container will indeed update\n * the bounds of all children (the whole subtree, in fact). This side effect should be exploited by using\n * `displayObject._bounds.getRectangle()` when traversing through all the bounds in a scene graph. Otherwise,\n * calling `getBounds` on each object in a subtree will cause the total cost to increase quadratically as\n * its height increases.\n *\n * The transforms of all objects in a container's **subtree** and of all **ancestors** are updated.\n * The world bounds of all display objects in a container's **subtree** will also be recalculated.\n *\n * The `_bounds` object stores the last calculation of the bounds. You can use to entirely skip bounds\n * calculation if needed.\n *\n * ```js\n * const lastCalculatedBounds = displayObject._bounds.getRectangle(optionalRect);\n * ```\n *\n * Do know that usage of `getLocalBounds` can corrupt the `_bounds` of children (the whole subtree, actually). This\n * is a known issue that has not been solved. See [getLocalBounds]{@link PIXI.DisplayObject#getLocalBounds} for more\n * details.\n *\n * `getBounds` should be called with `skipUpdate` equal to `true` in a render() call. This is because the transforms\n * are guaranteed to be update-to-date. In fact, recalculating inside a render() call may cause corruption in certain\n * cases.\n * @param skipUpdate - Setting to `true` will stop the transforms of the scene graph from\n * being updated. This means the calculation returned MAY be out of date BUT will give you a\n * nice performance boost.\n * @param rect - Optional rectangle to store the result of the bounds calculation.\n * @returns - The minimum axis-aligned rectangle in world space that fits around this object.\n */\n DisplayObject.prototype.getBounds = function (skipUpdate, rect) {\n if (!skipUpdate) {\n if (!this.parent) {\n this.parent = this._tempDisplayObjectParent;\n this.updateTransform();\n this.parent = null;\n }\n else {\n this._recursivePostUpdateTransform();\n this.updateTransform();\n }\n }\n if (this._bounds.updateID !== this._boundsID) {\n this.calculateBounds();\n this._bounds.updateID = this._boundsID;\n }\n if (!rect) {\n if (!this._boundsRect) {\n this._boundsRect = new Rectangle();\n }\n rect = this._boundsRect;\n }\n return this._bounds.getRectangle(rect);\n };\n /**\n * Retrieves the local bounds of the displayObject as a rectangle object.\n * @param rect - Optional rectangle to store the result of the bounds calculation.\n * @returns - The rectangular bounding area.\n */\n DisplayObject.prototype.getLocalBounds = function (rect) {\n if (!rect) {\n if (!this._localBoundsRect) {\n this._localBoundsRect = new Rectangle();\n }\n rect = this._localBoundsRect;\n }\n if (!this._localBounds) {\n this._localBounds = new Bounds();\n }\n var transformRef = this.transform;\n var parentRef = this.parent;\n this.parent = null;\n this.transform = this._tempDisplayObjectParent.transform;\n var worldBounds = this._bounds;\n var worldBoundsID = this._boundsID;\n this._bounds = this._localBounds;\n var bounds = this.getBounds(false, rect);\n this.parent = parentRef;\n this.transform = transformRef;\n this._bounds = worldBounds;\n this._bounds.updateID += this._boundsID - worldBoundsID; // reflect side-effects\n return bounds;\n };\n /**\n * Calculates the global position of the display object.\n * @param position - The world origin to calculate from.\n * @param point - A Point object in which to store the value, optional\n * (otherwise will create a new Point).\n * @param skipUpdate - Should we skip the update transform.\n * @returns - A point object representing the position of this object.\n */\n DisplayObject.prototype.toGlobal = function (position, point, skipUpdate) {\n if (skipUpdate === void 0) { skipUpdate = false; }\n if (!skipUpdate) {\n this._recursivePostUpdateTransform();\n // this parent check is for just in case the item is a root object.\n // If it is we need to give it a temporary parent so that displayObjectUpdateTransform works correctly\n // this is mainly to avoid a parent check in the main loop. Every little helps for performance :)\n if (!this.parent) {\n this.parent = this._tempDisplayObjectParent;\n this.displayObjectUpdateTransform();\n this.parent = null;\n }\n else {\n this.displayObjectUpdateTransform();\n }\n }\n // don't need to update the lot\n return this.worldTransform.apply(position, point);\n };\n /**\n * Calculates the local position of the display object relative to another point.\n * @param position - The world origin to calculate from.\n * @param from - The DisplayObject to calculate the global position from.\n * @param point - A Point object in which to store the value, optional\n * (otherwise will create a new Point).\n * @param skipUpdate - Should we skip the update transform\n * @returns - A point object representing the position of this object\n */\n DisplayObject.prototype.toLocal = function (position, from, point, skipUpdate) {\n if (from) {\n position = from.toGlobal(position, point, skipUpdate);\n }\n if (!skipUpdate) {\n this._recursivePostUpdateTransform();\n // this parent check is for just in case the item is a root object.\n // If it is we need to give it a temporary parent so that displayObjectUpdateTransform works correctly\n // this is mainly to avoid a parent check in the main loop. Every little helps for performance :)\n if (!this.parent) {\n this.parent = this._tempDisplayObjectParent;\n this.displayObjectUpdateTransform();\n this.parent = null;\n }\n else {\n this.displayObjectUpdateTransform();\n }\n }\n // simply apply the matrix..\n return this.worldTransform.applyInverse(position, point);\n };\n /**\n * Set the parent Container of this DisplayObject.\n * @param container - The Container to add this DisplayObject to.\n * @returns - The Container that this DisplayObject was added to.\n */\n DisplayObject.prototype.setParent = function (container) {\n if (!container || !container.addChild) {\n throw new Error('setParent: Argument must be a Container');\n }\n container.addChild(this);\n return container;\n };\n /**\n * Convenience function to set the position, scale, skew and pivot at once.\n * @param x - The X position\n * @param y - The Y position\n * @param scaleX - The X scale value\n * @param scaleY - The Y scale value\n * @param rotation - The rotation\n * @param skewX - The X skew value\n * @param skewY - The Y skew value\n * @param pivotX - The X pivot value\n * @param pivotY - The Y pivot value\n * @returns - The DisplayObject instance\n */\n DisplayObject.prototype.setTransform = function (x, y, scaleX, scaleY, rotation, skewX, skewY, pivotX, pivotY) {\n if (x === void 0) { x = 0; }\n if (y === void 0) { y = 0; }\n if (scaleX === void 0) { scaleX = 1; }\n if (scaleY === void 0) { scaleY = 1; }\n if (rotation === void 0) { rotation = 0; }\n if (skewX === void 0) { skewX = 0; }\n if (skewY === void 0) { skewY = 0; }\n if (pivotX === void 0) { pivotX = 0; }\n if (pivotY === void 0) { pivotY = 0; }\n this.position.x = x;\n this.position.y = y;\n this.scale.x = !scaleX ? 1 : scaleX;\n this.scale.y = !scaleY ? 1 : scaleY;\n this.rotation = rotation;\n this.skew.x = skewX;\n this.skew.y = skewY;\n this.pivot.x = pivotX;\n this.pivot.y = pivotY;\n return this;\n };\n /**\n * Base destroy method for generic display objects. This will automatically\n * remove the display object from its parent Container as well as remove\n * all current event listeners and internal references. Do not use a DisplayObject\n * after calling `destroy()`.\n * @param _options\n */\n DisplayObject.prototype.destroy = function (_options) {\n if (this.parent) {\n this.parent.removeChild(this);\n }\n this._destroyed = true;\n this.transform = null;\n this.parent = null;\n this._bounds = null;\n this.mask = null;\n this.cullArea = null;\n this.filters = null;\n this.filterArea = null;\n this.hitArea = null;\n this.interactive = false;\n this.interactiveChildren = false;\n this.emit('destroyed');\n this.removeAllListeners();\n };\n Object.defineProperty(DisplayObject.prototype, \"_tempDisplayObjectParent\", {\n /**\n * @protected\n * @member {PIXI.Container}\n */\n get: function () {\n if (this.tempDisplayObjectParent === null) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n this.tempDisplayObjectParent = new TemporaryDisplayObject();\n }\n return this.tempDisplayObjectParent;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Used in Renderer, cacheAsBitmap and other places where you call an `updateTransform` on root\n *\n * ```\n * const cacheParent = elem.enableTempParent();\n * elem.updateTransform();\n * elem.disableTempParent(cacheParent);\n * ```\n * @returns - current parent\n */\n DisplayObject.prototype.enableTempParent = function () {\n var myParent = this.parent;\n this.parent = this._tempDisplayObjectParent;\n return myParent;\n };\n /**\n * Pair method for `enableTempParent`\n * @param cacheParent - Actual parent of element\n */\n DisplayObject.prototype.disableTempParent = function (cacheParent) {\n this.parent = cacheParent;\n };\n Object.defineProperty(DisplayObject.prototype, \"x\", {\n /**\n * The position of the displayObject on the x axis relative to the local coordinates of the parent.\n * An alias to position.x\n */\n get: function () {\n return this.position.x;\n },\n set: function (value) {\n this.transform.position.x = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(DisplayObject.prototype, \"y\", {\n /**\n * The position of the displayObject on the y axis relative to the local coordinates of the parent.\n * An alias to position.y\n */\n get: function () {\n return this.position.y;\n },\n set: function (value) {\n this.transform.position.y = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(DisplayObject.prototype, \"worldTransform\", {\n /**\n * Current transform of the object based on world (parent) factors.\n * @readonly\n */\n get: function () {\n return this.transform.worldTransform;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(DisplayObject.prototype, \"localTransform\", {\n /**\n * Current transform of the object based on local factors: position, scale, other stuff.\n * @readonly\n */\n get: function () {\n return this.transform.localTransform;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(DisplayObject.prototype, \"position\", {\n /**\n * The coordinate of the object relative to the local coordinates of the parent.\n * @since 4.0.0\n */\n get: function () {\n return this.transform.position;\n },\n set: function (value) {\n this.transform.position.copyFrom(value);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(DisplayObject.prototype, \"scale\", {\n /**\n * The scale factors of this object along the local coordinate axes.\n *\n * The default scale is (1, 1).\n * @since 4.0.0\n */\n get: function () {\n return this.transform.scale;\n },\n set: function (value) {\n this.transform.scale.copyFrom(value);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(DisplayObject.prototype, \"pivot\", {\n /**\n * The center of rotation, scaling, and skewing for this display object in its local space. The `position`\n * is the projection of `pivot` in the parent's local space.\n *\n * By default, the pivot is the origin (0, 0).\n * @since 4.0.0\n */\n get: function () {\n return this.transform.pivot;\n },\n set: function (value) {\n this.transform.pivot.copyFrom(value);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(DisplayObject.prototype, \"skew\", {\n /**\n * The skew factor for the object in radians.\n * @since 4.0.0\n */\n get: function () {\n return this.transform.skew;\n },\n set: function (value) {\n this.transform.skew.copyFrom(value);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(DisplayObject.prototype, \"rotation\", {\n /**\n * The rotation of the object in radians.\n * 'rotation' and 'angle' have the same effect on a display object; rotation is in radians, angle is in degrees.\n */\n get: function () {\n return this.transform.rotation;\n },\n set: function (value) {\n this.transform.rotation = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(DisplayObject.prototype, \"angle\", {\n /**\n * The angle of the object in degrees.\n * 'rotation' and 'angle' have the same effect on a display object; rotation is in radians, angle is in degrees.\n */\n get: function () {\n return this.transform.rotation * RAD_TO_DEG;\n },\n set: function (value) {\n this.transform.rotation = value * DEG_TO_RAD;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(DisplayObject.prototype, \"zIndex\", {\n /**\n * The zIndex of the displayObject.\n *\n * If a container has the sortableChildren property set to true, children will be automatically\n * sorted by zIndex value; a higher value will mean it will be moved towards the end of the array,\n * and thus rendered on top of other display objects within the same container.\n * @see PIXI.Container#sortableChildren\n */\n get: function () {\n return this._zIndex;\n },\n set: function (value) {\n this._zIndex = value;\n if (this.parent) {\n this.parent.sortDirty = true;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(DisplayObject.prototype, \"worldVisible\", {\n /**\n * Indicates if the object is globally visible.\n * @readonly\n */\n get: function () {\n var item = this;\n do {\n if (!item.visible) {\n return false;\n }\n item = item.parent;\n } while (item);\n return true;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(DisplayObject.prototype, \"mask\", {\n /**\n * Sets a mask for the displayObject. A mask is an object that limits the visibility of an\n * object to the shape of the mask applied to it. In PixiJS a regular mask must be a\n * {@link PIXI.Graphics} or a {@link PIXI.Sprite} object. This allows for much faster masking in canvas as it\n * utilities shape clipping. Furthermore, a mask of an object must be in the subtree of its parent.\n * Otherwise, `getLocalBounds` may calculate incorrect bounds, which makes the container's width and height wrong.\n * To remove a mask, set this property to `null`.\n *\n * For sprite mask both alpha and red channel are used. Black mask is the same as transparent mask.\n * @example\n * const graphics = new PIXI.Graphics();\n * graphics.beginFill(0xFF3300);\n * graphics.drawRect(50, 250, 100, 100);\n * graphics.endFill();\n *\n * const sprite = new PIXI.Sprite(texture);\n * sprite.mask = graphics;\n * @todo At the moment, PIXI.CanvasRenderer doesn't support PIXI.Sprite as mask.\n */\n get: function () {\n return this._mask;\n },\n set: function (value) {\n if (this._mask === value) {\n return;\n }\n if (this._mask) {\n var maskObject = (this._mask.isMaskData\n ? this._mask.maskObject : this._mask);\n if (maskObject) {\n maskObject._maskRefCount--;\n if (maskObject._maskRefCount === 0) {\n maskObject.renderable = true;\n maskObject.isMask = false;\n }\n }\n }\n this._mask = value;\n if (this._mask) {\n var maskObject = (this._mask.isMaskData\n ? this._mask.maskObject : this._mask);\n if (maskObject) {\n if (maskObject._maskRefCount === 0) {\n maskObject.renderable = false;\n maskObject.isMask = true;\n }\n maskObject._maskRefCount++;\n }\n }\n },\n enumerable: false,\n configurable: true\n });\n return DisplayObject;\n}(EventEmitter));\n/**\n * @private\n */\nvar TemporaryDisplayObject = /** @class */ (function (_super) {\n __extends(TemporaryDisplayObject, _super);\n function TemporaryDisplayObject() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.sortDirty = null;\n return _this;\n }\n return TemporaryDisplayObject;\n}(DisplayObject));\n/**\n * DisplayObject default updateTransform, does not update children of container.\n * Will crash if there's no parent element.\n * @memberof PIXI.DisplayObject#\n * @method displayObjectUpdateTransform\n */\nDisplayObject.prototype.displayObjectUpdateTransform = DisplayObject.prototype.updateTransform;\n\nfunction sortChildren(a, b) {\n if (a.zIndex === b.zIndex) {\n return a._lastSortedIndex - b._lastSortedIndex;\n }\n return a.zIndex - b.zIndex;\n}\n/**\n * Container is a general-purpose display object that holds children. It also adds built-in support for advanced\n * rendering features like masking and filtering.\n *\n * It is the base class of all display objects that act as a container for other objects, including Graphics\n * and Sprite.\n *\n * ```js\n * import { BlurFilter } from '@pixi/filter-blur';\n * import { Container } from '@pixi/display';\n * import { Graphics } from '@pixi/graphics';\n * import { Sprite } from '@pixi/sprite';\n *\n * let container = new Container();\n * let sprite = Sprite.from(\"https://s3-us-west-2.amazonaws.com/s.cdpn.io/693612/IaUrttj.png\");\n *\n * sprite.width = 512;\n * sprite.height = 512;\n *\n * // Adds a sprite as a child to this container. As a result, the sprite will be rendered whenever the container\n * // is rendered.\n * container.addChild(sprite);\n *\n * // Blurs whatever is rendered by the container\n * container.filters = [new BlurFilter()];\n *\n * // Only the contents within a circle at the center should be rendered onto the screen.\n * container.mask = new Graphics()\n * .beginFill(0xffffff)\n * .drawCircle(sprite.width / 2, sprite.height / 2, Math.min(sprite.width, sprite.height) / 2)\n * .endFill();\n * ```\n * @memberof PIXI\n */\nvar Container = /** @class */ (function (_super) {\n __extends(Container, _super);\n function Container() {\n var _this = _super.call(this) || this;\n _this.children = [];\n _this.sortableChildren = settings.SORTABLE_CHILDREN;\n _this.sortDirty = false;\n return _this;\n /**\n * Fired when a DisplayObject is added to this Container.\n * @event PIXI.Container#childAdded\n * @param {PIXI.DisplayObject} child - The child added to the Container.\n * @param {PIXI.Container} container - The container that added the child.\n * @param {number} index - The children's index of the added child.\n */\n /**\n * Fired when a DisplayObject is removed from this Container.\n * @event PIXI.DisplayObject#childRemoved\n * @param {PIXI.DisplayObject} child - The child removed from the Container.\n * @param {PIXI.Container} container - The container that removed the child.\n * @param {number} index - The former children's index of the removed child\n */\n }\n /**\n * Overridable method that can be used by Container subclasses whenever the children array is modified.\n * @param _length\n */\n Container.prototype.onChildrenChange = function (_length) {\n /* empty */\n };\n /**\n * Adds one or more children to the container.\n *\n * Multiple items can be added like so: `myContainer.addChild(thingOne, thingTwo, thingThree)`\n * @param {...PIXI.DisplayObject} children - The DisplayObject(s) to add to the container\n * @returns {PIXI.DisplayObject} - The first child that was added.\n */\n Container.prototype.addChild = function () {\n var arguments$1 = arguments;\n\n var children = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n children[_i] = arguments$1[_i];\n }\n // if there is only one argument we can bypass looping through the them\n if (children.length > 1) {\n // loop through the array and add all children\n for (var i = 0; i < children.length; i++) {\n // eslint-disable-next-line prefer-rest-params\n this.addChild(children[i]);\n }\n }\n else {\n var child = children[0];\n // if the child has a parent then lets remove it as PixiJS objects can only exist in one place\n if (child.parent) {\n child.parent.removeChild(child);\n }\n child.parent = this;\n this.sortDirty = true;\n // ensure child transform will be recalculated\n child.transform._parentID = -1;\n this.children.push(child);\n // ensure bounds will be recalculated\n this._boundsID++;\n // TODO - lets either do all callbacks or all events.. not both!\n this.onChildrenChange(this.children.length - 1);\n this.emit('childAdded', child, this, this.children.length - 1);\n child.emit('added', this);\n }\n return children[0];\n };\n /**\n * Adds a child to the container at a specified index. If the index is out of bounds an error will be thrown\n * @param {PIXI.DisplayObject} child - The child to add\n * @param {number} index - The index to place the child in\n * @returns {PIXI.DisplayObject} The child that was added.\n */\n Container.prototype.addChildAt = function (child, index) {\n if (index < 0 || index > this.children.length) {\n throw new Error(child + \"addChildAt: The index \" + index + \" supplied is out of bounds \" + this.children.length);\n }\n if (child.parent) {\n child.parent.removeChild(child);\n }\n child.parent = this;\n this.sortDirty = true;\n // ensure child transform will be recalculated\n child.transform._parentID = -1;\n this.children.splice(index, 0, child);\n // ensure bounds will be recalculated\n this._boundsID++;\n // TODO - lets either do all callbacks or all events.. not both!\n this.onChildrenChange(index);\n child.emit('added', this);\n this.emit('childAdded', child, this, index);\n return child;\n };\n /**\n * Swaps the position of 2 Display Objects within this container.\n * @param child - First display object to swap\n * @param child2 - Second display object to swap\n */\n Container.prototype.swapChildren = function (child, child2) {\n if (child === child2) {\n return;\n }\n var index1 = this.getChildIndex(child);\n var index2 = this.getChildIndex(child2);\n this.children[index1] = child2;\n this.children[index2] = child;\n this.onChildrenChange(index1 < index2 ? index1 : index2);\n };\n /**\n * Returns the index position of a child DisplayObject instance\n * @param child - The DisplayObject instance to identify\n * @returns - The index position of the child display object to identify\n */\n Container.prototype.getChildIndex = function (child) {\n var index = this.children.indexOf(child);\n if (index === -1) {\n throw new Error('The supplied DisplayObject must be a child of the caller');\n }\n return index;\n };\n /**\n * Changes the position of an existing child in the display object container\n * @param child - The child DisplayObject instance for which you want to change the index number\n * @param index - The resulting index number for the child display object\n */\n Container.prototype.setChildIndex = function (child, index) {\n if (index < 0 || index >= this.children.length) {\n throw new Error(\"The index \" + index + \" supplied is out of bounds \" + this.children.length);\n }\n var currentIndex = this.getChildIndex(child);\n removeItems(this.children, currentIndex, 1); // remove from old position\n this.children.splice(index, 0, child); // add at new position\n this.onChildrenChange(index);\n };\n /**\n * Returns the child at the specified index\n * @param index - The index to get the child at\n * @returns - The child at the given index, if any.\n */\n Container.prototype.getChildAt = function (index) {\n if (index < 0 || index >= this.children.length) {\n throw new Error(\"getChildAt: Index (\" + index + \") does not exist.\");\n }\n return this.children[index];\n };\n /**\n * Removes one or more children from the container.\n * @param {...PIXI.DisplayObject} children - The DisplayObject(s) to remove\n * @returns {PIXI.DisplayObject} The first child that was removed.\n */\n Container.prototype.removeChild = function () {\n var arguments$1 = arguments;\n\n var children = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n children[_i] = arguments$1[_i];\n }\n // if there is only one argument we can bypass looping through the them\n if (children.length > 1) {\n // loop through the arguments property and remove all children\n for (var i = 0; i < children.length; i++) {\n this.removeChild(children[i]);\n }\n }\n else {\n var child = children[0];\n var index = this.children.indexOf(child);\n if (index === -1)\n { return null; }\n child.parent = null;\n // ensure child transform will be recalculated\n child.transform._parentID = -1;\n removeItems(this.children, index, 1);\n // ensure bounds will be recalculated\n this._boundsID++;\n // TODO - lets either do all callbacks or all events.. not both!\n this.onChildrenChange(index);\n child.emit('removed', this);\n this.emit('childRemoved', child, this, index);\n }\n return children[0];\n };\n /**\n * Removes a child from the specified index position.\n * @param index - The index to get the child from\n * @returns The child that was removed.\n */\n Container.prototype.removeChildAt = function (index) {\n var child = this.getChildAt(index);\n // ensure child transform will be recalculated..\n child.parent = null;\n child.transform._parentID = -1;\n removeItems(this.children, index, 1);\n // ensure bounds will be recalculated\n this._boundsID++;\n // TODO - lets either do all callbacks or all events.. not both!\n this.onChildrenChange(index);\n child.emit('removed', this);\n this.emit('childRemoved', child, this, index);\n return child;\n };\n /**\n * Removes all children from this container that are within the begin and end indexes.\n * @param beginIndex - The beginning position.\n * @param endIndex - The ending position. Default value is size of the container.\n * @returns - List of removed children\n */\n Container.prototype.removeChildren = function (beginIndex, endIndex) {\n if (beginIndex === void 0) { beginIndex = 0; }\n if (endIndex === void 0) { endIndex = this.children.length; }\n var begin = beginIndex;\n var end = endIndex;\n var range = end - begin;\n var removed;\n if (range > 0 && range <= end) {\n removed = this.children.splice(begin, range);\n for (var i = 0; i < removed.length; ++i) {\n removed[i].parent = null;\n if (removed[i].transform) {\n removed[i].transform._parentID = -1;\n }\n }\n this._boundsID++;\n this.onChildrenChange(beginIndex);\n for (var i = 0; i < removed.length; ++i) {\n removed[i].emit('removed', this);\n this.emit('childRemoved', removed[i], this, i);\n }\n return removed;\n }\n else if (range === 0 && this.children.length === 0) {\n return [];\n }\n throw new RangeError('removeChildren: numeric values are outside the acceptable range.');\n };\n /** Sorts children by zIndex. Previous order is maintained for 2 children with the same zIndex. */\n Container.prototype.sortChildren = function () {\n var sortRequired = false;\n for (var i = 0, j = this.children.length; i < j; ++i) {\n var child = this.children[i];\n child._lastSortedIndex = i;\n if (!sortRequired && child.zIndex !== 0) {\n sortRequired = true;\n }\n }\n if (sortRequired && this.children.length > 1) {\n this.children.sort(sortChildren);\n }\n this.sortDirty = false;\n };\n /** Updates the transform on all children of this container for rendering. */\n Container.prototype.updateTransform = function () {\n if (this.sortableChildren && this.sortDirty) {\n this.sortChildren();\n }\n this._boundsID++;\n this.transform.updateTransform(this.parent.transform);\n // TODO: check render flags, how to process stuff here\n this.worldAlpha = this.alpha * this.parent.worldAlpha;\n for (var i = 0, j = this.children.length; i < j; ++i) {\n var child = this.children[i];\n if (child.visible) {\n child.updateTransform();\n }\n }\n };\n /**\n * Recalculates the bounds of the container.\n *\n * This implementation will automatically fit the children's bounds into the calculation. Each child's bounds\n * is limited to its mask's bounds or filterArea, if any is applied.\n */\n Container.prototype.calculateBounds = function () {\n this._bounds.clear();\n this._calculateBounds();\n for (var i = 0; i < this.children.length; i++) {\n var child = this.children[i];\n if (!child.visible || !child.renderable) {\n continue;\n }\n child.calculateBounds();\n // TODO: filter+mask, need to mask both somehow\n if (child._mask) {\n var maskObject = (child._mask.isMaskData\n ? child._mask.maskObject : child._mask);\n if (maskObject) {\n maskObject.calculateBounds();\n this._bounds.addBoundsMask(child._bounds, maskObject._bounds);\n }\n else {\n this._bounds.addBounds(child._bounds);\n }\n }\n else if (child.filterArea) {\n this._bounds.addBoundsArea(child._bounds, child.filterArea);\n }\n else {\n this._bounds.addBounds(child._bounds);\n }\n }\n this._bounds.updateID = this._boundsID;\n };\n /**\n * Retrieves the local bounds of the displayObject as a rectangle object.\n *\n * Calling `getLocalBounds` may invalidate the `_bounds` of the whole subtree below. If using it inside a render()\n * call, it is advised to call `getBounds()` immediately after to recalculate the world bounds of the subtree.\n * @param rect - Optional rectangle to store the result of the bounds calculation.\n * @param skipChildrenUpdate - Setting to `true` will stop re-calculation of children transforms,\n * it was default behaviour of pixi 4.0-5.2 and caused many problems to users.\n * @returns - The rectangular bounding area.\n */\n Container.prototype.getLocalBounds = function (rect, skipChildrenUpdate) {\n if (skipChildrenUpdate === void 0) { skipChildrenUpdate = false; }\n var result = _super.prototype.getLocalBounds.call(this, rect);\n if (!skipChildrenUpdate) {\n for (var i = 0, j = this.children.length; i < j; ++i) {\n var child = this.children[i];\n if (child.visible) {\n child.updateTransform();\n }\n }\n }\n return result;\n };\n /**\n * Recalculates the content bounds of this object. This should be overriden to\n * calculate the bounds of this specific object (not including children).\n * @protected\n */\n Container.prototype._calculateBounds = function () {\n // FILL IN//\n };\n /**\n * Renders this object and its children with culling.\n * @protected\n * @param {PIXI.Renderer} renderer - The renderer\n */\n Container.prototype._renderWithCulling = function (renderer) {\n var sourceFrame = renderer.renderTexture.sourceFrame;\n // If the source frame is empty, stop rendering.\n if (!(sourceFrame.width > 0 && sourceFrame.height > 0)) {\n return;\n }\n // Render the content of the container only if its bounds intersect with the source frame.\n // All filters are on the stack at this point, and the filter source frame is bound:\n // therefore, even if the bounds to non intersect the filter frame, the filter\n // is still applied and any filter padding that is in the frame is rendered correctly.\n var bounds;\n var transform;\n // If cullArea is set, we use this rectangle instead of the bounds of the object. The cullArea\n // rectangle must completely contain the container and its children including filter padding.\n if (this.cullArea) {\n bounds = this.cullArea;\n transform = this.worldTransform;\n }\n // If the container doesn't override _render, we can skip the bounds calculation and intersection test.\n else if (this._render !== Container.prototype._render) {\n bounds = this.getBounds(true);\n }\n // Render the container if the source frame intersects the bounds.\n if (bounds && sourceFrame.intersects(bounds, transform)) {\n this._render(renderer);\n }\n // If the bounds are defined by cullArea and do not intersect with the source frame, stop rendering.\n else if (this.cullArea) {\n return;\n }\n // Unless cullArea is set, we cannot skip the children if the bounds of the container do not intersect\n // the source frame, because the children might have filters with nonzero padding, which may intersect\n // with the source frame while the bounds do not: filter padding is not included in the bounds.\n // If cullArea is not set, render the children with culling temporarily enabled so that they are not rendered\n // if they are out of frame; otherwise, render the children normally.\n for (var i = 0, j = this.children.length; i < j; ++i) {\n var child = this.children[i];\n var childCullable = child.cullable;\n child.cullable = childCullable || !this.cullArea;\n child.render(renderer);\n child.cullable = childCullable;\n }\n };\n /**\n * Renders the object using the WebGL renderer.\n *\n * The [_render]{@link PIXI.Container#_render} method is be overriden for rendering the contents of the\n * container itself. This `render` method will invoke it, and also invoke the `render` methods of all\n * children afterward.\n *\n * If `renderable` or `visible` is false or if `worldAlpha` is not positive or if `cullable` is true and\n * the bounds of this object are out of frame, this implementation will entirely skip rendering.\n * See {@link PIXI.DisplayObject} for choosing between `renderable` or `visible`. Generally,\n * setting alpha to zero is not recommended for purely skipping rendering.\n *\n * When your scene becomes large (especially when it is larger than can be viewed in a single screen), it is\n * advised to employ **culling** to automatically skip rendering objects outside of the current screen.\n * See [cullable]{@link PIXI.DisplayObject#cullable} and [cullArea]{@link PIXI.DisplayObject#cullArea}.\n * Other culling methods might be better suited for a large number static objects; see\n * [@pixi-essentials/cull]{@link https://www.npmjs.com/package/@pixi-essentials/cull} and\n * [pixi-cull]{@link https://www.npmjs.com/package/pixi-cull}.\n *\n * The [renderAdvanced]{@link PIXI.Container#renderAdvanced} method is internally used when when masking or\n * filtering is applied on a container. This does, however, break batching and can affect performance when\n * masking and filtering is applied extensively throughout the scene graph.\n * @param renderer - The renderer\n */\n Container.prototype.render = function (renderer) {\n // if the object is not visible or the alpha is 0 then no need to render this element\n if (!this.visible || this.worldAlpha <= 0 || !this.renderable) {\n return;\n }\n // do a quick check to see if this element has a mask or a filter.\n if (this._mask || (this.filters && this.filters.length)) {\n this.renderAdvanced(renderer);\n }\n else if (this.cullable) {\n this._renderWithCulling(renderer);\n }\n else {\n this._render(renderer);\n for (var i = 0, j = this.children.length; i < j; ++i) {\n this.children[i].render(renderer);\n }\n }\n };\n /**\n * Render the object using the WebGL renderer and advanced features.\n * @param renderer - The renderer\n */\n Container.prototype.renderAdvanced = function (renderer) {\n var filters = this.filters;\n var mask = this._mask;\n // push filter first as we need to ensure the stencil buffer is correct for any masking\n if (filters) {\n if (!this._enabledFilters) {\n this._enabledFilters = [];\n }\n this._enabledFilters.length = 0;\n for (var i = 0; i < filters.length; i++) {\n if (filters[i].enabled) {\n this._enabledFilters.push(filters[i]);\n }\n }\n }\n var flush = (filters && this._enabledFilters && this._enabledFilters.length)\n || (mask && (!mask.isMaskData\n || (mask.enabled && (mask.autoDetect || mask.type !== MASK_TYPES.NONE))));\n if (flush) {\n renderer.batch.flush();\n }\n if (filters && this._enabledFilters && this._enabledFilters.length) {\n renderer.filter.push(this, this._enabledFilters);\n }\n if (mask) {\n renderer.mask.push(this, this._mask);\n }\n if (this.cullable) {\n this._renderWithCulling(renderer);\n }\n else {\n this._render(renderer);\n for (var i = 0, j = this.children.length; i < j; ++i) {\n this.children[i].render(renderer);\n }\n }\n if (flush) {\n renderer.batch.flush();\n }\n if (mask) {\n renderer.mask.pop(this);\n }\n if (filters && this._enabledFilters && this._enabledFilters.length) {\n renderer.filter.pop();\n }\n };\n /**\n * To be overridden by the subclasses.\n * @param _renderer - The renderer\n */\n Container.prototype._render = function (_renderer) {\n // this is where content itself gets rendered...\n };\n /**\n * Removes all internal references and listeners as well as removes children from the display list.\n * Do not use a Container after calling `destroy`.\n * @param options - Options parameter. A boolean will act as if all options\n * have been set to that value\n * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy\n * method called as well. 'options' will be passed on to those calls.\n * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true\n * Should it destroy the texture of the child sprite\n * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true\n * Should it destroy the base texture of the child sprite\n */\n Container.prototype.destroy = function (options) {\n _super.prototype.destroy.call(this);\n this.sortDirty = false;\n var destroyChildren = typeof options === 'boolean' ? options : options && options.children;\n var oldChildren = this.removeChildren(0, this.children.length);\n if (destroyChildren) {\n for (var i = 0; i < oldChildren.length; ++i) {\n oldChildren[i].destroy(options);\n }\n }\n };\n Object.defineProperty(Container.prototype, \"width\", {\n /** The width of the Container, setting this will actually modify the scale to achieve the value set. */\n get: function () {\n return this.scale.x * this.getLocalBounds().width;\n },\n set: function (value) {\n var width = this.getLocalBounds().width;\n if (width !== 0) {\n this.scale.x = value / width;\n }\n else {\n this.scale.x = 1;\n }\n this._width = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Container.prototype, \"height\", {\n /** The height of the Container, setting this will actually modify the scale to achieve the value set. */\n get: function () {\n return this.scale.y * this.getLocalBounds().height;\n },\n set: function (value) {\n var height = this.getLocalBounds().height;\n if (height !== 0) {\n this.scale.y = value / height;\n }\n else {\n this.scale.y = 1;\n }\n this._height = value;\n },\n enumerable: false,\n configurable: true\n });\n return Container;\n}(DisplayObject));\n/**\n * Container default updateTransform, does update children of container.\n * Will crash if there's no parent element.\n * @memberof PIXI.Container#\n * @method containerUpdateTransform\n */\nContainer.prototype.containerUpdateTransform = Container.prototype.updateTransform;\n\nexport { Bounds, Container, DisplayObject, TemporaryDisplayObject };\n//# sourceMappingURL=display.mjs.map\n","/*!\n * @pixi/extensions - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/extensions is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n\r\nvar __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\n var arguments$1 = arguments;\n\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments$1[i];\r\n for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p)) { t[p] = s[p]; } }\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\n\n/**\n * Collection of valid extension types.\n * @memberof PIXI\n * @property {string} Application - Application plugins\n * @property {string} RendererPlugin - Plugins for Renderer\n * @property {string} CanvasRendererPlugin - Plugins for CanvasRenderer\n * @property {string} Loader - Plugins to use with Loader\n * @property {string} LoadParser - Parsers for Assets loader.\n * @property {string} ResolveParser - Parsers for Assets resolvers.\n * @property {string} CacheParser - Parsers for Assets cache.\n */\nvar ExtensionType;\n(function (ExtensionType) {\n ExtensionType[\"Application\"] = \"application\";\n ExtensionType[\"RendererPlugin\"] = \"renderer-webgl-plugin\";\n ExtensionType[\"CanvasRendererPlugin\"] = \"renderer-canvas-plugin\";\n ExtensionType[\"Loader\"] = \"loader\";\n ExtensionType[\"LoadParser\"] = \"load-parser\";\n ExtensionType[\"ResolveParser\"] = \"resolve-parser\";\n ExtensionType[\"CacheParser\"] = \"cache-parser\";\n ExtensionType[\"DetectionParser\"] = \"detection-parser\";\n})(ExtensionType || (ExtensionType = {}));\n/**\n * Convert input into extension format data.\n * @ignore\n */\nvar normalizeExtension = function (ext) {\n // Class/Object submission, use extension object\n if (typeof ext === 'function' || (typeof ext === 'object' && ext.extension)) {\n if (!ext.extension) {\n throw new Error('Extension class must have an extension object');\n }\n var metadata = (typeof ext.extension !== 'object')\n ? { type: ext.extension }\n : ext.extension;\n ext = __assign(__assign({}, metadata), { ref: ext });\n }\n if (typeof ext === 'object') {\n ext = __assign({}, ext);\n }\n else {\n throw new Error('Invalid extension type');\n }\n if (typeof ext.type === 'string') {\n ext.type = [ext.type];\n }\n return ext;\n};\n/**\n * Global registration of all PixiJS extensions. One-stop-shop for extensibility.\n * @memberof PIXI\n * @namespace extensions\n */\nvar extensions = {\n /** @ignore */\n _addHandlers: null,\n /** @ignore */\n _removeHandlers: null,\n /** @ignore */\n _queue: {},\n /**\n * Remove extensions from PixiJS.\n * @param extensions - Extensions to be removed.\n * @returns {PIXI.extensions} For chaining.\n */\n remove: function () {\n var arguments$1 = arguments;\n\n var _this = this;\n var extensions = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n extensions[_i] = arguments$1[_i];\n }\n extensions.map(normalizeExtension).forEach(function (ext) {\n ext.type.forEach(function (type) { var _a, _b; return (_b = (_a = _this._removeHandlers)[type]) === null || _b === void 0 ? void 0 : _b.call(_a, ext); });\n });\n return this;\n },\n /**\n * Register new extensions with PixiJS.\n * @param extensions - The spread of extensions to add to PixiJS.\n * @returns {PIXI.extensions} For chaining.\n */\n add: function () {\n var arguments$1 = arguments;\n\n var _this = this;\n var extensions = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n extensions[_i] = arguments$1[_i];\n }\n // Handle any extensions either passed as class w/ data or as data\n extensions.map(normalizeExtension).forEach(function (ext) {\n ext.type.forEach(function (type) {\n var handlers = _this._addHandlers;\n var queue = _this._queue;\n if (!handlers[type]) {\n queue[type] = queue[type] || [];\n queue[type].push(ext);\n }\n else {\n handlers[type](ext);\n }\n });\n });\n return this;\n },\n /**\n * Internal method to handle extensions by name.\n * @param type - The extension type.\n * @param onAdd - Function for handling when extensions are added/registered passes {@link PIXI.ExtensionFormat}.\n * @param onRemove - Function for handling when extensions are removed/unregistered passes {@link PIXI.ExtensionFormat}.\n * @returns {PIXI.extensions} For chaining.\n */\n handle: function (type, onAdd, onRemove) {\n var addHandlers = this._addHandlers = this._addHandlers || {};\n var removeHandlers = this._removeHandlers = this._removeHandlers || {};\n if (addHandlers[type] || removeHandlers[type]) {\n throw new Error(\"Extension type \" + type + \" already has a handler\");\n }\n addHandlers[type] = onAdd;\n removeHandlers[type] = onRemove;\n // Process the queue\n var queue = this._queue;\n // Process any plugins that have been registered before the handler\n if (queue[type]) {\n queue[type].forEach(function (ext) { return onAdd(ext); });\n delete queue[type];\n }\n return this;\n },\n /**\n * Handle a type, but using a map by `name` property.\n * @param type - Type of extension to handle.\n * @param map - The object map of named extensions.\n * @returns {PIXI.extensions} For chaining.\n */\n handleByMap: function (type, map) {\n return this.handle(type, function (extension) {\n map[extension.name] = extension.ref;\n }, function (extension) {\n delete map[extension.name];\n });\n },\n /**\n * Handle a type, but using a list of extensions.\n * @param type - Type of extension to handle.\n * @param list - The list of extensions.\n * @returns {PIXI.extensions} For chaining.\n */\n handleByList: function (type, list) {\n return this.handle(type, function (extension) {\n var _a, _b;\n if (list.includes(extension.ref)) {\n return;\n }\n list.push(extension.ref);\n // TODO: remove me later, only added for @pixi/loaders\n if (type === ExtensionType.Loader) {\n (_b = (_a = extension.ref).add) === null || _b === void 0 ? void 0 : _b.call(_a);\n }\n }, function (extension) {\n var index = list.indexOf(extension.ref);\n if (index !== -1) {\n list.splice(index, 1);\n }\n });\n },\n};\n\nexport { ExtensionType, extensions };\n//# sourceMappingURL=extensions.mjs.map\n","/*!\n * @pixi/runner - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/runner is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\n/**\n * A Runner is a highly performant and simple alternative to signals. Best used in situations\n * where events are dispatched to many objects at high frequency (say every frame!)\n *\n *\n * like a signal..\n * ```\n * import { Runner } from '@pixi/runner';\n *\n * const myObject = {\n * loaded: new Runner('loaded')\n * }\n *\n * const listener = {\n * loaded: function(){\n * // thin\n * }\n * }\n *\n * myObject.loaded.add(listener);\n *\n * myObject.loaded.emit();\n * ```\n *\n * Or for handling calling the same function on many items\n * ```\n * import { Runner } from '@pixi/runner';\n *\n * const myGame = {\n * update: new Runner('update')\n * }\n *\n * const gameObject = {\n * update: function(time){\n * // update my gamey state\n * }\n * }\n *\n * myGame.update.add(gameObject);\n *\n * myGame.update.emit(time);\n * ```\n * @memberof PIXI\n */\nvar Runner = /** @class */ (function () {\n /**\n * @param name - The function name that will be executed on the listeners added to this Runner.\n */\n function Runner(name) {\n this.items = [];\n this._name = name;\n this._aliasCount = 0;\n }\n /* eslint-disable jsdoc/require-param, jsdoc/check-param-names */\n /**\n * Dispatch/Broadcast Runner to all listeners added to the queue.\n * @param {...any} params - (optional) parameters to pass to each listener\n */\n /* eslint-enable jsdoc/require-param, jsdoc/check-param-names */\n Runner.prototype.emit = function (a0, a1, a2, a3, a4, a5, a6, a7) {\n if (arguments.length > 8) {\n throw new Error('max arguments reached');\n }\n var _a = this, name = _a.name, items = _a.items;\n this._aliasCount++;\n for (var i = 0, len = items.length; i < len; i++) {\n items[i][name](a0, a1, a2, a3, a4, a5, a6, a7);\n }\n if (items === this.items) {\n this._aliasCount--;\n }\n return this;\n };\n Runner.prototype.ensureNonAliasedItems = function () {\n if (this._aliasCount > 0 && this.items.length > 1) {\n this._aliasCount = 0;\n this.items = this.items.slice(0);\n }\n };\n /**\n * Add a listener to the Runner\n *\n * Runners do not need to have scope or functions passed to them.\n * All that is required is to pass the listening object and ensure that it has contains a function that has the same name\n * as the name provided to the Runner when it was created.\n *\n * Eg A listener passed to this Runner will require a 'complete' function.\n *\n * ```\n * import { Runner } from '@pixi/runner';\n *\n * const complete = new Runner('complete');\n * ```\n *\n * The scope used will be the object itself.\n * @param {any} item - The object that will be listening.\n */\n Runner.prototype.add = function (item) {\n if (item[this._name]) {\n this.ensureNonAliasedItems();\n this.remove(item);\n this.items.push(item);\n }\n return this;\n };\n /**\n * Remove a single listener from the dispatch queue.\n * @param {any} item - The listener that you would like to remove.\n */\n Runner.prototype.remove = function (item) {\n var index = this.items.indexOf(item);\n if (index !== -1) {\n this.ensureNonAliasedItems();\n this.items.splice(index, 1);\n }\n return this;\n };\n /**\n * Check to see if the listener is already in the Runner\n * @param {any} item - The listener that you would like to check.\n */\n Runner.prototype.contains = function (item) {\n return this.items.indexOf(item) !== -1;\n };\n /** Remove all listeners from the Runner */\n Runner.prototype.removeAll = function () {\n this.ensureNonAliasedItems();\n this.items.length = 0;\n return this;\n };\n /** Remove all references, don't use after this. */\n Runner.prototype.destroy = function () {\n this.removeAll();\n this.items = null;\n this._name = null;\n };\n Object.defineProperty(Runner.prototype, \"empty\", {\n /**\n * `true` if there are no this Runner contains no listeners\n * @readonly\n */\n get: function () {\n return this.items.length === 0;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Runner.prototype, \"name\", {\n /**\n * The name of the runner.\n * @readonly\n */\n get: function () {\n return this._name;\n },\n enumerable: false,\n configurable: true\n });\n return Runner;\n}());\nObject.defineProperties(Runner.prototype, {\n /**\n * Alias for `emit`\n * @memberof PIXI.Runner#\n * @method dispatch\n * @see PIXI.Runner#emit\n */\n dispatch: { value: Runner.prototype.emit },\n /**\n * Alias for `emit`\n * @memberof PIXI.Runner#\n * @method run\n * @see PIXI.Runner#emit\n */\n run: { value: Runner.prototype.emit },\n});\n\nexport { Runner };\n//# sourceMappingURL=runner.mjs.map\n","/*!\n * @pixi/ticker - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/ticker is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { settings } from '@pixi/settings';\nimport { ExtensionType } from '@pixi/extensions';\n\n/**\n * Target frames per millisecond.\n * @static\n * @name TARGET_FPMS\n * @memberof PIXI.settings\n * @type {number}\n * @default 0.06\n */\nsettings.TARGET_FPMS = 0.06;\n\n/**\n * Represents the update priorities used by internal PIXI classes when registered with\n * the {@link PIXI.Ticker} object. Higher priority items are updated first and lower\n * priority items, such as render, should go later.\n * @static\n * @constant\n * @name UPDATE_PRIORITY\n * @memberof PIXI\n * @enum {number}\n * @property {number} [INTERACTION=50] Highest priority, used for {@link PIXI.InteractionManager}\n * @property {number} [HIGH=25] High priority updating, {@link PIXI.VideoBaseTexture} and {@link PIXI.AnimatedSprite}\n * @property {number} [NORMAL=0] Default priority for ticker events, see {@link PIXI.Ticker#add}.\n * @property {number} [LOW=-25] Low priority used for {@link PIXI.Application} rendering.\n * @property {number} [UTILITY=-50] Lowest priority used for {@link PIXI.BasePrepare} utility.\n */\nvar UPDATE_PRIORITY;\n(function (UPDATE_PRIORITY) {\n UPDATE_PRIORITY[UPDATE_PRIORITY[\"INTERACTION\"] = 50] = \"INTERACTION\";\n UPDATE_PRIORITY[UPDATE_PRIORITY[\"HIGH\"] = 25] = \"HIGH\";\n UPDATE_PRIORITY[UPDATE_PRIORITY[\"NORMAL\"] = 0] = \"NORMAL\";\n UPDATE_PRIORITY[UPDATE_PRIORITY[\"LOW\"] = -25] = \"LOW\";\n UPDATE_PRIORITY[UPDATE_PRIORITY[\"UTILITY\"] = -50] = \"UTILITY\";\n})(UPDATE_PRIORITY || (UPDATE_PRIORITY = {}));\n\n/**\n * Internal class for handling the priority sorting of ticker handlers.\n * @private\n * @class\n * @memberof PIXI\n */\nvar TickerListener = /** @class */ (function () {\n /**\n * Constructor\n * @private\n * @param fn - The listener function to be added for one update\n * @param context - The listener context\n * @param priority - The priority for emitting\n * @param once - If the handler should fire once\n */\n function TickerListener(fn, context, priority, once) {\n if (context === void 0) { context = null; }\n if (priority === void 0) { priority = 0; }\n if (once === void 0) { once = false; }\n /** The next item in chain. */\n this.next = null;\n /** The previous item in chain. */\n this.previous = null;\n /** `true` if this listener has been destroyed already. */\n this._destroyed = false;\n this.fn = fn;\n this.context = context;\n this.priority = priority;\n this.once = once;\n }\n /**\n * Simple compare function to figure out if a function and context match.\n * @private\n * @param fn - The listener function to be added for one update\n * @param context - The listener context\n * @returns `true` if the listener match the arguments\n */\n TickerListener.prototype.match = function (fn, context) {\n if (context === void 0) { context = null; }\n return this.fn === fn && this.context === context;\n };\n /**\n * Emit by calling the current function.\n * @private\n * @param deltaTime - time since the last emit.\n * @returns Next ticker\n */\n TickerListener.prototype.emit = function (deltaTime) {\n if (this.fn) {\n if (this.context) {\n this.fn.call(this.context, deltaTime);\n }\n else {\n this.fn(deltaTime);\n }\n }\n var redirect = this.next;\n if (this.once) {\n this.destroy(true);\n }\n // Soft-destroying should remove\n // the next reference\n if (this._destroyed) {\n this.next = null;\n }\n return redirect;\n };\n /**\n * Connect to the list.\n * @private\n * @param previous - Input node, previous listener\n */\n TickerListener.prototype.connect = function (previous) {\n this.previous = previous;\n if (previous.next) {\n previous.next.previous = this;\n }\n this.next = previous.next;\n previous.next = this;\n };\n /**\n * Destroy and don't use after this.\n * @private\n * @param hard - `true` to remove the `next` reference, this\n * is considered a hard destroy. Soft destroy maintains the next reference.\n * @returns The listener to redirect while emitting or removing.\n */\n TickerListener.prototype.destroy = function (hard) {\n if (hard === void 0) { hard = false; }\n this._destroyed = true;\n this.fn = null;\n this.context = null;\n // Disconnect, hook up next and previous\n if (this.previous) {\n this.previous.next = this.next;\n }\n if (this.next) {\n this.next.previous = this.previous;\n }\n // Redirect to the next item\n var redirect = this.next;\n // Remove references\n this.next = hard ? null : redirect;\n this.previous = null;\n return redirect;\n };\n return TickerListener;\n}());\n\n/**\n * A Ticker class that runs an update loop that other objects listen to.\n *\n * This class is composed around listeners meant for execution on the next requested animation frame.\n * Animation frames are requested only when necessary, e.g. When the ticker is started and the emitter has listeners.\n * @class\n * @memberof PIXI\n */\nvar Ticker = /** @class */ (function () {\n function Ticker() {\n var _this = this;\n /**\n * Whether or not this ticker should invoke the method\n * {@link PIXI.Ticker#start} automatically\n * when a listener is added.\n */\n this.autoStart = false;\n /**\n * Scalar time value from last frame to this frame.\n * This value is capped by setting {@link PIXI.Ticker#minFPS}\n * and is scaled with {@link PIXI.Ticker#speed}.\n * **Note:** The cap may be exceeded by scaling.\n */\n this.deltaTime = 1;\n /**\n * The last time {@link PIXI.Ticker#update} was invoked.\n * This value is also reset internally outside of invoking\n * update, but only when a new animation frame is requested.\n * If the platform supports DOMHighResTimeStamp,\n * this value will have a precision of 1 µs.\n */\n this.lastTime = -1;\n /**\n * Factor of current {@link PIXI.Ticker#deltaTime}.\n * @example\n * // Scales ticker.deltaTime to what would be\n * // the equivalent of approximately 120 FPS\n * ticker.speed = 2;\n */\n this.speed = 1;\n /**\n * Whether or not this ticker has been started.\n * `true` if {@link PIXI.Ticker#start} has been called.\n * `false` if {@link PIXI.Ticker#stop} has been called.\n * While `false`, this value may change to `true` in the\n * event of {@link PIXI.Ticker#autoStart} being `true`\n * and a listener is added.\n */\n this.started = false;\n /** Internal current frame request ID */\n this._requestId = null;\n /**\n * Internal value managed by minFPS property setter and getter.\n * This is the maximum allowed milliseconds between updates.\n */\n this._maxElapsedMS = 100;\n /**\n * Internal value managed by minFPS property setter and getter.\n * This is the minimum allowed milliseconds between updates.\n */\n this._minElapsedMS = 0;\n /** If enabled, deleting is disabled.*/\n this._protected = false;\n /** The last time keyframe was executed. Maintains a relatively fixed interval with the previous value. */\n this._lastFrame = -1;\n this._head = new TickerListener(null, null, Infinity);\n this.deltaMS = 1 / settings.TARGET_FPMS;\n this.elapsedMS = 1 / settings.TARGET_FPMS;\n this._tick = function (time) {\n _this._requestId = null;\n if (_this.started) {\n // Invoke listeners now\n _this.update(time);\n // Listener side effects may have modified ticker state.\n if (_this.started && _this._requestId === null && _this._head.next) {\n _this._requestId = requestAnimationFrame(_this._tick);\n }\n }\n };\n }\n /**\n * Conditionally requests a new animation frame.\n * If a frame has not already been requested, and if the internal\n * emitter has listeners, a new frame is requested.\n * @private\n */\n Ticker.prototype._requestIfNeeded = function () {\n if (this._requestId === null && this._head.next) {\n // ensure callbacks get correct delta\n this.lastTime = performance.now();\n this._lastFrame = this.lastTime;\n this._requestId = requestAnimationFrame(this._tick);\n }\n };\n /**\n * Conditionally cancels a pending animation frame.\n * @private\n */\n Ticker.prototype._cancelIfNeeded = function () {\n if (this._requestId !== null) {\n cancelAnimationFrame(this._requestId);\n this._requestId = null;\n }\n };\n /**\n * Conditionally requests a new animation frame.\n * If the ticker has been started it checks if a frame has not already\n * been requested, and if the internal emitter has listeners. If these\n * conditions are met, a new frame is requested. If the ticker has not\n * been started, but autoStart is `true`, then the ticker starts now,\n * and continues with the previous conditions to request a new frame.\n * @private\n */\n Ticker.prototype._startIfPossible = function () {\n if (this.started) {\n this._requestIfNeeded();\n }\n else if (this.autoStart) {\n this.start();\n }\n };\n /**\n * Register a handler for tick events. Calls continuously unless\n * it is removed or the ticker is stopped.\n * @param fn - The listener function to be added for updates\n * @param context - The listener context\n * @param {number} [priority=PIXI.UPDATE_PRIORITY.NORMAL] - The priority for emitting\n * @returns This instance of a ticker\n */\n Ticker.prototype.add = function (fn, context, priority) {\n if (priority === void 0) { priority = UPDATE_PRIORITY.NORMAL; }\n return this._addListener(new TickerListener(fn, context, priority));\n };\n /**\n * Add a handler for the tick event which is only execute once.\n * @param fn - The listener function to be added for one update\n * @param context - The listener context\n * @param {number} [priority=PIXI.UPDATE_PRIORITY.NORMAL] - The priority for emitting\n * @returns This instance of a ticker\n */\n Ticker.prototype.addOnce = function (fn, context, priority) {\n if (priority === void 0) { priority = UPDATE_PRIORITY.NORMAL; }\n return this._addListener(new TickerListener(fn, context, priority, true));\n };\n /**\n * Internally adds the event handler so that it can be sorted by priority.\n * Priority allows certain handler (user, AnimatedSprite, Interaction) to be run\n * before the rendering.\n * @private\n * @param listener - Current listener being added.\n * @returns This instance of a ticker\n */\n Ticker.prototype._addListener = function (listener) {\n // For attaching to head\n var current = this._head.next;\n var previous = this._head;\n // Add the first item\n if (!current) {\n listener.connect(previous);\n }\n else {\n // Go from highest to lowest priority\n while (current) {\n if (listener.priority > current.priority) {\n listener.connect(previous);\n break;\n }\n previous = current;\n current = current.next;\n }\n // Not yet connected\n if (!listener.previous) {\n listener.connect(previous);\n }\n }\n this._startIfPossible();\n return this;\n };\n /**\n * Removes any handlers matching the function and context parameters.\n * If no handlers are left after removing, then it cancels the animation frame.\n * @param fn - The listener function to be removed\n * @param context - The listener context to be removed\n * @returns This instance of a ticker\n */\n Ticker.prototype.remove = function (fn, context) {\n var listener = this._head.next;\n while (listener) {\n // We found a match, lets remove it\n // no break to delete all possible matches\n // incase a listener was added 2+ times\n if (listener.match(fn, context)) {\n listener = listener.destroy();\n }\n else {\n listener = listener.next;\n }\n }\n if (!this._head.next) {\n this._cancelIfNeeded();\n }\n return this;\n };\n Object.defineProperty(Ticker.prototype, \"count\", {\n /**\n * The number of listeners on this ticker, calculated by walking through linked list\n * @readonly\n * @member {number}\n */\n get: function () {\n if (!this._head) {\n return 0;\n }\n var count = 0;\n var current = this._head;\n while ((current = current.next)) {\n count++;\n }\n return count;\n },\n enumerable: false,\n configurable: true\n });\n /** Starts the ticker. If the ticker has listeners a new animation frame is requested at this point. */\n Ticker.prototype.start = function () {\n if (!this.started) {\n this.started = true;\n this._requestIfNeeded();\n }\n };\n /** Stops the ticker. If the ticker has requested an animation frame it is canceled at this point. */\n Ticker.prototype.stop = function () {\n if (this.started) {\n this.started = false;\n this._cancelIfNeeded();\n }\n };\n /** Destroy the ticker and don't use after this. Calling this method removes all references to internal events. */\n Ticker.prototype.destroy = function () {\n if (!this._protected) {\n this.stop();\n var listener = this._head.next;\n while (listener) {\n listener = listener.destroy(true);\n }\n this._head.destroy();\n this._head = null;\n }\n };\n /**\n * Triggers an update. An update entails setting the\n * current {@link PIXI.Ticker#elapsedMS},\n * the current {@link PIXI.Ticker#deltaTime},\n * invoking all listeners with current deltaTime,\n * and then finally setting {@link PIXI.Ticker#lastTime}\n * with the value of currentTime that was provided.\n * This method will be called automatically by animation\n * frame callbacks if the ticker instance has been started\n * and listeners are added.\n * @param {number} [currentTime=performance.now()] - the current time of execution\n */\n Ticker.prototype.update = function (currentTime) {\n if (currentTime === void 0) { currentTime = performance.now(); }\n var elapsedMS;\n // If the difference in time is zero or negative, we ignore most of the work done here.\n // If there is no valid difference, then should be no reason to let anyone know about it.\n // A zero delta, is exactly that, nothing should update.\n //\n // The difference in time can be negative, and no this does not mean time traveling.\n // This can be the result of a race condition between when an animation frame is requested\n // on the current JavaScript engine event loop, and when the ticker's start method is invoked\n // (which invokes the internal _requestIfNeeded method). If a frame is requested before\n // _requestIfNeeded is invoked, then the callback for the animation frame the ticker requests,\n // can receive a time argument that can be less than the lastTime value that was set within\n // _requestIfNeeded. This difference is in microseconds, but this is enough to cause problems.\n //\n // This check covers this browser engine timing issue, as well as if consumers pass an invalid\n // currentTime value. This may happen if consumers opt-out of the autoStart, and update themselves.\n if (currentTime > this.lastTime) {\n // Save uncapped elapsedMS for measurement\n elapsedMS = this.elapsedMS = currentTime - this.lastTime;\n // cap the milliseconds elapsed used for deltaTime\n if (elapsedMS > this._maxElapsedMS) {\n elapsedMS = this._maxElapsedMS;\n }\n elapsedMS *= this.speed;\n // If not enough time has passed, exit the function.\n // Get ready for next frame by setting _lastFrame, but based on _minElapsedMS\n // adjustment to ensure a relatively stable interval.\n if (this._minElapsedMS) {\n var delta = currentTime - this._lastFrame | 0;\n if (delta < this._minElapsedMS) {\n return;\n }\n this._lastFrame = currentTime - (delta % this._minElapsedMS);\n }\n this.deltaMS = elapsedMS;\n this.deltaTime = this.deltaMS * settings.TARGET_FPMS;\n // Cache a local reference, in-case ticker is destroyed\n // during the emit, we can still check for head.next\n var head = this._head;\n // Invoke listeners added to internal emitter\n var listener = head.next;\n while (listener) {\n listener = listener.emit(this.deltaTime);\n }\n if (!head.next) {\n this._cancelIfNeeded();\n }\n }\n else {\n this.deltaTime = this.deltaMS = this.elapsedMS = 0;\n }\n this.lastTime = currentTime;\n };\n Object.defineProperty(Ticker.prototype, \"FPS\", {\n /**\n * The frames per second at which this ticker is running.\n * The default is approximately 60 in most modern browsers.\n * **Note:** This does not factor in the value of\n * {@link PIXI.Ticker#speed}, which is specific\n * to scaling {@link PIXI.Ticker#deltaTime}.\n * @member {number}\n * @readonly\n */\n get: function () {\n return 1000 / this.elapsedMS;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Ticker.prototype, \"minFPS\", {\n /**\n * Manages the maximum amount of milliseconds allowed to\n * elapse between invoking {@link PIXI.Ticker#update}.\n * This value is used to cap {@link PIXI.Ticker#deltaTime},\n * but does not effect the measured value of {@link PIXI.Ticker#FPS}.\n * When setting this property it is clamped to a value between\n * `0` and `PIXI.settings.TARGET_FPMS * 1000`.\n * @member {number}\n * @default 10\n */\n get: function () {\n return 1000 / this._maxElapsedMS;\n },\n set: function (fps) {\n // Minimum must be below the maxFPS\n var minFPS = Math.min(this.maxFPS, fps);\n // Must be at least 0, but below 1 / settings.TARGET_FPMS\n var minFPMS = Math.min(Math.max(0, minFPS) / 1000, settings.TARGET_FPMS);\n this._maxElapsedMS = 1 / minFPMS;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Ticker.prototype, \"maxFPS\", {\n /**\n * Manages the minimum amount of milliseconds required to\n * elapse between invoking {@link PIXI.Ticker#update}.\n * This will effect the measured value of {@link PIXI.Ticker#FPS}.\n * If it is set to `0`, then there is no limit; PixiJS will render as many frames as it can.\n * Otherwise it will be at least `minFPS`\n * @member {number}\n * @default 0\n */\n get: function () {\n if (this._minElapsedMS) {\n return Math.round(1000 / this._minElapsedMS);\n }\n return 0;\n },\n set: function (fps) {\n if (fps === 0) {\n this._minElapsedMS = 0;\n }\n else {\n // Max must be at least the minFPS\n var maxFPS = Math.max(this.minFPS, fps);\n this._minElapsedMS = 1 / (maxFPS / 1000);\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Ticker, \"shared\", {\n /**\n * The shared ticker instance used by {@link PIXI.AnimatedSprite} and by\n * {@link PIXI.VideoResource} to update animation frames / video textures.\n *\n * It may also be used by {@link PIXI.Application} if created with the `sharedTicker` option property set to true.\n *\n * The property {@link PIXI.Ticker#autoStart} is set to `true` for this instance.\n * Please follow the examples for usage, including how to opt-out of auto-starting the shared ticker.\n * @example\n * let ticker = PIXI.Ticker.shared;\n * // Set this to prevent starting this ticker when listeners are added.\n * // By default this is true only for the PIXI.Ticker.shared instance.\n * ticker.autoStart = false;\n * // FYI, call this to ensure the ticker is stopped. It should be stopped\n * // if you have not attempted to render anything yet.\n * ticker.stop();\n * // Call this when you are ready for a running shared ticker.\n * ticker.start();\n * @example\n * // You may use the shared ticker to render...\n * let renderer = PIXI.autoDetectRenderer();\n * let stage = new PIXI.Container();\n * document.body.appendChild(renderer.view);\n * ticker.add(function (time) {\n * renderer.render(stage);\n * });\n * @example\n * // Or you can just update it manually.\n * ticker.autoStart = false;\n * ticker.stop();\n * function animate(time) {\n * ticker.update(time);\n * renderer.render(stage);\n * requestAnimationFrame(animate);\n * }\n * animate(performance.now());\n * @member {PIXI.Ticker}\n * @static\n */\n get: function () {\n if (!Ticker._shared) {\n var shared = Ticker._shared = new Ticker();\n shared.autoStart = true;\n shared._protected = true;\n }\n return Ticker._shared;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Ticker, \"system\", {\n /**\n * The system ticker instance used by {@link PIXI.InteractionManager} and by\n * {@link PIXI.BasePrepare} for core timing functionality that shouldn't usually need to be paused,\n * unlike the `shared` ticker which drives visual animations and rendering which may want to be paused.\n *\n * The property {@link PIXI.Ticker#autoStart} is set to `true` for this instance.\n * @member {PIXI.Ticker}\n * @static\n */\n get: function () {\n if (!Ticker._system) {\n var system = Ticker._system = new Ticker();\n system.autoStart = true;\n system._protected = true;\n }\n return Ticker._system;\n },\n enumerable: false,\n configurable: true\n });\n return Ticker;\n}());\n\n/**\n * Middleware for for Application Ticker.\n * @example\n * import {TickerPlugin} from '@pixi/ticker';\n * import {Application} from '@pixi/app';\n * import {extensions} from '@pixi/extensions';\n * extensions.add(TickerPlugin);\n * @class\n * @memberof PIXI\n */\nvar TickerPlugin = /** @class */ (function () {\n function TickerPlugin() {\n }\n /**\n * Initialize the plugin with scope of application instance\n * @static\n * @private\n * @param {object} [options] - See application options\n */\n TickerPlugin.init = function (options) {\n var _this = this;\n // Set default\n options = Object.assign({\n autoStart: true,\n sharedTicker: false,\n }, options);\n // Create ticker setter\n Object.defineProperty(this, 'ticker', {\n set: function (ticker) {\n if (this._ticker) {\n this._ticker.remove(this.render, this);\n }\n this._ticker = ticker;\n if (ticker) {\n ticker.add(this.render, this, UPDATE_PRIORITY.LOW);\n }\n },\n get: function () {\n return this._ticker;\n },\n });\n /**\n * Convenience method for stopping the render.\n * @method\n * @memberof PIXI.Application\n * @instance\n */\n this.stop = function () {\n _this._ticker.stop();\n };\n /**\n * Convenience method for starting the render.\n * @method\n * @memberof PIXI.Application\n * @instance\n */\n this.start = function () {\n _this._ticker.start();\n };\n /**\n * Internal reference to the ticker.\n * @type {PIXI.Ticker}\n * @name _ticker\n * @memberof PIXI.Application#\n * @private\n */\n this._ticker = null;\n /**\n * Ticker for doing render updates.\n * @type {PIXI.Ticker}\n * @name ticker\n * @memberof PIXI.Application#\n * @default PIXI.Ticker.shared\n */\n this.ticker = options.sharedTicker ? Ticker.shared : new Ticker();\n // Start the rendering\n if (options.autoStart) {\n this.start();\n }\n };\n /**\n * Clean up the ticker, scoped to application.\n * @static\n * @private\n */\n TickerPlugin.destroy = function () {\n if (this._ticker) {\n var oldTicker = this._ticker;\n this.ticker = null;\n oldTicker.destroy();\n }\n };\n /** @ignore */\n TickerPlugin.extension = ExtensionType.Application;\n return TickerPlugin;\n}());\n\nexport { Ticker, TickerPlugin, UPDATE_PRIORITY };\n//# sourceMappingURL=ticker.mjs.map\n","/*!\n * @pixi/core - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/core is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { settings } from '@pixi/settings';\nimport { ENV, ALPHA_MODES, SCALE_MODES, FORMATS, TYPES, TARGETS, MIPMAP_MODES, MSAA_QUALITY, BUFFER_TYPE, CLEAR_MODES, DRAW_MODES, BUFFER_BITS, MASK_TYPES, PRECISION, BLEND_MODES, GC_MODES, SAMPLER_TYPES, WRAP_MODES, RENDERER_TYPE } from '@pixi/constants';\nimport { isMobile, isPow2, BaseTextureCache, TextureCache, uid, EventEmitter, determineCrossOrigin, getResolutionOfUrl, deprecation, nextPow2, getBufferType, ProgramCache, removeItems, hex2string, hex2rgb, sayHello, isWebGLSupported, premultiplyBlendMode, log2, premultiplyTint } from '@pixi/utils';\nimport { extensions as extensions$1, ExtensionType } from '@pixi/extensions';\nexport * from '@pixi/extensions';\nimport { Runner } from '@pixi/runner';\nimport { Ticker } from '@pixi/ticker';\nimport { groupD8, Rectangle, Point, Matrix } from '@pixi/math';\n\n/**\n * The maximum support for using WebGL. If a device does not\n * support WebGL version, for instance WebGL 2, it will still\n * attempt to fallback support to WebGL 1. If you want to\n * explicitly remove feature support to target a more stable\n * baseline, prefer a lower environment.\n *\n * Due to {@link https://bugs.chromium.org/p/chromium/issues/detail?id=934823|bug in chromium}\n * we disable webgl2 by default for all non-apple mobile devices.\n * @static\n * @name PREFER_ENV\n * @memberof PIXI.settings\n * @type {number}\n * @default PIXI.ENV.WEBGL2\n */\nsettings.PREFER_ENV = isMobile.any ? ENV.WEBGL : ENV.WEBGL2;\n/**\n * If set to `true`, *only* Textures and BaseTexture objects stored\n * in the caches ({@link PIXI.utils.TextureCache TextureCache} and\n * {@link PIXI.utils.BaseTextureCache BaseTextureCache}) can be\n * used when calling {@link PIXI.Texture.from Texture.from} or\n * {@link PIXI.BaseTexture.from BaseTexture.from}.\n * Otherwise, these `from` calls throw an exception. Using this property\n * can be useful if you want to enforce preloading all assets with\n * {@link PIXI.Loader Loader}.\n * @static\n * @name STRICT_TEXTURE_CACHE\n * @memberof PIXI.settings\n * @type {boolean}\n * @default false\n */\nsettings.STRICT_TEXTURE_CACHE = false;\n\n/**\n * Collection of installed resource types, class must extend {@link PIXI.Resource}.\n * @example\n * class CustomResource extends PIXI.Resource {\n * // MUST have source, options constructor signature\n * // for auto-detected resources to be created.\n * constructor(source, options) {\n * super();\n * }\n * upload(renderer, baseTexture, glTexture) {\n * // upload with GL\n * return true;\n * }\n * // used to auto-detect resource\n * static test(source, extension) {\n * return extension === 'xyz'|| source instanceof SomeClass;\n * }\n * }\n * // Install the new resource type\n * PIXI.INSTALLED.push(CustomResource);\n * @memberof PIXI\n * @type {Array}\n * @static\n * @readonly\n */\nvar INSTALLED = [];\n/**\n * Create a resource element from a single source element. This\n * auto-detects which type of resource to create. All resources that\n * are auto-detectable must have a static `test` method and a constructor\n * with the arguments `(source, options?)`. Currently, the supported\n * resources for auto-detection include:\n * - {@link PIXI.ImageResource}\n * - {@link PIXI.CanvasResource}\n * - {@link PIXI.VideoResource}\n * - {@link PIXI.SVGResource}\n * - {@link PIXI.BufferResource}\n * @static\n * @memberof PIXI\n * @function autoDetectResource\n * @param {string|*} source - Resource source, this can be the URL to the resource,\n * a typed-array (for BufferResource), HTMLVideoElement, SVG data-uri\n * or any other resource that can be auto-detected. If not resource is\n * detected, it's assumed to be an ImageResource.\n * @param {object} [options] - Pass-through options to use for Resource\n * @param {number} [options.width] - Width of BufferResource or SVG rasterization\n * @param {number} [options.height] - Height of BufferResource or SVG rasterization\n * @param {boolean} [options.autoLoad=true] - Image, SVG and Video flag to start loading\n * @param {number} [options.scale=1] - SVG source scale. Overridden by width, height\n * @param {boolean} [options.createBitmap=PIXI.settings.CREATE_IMAGE_BITMAP] - Image option to create Bitmap object\n * @param {boolean} [options.crossorigin=true] - Image and Video option to set crossOrigin\n * @param {boolean} [options.autoPlay=true] - Video option to start playing video immediately\n * @param {number} [options.updateFPS=0] - Video option to update how many times a second the\n * texture should be updated from the video. Leave at 0 to update at every render\n * @returns {PIXI.Resource} The created resource.\n */\nfunction autoDetectResource(source, options) {\n if (!source) {\n return null;\n }\n var extension = '';\n if (typeof source === 'string') {\n // search for file extension: period, 3-4 chars, then ?, # or EOL\n var result = (/\\.(\\w{3,4})(?:$|\\?|#)/i).exec(source);\n if (result) {\n extension = result[1].toLowerCase();\n }\n }\n for (var i = INSTALLED.length - 1; i >= 0; --i) {\n var ResourcePlugin = INSTALLED[i];\n if (ResourcePlugin.test && ResourcePlugin.test(source, extension)) {\n return new ResourcePlugin(source, options);\n }\n }\n throw new Error('Unrecognized source type to auto-detect Resource');\n}\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nvar __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\n var arguments$1 = arguments;\n\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments$1[i];\r\n for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p)) { t[p] = s[p]; } }\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\n\r\nfunction __rest(s, e) {\r\n var t = {};\r\n for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n { t[p] = s[p]; } }\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n { for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n { t[p[i]] = s[p[i]]; }\r\n } }\r\n return t;\r\n}\n\n/**\n * Base resource class for textures that manages validation and uploading, depending on its type.\n *\n * Uploading of a base texture to the GPU is required.\n * @memberof PIXI\n */\nvar Resource = /** @class */ (function () {\n /**\n * @param width - Width of the resource\n * @param height - Height of the resource\n */\n function Resource(width, height) {\n if (width === void 0) { width = 0; }\n if (height === void 0) { height = 0; }\n this._width = width;\n this._height = height;\n this.destroyed = false;\n this.internal = false;\n this.onResize = new Runner('setRealSize');\n this.onUpdate = new Runner('update');\n this.onError = new Runner('onError');\n }\n /**\n * Bind to a parent BaseTexture\n * @param baseTexture - Parent texture\n */\n Resource.prototype.bind = function (baseTexture) {\n this.onResize.add(baseTexture);\n this.onUpdate.add(baseTexture);\n this.onError.add(baseTexture);\n // Call a resize immediate if we already\n // have the width and height of the resource\n if (this._width || this._height) {\n this.onResize.emit(this._width, this._height);\n }\n };\n /**\n * Unbind to a parent BaseTexture\n * @param baseTexture - Parent texture\n */\n Resource.prototype.unbind = function (baseTexture) {\n this.onResize.remove(baseTexture);\n this.onUpdate.remove(baseTexture);\n this.onError.remove(baseTexture);\n };\n /**\n * Trigger a resize event\n * @param width - X dimension\n * @param height - Y dimension\n */\n Resource.prototype.resize = function (width, height) {\n if (width !== this._width || height !== this._height) {\n this._width = width;\n this._height = height;\n this.onResize.emit(width, height);\n }\n };\n Object.defineProperty(Resource.prototype, \"valid\", {\n /**\n * Has been validated\n * @readonly\n */\n get: function () {\n return !!this._width && !!this._height;\n },\n enumerable: false,\n configurable: true\n });\n /** Has been updated trigger event. */\n Resource.prototype.update = function () {\n if (!this.destroyed) {\n this.onUpdate.emit();\n }\n };\n /**\n * This can be overridden to start preloading a resource\n * or do any other prepare step.\n * @protected\n * @returns Handle the validate event\n */\n Resource.prototype.load = function () {\n return Promise.resolve(this);\n };\n Object.defineProperty(Resource.prototype, \"width\", {\n /**\n * The width of the resource.\n * @readonly\n */\n get: function () {\n return this._width;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Resource.prototype, \"height\", {\n /**\n * The height of the resource.\n * @readonly\n */\n get: function () {\n return this._height;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Set the style, optional to override\n * @param _renderer - yeah, renderer!\n * @param _baseTexture - the texture\n * @param _glTexture - texture instance for this webgl context\n * @returns - `true` is success\n */\n Resource.prototype.style = function (_renderer, _baseTexture, _glTexture) {\n return false;\n };\n /** Clean up anything, this happens when destroying is ready. */\n Resource.prototype.dispose = function () {\n // override\n };\n /**\n * Call when destroying resource, unbind any BaseTexture object\n * before calling this method, as reference counts are maintained\n * internally.\n */\n Resource.prototype.destroy = function () {\n if (!this.destroyed) {\n this.destroyed = true;\n this.dispose();\n this.onError.removeAll();\n this.onError = null;\n this.onResize.removeAll();\n this.onResize = null;\n this.onUpdate.removeAll();\n this.onUpdate = null;\n }\n };\n /**\n * Abstract, used to auto-detect resource type.\n * @param {*} _source - The source object\n * @param {string} _extension - The extension of source, if set\n */\n Resource.test = function (_source, _extension) {\n return false;\n };\n return Resource;\n}());\n\n/**\n * @interface SharedArrayBuffer\n */\n/**\n * Buffer resource with data of typed array.\n * @memberof PIXI\n */\nvar BufferResource = /** @class */ (function (_super) {\n __extends(BufferResource, _super);\n /**\n * @param source - Source buffer\n * @param options - Options\n * @param {number} options.width - Width of the texture\n * @param {number} options.height - Height of the texture\n */\n function BufferResource(source, options) {\n var _this = this;\n var _a = options || {}, width = _a.width, height = _a.height;\n if (!width || !height) {\n throw new Error('BufferResource width or height invalid');\n }\n _this = _super.call(this, width, height) || this;\n _this.data = source;\n return _this;\n }\n /**\n * Upload the texture to the GPU.\n * @param renderer - Upload to the renderer\n * @param baseTexture - Reference to parent texture\n * @param glTexture - glTexture\n * @returns - true is success\n */\n BufferResource.prototype.upload = function (renderer, baseTexture, glTexture) {\n var gl = renderer.gl;\n gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.alphaMode === ALPHA_MODES.UNPACK);\n var width = baseTexture.realWidth;\n var height = baseTexture.realHeight;\n if (glTexture.width === width && glTexture.height === height) {\n gl.texSubImage2D(baseTexture.target, 0, 0, 0, width, height, baseTexture.format, glTexture.type, this.data);\n }\n else {\n glTexture.width = width;\n glTexture.height = height;\n gl.texImage2D(baseTexture.target, 0, glTexture.internalFormat, width, height, 0, baseTexture.format, glTexture.type, this.data);\n }\n return true;\n };\n /** Destroy and don't use after this. */\n BufferResource.prototype.dispose = function () {\n this.data = null;\n };\n /**\n * Used to auto-detect the type of resource.\n * @param {*} source - The source object\n * @returns {boolean} `true` if \n */\n BufferResource.test = function (source) {\n return source instanceof Float32Array\n || source instanceof Uint8Array\n || source instanceof Uint32Array;\n };\n return BufferResource;\n}(Resource));\n\nvar defaultBufferOptions = {\n scaleMode: SCALE_MODES.NEAREST,\n format: FORMATS.RGBA,\n alphaMode: ALPHA_MODES.NPM,\n};\n/**\n * A Texture stores the information that represents an image.\n * All textures have a base texture, which contains information about the source.\n * Therefore you can have many textures all using a single BaseTexture\n * @memberof PIXI\n * @typeParam R - The BaseTexture's Resource type.\n * @typeParam RO - The options for constructing resource.\n */\nvar BaseTexture = /** @class */ (function (_super) {\n __extends(BaseTexture, _super);\n /**\n * @param {PIXI.Resource|string|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} [resource=null] -\n * The current resource to use, for things that aren't Resource objects, will be converted\n * into a Resource.\n * @param options - Collection of options\n * @param {PIXI.MIPMAP_MODES} [options.mipmap=PIXI.settings.MIPMAP_TEXTURES] - If mipmapping is enabled for texture\n * @param {number} [options.anisotropicLevel=PIXI.settings.ANISOTROPIC_LEVEL] - Anisotropic filtering level of texture\n * @param {PIXI.WRAP_MODES} [options.wrapMode=PIXI.settings.WRAP_MODE] - Wrap mode for textures\n * @param {PIXI.SCALE_MODES} [options.scaleMode=PIXI.settings.SCALE_MODE] - Default scale mode, linear, nearest\n * @param {PIXI.FORMATS} [options.format=PIXI.FORMATS.RGBA] - GL format type\n * @param {PIXI.TYPES} [options.type=PIXI.TYPES.UNSIGNED_BYTE] - GL data type\n * @param {PIXI.TARGETS} [options.target=PIXI.TARGETS.TEXTURE_2D] - GL texture target\n * @param {PIXI.ALPHA_MODES} [options.alphaMode=PIXI.ALPHA_MODES.UNPACK] - Pre multiply the image alpha\n * @param {number} [options.width=0] - Width of the texture\n * @param {number} [options.height=0] - Height of the texture\n * @param {number} [options.resolution=PIXI.settings.RESOLUTION] - Resolution of the base texture\n * @param {object} [options.resourceOptions] - Optional resource options,\n * see {@link PIXI.autoDetectResource autoDetectResource}\n */\n function BaseTexture(resource, options) {\n if (resource === void 0) { resource = null; }\n if (options === void 0) { options = null; }\n var _this = _super.call(this) || this;\n options = options || {};\n var alphaMode = options.alphaMode, mipmap = options.mipmap, anisotropicLevel = options.anisotropicLevel, scaleMode = options.scaleMode, width = options.width, height = options.height, wrapMode = options.wrapMode, format = options.format, type = options.type, target = options.target, resolution = options.resolution, resourceOptions = options.resourceOptions;\n // Convert the resource to a Resource object\n if (resource && !(resource instanceof Resource)) {\n resource = autoDetectResource(resource, resourceOptions);\n resource.internal = true;\n }\n _this.resolution = resolution || settings.RESOLUTION;\n _this.width = Math.round((width || 0) * _this.resolution) / _this.resolution;\n _this.height = Math.round((height || 0) * _this.resolution) / _this.resolution;\n _this._mipmap = mipmap !== undefined ? mipmap : settings.MIPMAP_TEXTURES;\n _this.anisotropicLevel = anisotropicLevel !== undefined ? anisotropicLevel : settings.ANISOTROPIC_LEVEL;\n _this._wrapMode = wrapMode || settings.WRAP_MODE;\n _this._scaleMode = scaleMode !== undefined ? scaleMode : settings.SCALE_MODE;\n _this.format = format || FORMATS.RGBA;\n _this.type = type || TYPES.UNSIGNED_BYTE;\n _this.target = target || TARGETS.TEXTURE_2D;\n _this.alphaMode = alphaMode !== undefined ? alphaMode : ALPHA_MODES.UNPACK;\n _this.uid = uid();\n _this.touched = 0;\n _this.isPowerOfTwo = false;\n _this._refreshPOT();\n _this._glTextures = {};\n _this.dirtyId = 0;\n _this.dirtyStyleId = 0;\n _this.cacheId = null;\n _this.valid = width > 0 && height > 0;\n _this.textureCacheIds = [];\n _this.destroyed = false;\n _this.resource = null;\n _this._batchEnabled = 0;\n _this._batchLocation = 0;\n _this.parentTextureArray = null;\n /**\n * Fired when a not-immediately-available source finishes loading.\n * @protected\n * @event PIXI.BaseTexture#loaded\n * @param {PIXI.BaseTexture} baseTexture - Resource loaded.\n */\n /**\n * Fired when a not-immediately-available source fails to load.\n * @protected\n * @event PIXI.BaseTexture#error\n * @param {PIXI.BaseTexture} baseTexture - Resource errored.\n * @param {ErrorEvent} event - Load error event.\n */\n /**\n * Fired when BaseTexture is updated.\n * @protected\n * @event PIXI.BaseTexture#loaded\n * @param {PIXI.BaseTexture} baseTexture - Resource loaded.\n */\n /**\n * Fired when BaseTexture is updated.\n * @protected\n * @event PIXI.BaseTexture#update\n * @param {PIXI.BaseTexture} baseTexture - Instance of texture being updated.\n */\n /**\n * Fired when BaseTexture is destroyed.\n * @protected\n * @event PIXI.BaseTexture#dispose\n * @param {PIXI.BaseTexture} baseTexture - Instance of texture being destroyed.\n */\n // Set the resource\n _this.setResource(resource);\n return _this;\n }\n Object.defineProperty(BaseTexture.prototype, \"realWidth\", {\n /**\n * Pixel width of the source of this texture\n * @readonly\n */\n get: function () {\n return Math.round(this.width * this.resolution);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BaseTexture.prototype, \"realHeight\", {\n /**\n * Pixel height of the source of this texture\n * @readonly\n */\n get: function () {\n return Math.round(this.height * this.resolution);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BaseTexture.prototype, \"mipmap\", {\n /**\n * Mipmap mode of the texture, affects downscaled images\n * @default PIXI.settings.MIPMAP_TEXTURES\n */\n get: function () {\n return this._mipmap;\n },\n set: function (value) {\n if (this._mipmap !== value) {\n this._mipmap = value;\n this.dirtyStyleId++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BaseTexture.prototype, \"scaleMode\", {\n /**\n * The scale mode to apply when scaling this texture\n * @default PIXI.settings.SCALE_MODE\n */\n get: function () {\n return this._scaleMode;\n },\n set: function (value) {\n if (this._scaleMode !== value) {\n this._scaleMode = value;\n this.dirtyStyleId++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BaseTexture.prototype, \"wrapMode\", {\n /**\n * How the texture wraps\n * @default PIXI.settings.WRAP_MODE\n */\n get: function () {\n return this._wrapMode;\n },\n set: function (value) {\n if (this._wrapMode !== value) {\n this._wrapMode = value;\n this.dirtyStyleId++;\n }\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Changes style options of BaseTexture\n * @param scaleMode - Pixi scalemode\n * @param mipmap - enable mipmaps\n * @returns - this\n */\n BaseTexture.prototype.setStyle = function (scaleMode, mipmap) {\n var dirty;\n if (scaleMode !== undefined && scaleMode !== this.scaleMode) {\n this.scaleMode = scaleMode;\n dirty = true;\n }\n if (mipmap !== undefined && mipmap !== this.mipmap) {\n this.mipmap = mipmap;\n dirty = true;\n }\n if (dirty) {\n this.dirtyStyleId++;\n }\n return this;\n };\n /**\n * Changes w/h/resolution. Texture becomes valid if width and height are greater than zero.\n * @param desiredWidth - Desired visual width\n * @param desiredHeight - Desired visual height\n * @param resolution - Optionally set resolution\n * @returns - this\n */\n BaseTexture.prototype.setSize = function (desiredWidth, desiredHeight, resolution) {\n resolution = resolution || this.resolution;\n return this.setRealSize(desiredWidth * resolution, desiredHeight * resolution, resolution);\n };\n /**\n * Sets real size of baseTexture, preserves current resolution.\n * @param realWidth - Full rendered width\n * @param realHeight - Full rendered height\n * @param resolution - Optionally set resolution\n * @returns - this\n */\n BaseTexture.prototype.setRealSize = function (realWidth, realHeight, resolution) {\n this.resolution = resolution || this.resolution;\n this.width = Math.round(realWidth) / this.resolution;\n this.height = Math.round(realHeight) / this.resolution;\n this._refreshPOT();\n this.update();\n return this;\n };\n /**\n * Refresh check for isPowerOfTwo texture based on size\n * @private\n */\n BaseTexture.prototype._refreshPOT = function () {\n this.isPowerOfTwo = isPow2(this.realWidth) && isPow2(this.realHeight);\n };\n /**\n * Changes resolution\n * @param resolution - res\n * @returns - this\n */\n BaseTexture.prototype.setResolution = function (resolution) {\n var oldResolution = this.resolution;\n if (oldResolution === resolution) {\n return this;\n }\n this.resolution = resolution;\n if (this.valid) {\n this.width = Math.round(this.width * oldResolution) / resolution;\n this.height = Math.round(this.height * oldResolution) / resolution;\n this.emit('update', this);\n }\n this._refreshPOT();\n return this;\n };\n /**\n * Sets the resource if it wasn't set. Throws error if resource already present\n * @param resource - that is managing this BaseTexture\n * @returns - this\n */\n BaseTexture.prototype.setResource = function (resource) {\n if (this.resource === resource) {\n return this;\n }\n if (this.resource) {\n throw new Error('Resource can be set only once');\n }\n resource.bind(this);\n this.resource = resource;\n return this;\n };\n /** Invalidates the object. Texture becomes valid if width and height are greater than zero. */\n BaseTexture.prototype.update = function () {\n if (!this.valid) {\n if (this.width > 0 && this.height > 0) {\n this.valid = true;\n this.emit('loaded', this);\n this.emit('update', this);\n }\n }\n else {\n this.dirtyId++;\n this.dirtyStyleId++;\n this.emit('update', this);\n }\n };\n /**\n * Handle errors with resources.\n * @private\n * @param event - Error event emitted.\n */\n BaseTexture.prototype.onError = function (event) {\n this.emit('error', this, event);\n };\n /**\n * Destroys this base texture.\n * The method stops if resource doesn't want this texture to be destroyed.\n * Removes texture from all caches.\n */\n BaseTexture.prototype.destroy = function () {\n // remove and destroy the resource\n if (this.resource) {\n this.resource.unbind(this);\n // only destroy resourced created internally\n if (this.resource.internal) {\n this.resource.destroy();\n }\n this.resource = null;\n }\n if (this.cacheId) {\n delete BaseTextureCache[this.cacheId];\n delete TextureCache[this.cacheId];\n this.cacheId = null;\n }\n // finally let the WebGL renderer know..\n this.dispose();\n BaseTexture.removeFromCache(this);\n this.textureCacheIds = null;\n this.destroyed = true;\n };\n /**\n * Frees the texture from WebGL memory without destroying this texture object.\n * This means you can still use the texture later which will upload it to GPU\n * memory again.\n * @fires PIXI.BaseTexture#dispose\n */\n BaseTexture.prototype.dispose = function () {\n this.emit('dispose', this);\n };\n /** Utility function for BaseTexture|Texture cast. */\n BaseTexture.prototype.castToBaseTexture = function () {\n return this;\n };\n /**\n * Helper function that creates a base texture based on the source you provide.\n * The source can be - image url, image element, canvas element. If the\n * source is an image url or an image element and not in the base texture\n * cache, it will be created and loaded.\n * @static\n * @param {string|string[]|HTMLImageElement|HTMLCanvasElement|SVGElement|HTMLVideoElement} source - The\n * source to create base texture from.\n * @param options - See {@link PIXI.BaseTexture}'s constructor for options.\n * @param {string} [options.pixiIdPrefix=pixiid] - If a source has no id, this is the prefix of the generated id\n * @param {boolean} [strict] - Enforce strict-mode, see {@link PIXI.settings.STRICT_TEXTURE_CACHE}.\n * @returns {PIXI.BaseTexture} The new base texture.\n */\n BaseTexture.from = function (source, options, strict) {\n if (strict === void 0) { strict = settings.STRICT_TEXTURE_CACHE; }\n var isFrame = typeof source === 'string';\n var cacheId = null;\n if (isFrame) {\n cacheId = source;\n }\n else {\n if (!source._pixiId) {\n var prefix = (options && options.pixiIdPrefix) || 'pixiid';\n source._pixiId = prefix + \"_\" + uid();\n }\n cacheId = source._pixiId;\n }\n var baseTexture = BaseTextureCache[cacheId];\n // Strict-mode rejects invalid cacheIds\n if (isFrame && strict && !baseTexture) {\n throw new Error(\"The cacheId \\\"\" + cacheId + \"\\\" does not exist in BaseTextureCache.\");\n }\n if (!baseTexture) {\n baseTexture = new BaseTexture(source, options);\n baseTexture.cacheId = cacheId;\n BaseTexture.addToCache(baseTexture, cacheId);\n }\n return baseTexture;\n };\n /**\n * Create a new BaseTexture with a BufferResource from a Float32Array.\n * RGBA values are floats from 0 to 1.\n * @param {Float32Array|Uint8Array} buffer - The optional array to use, if no data\n * is provided, a new Float32Array is created.\n * @param width - Width of the resource\n * @param height - Height of the resource\n * @param options - See {@link PIXI.BaseTexture}'s constructor for options.\n * Default properties are different from the constructor's defaults.\n * @param {PIXI.FORMATS} [options.format=PIXI.FORMATS.RGBA] - GL format type\n * @param {PIXI.ALPHA_MODES} [options.alphaMode=PIXI.ALPHA_MODES.NPM] - Image alpha, not premultiplied by default\n * @param {PIXI.SCALE_MODES} [options.scaleMode=PIXI.SCALE_MODES.NEAREST] - Scale mode, pixelating by default\n * @returns - The resulting new BaseTexture\n */\n BaseTexture.fromBuffer = function (buffer, width, height, options) {\n buffer = buffer || new Float32Array(width * height * 4);\n var resource = new BufferResource(buffer, { width: width, height: height });\n var type = buffer instanceof Float32Array ? TYPES.FLOAT : TYPES.UNSIGNED_BYTE;\n return new BaseTexture(resource, Object.assign({}, defaultBufferOptions, options || { width: width, height: height, type: type }));\n };\n /**\n * Adds a BaseTexture to the global BaseTextureCache. This cache is shared across the whole PIXI object.\n * @param {PIXI.BaseTexture} baseTexture - The BaseTexture to add to the cache.\n * @param {string} id - The id that the BaseTexture will be stored against.\n */\n BaseTexture.addToCache = function (baseTexture, id) {\n if (id) {\n if (baseTexture.textureCacheIds.indexOf(id) === -1) {\n baseTexture.textureCacheIds.push(id);\n }\n if (BaseTextureCache[id]) {\n // eslint-disable-next-line no-console\n console.warn(\"BaseTexture added to the cache with an id [\" + id + \"] that already had an entry\");\n }\n BaseTextureCache[id] = baseTexture;\n }\n };\n /**\n * Remove a BaseTexture from the global BaseTextureCache.\n * @param {string|PIXI.BaseTexture} baseTexture - id of a BaseTexture to be removed, or a BaseTexture instance itself.\n * @returns {PIXI.BaseTexture|null} The BaseTexture that was removed.\n */\n BaseTexture.removeFromCache = function (baseTexture) {\n if (typeof baseTexture === 'string') {\n var baseTextureFromCache = BaseTextureCache[baseTexture];\n if (baseTextureFromCache) {\n var index = baseTextureFromCache.textureCacheIds.indexOf(baseTexture);\n if (index > -1) {\n baseTextureFromCache.textureCacheIds.splice(index, 1);\n }\n delete BaseTextureCache[baseTexture];\n return baseTextureFromCache;\n }\n }\n else if (baseTexture && baseTexture.textureCacheIds) {\n for (var i = 0; i < baseTexture.textureCacheIds.length; ++i) {\n delete BaseTextureCache[baseTexture.textureCacheIds[i]];\n }\n baseTexture.textureCacheIds.length = 0;\n return baseTexture;\n }\n return null;\n };\n /** Global number of the texture batch, used by multi-texture renderers. */\n BaseTexture._globalBatch = 0;\n return BaseTexture;\n}(EventEmitter));\n\n/**\n * Resource that can manage several resource (items) inside.\n * All resources need to have the same pixel size.\n * Parent class for CubeResource and ArrayResource\n * @memberof PIXI\n */\nvar AbstractMultiResource = /** @class */ (function (_super) {\n __extends(AbstractMultiResource, _super);\n /**\n * @param length\n * @param options - Options to for Resource constructor\n * @param {number} [options.width] - Width of the resource\n * @param {number} [options.height] - Height of the resource\n */\n function AbstractMultiResource(length, options) {\n var _this = this;\n var _a = options || {}, width = _a.width, height = _a.height;\n _this = _super.call(this, width, height) || this;\n _this.items = [];\n _this.itemDirtyIds = [];\n for (var i = 0; i < length; i++) {\n var partTexture = new BaseTexture();\n _this.items.push(partTexture);\n // -2 - first run of texture array upload\n // -1 - texture item was allocated\n // >=0 - texture item uploaded , in sync with items[i].dirtyId\n _this.itemDirtyIds.push(-2);\n }\n _this.length = length;\n _this._load = null;\n _this.baseTexture = null;\n return _this;\n }\n /**\n * Used from ArrayResource and CubeResource constructors.\n * @param resources - Can be resources, image elements, canvas, etc. ,\n * length should be same as constructor length\n * @param options - Detect options for resources\n */\n AbstractMultiResource.prototype.initFromArray = function (resources, options) {\n for (var i = 0; i < this.length; i++) {\n if (!resources[i]) {\n continue;\n }\n if (resources[i].castToBaseTexture) {\n this.addBaseTextureAt(resources[i].castToBaseTexture(), i);\n }\n else if (resources[i] instanceof Resource) {\n this.addResourceAt(resources[i], i);\n }\n else {\n this.addResourceAt(autoDetectResource(resources[i], options), i);\n }\n }\n };\n /** Destroy this BaseImageResource. */\n AbstractMultiResource.prototype.dispose = function () {\n for (var i = 0, len = this.length; i < len; i++) {\n this.items[i].destroy();\n }\n this.items = null;\n this.itemDirtyIds = null;\n this._load = null;\n };\n /**\n * Set a resource by ID\n * @param resource\n * @param index - Zero-based index of resource to set\n * @returns - Instance for chaining\n */\n AbstractMultiResource.prototype.addResourceAt = function (resource, index) {\n if (!this.items[index]) {\n throw new Error(\"Index \" + index + \" is out of bounds\");\n }\n // Inherit the first resource dimensions\n if (resource.valid && !this.valid) {\n this.resize(resource.width, resource.height);\n }\n this.items[index].setResource(resource);\n return this;\n };\n /**\n * Set the parent base texture.\n * @param baseTexture\n */\n AbstractMultiResource.prototype.bind = function (baseTexture) {\n if (this.baseTexture !== null) {\n throw new Error('Only one base texture per TextureArray is allowed');\n }\n _super.prototype.bind.call(this, baseTexture);\n for (var i = 0; i < this.length; i++) {\n this.items[i].parentTextureArray = baseTexture;\n this.items[i].on('update', baseTexture.update, baseTexture);\n }\n };\n /**\n * Unset the parent base texture.\n * @param baseTexture\n */\n AbstractMultiResource.prototype.unbind = function (baseTexture) {\n _super.prototype.unbind.call(this, baseTexture);\n for (var i = 0; i < this.length; i++) {\n this.items[i].parentTextureArray = null;\n this.items[i].off('update', baseTexture.update, baseTexture);\n }\n };\n /**\n * Load all the resources simultaneously\n * @returns - When load is resolved\n */\n AbstractMultiResource.prototype.load = function () {\n var _this = this;\n if (this._load) {\n return this._load;\n }\n var resources = this.items.map(function (item) { return item.resource; }).filter(function (item) { return item; });\n // TODO: also implement load part-by-part strategy\n var promises = resources.map(function (item) { return item.load(); });\n this._load = Promise.all(promises)\n .then(function () {\n var _a = _this.items[0], realWidth = _a.realWidth, realHeight = _a.realHeight;\n _this.resize(realWidth, realHeight);\n return Promise.resolve(_this);\n });\n return this._load;\n };\n return AbstractMultiResource;\n}(Resource));\n\n/**\n * A resource that contains a number of sources.\n * @memberof PIXI\n */\nvar ArrayResource = /** @class */ (function (_super) {\n __extends(ArrayResource, _super);\n /**\n * @param source - Number of items in array or the collection\n * of image URLs to use. Can also be resources, image elements, canvas, etc.\n * @param options - Options to apply to {@link PIXI.autoDetectResource}\n * @param {number} [options.width] - Width of the resource\n * @param {number} [options.height] - Height of the resource\n */\n function ArrayResource(source, options) {\n var _this = this;\n var _a = options || {}, width = _a.width, height = _a.height;\n var urls;\n var length;\n if (Array.isArray(source)) {\n urls = source;\n length = source.length;\n }\n else {\n length = source;\n }\n _this = _super.call(this, length, { width: width, height: height }) || this;\n if (urls) {\n _this.initFromArray(urls, options);\n }\n return _this;\n }\n /**\n * Set a baseTexture by ID,\n * ArrayResource just takes resource from it, nothing more\n * @param baseTexture\n * @param index - Zero-based index of resource to set\n * @returns - Instance for chaining\n */\n ArrayResource.prototype.addBaseTextureAt = function (baseTexture, index) {\n if (baseTexture.resource) {\n this.addResourceAt(baseTexture.resource, index);\n }\n else {\n throw new Error('ArrayResource does not support RenderTexture');\n }\n return this;\n };\n /**\n * Add binding\n * @param baseTexture\n */\n ArrayResource.prototype.bind = function (baseTexture) {\n _super.prototype.bind.call(this, baseTexture);\n baseTexture.target = TARGETS.TEXTURE_2D_ARRAY;\n };\n /**\n * Upload the resources to the GPU.\n * @param renderer\n * @param texture\n * @param glTexture\n * @returns - whether texture was uploaded\n */\n ArrayResource.prototype.upload = function (renderer, texture, glTexture) {\n var _a = this, length = _a.length, itemDirtyIds = _a.itemDirtyIds, items = _a.items;\n var gl = renderer.gl;\n if (glTexture.dirtyId < 0) {\n gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, glTexture.internalFormat, this._width, this._height, length, 0, texture.format, glTexture.type, null);\n }\n for (var i = 0; i < length; i++) {\n var item = items[i];\n if (itemDirtyIds[i] < item.dirtyId) {\n itemDirtyIds[i] = item.dirtyId;\n if (item.valid) {\n gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, // xoffset\n 0, // yoffset\n i, // zoffset\n item.resource.width, item.resource.height, 1, texture.format, glTexture.type, item.resource.source);\n }\n }\n }\n return true;\n };\n return ArrayResource;\n}(AbstractMultiResource));\n\n/**\n * Base for all the image/canvas resources.\n * @memberof PIXI\n */\nvar BaseImageResource = /** @class */ (function (_super) {\n __extends(BaseImageResource, _super);\n /**\n * @param {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|SVGElement} source\n */\n function BaseImageResource(source) {\n var _this = this;\n var sourceAny = source;\n var width = sourceAny.naturalWidth || sourceAny.videoWidth || sourceAny.width;\n var height = sourceAny.naturalHeight || sourceAny.videoHeight || sourceAny.height;\n _this = _super.call(this, width, height) || this;\n _this.source = source;\n _this.noSubImage = false;\n return _this;\n }\n /**\n * Set cross origin based detecting the url and the crossorigin\n * @param element - Element to apply crossOrigin\n * @param url - URL to check\n * @param crossorigin - Cross origin value to use\n */\n BaseImageResource.crossOrigin = function (element, url, crossorigin) {\n if (crossorigin === undefined && url.indexOf('data:') !== 0) {\n element.crossOrigin = determineCrossOrigin(url);\n }\n else if (crossorigin !== false) {\n element.crossOrigin = typeof crossorigin === 'string' ? crossorigin : 'anonymous';\n }\n };\n /**\n * Upload the texture to the GPU.\n * @param renderer - Upload to the renderer\n * @param baseTexture - Reference to parent texture\n * @param glTexture\n * @param {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|SVGElement} [source] - (optional)\n * @returns - true is success\n */\n BaseImageResource.prototype.upload = function (renderer, baseTexture, glTexture, source) {\n var gl = renderer.gl;\n var width = baseTexture.realWidth;\n var height = baseTexture.realHeight;\n source = source || this.source;\n if (source instanceof HTMLImageElement) {\n if (!source.complete || source.naturalWidth === 0) {\n return false;\n }\n }\n else if (source instanceof HTMLVideoElement) {\n if (source.readyState <= 1) {\n return false;\n }\n }\n gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.alphaMode === ALPHA_MODES.UNPACK);\n if (!this.noSubImage\n && baseTexture.target === gl.TEXTURE_2D\n && glTexture.width === width\n && glTexture.height === height) {\n gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, baseTexture.format, glTexture.type, source);\n }\n else {\n glTexture.width = width;\n glTexture.height = height;\n gl.texImage2D(baseTexture.target, 0, glTexture.internalFormat, baseTexture.format, glTexture.type, source);\n }\n return true;\n };\n /**\n * Checks if source width/height was changed, resize can cause extra baseTexture update.\n * Triggers one update in any case.\n */\n BaseImageResource.prototype.update = function () {\n if (this.destroyed) {\n return;\n }\n var source = this.source;\n var width = source.naturalWidth || source.videoWidth || source.width;\n var height = source.naturalHeight || source.videoHeight || source.height;\n this.resize(width, height);\n _super.prototype.update.call(this);\n };\n /** Destroy this {@link BaseImageResource} */\n BaseImageResource.prototype.dispose = function () {\n this.source = null;\n };\n return BaseImageResource;\n}(Resource));\n\n/**\n * @interface OffscreenCanvas\n */\n/**\n * Resource type for HTMLCanvasElement.\n * @memberof PIXI\n */\nvar CanvasResource = /** @class */ (function (_super) {\n __extends(CanvasResource, _super);\n /**\n * @param source - Canvas element to use\n */\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n function CanvasResource(source) {\n return _super.call(this, source) || this;\n }\n /**\n * Used to auto-detect the type of resource.\n * @param {*} source - The source object\n * @returns {boolean} `true` if source is HTMLCanvasElement or OffscreenCanvas\n */\n CanvasResource.test = function (source) {\n var OffscreenCanvas = globalThis.OffscreenCanvas;\n // Check for browsers that don't yet support OffscreenCanvas\n if (OffscreenCanvas && source instanceof OffscreenCanvas) {\n return true;\n }\n return globalThis.HTMLCanvasElement && source instanceof HTMLCanvasElement;\n };\n return CanvasResource;\n}(BaseImageResource));\n\n/**\n * Resource for a CubeTexture which contains six resources.\n * @memberof PIXI\n */\nvar CubeResource = /** @class */ (function (_super) {\n __extends(CubeResource, _super);\n /**\n * @param {Array} [source] - Collection of URLs or resources\n * to use as the sides of the cube.\n * @param options - ImageResource options\n * @param {number} [options.width] - Width of resource\n * @param {number} [options.height] - Height of resource\n * @param {number} [options.autoLoad=true] - Whether to auto-load resources\n * @param {number} [options.linkBaseTexture=true] - In case BaseTextures are supplied,\n * whether to copy them or use\n */\n function CubeResource(source, options) {\n var _this = this;\n var _a = options || {}, width = _a.width, height = _a.height, autoLoad = _a.autoLoad, linkBaseTexture = _a.linkBaseTexture;\n if (source && source.length !== CubeResource.SIDES) {\n throw new Error(\"Invalid length. Got \" + source.length + \", expected 6\");\n }\n _this = _super.call(this, 6, { width: width, height: height }) || this;\n for (var i = 0; i < CubeResource.SIDES; i++) {\n _this.items[i].target = TARGETS.TEXTURE_CUBE_MAP_POSITIVE_X + i;\n }\n _this.linkBaseTexture = linkBaseTexture !== false;\n if (source) {\n _this.initFromArray(source, options);\n }\n if (autoLoad !== false) {\n _this.load();\n }\n return _this;\n }\n /**\n * Add binding.\n * @param baseTexture - parent base texture\n */\n CubeResource.prototype.bind = function (baseTexture) {\n _super.prototype.bind.call(this, baseTexture);\n baseTexture.target = TARGETS.TEXTURE_CUBE_MAP;\n };\n CubeResource.prototype.addBaseTextureAt = function (baseTexture, index, linkBaseTexture) {\n if (!this.items[index]) {\n throw new Error(\"Index \" + index + \" is out of bounds\");\n }\n if (!this.linkBaseTexture\n || baseTexture.parentTextureArray\n || Object.keys(baseTexture._glTextures).length > 0) {\n // copy mode\n if (baseTexture.resource) {\n this.addResourceAt(baseTexture.resource, index);\n }\n else {\n throw new Error(\"CubeResource does not support copying of renderTexture.\");\n }\n }\n else {\n // link mode, the difficult one!\n baseTexture.target = TARGETS.TEXTURE_CUBE_MAP_POSITIVE_X + index;\n baseTexture.parentTextureArray = this.baseTexture;\n this.items[index] = baseTexture;\n }\n if (baseTexture.valid && !this.valid) {\n this.resize(baseTexture.realWidth, baseTexture.realHeight);\n }\n this.items[index] = baseTexture;\n return this;\n };\n /**\n * Upload the resource\n * @param renderer\n * @param _baseTexture\n * @param glTexture\n * @returns {boolean} true is success\n */\n CubeResource.prototype.upload = function (renderer, _baseTexture, glTexture) {\n var dirty = this.itemDirtyIds;\n for (var i = 0; i < CubeResource.SIDES; i++) {\n var side = this.items[i];\n if (dirty[i] < side.dirtyId || glTexture.dirtyId < _baseTexture.dirtyId) {\n if (side.valid && side.resource) {\n side.resource.upload(renderer, side, glTexture);\n dirty[i] = side.dirtyId;\n }\n else if (dirty[i] < -1) {\n // either item is not valid yet, either its a renderTexture\n // allocate the memory\n renderer.gl.texImage2D(side.target, 0, glTexture.internalFormat, _baseTexture.realWidth, _baseTexture.realHeight, 0, _baseTexture.format, glTexture.type, null);\n dirty[i] = -1;\n }\n }\n }\n return true;\n };\n /**\n * Used to auto-detect the type of resource.\n * @param {*} source - The source object\n * @returns {boolean} `true` if source is an array of 6 elements\n */\n CubeResource.test = function (source) {\n return Array.isArray(source) && source.length === CubeResource.SIDES;\n };\n /** Number of texture sides to store for CubeResources. */\n CubeResource.SIDES = 6;\n return CubeResource;\n}(AbstractMultiResource));\n\n/**\n * Resource type for HTMLImageElement.\n * @memberof PIXI\n */\nvar ImageResource = /** @class */ (function (_super) {\n __extends(ImageResource, _super);\n /**\n * @param source - image source or URL\n * @param options\n * @param {boolean} [options.autoLoad=true] - start loading process\n * @param {boolean} [options.createBitmap=PIXI.settings.CREATE_IMAGE_BITMAP] - whether its required to create\n * a bitmap before upload\n * @param {boolean} [options.crossorigin=true] - Load image using cross origin\n * @param {PIXI.ALPHA_MODES} [options.alphaMode=PIXI.ALPHA_MODES.UNPACK] - Premultiply image alpha in bitmap\n */\n function ImageResource(source, options) {\n var _this = this;\n options = options || {};\n if (!(source instanceof HTMLImageElement)) {\n var imageElement = new Image();\n BaseImageResource.crossOrigin(imageElement, source, options.crossorigin);\n imageElement.src = source;\n source = imageElement;\n }\n _this = _super.call(this, source) || this;\n // FireFox 68, and possibly other versions, seems like setting the HTMLImageElement#width and #height\n // to non-zero values before its loading completes if images are in a cache.\n // Because of this, need to set the `_width` and the `_height` to zero to avoid uploading incomplete images.\n // Please refer to the issue #5968 (https://github.com/pixijs/pixi.js/issues/5968).\n if (!source.complete && !!_this._width && !!_this._height) {\n _this._width = 0;\n _this._height = 0;\n }\n _this.url = source.src;\n _this._process = null;\n _this.preserveBitmap = false;\n _this.createBitmap = (options.createBitmap !== undefined\n ? options.createBitmap : settings.CREATE_IMAGE_BITMAP) && !!globalThis.createImageBitmap;\n _this.alphaMode = typeof options.alphaMode === 'number' ? options.alphaMode : null;\n _this.bitmap = null;\n _this._load = null;\n if (options.autoLoad !== false) {\n _this.load();\n }\n return _this;\n }\n /**\n * Returns a promise when image will be loaded and processed.\n * @param createBitmap - whether process image into bitmap\n */\n ImageResource.prototype.load = function (createBitmap) {\n var _this = this;\n if (this._load) {\n return this._load;\n }\n if (createBitmap !== undefined) {\n this.createBitmap = createBitmap;\n }\n this._load = new Promise(function (resolve, reject) {\n var source = _this.source;\n _this.url = source.src;\n var completed = function () {\n if (_this.destroyed) {\n return;\n }\n source.onload = null;\n source.onerror = null;\n _this.resize(source.width, source.height);\n _this._load = null;\n if (_this.createBitmap) {\n resolve(_this.process());\n }\n else {\n resolve(_this);\n }\n };\n if (source.complete && source.src) {\n completed();\n }\n else {\n source.onload = completed;\n source.onerror = function (event) {\n // Avoids Promise freezing when resource broken\n reject(event);\n _this.onError.emit(event);\n };\n }\n });\n return this._load;\n };\n /**\n * Called when we need to convert image into BitmapImage.\n * Can be called multiple times, real promise is cached inside.\n * @returns - Cached promise to fill that bitmap\n */\n ImageResource.prototype.process = function () {\n var _this = this;\n var source = this.source;\n if (this._process !== null) {\n return this._process;\n }\n if (this.bitmap !== null || !globalThis.createImageBitmap) {\n return Promise.resolve(this);\n }\n var createImageBitmap = globalThis.createImageBitmap;\n var cors = !source.crossOrigin || source.crossOrigin === 'anonymous';\n this._process = fetch(source.src, {\n mode: cors ? 'cors' : 'no-cors'\n })\n .then(function (r) { return r.blob(); })\n .then(function (blob) { return createImageBitmap(blob, 0, 0, source.width, source.height, {\n premultiplyAlpha: _this.alphaMode === null || _this.alphaMode === ALPHA_MODES.UNPACK\n ? 'premultiply' : 'none',\n }); })\n .then(function (bitmap) {\n if (_this.destroyed) {\n return Promise.reject();\n }\n _this.bitmap = bitmap;\n _this.update();\n _this._process = null;\n return Promise.resolve(_this);\n });\n return this._process;\n };\n /**\n * Upload the image resource to GPU.\n * @param renderer - Renderer to upload to\n * @param baseTexture - BaseTexture for this resource\n * @param glTexture - GLTexture to use\n * @returns {boolean} true is success\n */\n ImageResource.prototype.upload = function (renderer, baseTexture, glTexture) {\n if (typeof this.alphaMode === 'number') {\n // bitmap stores unpack premultiply flag, we dont have to notify texImage2D about it\n baseTexture.alphaMode = this.alphaMode;\n }\n if (!this.createBitmap) {\n return _super.prototype.upload.call(this, renderer, baseTexture, glTexture);\n }\n if (!this.bitmap) {\n // yeah, ignore the output\n this.process();\n if (!this.bitmap) {\n return false;\n }\n }\n _super.prototype.upload.call(this, renderer, baseTexture, glTexture, this.bitmap);\n if (!this.preserveBitmap) {\n // checks if there are other renderers that possibly need this bitmap\n var flag = true;\n var glTextures = baseTexture._glTextures;\n for (var key in glTextures) {\n var otherTex = glTextures[key];\n if (otherTex !== glTexture && otherTex.dirtyId !== baseTexture.dirtyId) {\n flag = false;\n break;\n }\n }\n if (flag) {\n if (this.bitmap.close) {\n this.bitmap.close();\n }\n this.bitmap = null;\n }\n }\n return true;\n };\n /** Destroys this resource. */\n ImageResource.prototype.dispose = function () {\n this.source.onload = null;\n this.source.onerror = null;\n _super.prototype.dispose.call(this);\n if (this.bitmap) {\n this.bitmap.close();\n this.bitmap = null;\n }\n this._process = null;\n this._load = null;\n };\n /**\n * Used to auto-detect the type of resource.\n * @param {*} source - The source object\n * @returns {boolean} `true` if source is string or HTMLImageElement\n */\n ImageResource.test = function (source) {\n return typeof source === 'string' || source instanceof HTMLImageElement;\n };\n return ImageResource;\n}(BaseImageResource));\n\n/**\n * Resource type for SVG elements and graphics.\n * @memberof PIXI\n */\nvar SVGResource = /** @class */ (function (_super) {\n __extends(SVGResource, _super);\n /**\n * @param sourceBase64 - Base64 encoded SVG element or URL for SVG file.\n * @param {object} [options] - Options to use\n * @param {number} [options.scale=1] - Scale to apply to SVG. Overridden by...\n * @param {number} [options.width] - Rasterize SVG this wide. Aspect ratio preserved if height not specified.\n * @param {number} [options.height] - Rasterize SVG this high. Aspect ratio preserved if width not specified.\n * @param {boolean} [options.autoLoad=true] - Start loading right away.\n */\n function SVGResource(sourceBase64, options) {\n var _this = this;\n options = options || {};\n _this = _super.call(this, settings.ADAPTER.createCanvas()) || this;\n _this._width = 0;\n _this._height = 0;\n _this.svg = sourceBase64;\n _this.scale = options.scale || 1;\n _this._overrideWidth = options.width;\n _this._overrideHeight = options.height;\n _this._resolve = null;\n _this._crossorigin = options.crossorigin;\n _this._load = null;\n if (options.autoLoad !== false) {\n _this.load();\n }\n return _this;\n }\n SVGResource.prototype.load = function () {\n var _this = this;\n if (this._load) {\n return this._load;\n }\n this._load = new Promise(function (resolve) {\n // Save this until after load is finished\n _this._resolve = function () {\n _this.resize(_this.source.width, _this.source.height);\n resolve(_this);\n };\n // Convert SVG inline string to data-uri\n if (SVGResource.SVG_XML.test(_this.svg.trim())) {\n if (!btoa) {\n throw new Error('Your browser doesn\\'t support base64 conversions.');\n }\n _this.svg = \"data:image/svg+xml;base64,\" + btoa(unescape(encodeURIComponent(_this.svg)));\n }\n _this._loadSvg();\n });\n return this._load;\n };\n /** Loads an SVG image from `imageUrl` or `data URL`. */\n SVGResource.prototype._loadSvg = function () {\n var _this = this;\n var tempImage = new Image();\n BaseImageResource.crossOrigin(tempImage, this.svg, this._crossorigin);\n tempImage.src = this.svg;\n tempImage.onerror = function (event) {\n if (!_this._resolve) {\n return;\n }\n tempImage.onerror = null;\n _this.onError.emit(event);\n };\n tempImage.onload = function () {\n if (!_this._resolve) {\n return;\n }\n var svgWidth = tempImage.width;\n var svgHeight = tempImage.height;\n if (!svgWidth || !svgHeight) {\n throw new Error('The SVG image must have width and height defined (in pixels), canvas API needs them.');\n }\n // Set render size\n var width = svgWidth * _this.scale;\n var height = svgHeight * _this.scale;\n if (_this._overrideWidth || _this._overrideHeight) {\n width = _this._overrideWidth || _this._overrideHeight / svgHeight * svgWidth;\n height = _this._overrideHeight || _this._overrideWidth / svgWidth * svgHeight;\n }\n width = Math.round(width);\n height = Math.round(height);\n // Create a canvas element\n var canvas = _this.source;\n canvas.width = width;\n canvas.height = height;\n canvas._pixiId = \"canvas_\" + uid();\n // Draw the Svg to the canvas\n canvas\n .getContext('2d')\n .drawImage(tempImage, 0, 0, svgWidth, svgHeight, 0, 0, width, height);\n _this._resolve();\n _this._resolve = null;\n };\n };\n /**\n * Get size from an svg string using a regular expression.\n * @param svgString - a serialized svg element\n * @returns - image extension\n */\n SVGResource.getSize = function (svgString) {\n var sizeMatch = SVGResource.SVG_SIZE.exec(svgString);\n var size = {};\n if (sizeMatch) {\n size[sizeMatch[1]] = Math.round(parseFloat(sizeMatch[3]));\n size[sizeMatch[5]] = Math.round(parseFloat(sizeMatch[7]));\n }\n return size;\n };\n /** Destroys this texture. */\n SVGResource.prototype.dispose = function () {\n _super.prototype.dispose.call(this);\n this._resolve = null;\n this._crossorigin = null;\n };\n /**\n * Used to auto-detect the type of resource.\n * @param {*} source - The source object\n * @param {string} extension - The extension of source, if set\n * @returns {boolean} - If the source is a SVG source or data file\n */\n SVGResource.test = function (source, extension) {\n // url file extension is SVG\n return extension === 'svg'\n // source is SVG data-uri\n || (typeof source === 'string' && source.startsWith('data:image/svg+xml'))\n // source is SVG inline\n || (typeof source === 'string' && SVGResource.SVG_XML.test(source));\n };\n /**\n * Regular expression for SVG XML document.\n * @example <?xml version=\"1.0\" encoding=\"utf-8\" ?><!-- image/svg --><svg\n * @readonly\n */\n SVGResource.SVG_XML = /^(<\\?xml[^?]+\\?>)?\\s*()]*-->)?\\s*\\]*(?:\\s(width|height)=('|\")(\\d*(?:\\.\\d+)?)(?:px)?('|\"))[^>]*(?:\\s(width|height)=('|\")(\\d*(?:\\.\\d+)?)(?:px)?('|\"))[^>]*>/i; // eslint-disable-line max-len\n return SVGResource;\n}(BaseImageResource));\n\n/**\n * Resource type for {@code HTMLVideoElement}.\n * @memberof PIXI\n */\nvar VideoResource = /** @class */ (function (_super) {\n __extends(VideoResource, _super);\n /**\n * @param {HTMLVideoElement|object|string|Array} source - Video element to use.\n * @param {object} [options] - Options to use\n * @param {boolean} [options.autoLoad=true] - Start loading the video immediately\n * @param {boolean} [options.autoPlay=true] - Start playing video immediately\n * @param {number} [options.updateFPS=0] - How many times a second to update the texture from the video.\n * Leave at 0 to update at every render.\n * @param {boolean} [options.crossorigin=true] - Load image using cross origin\n */\n function VideoResource(source, options) {\n var _this = this;\n options = options || {};\n if (!(source instanceof HTMLVideoElement)) {\n var videoElement = document.createElement('video');\n // workaround for https://github.com/pixijs/pixi.js/issues/5996\n videoElement.setAttribute('preload', 'auto');\n videoElement.setAttribute('webkit-playsinline', '');\n videoElement.setAttribute('playsinline', '');\n if (typeof source === 'string') {\n source = [source];\n }\n var firstSrc = source[0].src || source[0];\n BaseImageResource.crossOrigin(videoElement, firstSrc, options.crossorigin);\n // array of objects or strings\n for (var i = 0; i < source.length; ++i) {\n var sourceElement = document.createElement('source');\n var _a = source[i], src = _a.src, mime = _a.mime;\n src = src || source[i];\n var baseSrc = src.split('?').shift().toLowerCase();\n var ext = baseSrc.slice(baseSrc.lastIndexOf('.') + 1);\n mime = mime || VideoResource.MIME_TYPES[ext] || \"video/\" + ext;\n sourceElement.src = src;\n sourceElement.type = mime;\n videoElement.appendChild(sourceElement);\n }\n // Override the source\n source = videoElement;\n }\n _this = _super.call(this, source) || this;\n _this.noSubImage = true;\n _this._autoUpdate = true;\n _this._isConnectedToTicker = false;\n _this._updateFPS = options.updateFPS || 0;\n _this._msToNextUpdate = 0;\n _this.autoPlay = options.autoPlay !== false;\n _this._load = null;\n _this._resolve = null;\n // Bind for listeners\n _this._onCanPlay = _this._onCanPlay.bind(_this);\n _this._onError = _this._onError.bind(_this);\n if (options.autoLoad !== false) {\n _this.load();\n }\n return _this;\n }\n /**\n * Trigger updating of the texture.\n * @param _deltaTime - time delta since last tick\n */\n VideoResource.prototype.update = function (_deltaTime) {\n if (!this.destroyed) {\n // account for if video has had its playbackRate changed\n var elapsedMS = Ticker.shared.elapsedMS * this.source.playbackRate;\n this._msToNextUpdate = Math.floor(this._msToNextUpdate - elapsedMS);\n if (!this._updateFPS || this._msToNextUpdate <= 0) {\n _super.prototype.update.call(this);\n this._msToNextUpdate = this._updateFPS ? Math.floor(1000 / this._updateFPS) : 0;\n }\n }\n };\n /**\n * Start preloading the video resource.\n * @returns {Promise} Handle the validate event\n */\n VideoResource.prototype.load = function () {\n var _this = this;\n if (this._load) {\n return this._load;\n }\n var source = this.source;\n if ((source.readyState === source.HAVE_ENOUGH_DATA || source.readyState === source.HAVE_FUTURE_DATA)\n && source.width && source.height) {\n source.complete = true;\n }\n source.addEventListener('play', this._onPlayStart.bind(this));\n source.addEventListener('pause', this._onPlayStop.bind(this));\n if (!this._isSourceReady()) {\n source.addEventListener('canplay', this._onCanPlay);\n source.addEventListener('canplaythrough', this._onCanPlay);\n source.addEventListener('error', this._onError, true);\n }\n else {\n this._onCanPlay();\n }\n this._load = new Promise(function (resolve) {\n if (_this.valid) {\n resolve(_this);\n }\n else {\n _this._resolve = resolve;\n source.load();\n }\n });\n return this._load;\n };\n /**\n * Handle video error events.\n * @param event\n */\n VideoResource.prototype._onError = function (event) {\n this.source.removeEventListener('error', this._onError, true);\n this.onError.emit(event);\n };\n /**\n * Returns true if the underlying source is playing.\n * @returns - True if playing.\n */\n VideoResource.prototype._isSourcePlaying = function () {\n var source = this.source;\n return (!source.paused && !source.ended && this._isSourceReady());\n };\n /**\n * Returns true if the underlying source is ready for playing.\n * @returns - True if ready.\n */\n VideoResource.prototype._isSourceReady = function () {\n var source = this.source;\n return source.readyState > 2;\n };\n /** Runs the update loop when the video is ready to play. */\n VideoResource.prototype._onPlayStart = function () {\n // Just in case the video has not received its can play even yet..\n if (!this.valid) {\n this._onCanPlay();\n }\n if (this.autoUpdate && !this._isConnectedToTicker) {\n Ticker.shared.add(this.update, this);\n this._isConnectedToTicker = true;\n }\n };\n /** Fired when a pause event is triggered, stops the update loop. */\n VideoResource.prototype._onPlayStop = function () {\n if (this._isConnectedToTicker) {\n Ticker.shared.remove(this.update, this);\n this._isConnectedToTicker = false;\n }\n };\n /** Fired when the video is loaded and ready to play. */\n VideoResource.prototype._onCanPlay = function () {\n var source = this.source;\n source.removeEventListener('canplay', this._onCanPlay);\n source.removeEventListener('canplaythrough', this._onCanPlay);\n var valid = this.valid;\n this.resize(source.videoWidth, source.videoHeight);\n // prevent multiple loaded dispatches..\n if (!valid && this._resolve) {\n this._resolve(this);\n this._resolve = null;\n }\n if (this._isSourcePlaying()) {\n this._onPlayStart();\n }\n else if (this.autoPlay) {\n source.play();\n }\n };\n /** Destroys this texture. */\n VideoResource.prototype.dispose = function () {\n if (this._isConnectedToTicker) {\n Ticker.shared.remove(this.update, this);\n this._isConnectedToTicker = false;\n }\n var source = this.source;\n if (source) {\n source.removeEventListener('error', this._onError, true);\n source.pause();\n source.src = '';\n source.load();\n }\n _super.prototype.dispose.call(this);\n };\n Object.defineProperty(VideoResource.prototype, \"autoUpdate\", {\n /** Should the base texture automatically update itself, set to true by default. */\n get: function () {\n return this._autoUpdate;\n },\n set: function (value) {\n if (value !== this._autoUpdate) {\n this._autoUpdate = value;\n if (!this._autoUpdate && this._isConnectedToTicker) {\n Ticker.shared.remove(this.update, this);\n this._isConnectedToTicker = false;\n }\n else if (this._autoUpdate && !this._isConnectedToTicker && this._isSourcePlaying()) {\n Ticker.shared.add(this.update, this);\n this._isConnectedToTicker = true;\n }\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(VideoResource.prototype, \"updateFPS\", {\n /**\n * How many times a second to update the texture from the video. Leave at 0 to update at every render.\n * A lower fps can help performance, as updating the texture at 60fps on a 30ps video may not be efficient.\n */\n get: function () {\n return this._updateFPS;\n },\n set: function (value) {\n if (value !== this._updateFPS) {\n this._updateFPS = value;\n }\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Used to auto-detect the type of resource.\n * @param {*} source - The source object\n * @param {string} extension - The extension of source, if set\n * @returns {boolean} `true` if video source\n */\n VideoResource.test = function (source, extension) {\n return (globalThis.HTMLVideoElement && source instanceof HTMLVideoElement)\n || VideoResource.TYPES.indexOf(extension) > -1;\n };\n /**\n * List of common video file extensions supported by VideoResource.\n * @readonly\n */\n VideoResource.TYPES = ['mp4', 'm4v', 'webm', 'ogg', 'ogv', 'h264', 'avi', 'mov'];\n /**\n * Map of video MIME types that can't be directly derived from file extensions.\n * @readonly\n */\n VideoResource.MIME_TYPES = {\n ogv: 'video/ogg',\n mov: 'video/quicktime',\n m4v: 'video/mp4',\n };\n return VideoResource;\n}(BaseImageResource));\n\n/**\n * Resource type for ImageBitmap.\n * @memberof PIXI\n */\nvar ImageBitmapResource = /** @class */ (function (_super) {\n __extends(ImageBitmapResource, _super);\n /**\n * @param source - Image element to use\n */\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n function ImageBitmapResource(source) {\n return _super.call(this, source) || this;\n }\n /**\n * Used to auto-detect the type of resource.\n * @param {*} source - The source object\n * @returns {boolean} `true` if source is an ImageBitmap\n */\n ImageBitmapResource.test = function (source) {\n return !!globalThis.createImageBitmap && typeof ImageBitmap !== 'undefined' && source instanceof ImageBitmap;\n };\n return ImageBitmapResource;\n}(BaseImageResource));\n\nINSTALLED.push(ImageResource, ImageBitmapResource, CanvasResource, VideoResource, SVGResource, BufferResource, CubeResource, ArrayResource);\n\nvar _resources = {\n __proto__: null,\n Resource: Resource,\n BaseImageResource: BaseImageResource,\n INSTALLED: INSTALLED,\n autoDetectResource: autoDetectResource,\n AbstractMultiResource: AbstractMultiResource,\n ArrayResource: ArrayResource,\n BufferResource: BufferResource,\n CanvasResource: CanvasResource,\n CubeResource: CubeResource,\n ImageResource: ImageResource,\n SVGResource: SVGResource,\n VideoResource: VideoResource,\n ImageBitmapResource: ImageBitmapResource\n};\n\n/**\n * Resource type for DepthTexture.\n * @memberof PIXI\n */\nvar DepthResource = /** @class */ (function (_super) {\n __extends(DepthResource, _super);\n function DepthResource() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n /**\n * Upload the texture to the GPU.\n * @param renderer - Upload to the renderer\n * @param baseTexture - Reference to parent texture\n * @param glTexture - glTexture\n * @returns - true is success\n */\n DepthResource.prototype.upload = function (renderer, baseTexture, glTexture) {\n var gl = renderer.gl;\n gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.alphaMode === ALPHA_MODES.UNPACK);\n var width = baseTexture.realWidth;\n var height = baseTexture.realHeight;\n if (glTexture.width === width && glTexture.height === height) {\n gl.texSubImage2D(baseTexture.target, 0, 0, 0, width, height, baseTexture.format, glTexture.type, this.data);\n }\n else {\n glTexture.width = width;\n glTexture.height = height;\n gl.texImage2D(baseTexture.target, 0, glTexture.internalFormat, width, height, 0, baseTexture.format, glTexture.type, this.data);\n }\n return true;\n };\n return DepthResource;\n}(BufferResource));\n\n/**\n * A framebuffer can be used to render contents off of the screen. {@link PIXI.BaseRenderTexture} uses\n * one internally to render into itself. You can attach a depth or stencil buffer to a framebuffer.\n *\n * On WebGL 2 machines, shaders can output to multiple textures simultaneously with GLSL 300 ES.\n * @memberof PIXI\n */\nvar Framebuffer = /** @class */ (function () {\n /**\n * @param width - Width of the frame buffer\n * @param height - Height of the frame buffer\n */\n function Framebuffer(width, height) {\n this.width = Math.round(width || 100);\n this.height = Math.round(height || 100);\n this.stencil = false;\n this.depth = false;\n this.dirtyId = 0;\n this.dirtyFormat = 0;\n this.dirtySize = 0;\n this.depthTexture = null;\n this.colorTextures = [];\n this.glFramebuffers = {};\n this.disposeRunner = new Runner('disposeFramebuffer');\n this.multisample = MSAA_QUALITY.NONE;\n }\n Object.defineProperty(Framebuffer.prototype, \"colorTexture\", {\n /**\n * Reference to the colorTexture.\n * @readonly\n */\n get: function () {\n return this.colorTextures[0];\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Add texture to the colorTexture array.\n * @param index - Index of the array to add the texture to\n * @param texture - Texture to add to the array\n */\n Framebuffer.prototype.addColorTexture = function (index, texture) {\n if (index === void 0) { index = 0; }\n // TODO add some validation to the texture - same width / height etc?\n this.colorTextures[index] = texture || new BaseTexture(null, {\n scaleMode: SCALE_MODES.NEAREST,\n resolution: 1,\n mipmap: MIPMAP_MODES.OFF,\n width: this.width,\n height: this.height,\n });\n this.dirtyId++;\n this.dirtyFormat++;\n return this;\n };\n /**\n * Add a depth texture to the frame buffer.\n * @param texture - Texture to add.\n */\n Framebuffer.prototype.addDepthTexture = function (texture) {\n /* eslint-disable max-len */\n this.depthTexture = texture || new BaseTexture(new DepthResource(null, { width: this.width, height: this.height }), {\n scaleMode: SCALE_MODES.NEAREST,\n resolution: 1,\n width: this.width,\n height: this.height,\n mipmap: MIPMAP_MODES.OFF,\n format: FORMATS.DEPTH_COMPONENT,\n type: TYPES.UNSIGNED_SHORT,\n });\n this.dirtyId++;\n this.dirtyFormat++;\n return this;\n };\n /** Enable depth on the frame buffer. */\n Framebuffer.prototype.enableDepth = function () {\n this.depth = true;\n this.dirtyId++;\n this.dirtyFormat++;\n return this;\n };\n /** Enable stencil on the frame buffer. */\n Framebuffer.prototype.enableStencil = function () {\n this.stencil = true;\n this.dirtyId++;\n this.dirtyFormat++;\n return this;\n };\n /**\n * Resize the frame buffer\n * @param width - Width of the frame buffer to resize to\n * @param height - Height of the frame buffer to resize to\n */\n Framebuffer.prototype.resize = function (width, height) {\n width = Math.round(width);\n height = Math.round(height);\n if (width === this.width && height === this.height)\n { return; }\n this.width = width;\n this.height = height;\n this.dirtyId++;\n this.dirtySize++;\n for (var i = 0; i < this.colorTextures.length; i++) {\n var texture = this.colorTextures[i];\n var resolution = texture.resolution;\n // take into account the fact the texture may have a different resolution..\n texture.setSize(width / resolution, height / resolution);\n }\n if (this.depthTexture) {\n var resolution = this.depthTexture.resolution;\n this.depthTexture.setSize(width / resolution, height / resolution);\n }\n };\n /** Disposes WebGL resources that are connected to this geometry. */\n Framebuffer.prototype.dispose = function () {\n this.disposeRunner.emit(this, false);\n };\n /** Destroys and removes the depth texture added to this framebuffer. */\n Framebuffer.prototype.destroyDepthTexture = function () {\n if (this.depthTexture) {\n this.depthTexture.destroy();\n this.depthTexture = null;\n ++this.dirtyId;\n ++this.dirtyFormat;\n }\n };\n return Framebuffer;\n}());\n\n/**\n * A BaseRenderTexture is a special texture that allows any PixiJS display object to be rendered to it.\n *\n * __Hint__: All DisplayObjects (i.e. Sprites) that render to a BaseRenderTexture should be preloaded\n * otherwise black rectangles will be drawn instead.\n *\n * A BaseRenderTexture takes a snapshot of any Display Object given to its render method. The position\n * and rotation of the given Display Objects is ignored. For example:\n *\n * ```js\n * let renderer = PIXI.autoDetectRenderer();\n * let baseRenderTexture = new PIXI.BaseRenderTexture({ width: 800, height: 600 });\n * let renderTexture = new PIXI.RenderTexture(baseRenderTexture);\n * let sprite = PIXI.Sprite.from(\"spinObj_01.png\");\n *\n * sprite.position.x = 800/2;\n * sprite.position.y = 600/2;\n * sprite.anchor.x = 0.5;\n * sprite.anchor.y = 0.5;\n *\n * renderer.render(sprite, {renderTexture});\n * ```\n *\n * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0\n * you can clear the transform\n *\n * ```js\n *\n * sprite.setTransform()\n *\n * let baseRenderTexture = new PIXI.BaseRenderTexture({ width: 100, height: 100 });\n * let renderTexture = new PIXI.RenderTexture(baseRenderTexture);\n *\n * renderer.render(sprite, {renderTexture}); // Renders to center of RenderTexture\n * ```\n * @memberof PIXI\n */\nvar BaseRenderTexture = /** @class */ (function (_super) {\n __extends(BaseRenderTexture, _super);\n /**\n * @param options\n * @param {number} [options.width=100] - The width of the base render texture.\n * @param {number} [options.height=100] - The height of the base render texture.\n * @param {PIXI.SCALE_MODES} [options.scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES}\n * for possible values.\n * @param {number} [options.resolution=PIXI.settings.RESOLUTION] - The resolution / device pixel ratio\n * of the texture being generated.\n * @param {PIXI.MSAA_QUALITY} [options.multisample=PIXI.MSAA_QUALITY.NONE] - The number of samples of the frame buffer.\n */\n function BaseRenderTexture(options) {\n if (options === void 0) { options = {}; }\n var _this = this;\n if (typeof options === 'number') {\n /* eslint-disable prefer-rest-params */\n // Backward compatibility of signature\n var width = arguments[0];\n var height = arguments[1];\n var scaleMode = arguments[2];\n var resolution = arguments[3];\n options = { width: width, height: height, scaleMode: scaleMode, resolution: resolution };\n /* eslint-enable prefer-rest-params */\n }\n options.width = options.width || 100;\n options.height = options.height || 100;\n options.multisample = options.multisample !== undefined ? options.multisample : MSAA_QUALITY.NONE;\n _this = _super.call(this, null, options) || this;\n // Set defaults\n _this.mipmap = MIPMAP_MODES.OFF;\n _this.valid = true;\n _this.clearColor = [0, 0, 0, 0];\n _this.framebuffer = new Framebuffer(_this.realWidth, _this.realHeight)\n .addColorTexture(0, _this);\n _this.framebuffer.multisample = options.multisample;\n // TODO - could this be added the systems?\n _this.maskStack = [];\n _this.filterStack = [{}];\n return _this;\n }\n /**\n * Resizes the BaseRenderTexture.\n * @param desiredWidth - The desired width to resize to.\n * @param desiredHeight - The desired height to resize to.\n */\n BaseRenderTexture.prototype.resize = function (desiredWidth, desiredHeight) {\n this.framebuffer.resize(desiredWidth * this.resolution, desiredHeight * this.resolution);\n this.setRealSize(this.framebuffer.width, this.framebuffer.height);\n };\n /**\n * Frees the texture and framebuffer from WebGL memory without destroying this texture object.\n * This means you can still use the texture later which will upload it to GPU\n * memory again.\n * @fires PIXI.BaseTexture#dispose\n */\n BaseRenderTexture.prototype.dispose = function () {\n this.framebuffer.dispose();\n _super.prototype.dispose.call(this);\n };\n /** Destroys this texture. */\n BaseRenderTexture.prototype.destroy = function () {\n _super.prototype.destroy.call(this);\n this.framebuffer.destroyDepthTexture();\n this.framebuffer = null;\n };\n return BaseRenderTexture;\n}(BaseTexture));\n\n/**\n * Stores a texture's frame in UV coordinates, in\n * which everything lies in the rectangle `[(0,0), (1,0),\n * (1,1), (0,1)]`.\n *\n * | Corner | Coordinates |\n * |--------------|-------------|\n * | Top-Left | `(x0,y0)` |\n * | Top-Right | `(x1,y1)` |\n * | Bottom-Right | `(x2,y2)` |\n * | Bottom-Left | `(x3,y3)` |\n * @protected\n * @memberof PIXI\n */\nvar TextureUvs = /** @class */ (function () {\n function TextureUvs() {\n this.x0 = 0;\n this.y0 = 0;\n this.x1 = 1;\n this.y1 = 0;\n this.x2 = 1;\n this.y2 = 1;\n this.x3 = 0;\n this.y3 = 1;\n this.uvsFloat32 = new Float32Array(8);\n }\n /**\n * Sets the texture Uvs based on the given frame information.\n * @protected\n * @param frame - The frame of the texture\n * @param baseFrame - The base frame of the texture\n * @param rotate - Rotation of frame, see {@link PIXI.groupD8}\n */\n TextureUvs.prototype.set = function (frame, baseFrame, rotate) {\n var tw = baseFrame.width;\n var th = baseFrame.height;\n if (rotate) {\n // width and height div 2 div baseFrame size\n var w2 = frame.width / 2 / tw;\n var h2 = frame.height / 2 / th;\n // coordinates of center\n var cX = (frame.x / tw) + w2;\n var cY = (frame.y / th) + h2;\n rotate = groupD8.add(rotate, groupD8.NW); // NW is top-left corner\n this.x0 = cX + (w2 * groupD8.uX(rotate));\n this.y0 = cY + (h2 * groupD8.uY(rotate));\n rotate = groupD8.add(rotate, 2); // rotate 90 degrees clockwise\n this.x1 = cX + (w2 * groupD8.uX(rotate));\n this.y1 = cY + (h2 * groupD8.uY(rotate));\n rotate = groupD8.add(rotate, 2);\n this.x2 = cX + (w2 * groupD8.uX(rotate));\n this.y2 = cY + (h2 * groupD8.uY(rotate));\n rotate = groupD8.add(rotate, 2);\n this.x3 = cX + (w2 * groupD8.uX(rotate));\n this.y3 = cY + (h2 * groupD8.uY(rotate));\n }\n else {\n this.x0 = frame.x / tw;\n this.y0 = frame.y / th;\n this.x1 = (frame.x + frame.width) / tw;\n this.y1 = frame.y / th;\n this.x2 = (frame.x + frame.width) / tw;\n this.y2 = (frame.y + frame.height) / th;\n this.x3 = frame.x / tw;\n this.y3 = (frame.y + frame.height) / th;\n }\n this.uvsFloat32[0] = this.x0;\n this.uvsFloat32[1] = this.y0;\n this.uvsFloat32[2] = this.x1;\n this.uvsFloat32[3] = this.y1;\n this.uvsFloat32[4] = this.x2;\n this.uvsFloat32[5] = this.y2;\n this.uvsFloat32[6] = this.x3;\n this.uvsFloat32[7] = this.y3;\n };\n TextureUvs.prototype.toString = function () {\n return \"[@pixi/core:TextureUvs \"\n + (\"x0=\" + this.x0 + \" y0=\" + this.y0 + \" \")\n + (\"x1=\" + this.x1 + \" y1=\" + this.y1 + \" x2=\" + this.x2 + \" \")\n + (\"y2=\" + this.y2 + \" x3=\" + this.x3 + \" y3=\" + this.y3)\n + \"]\";\n };\n return TextureUvs;\n}());\n\nvar DEFAULT_UVS = new TextureUvs();\n/**\n * Used to remove listeners from WHITE and EMPTY Textures\n * @ignore\n */\nfunction removeAllHandlers(tex) {\n tex.destroy = function _emptyDestroy() { };\n tex.on = function _emptyOn() { };\n tex.once = function _emptyOnce() { };\n tex.emit = function _emptyEmit() { };\n}\n/**\n * A texture stores the information that represents an image or part of an image.\n *\n * It cannot be added to the display list directly; instead use it as the texture for a Sprite.\n * If no frame is provided for a texture, then the whole image is used.\n *\n * You can directly create a texture from an image and then reuse it multiple times like this :\n *\n * ```js\n * let texture = PIXI.Texture.from('assets/image.png');\n * let sprite1 = new PIXI.Sprite(texture);\n * let sprite2 = new PIXI.Sprite(texture);\n * ```\n *\n * If you didnt pass the texture frame to constructor, it enables `noFrame` mode:\n * it subscribes on baseTexture events, it automatically resizes at the same time as baseTexture.\n *\n * Textures made from SVGs, loaded or not, cannot be used before the file finishes processing.\n * You can check for this by checking the sprite's _textureID property.\n * ```js\n * var texture = PIXI.Texture.from('assets/image.svg');\n * var sprite1 = new PIXI.Sprite(texture);\n * //sprite1._textureID should not be undefined if the texture has finished processing the SVG file\n * ```\n * You can use a ticker or rAF to ensure your sprites load the finished textures after processing. See issue #3068.\n * @memberof PIXI\n * @typeParam R - The BaseTexture's Resource type.\n */\nvar Texture = /** @class */ (function (_super) {\n __extends(Texture, _super);\n /**\n * @param baseTexture - The base texture source to create the texture from\n * @param frame - The rectangle frame of the texture to show\n * @param orig - The area of original texture\n * @param trim - Trimmed rectangle of original texture\n * @param rotate - indicates how the texture was rotated by texture packer. See {@link PIXI.groupD8}\n * @param anchor - Default anchor point used for sprite placement / rotation\n */\n function Texture(baseTexture, frame, orig, trim, rotate, anchor) {\n var _this = _super.call(this) || this;\n _this.noFrame = false;\n if (!frame) {\n _this.noFrame = true;\n frame = new Rectangle(0, 0, 1, 1);\n }\n if (baseTexture instanceof Texture) {\n baseTexture = baseTexture.baseTexture;\n }\n _this.baseTexture = baseTexture;\n _this._frame = frame;\n _this.trim = trim;\n _this.valid = false;\n _this._uvs = DEFAULT_UVS;\n _this.uvMatrix = null;\n _this.orig = orig || frame; // new Rectangle(0, 0, 1, 1);\n _this._rotate = Number(rotate || 0);\n if (rotate === true) {\n // this is old texturepacker legacy, some games/libraries are passing \"true\" for rotated textures\n _this._rotate = 2;\n }\n else if (_this._rotate % 2 !== 0) {\n throw new Error('attempt to use diamond-shaped UVs. If you are sure, set rotation manually');\n }\n _this.defaultAnchor = anchor ? new Point(anchor.x, anchor.y) : new Point(0, 0);\n _this._updateID = 0;\n _this.textureCacheIds = [];\n if (!baseTexture.valid) {\n baseTexture.once('loaded', _this.onBaseTextureUpdated, _this);\n }\n else if (_this.noFrame) {\n // if there is no frame we should monitor for any base texture changes..\n if (baseTexture.valid) {\n _this.onBaseTextureUpdated(baseTexture);\n }\n }\n else {\n _this.frame = frame;\n }\n if (_this.noFrame) {\n baseTexture.on('update', _this.onBaseTextureUpdated, _this);\n }\n return _this;\n }\n /**\n * Updates this texture on the gpu.\n *\n * Calls the TextureResource update.\n *\n * If you adjusted `frame` manually, please call `updateUvs()` instead.\n */\n Texture.prototype.update = function () {\n if (this.baseTexture.resource) {\n this.baseTexture.resource.update();\n }\n };\n /**\n * Called when the base texture is updated\n * @protected\n * @param baseTexture - The base texture.\n */\n Texture.prototype.onBaseTextureUpdated = function (baseTexture) {\n if (this.noFrame) {\n if (!this.baseTexture.valid) {\n return;\n }\n this._frame.width = baseTexture.width;\n this._frame.height = baseTexture.height;\n this.valid = true;\n this.updateUvs();\n }\n else {\n // TODO this code looks confusing.. boo to abusing getters and setters!\n // if user gave us frame that has bigger size than resized texture it can be a problem\n this.frame = this._frame;\n }\n this.emit('update', this);\n };\n /**\n * Destroys this texture\n * @param [destroyBase=false] - Whether to destroy the base texture as well\n */\n Texture.prototype.destroy = function (destroyBase) {\n if (this.baseTexture) {\n if (destroyBase) {\n var resource = this.baseTexture.resource;\n // delete the texture if it exists in the texture cache..\n // this only needs to be removed if the base texture is actually destroyed too..\n if (resource && resource.url && TextureCache[resource.url]) {\n Texture.removeFromCache(resource.url);\n }\n this.baseTexture.destroy();\n }\n this.baseTexture.off('loaded', this.onBaseTextureUpdated, this);\n this.baseTexture.off('update', this.onBaseTextureUpdated, this);\n this.baseTexture = null;\n }\n this._frame = null;\n this._uvs = null;\n this.trim = null;\n this.orig = null;\n this.valid = false;\n Texture.removeFromCache(this);\n this.textureCacheIds = null;\n };\n /**\n * Creates a new texture object that acts the same as this one.\n * @returns - The new texture\n */\n Texture.prototype.clone = function () {\n var clonedFrame = this._frame.clone();\n var clonedOrig = this._frame === this.orig ? clonedFrame : this.orig.clone();\n var clonedTexture = new Texture(this.baseTexture, !this.noFrame && clonedFrame, clonedOrig, this.trim && this.trim.clone(), this.rotate, this.defaultAnchor);\n if (this.noFrame) {\n clonedTexture._frame = clonedFrame;\n }\n return clonedTexture;\n };\n /**\n * Updates the internal WebGL UV cache. Use it after you change `frame` or `trim` of the texture.\n * Call it after changing the frame\n */\n Texture.prototype.updateUvs = function () {\n if (this._uvs === DEFAULT_UVS) {\n this._uvs = new TextureUvs();\n }\n this._uvs.set(this._frame, this.baseTexture, this.rotate);\n this._updateID++;\n };\n /**\n * Helper function that creates a new Texture based on the source you provide.\n * The source can be - frame id, image url, video url, canvas element, video element, base texture\n * @param {string|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|PIXI.BaseTexture} source -\n * Source or array of sources to create texture from\n * @param options - See {@link PIXI.BaseTexture}'s constructor for options.\n * @param {string} [options.pixiIdPrefix=pixiid] - If a source has no id, this is the prefix of the generated id\n * @param {boolean} [strict] - Enforce strict-mode, see {@link PIXI.settings.STRICT_TEXTURE_CACHE}.\n * @returns {PIXI.Texture} The newly created texture\n */\n Texture.from = function (source, options, strict) {\n if (options === void 0) { options = {}; }\n if (strict === void 0) { strict = settings.STRICT_TEXTURE_CACHE; }\n var isFrame = typeof source === 'string';\n var cacheId = null;\n if (isFrame) {\n cacheId = source;\n }\n else if (source instanceof BaseTexture) {\n if (!source.cacheId) {\n var prefix = (options && options.pixiIdPrefix) || 'pixiid';\n source.cacheId = prefix + \"-\" + uid();\n BaseTexture.addToCache(source, source.cacheId);\n }\n cacheId = source.cacheId;\n }\n else {\n if (!source._pixiId) {\n var prefix = (options && options.pixiIdPrefix) || 'pixiid';\n source._pixiId = prefix + \"_\" + uid();\n }\n cacheId = source._pixiId;\n }\n var texture = TextureCache[cacheId];\n // Strict-mode rejects invalid cacheIds\n if (isFrame && strict && !texture) {\n throw new Error(\"The cacheId \\\"\" + cacheId + \"\\\" does not exist in TextureCache.\");\n }\n if (!texture && !(source instanceof BaseTexture)) {\n if (!options.resolution) {\n options.resolution = getResolutionOfUrl(source);\n }\n texture = new Texture(new BaseTexture(source, options));\n texture.baseTexture.cacheId = cacheId;\n BaseTexture.addToCache(texture.baseTexture, cacheId);\n Texture.addToCache(texture, cacheId);\n }\n else if (!texture && (source instanceof BaseTexture)) {\n texture = new Texture(source);\n Texture.addToCache(texture, cacheId);\n }\n // lets assume its a base texture!\n return texture;\n };\n /**\n * Useful for loading textures via URLs. Use instead of `Texture.from` because\n * it does a better job of handling failed URLs more effectively. This also ignores\n * `PIXI.settings.STRICT_TEXTURE_CACHE`. Works for Videos, SVGs, Images.\n * @param url - The remote URL or array of URLs to load.\n * @param options - Optional options to include\n * @returns - A Promise that resolves to a Texture.\n */\n Texture.fromURL = function (url, options) {\n var resourceOptions = Object.assign({ autoLoad: false }, options === null || options === void 0 ? void 0 : options.resourceOptions);\n var texture = Texture.from(url, Object.assign({ resourceOptions: resourceOptions }, options), false);\n var resource = texture.baseTexture.resource;\n // The texture was already loaded\n if (texture.baseTexture.valid) {\n return Promise.resolve(texture);\n }\n // Manually load the texture, this should allow users to handle load errors\n return resource.load().then(function () { return Promise.resolve(texture); });\n };\n /**\n * Create a new Texture with a BufferResource from a Float32Array.\n * RGBA values are floats from 0 to 1.\n * @param {Float32Array|Uint8Array} buffer - The optional array to use, if no data\n * is provided, a new Float32Array is created.\n * @param width - Width of the resource\n * @param height - Height of the resource\n * @param options - See {@link PIXI.BaseTexture}'s constructor for options.\n * @returns - The resulting new BaseTexture\n */\n Texture.fromBuffer = function (buffer, width, height, options) {\n return new Texture(BaseTexture.fromBuffer(buffer, width, height, options));\n };\n /**\n * Create a texture from a source and add to the cache.\n * @param {HTMLImageElement|HTMLCanvasElement|string} source - The input source.\n * @param imageUrl - File name of texture, for cache and resolving resolution.\n * @param name - Human readable name for the texture cache. If no name is\n * specified, only `imageUrl` will be used as the cache ID.\n * @param options\n * @returns - Output texture\n */\n Texture.fromLoader = function (source, imageUrl, name, options) {\n var baseTexture = new BaseTexture(source, Object.assign({\n scaleMode: settings.SCALE_MODE,\n resolution: getResolutionOfUrl(imageUrl),\n }, options));\n var resource = baseTexture.resource;\n if (resource instanceof ImageResource) {\n resource.url = imageUrl;\n }\n var texture = new Texture(baseTexture);\n // No name, use imageUrl instead\n if (!name) {\n name = imageUrl;\n }\n // lets also add the frame to pixi's global cache for 'fromLoader' function\n BaseTexture.addToCache(texture.baseTexture, name);\n Texture.addToCache(texture, name);\n // also add references by url if they are different.\n if (name !== imageUrl) {\n BaseTexture.addToCache(texture.baseTexture, imageUrl);\n Texture.addToCache(texture, imageUrl);\n }\n // Generally images are valid right away\n if (texture.baseTexture.valid) {\n return Promise.resolve(texture);\n }\n // SVG assets need to be parsed async, let's wait\n return new Promise(function (resolve) {\n texture.baseTexture.once('loaded', function () { return resolve(texture); });\n });\n };\n /**\n * Adds a Texture to the global TextureCache. This cache is shared across the whole PIXI object.\n * @param texture - The Texture to add to the cache.\n * @param id - The id that the Texture will be stored against.\n */\n Texture.addToCache = function (texture, id) {\n if (id) {\n if (texture.textureCacheIds.indexOf(id) === -1) {\n texture.textureCacheIds.push(id);\n }\n if (TextureCache[id]) {\n // eslint-disable-next-line no-console\n console.warn(\"Texture added to the cache with an id [\" + id + \"] that already had an entry\");\n }\n TextureCache[id] = texture;\n }\n };\n /**\n * Remove a Texture from the global TextureCache.\n * @param texture - id of a Texture to be removed, or a Texture instance itself\n * @returns - The Texture that was removed\n */\n Texture.removeFromCache = function (texture) {\n if (typeof texture === 'string') {\n var textureFromCache = TextureCache[texture];\n if (textureFromCache) {\n var index = textureFromCache.textureCacheIds.indexOf(texture);\n if (index > -1) {\n textureFromCache.textureCacheIds.splice(index, 1);\n }\n delete TextureCache[texture];\n return textureFromCache;\n }\n }\n else if (texture && texture.textureCacheIds) {\n for (var i = 0; i < texture.textureCacheIds.length; ++i) {\n // Check that texture matches the one being passed in before deleting it from the cache.\n if (TextureCache[texture.textureCacheIds[i]] === texture) {\n delete TextureCache[texture.textureCacheIds[i]];\n }\n }\n texture.textureCacheIds.length = 0;\n return texture;\n }\n return null;\n };\n Object.defineProperty(Texture.prototype, \"resolution\", {\n /**\n * Returns resolution of baseTexture\n * @readonly\n */\n get: function () {\n return this.baseTexture.resolution;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Texture.prototype, \"frame\", {\n /**\n * The frame specifies the region of the base texture that this texture uses.\n * Please call `updateUvs()` after you change coordinates of `frame` manually.\n */\n get: function () {\n return this._frame;\n },\n set: function (frame) {\n this._frame = frame;\n this.noFrame = false;\n var x = frame.x, y = frame.y, width = frame.width, height = frame.height;\n var xNotFit = x + width > this.baseTexture.width;\n var yNotFit = y + height > this.baseTexture.height;\n if (xNotFit || yNotFit) {\n var relationship = xNotFit && yNotFit ? 'and' : 'or';\n var errorX = \"X: \" + x + \" + \" + width + \" = \" + (x + width) + \" > \" + this.baseTexture.width;\n var errorY = \"Y: \" + y + \" + \" + height + \" = \" + (y + height) + \" > \" + this.baseTexture.height;\n throw new Error('Texture Error: frame does not fit inside the base Texture dimensions: '\n + (errorX + \" \" + relationship + \" \" + errorY));\n }\n this.valid = width && height && this.baseTexture.valid;\n if (!this.trim && !this.rotate) {\n this.orig = frame;\n }\n if (this.valid) {\n this.updateUvs();\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Texture.prototype, \"rotate\", {\n /**\n * Indicates whether the texture is rotated inside the atlas\n * set to 2 to compensate for texture packer rotation\n * set to 6 to compensate for spine packer rotation\n * can be used to rotate or mirror sprites\n * See {@link PIXI.groupD8} for explanation\n */\n get: function () {\n return this._rotate;\n },\n set: function (rotate) {\n this._rotate = rotate;\n if (this.valid) {\n this.updateUvs();\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Texture.prototype, \"width\", {\n /** The width of the Texture in pixels. */\n get: function () {\n return this.orig.width;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Texture.prototype, \"height\", {\n /** The height of the Texture in pixels. */\n get: function () {\n return this.orig.height;\n },\n enumerable: false,\n configurable: true\n });\n /** Utility function for BaseTexture|Texture cast. */\n Texture.prototype.castToBaseTexture = function () {\n return this.baseTexture;\n };\n Object.defineProperty(Texture, \"EMPTY\", {\n /** An empty texture, used often to not have to create multiple empty textures. Can not be destroyed. */\n get: function () {\n if (!Texture._EMPTY) {\n Texture._EMPTY = new Texture(new BaseTexture());\n removeAllHandlers(Texture._EMPTY);\n removeAllHandlers(Texture._EMPTY.baseTexture);\n }\n return Texture._EMPTY;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Texture, \"WHITE\", {\n /** A white texture of 16x16 size, used for graphics and other things Can not be destroyed. */\n get: function () {\n if (!Texture._WHITE) {\n var canvas = settings.ADAPTER.createCanvas(16, 16);\n var context = canvas.getContext('2d');\n canvas.width = 16;\n canvas.height = 16;\n context.fillStyle = 'white';\n context.fillRect(0, 0, 16, 16);\n Texture._WHITE = new Texture(BaseTexture.from(canvas));\n removeAllHandlers(Texture._WHITE);\n removeAllHandlers(Texture._WHITE.baseTexture);\n }\n return Texture._WHITE;\n },\n enumerable: false,\n configurable: true\n });\n return Texture;\n}(EventEmitter));\n\n/**\n * A RenderTexture is a special texture that allows any PixiJS display object to be rendered to it.\n *\n * __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded\n * otherwise black rectangles will be drawn instead.\n *\n * __Hint-2__: The actual memory allocation will happen on first render.\n * You shouldn't create renderTextures each frame just to delete them after, try to reuse them.\n *\n * A RenderTexture takes a snapshot of any Display Object given to its render method. For example:\n *\n * ```js\n * let renderer = PIXI.autoDetectRenderer();\n * let renderTexture = PIXI.RenderTexture.create({ width: 800, height: 600 });\n * let sprite = PIXI.Sprite.from(\"spinObj_01.png\");\n *\n * sprite.position.x = 800/2;\n * sprite.position.y = 600/2;\n * sprite.anchor.x = 0.5;\n * sprite.anchor.y = 0.5;\n *\n * renderer.render(sprite, {renderTexture});\n * ```\n * Note that you should not create a new renderer, but reuse the same one as the rest of the application.\n *\n * The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0\n * you can clear the transform\n *\n * ```js\n *\n * sprite.setTransform()\n *\n * let renderTexture = new PIXI.RenderTexture.create({ width: 100, height: 100 });\n *\n * renderer.render(sprite, {renderTexture}); // Renders to center of RenderTexture\n * ```\n * @memberof PIXI\n */\nvar RenderTexture = /** @class */ (function (_super) {\n __extends(RenderTexture, _super);\n /**\n * @param baseRenderTexture - The base texture object that this texture uses.\n * @param frame - The rectangle frame of the texture to show.\n */\n function RenderTexture(baseRenderTexture, frame) {\n var _this = _super.call(this, baseRenderTexture, frame) || this;\n _this.valid = true;\n _this.filterFrame = null;\n _this.filterPoolKey = null;\n _this.updateUvs();\n return _this;\n }\n Object.defineProperty(RenderTexture.prototype, \"framebuffer\", {\n /**\n * Shortcut to `this.baseTexture.framebuffer`, saves baseTexture cast.\n * @readonly\n */\n get: function () {\n return this.baseTexture.framebuffer;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(RenderTexture.prototype, \"multisample\", {\n /**\n * Shortcut to `this.framebuffer.multisample`.\n * @default PIXI.MSAA_QUALITY.NONE\n */\n get: function () {\n return this.framebuffer.multisample;\n },\n set: function (value) {\n this.framebuffer.multisample = value;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Resizes the RenderTexture.\n * @param desiredWidth - The desired width to resize to.\n * @param desiredHeight - The desired height to resize to.\n * @param resizeBaseTexture - Should the baseTexture.width and height values be resized as well?\n */\n RenderTexture.prototype.resize = function (desiredWidth, desiredHeight, resizeBaseTexture) {\n if (resizeBaseTexture === void 0) { resizeBaseTexture = true; }\n var resolution = this.baseTexture.resolution;\n var width = Math.round(desiredWidth * resolution) / resolution;\n var height = Math.round(desiredHeight * resolution) / resolution;\n // TODO - could be not required..\n this.valid = (width > 0 && height > 0);\n this._frame.width = this.orig.width = width;\n this._frame.height = this.orig.height = height;\n if (resizeBaseTexture) {\n this.baseTexture.resize(width, height);\n }\n this.updateUvs();\n };\n /**\n * Changes the resolution of baseTexture, but does not change framebuffer size.\n * @param resolution - The new resolution to apply to RenderTexture\n */\n RenderTexture.prototype.setResolution = function (resolution) {\n var baseTexture = this.baseTexture;\n if (baseTexture.resolution === resolution) {\n return;\n }\n baseTexture.setResolution(resolution);\n this.resize(baseTexture.width, baseTexture.height, false);\n };\n RenderTexture.create = function (options) {\n var arguments$1 = arguments;\n\n var rest = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n rest[_i - 1] = arguments$1[_i];\n }\n // @deprecated fallback, old-style: create(width, height, scaleMode, resolution)\n if (typeof options === 'number') {\n deprecation('6.0.0', 'Arguments (width, height, scaleMode, resolution) have been deprecated.');\n /* eslint-disable prefer-rest-params */\n options = {\n width: options,\n height: rest[0],\n scaleMode: rest[1],\n resolution: rest[2],\n };\n /* eslint-enable prefer-rest-params */\n }\n return new RenderTexture(new BaseRenderTexture(options));\n };\n return RenderTexture;\n}(Texture));\n\n/**\n * Texture pool, used by FilterSystem and plugins.\n *\n * Stores collection of temporary pow2 or screen-sized renderTextures\n *\n * If you use custom RenderTexturePool for your filters, you can use methods\n * `getFilterTexture` and `returnFilterTexture` same as in\n * @memberof PIXI\n */\nvar RenderTexturePool = /** @class */ (function () {\n /**\n * @param textureOptions - options that will be passed to BaseRenderTexture constructor\n * @param {PIXI.SCALE_MODES} [textureOptions.scaleMode] - See {@link PIXI.SCALE_MODES} for possible values.\n */\n function RenderTexturePool(textureOptions) {\n this.texturePool = {};\n this.textureOptions = textureOptions || {};\n this.enableFullScreen = false;\n this._pixelsWidth = 0;\n this._pixelsHeight = 0;\n }\n /**\n * Creates texture with params that were specified in pool constructor.\n * @param realWidth - Width of texture in pixels.\n * @param realHeight - Height of texture in pixels.\n * @param multisample - Number of samples of the framebuffer.\n */\n RenderTexturePool.prototype.createTexture = function (realWidth, realHeight, multisample) {\n if (multisample === void 0) { multisample = MSAA_QUALITY.NONE; }\n var baseRenderTexture = new BaseRenderTexture(Object.assign({\n width: realWidth,\n height: realHeight,\n resolution: 1,\n multisample: multisample,\n }, this.textureOptions));\n return new RenderTexture(baseRenderTexture);\n };\n /**\n * Gets a Power-of-Two render texture or fullScreen texture\n * @param minWidth - The minimum width of the render texture.\n * @param minHeight - The minimum height of the render texture.\n * @param resolution - The resolution of the render texture.\n * @param multisample - Number of samples of the render texture.\n * @returns The new render texture.\n */\n RenderTexturePool.prototype.getOptimalTexture = function (minWidth, minHeight, resolution, multisample) {\n if (resolution === void 0) { resolution = 1; }\n if (multisample === void 0) { multisample = MSAA_QUALITY.NONE; }\n var key;\n minWidth = Math.ceil((minWidth * resolution) - 1e-6);\n minHeight = Math.ceil((minHeight * resolution) - 1e-6);\n if (!this.enableFullScreen || minWidth !== this._pixelsWidth || minHeight !== this._pixelsHeight) {\n minWidth = nextPow2(minWidth);\n minHeight = nextPow2(minHeight);\n key = (((minWidth & 0xFFFF) << 16) | (minHeight & 0xFFFF)) >>> 0;\n if (multisample > 1) {\n key += multisample * 0x100000000;\n }\n }\n else {\n key = multisample > 1 ? -multisample : -1;\n }\n if (!this.texturePool[key]) {\n this.texturePool[key] = [];\n }\n var renderTexture = this.texturePool[key].pop();\n if (!renderTexture) {\n renderTexture = this.createTexture(minWidth, minHeight, multisample);\n }\n renderTexture.filterPoolKey = key;\n renderTexture.setResolution(resolution);\n return renderTexture;\n };\n /**\n * Gets extra texture of the same size as input renderTexture\n *\n * `getFilterTexture(input, 0.5)` or `getFilterTexture(0.5, input)`\n * @param input - renderTexture from which size and resolution will be copied\n * @param resolution - override resolution of the renderTexture\n * It overrides, it does not multiply\n * @param multisample - number of samples of the renderTexture\n */\n RenderTexturePool.prototype.getFilterTexture = function (input, resolution, multisample) {\n var filterTexture = this.getOptimalTexture(input.width, input.height, resolution || input.resolution, multisample || MSAA_QUALITY.NONE);\n filterTexture.filterFrame = input.filterFrame;\n return filterTexture;\n };\n /**\n * Place a render texture back into the pool.\n * @param renderTexture - The renderTexture to free\n */\n RenderTexturePool.prototype.returnTexture = function (renderTexture) {\n var key = renderTexture.filterPoolKey;\n renderTexture.filterFrame = null;\n this.texturePool[key].push(renderTexture);\n };\n /**\n * Alias for returnTexture, to be compliant with FilterSystem interface.\n * @param renderTexture - The renderTexture to free\n */\n RenderTexturePool.prototype.returnFilterTexture = function (renderTexture) {\n this.returnTexture(renderTexture);\n };\n /**\n * Clears the pool.\n * @param destroyTextures - Destroy all stored textures.\n */\n RenderTexturePool.prototype.clear = function (destroyTextures) {\n destroyTextures = destroyTextures !== false;\n if (destroyTextures) {\n for (var i in this.texturePool) {\n var textures = this.texturePool[i];\n if (textures) {\n for (var j = 0; j < textures.length; j++) {\n textures[j].destroy(true);\n }\n }\n }\n }\n this.texturePool = {};\n };\n /**\n * If screen size was changed, drops all screen-sized textures,\n * sets new screen size, sets `enableFullScreen` to true\n *\n * Size is measured in pixels, `renderer.view` can be passed here, not `renderer.screen`\n * @param size - Initial size of screen.\n */\n RenderTexturePool.prototype.setScreenSize = function (size) {\n if (size.width === this._pixelsWidth\n && size.height === this._pixelsHeight) {\n return;\n }\n this.enableFullScreen = size.width > 0 && size.height > 0;\n for (var i in this.texturePool) {\n if (!(Number(i) < 0)) {\n continue;\n }\n var textures = this.texturePool[i];\n if (textures) {\n for (var j = 0; j < textures.length; j++) {\n textures[j].destroy(true);\n }\n }\n this.texturePool[i] = [];\n }\n this._pixelsWidth = size.width;\n this._pixelsHeight = size.height;\n };\n /**\n * Key that is used to store fullscreen renderTextures in a pool\n * @constant\n */\n RenderTexturePool.SCREEN_KEY = -1;\n return RenderTexturePool;\n}());\n\n/* eslint-disable max-len */\n/**\n * Holds the information for a single attribute structure required to render geometry.\n *\n * This does not contain the actual data, but instead has a buffer id that maps to a {@link PIXI.Buffer}\n * This can include anything from positions, uvs, normals, colors etc.\n * @memberof PIXI\n */\nvar Attribute = /** @class */ (function () {\n /**\n * @param buffer - the id of the buffer that this attribute will look for\n * @param size - the size of the attribute. If you have 2 floats per vertex (eg position x and y) this would be 2.\n * @param normalized - should the data be normalized.\n * @param {PIXI.TYPES} [type=PIXI.TYPES.FLOAT] - what type of number is the attribute. Check {@link PIXI.TYPES} to see the ones available\n * @param [stride=0] - How far apart, in bytes, the start of each value is. (used for interleaving data)\n * @param [start=0] - How far into the array to start reading values (used for interleaving data)\n * @param [instance=false] - Whether the geometry is instanced.\n */\n function Attribute(buffer, size, normalized, type, stride, start, instance) {\n if (size === void 0) { size = 0; }\n if (normalized === void 0) { normalized = false; }\n if (type === void 0) { type = TYPES.FLOAT; }\n this.buffer = buffer;\n this.size = size;\n this.normalized = normalized;\n this.type = type;\n this.stride = stride;\n this.start = start;\n this.instance = instance;\n }\n /** Destroys the Attribute. */\n Attribute.prototype.destroy = function () {\n this.buffer = null;\n };\n /**\n * Helper function that creates an Attribute based on the information provided\n * @param buffer - the id of the buffer that this attribute will look for\n * @param [size=0] - the size of the attribute. If you have 2 floats per vertex (eg position x and y) this would be 2\n * @param [normalized=false] - should the data be normalized.\n * @param [type=PIXI.TYPES.FLOAT] - what type of number is the attribute. Check {@link PIXI.TYPES} to see the ones available\n * @param [stride=0] - How far apart, in bytes, the start of each value is. (used for interleaving data)\n * @returns - A new {@link PIXI.Attribute} based on the information provided\n */\n Attribute.from = function (buffer, size, normalized, type, stride) {\n return new Attribute(buffer, size, normalized, type, stride);\n };\n return Attribute;\n}());\n\nvar UID$4 = 0;\n/**\n * A wrapper for data so that it can be used and uploaded by WebGL\n * @memberof PIXI\n */\nvar Buffer = /** @class */ (function () {\n /**\n * @param {PIXI.IArrayBuffer} data - the data to store in the buffer.\n * @param _static - `true` for static buffer\n * @param index - `true` for index buffer\n */\n function Buffer(data, _static, index) {\n if (_static === void 0) { _static = true; }\n if (index === void 0) { index = false; }\n this.data = (data || new Float32Array(1));\n this._glBuffers = {};\n this._updateID = 0;\n this.index = index;\n this.static = _static;\n this.id = UID$4++;\n this.disposeRunner = new Runner('disposeBuffer');\n }\n // TODO could explore flagging only a partial upload?\n /**\n * Flags this buffer as requiring an upload to the GPU.\n * @param {PIXI.IArrayBuffer|number[]} [data] - the data to update in the buffer.\n */\n Buffer.prototype.update = function (data) {\n if (data instanceof Array) {\n data = new Float32Array(data);\n }\n this.data = data || this.data;\n this._updateID++;\n };\n /** Disposes WebGL resources that are connected to this geometry. */\n Buffer.prototype.dispose = function () {\n this.disposeRunner.emit(this, false);\n };\n /** Destroys the buffer. */\n Buffer.prototype.destroy = function () {\n this.dispose();\n this.data = null;\n };\n Object.defineProperty(Buffer.prototype, \"index\", {\n get: function () {\n return this.type === BUFFER_TYPE.ELEMENT_ARRAY_BUFFER;\n },\n /**\n * Flags whether this is an index buffer.\n *\n * Index buffers are of type `ELEMENT_ARRAY_BUFFER`. Note that setting this property to false will make\n * the buffer of type `ARRAY_BUFFER`.\n *\n * For backwards compatibility.\n */\n set: function (value) {\n this.type = value ? BUFFER_TYPE.ELEMENT_ARRAY_BUFFER : BUFFER_TYPE.ARRAY_BUFFER;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Helper function that creates a buffer based on an array or TypedArray\n * @param {ArrayBufferView | number[]} data - the TypedArray that the buffer will store. If this is a regular Array it will be converted to a Float32Array.\n * @returns - A new Buffer based on the data provided.\n */\n Buffer.from = function (data) {\n if (data instanceof Array) {\n data = new Float32Array(data);\n }\n return new Buffer(data);\n };\n return Buffer;\n}());\n\n/* eslint-disable object-shorthand */\nvar map$1 = {\n Float32Array: Float32Array,\n Uint32Array: Uint32Array,\n Int32Array: Int32Array,\n Uint8Array: Uint8Array,\n};\nfunction interleaveTypedArrays(arrays, sizes) {\n var outSize = 0;\n var stride = 0;\n var views = {};\n for (var i = 0; i < arrays.length; i++) {\n stride += sizes[i];\n outSize += arrays[i].length;\n }\n var buffer = new ArrayBuffer(outSize * 4);\n var out = null;\n var littleOffset = 0;\n for (var i = 0; i < arrays.length; i++) {\n var size = sizes[i];\n var array = arrays[i];\n var type = getBufferType(array);\n if (!views[type]) {\n views[type] = new map$1[type](buffer);\n }\n out = views[type];\n for (var j = 0; j < array.length; j++) {\n var indexStart = ((j / size | 0) * stride) + littleOffset;\n var index = j % size;\n out[indexStart + index] = array[j];\n }\n littleOffset += size;\n }\n return new Float32Array(buffer);\n}\n\nvar byteSizeMap$1 = { 5126: 4, 5123: 2, 5121: 1 };\nvar UID$3 = 0;\n/* eslint-disable object-shorthand */\nvar map = {\n Float32Array: Float32Array,\n Uint32Array: Uint32Array,\n Int32Array: Int32Array,\n Uint8Array: Uint8Array,\n Uint16Array: Uint16Array,\n};\n/* eslint-disable max-len */\n/**\n * The Geometry represents a model. It consists of two components:\n * - GeometryStyle - The structure of the model such as the attributes layout\n * - GeometryData - the data of the model - this consists of buffers.\n * This can include anything from positions, uvs, normals, colors etc.\n *\n * Geometry can be defined without passing in a style or data if required (thats how I prefer!)\n *\n * ```js\n * let geometry = new PIXI.Geometry();\n *\n * geometry.addAttribute('positions', [0, 0, 100, 0, 100, 100, 0, 100], 2);\n * geometry.addAttribute('uvs', [0,0,1,0,1,1,0,1],2)\n * geometry.addIndex([0,1,2,1,3,2])\n * ```\n * @memberof PIXI\n */\nvar Geometry = /** @class */ (function () {\n /**\n * @param buffers - An array of buffers. optional.\n * @param attributes - Of the geometry, optional structure of the attributes layout\n */\n function Geometry(buffers, attributes) {\n if (buffers === void 0) { buffers = []; }\n if (attributes === void 0) { attributes = {}; }\n this.buffers = buffers;\n this.indexBuffer = null;\n this.attributes = attributes;\n this.glVertexArrayObjects = {};\n this.id = UID$3++;\n this.instanced = false;\n this.instanceCount = 1;\n this.disposeRunner = new Runner('disposeGeometry');\n this.refCount = 0;\n }\n /**\n *\n * Adds an attribute to the geometry\n * Note: `stride` and `start` should be `undefined` if you dont know them, not 0!\n * @param id - the name of the attribute (matching up to a shader)\n * @param {PIXI.Buffer|number[]} buffer - the buffer that holds the data of the attribute . You can also provide an Array and a buffer will be created from it.\n * @param size - the size of the attribute. If you have 2 floats per vertex (eg position x and y) this would be 2\n * @param normalized - should the data be normalized.\n * @param [type=PIXI.TYPES.FLOAT] - what type of number is the attribute. Check {PIXI.TYPES} to see the ones available\n * @param [stride=0] - How far apart, in bytes, the start of each value is. (used for interleaving data)\n * @param [start=0] - How far into the array to start reading values (used for interleaving data)\n * @param instance - Instancing flag\n * @returns - Returns self, useful for chaining.\n */\n Geometry.prototype.addAttribute = function (id, buffer, size, normalized, type, stride, start, instance) {\n if (size === void 0) { size = 0; }\n if (normalized === void 0) { normalized = false; }\n if (instance === void 0) { instance = false; }\n if (!buffer) {\n throw new Error('You must pass a buffer when creating an attribute');\n }\n // check if this is a buffer!\n if (!(buffer instanceof Buffer)) {\n // its an array!\n if (buffer instanceof Array) {\n buffer = new Float32Array(buffer);\n }\n buffer = new Buffer(buffer);\n }\n var ids = id.split('|');\n if (ids.length > 1) {\n for (var i = 0; i < ids.length; i++) {\n this.addAttribute(ids[i], buffer, size, normalized, type);\n }\n return this;\n }\n var bufferIndex = this.buffers.indexOf(buffer);\n if (bufferIndex === -1) {\n this.buffers.push(buffer);\n bufferIndex = this.buffers.length - 1;\n }\n this.attributes[id] = new Attribute(bufferIndex, size, normalized, type, stride, start, instance);\n // assuming that if there is instanced data then this will be drawn with instancing!\n this.instanced = this.instanced || instance;\n return this;\n };\n /**\n * Returns the requested attribute.\n * @param id - The name of the attribute required\n * @returns - The attribute requested.\n */\n Geometry.prototype.getAttribute = function (id) {\n return this.attributes[id];\n };\n /**\n * Returns the requested buffer.\n * @param id - The name of the buffer required.\n * @returns - The buffer requested.\n */\n Geometry.prototype.getBuffer = function (id) {\n return this.buffers[this.getAttribute(id).buffer];\n };\n /**\n *\n * Adds an index buffer to the geometry\n * 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.\n * @param {PIXI.Buffer|number[]} [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.\n * @returns - Returns self, useful for chaining.\n */\n Geometry.prototype.addIndex = function (buffer) {\n if (!(buffer instanceof Buffer)) {\n // its an array!\n if (buffer instanceof Array) {\n buffer = new Uint16Array(buffer);\n }\n buffer = new Buffer(buffer);\n }\n buffer.type = BUFFER_TYPE.ELEMENT_ARRAY_BUFFER;\n this.indexBuffer = buffer;\n if (this.buffers.indexOf(buffer) === -1) {\n this.buffers.push(buffer);\n }\n return this;\n };\n /**\n * Returns the index buffer\n * @returns - The index buffer.\n */\n Geometry.prototype.getIndex = function () {\n return this.indexBuffer;\n };\n /**\n * This function modifies the structure so that all current attributes become interleaved into a single buffer\n * This can be useful if your model remains static as it offers a little performance boost\n * @returns - Returns self, useful for chaining.\n */\n Geometry.prototype.interleave = function () {\n // a simple check to see if buffers are already interleaved..\n if (this.buffers.length === 1 || (this.buffers.length === 2 && this.indexBuffer))\n { return this; }\n // assume already that no buffers are interleaved\n var arrays = [];\n var sizes = [];\n var interleavedBuffer = new Buffer();\n var i;\n for (i in this.attributes) {\n var attribute = this.attributes[i];\n var buffer = this.buffers[attribute.buffer];\n arrays.push(buffer.data);\n sizes.push((attribute.size * byteSizeMap$1[attribute.type]) / 4);\n attribute.buffer = 0;\n }\n interleavedBuffer.data = interleaveTypedArrays(arrays, sizes);\n for (i = 0; i < this.buffers.length; i++) {\n if (this.buffers[i] !== this.indexBuffer) {\n this.buffers[i].destroy();\n }\n }\n this.buffers = [interleavedBuffer];\n if (this.indexBuffer) {\n this.buffers.push(this.indexBuffer);\n }\n return this;\n };\n /** Get the size of the geometries, in vertices. */\n Geometry.prototype.getSize = function () {\n for (var i in this.attributes) {\n var attribute = this.attributes[i];\n var buffer = this.buffers[attribute.buffer];\n return buffer.data.length / ((attribute.stride / 4) || attribute.size);\n }\n return 0;\n };\n /** Disposes WebGL resources that are connected to this geometry. */\n Geometry.prototype.dispose = function () {\n this.disposeRunner.emit(this, false);\n };\n /** Destroys the geometry. */\n Geometry.prototype.destroy = function () {\n this.dispose();\n this.buffers = null;\n this.indexBuffer = null;\n this.attributes = null;\n };\n /**\n * Returns a clone of the geometry.\n * @returns - A new clone of this geometry.\n */\n Geometry.prototype.clone = function () {\n var geometry = new Geometry();\n for (var i = 0; i < this.buffers.length; i++) {\n geometry.buffers[i] = new Buffer(this.buffers[i].data.slice(0));\n }\n for (var i in this.attributes) {\n var attrib = this.attributes[i];\n geometry.attributes[i] = new Attribute(attrib.buffer, attrib.size, attrib.normalized, attrib.type, attrib.stride, attrib.start, attrib.instance);\n }\n if (this.indexBuffer) {\n geometry.indexBuffer = geometry.buffers[this.buffers.indexOf(this.indexBuffer)];\n geometry.indexBuffer.type = BUFFER_TYPE.ELEMENT_ARRAY_BUFFER;\n }\n return geometry;\n };\n /**\n * Merges an array of geometries into a new single one.\n *\n * Geometry attribute styles must match for this operation to work.\n * @param geometries - array of geometries to merge\n * @returns - Shiny new geometry!\n */\n Geometry.merge = function (geometries) {\n // todo add a geometry check!\n // also a size check.. cant be too big!]\n var geometryOut = new Geometry();\n var arrays = [];\n var sizes = [];\n var offsets = [];\n var geometry;\n // pass one.. get sizes..\n for (var i = 0; i < geometries.length; i++) {\n geometry = geometries[i];\n for (var j = 0; j < geometry.buffers.length; j++) {\n sizes[j] = sizes[j] || 0;\n sizes[j] += geometry.buffers[j].data.length;\n offsets[j] = 0;\n }\n }\n // build the correct size arrays..\n for (var i = 0; i < geometry.buffers.length; i++) {\n // TODO types!\n arrays[i] = new map[getBufferType(geometry.buffers[i].data)](sizes[i]);\n geometryOut.buffers[i] = new Buffer(arrays[i]);\n }\n // pass to set data..\n for (var i = 0; i < geometries.length; i++) {\n geometry = geometries[i];\n for (var j = 0; j < geometry.buffers.length; j++) {\n arrays[j].set(geometry.buffers[j].data, offsets[j]);\n offsets[j] += geometry.buffers[j].data.length;\n }\n }\n geometryOut.attributes = geometry.attributes;\n if (geometry.indexBuffer) {\n geometryOut.indexBuffer = geometryOut.buffers[geometry.buffers.indexOf(geometry.indexBuffer)];\n geometryOut.indexBuffer.type = BUFFER_TYPE.ELEMENT_ARRAY_BUFFER;\n var offset = 0;\n var stride = 0;\n var offset2 = 0;\n var bufferIndexToCount = 0;\n // get a buffer\n for (var i = 0; i < geometry.buffers.length; i++) {\n if (geometry.buffers[i] !== geometry.indexBuffer) {\n bufferIndexToCount = i;\n break;\n }\n }\n // figure out the stride of one buffer..\n for (var i in geometry.attributes) {\n var attribute = geometry.attributes[i];\n if ((attribute.buffer | 0) === bufferIndexToCount) {\n stride += ((attribute.size * byteSizeMap$1[attribute.type]) / 4);\n }\n }\n // time to off set all indexes..\n for (var i = 0; i < geometries.length; i++) {\n var indexBufferData = geometries[i].indexBuffer.data;\n for (var j = 0; j < indexBufferData.length; j++) {\n geometryOut.indexBuffer.data[j + offset2] += offset;\n }\n offset += geometries[i].buffers[bufferIndexToCount].data.length / (stride);\n offset2 += indexBufferData.length;\n }\n }\n return geometryOut;\n };\n return Geometry;\n}());\n\n/**\n * Helper class to create a quad\n * @memberof PIXI\n */\nvar Quad = /** @class */ (function (_super) {\n __extends(Quad, _super);\n function Quad() {\n var _this = _super.call(this) || this;\n _this.addAttribute('aVertexPosition', new Float32Array([\n 0, 0,\n 1, 0,\n 1, 1,\n 0, 1 ]))\n .addIndex([0, 1, 3, 2]);\n return _this;\n }\n return Quad;\n}(Geometry));\n\n/**\n * Helper class to create a quad with uvs like in v4\n * @memberof PIXI\n */\nvar QuadUv = /** @class */ (function (_super) {\n __extends(QuadUv, _super);\n function QuadUv() {\n var _this = _super.call(this) || this;\n _this.vertices = new Float32Array([\n -1, -1,\n 1, -1,\n 1, 1,\n -1, 1 ]);\n _this.uvs = new Float32Array([\n 0, 0,\n 1, 0,\n 1, 1,\n 0, 1 ]);\n _this.vertexBuffer = new Buffer(_this.vertices);\n _this.uvBuffer = new Buffer(_this.uvs);\n _this.addAttribute('aVertexPosition', _this.vertexBuffer)\n .addAttribute('aTextureCoord', _this.uvBuffer)\n .addIndex([0, 1, 2, 0, 2, 3]);\n return _this;\n }\n /**\n * Maps two Rectangle to the quad.\n * @param targetTextureFrame - The first rectangle\n * @param destinationFrame - The second rectangle\n * @returns - Returns itself.\n */\n QuadUv.prototype.map = function (targetTextureFrame, destinationFrame) {\n var x = 0; // destinationFrame.x / targetTextureFrame.width;\n var y = 0; // destinationFrame.y / targetTextureFrame.height;\n this.uvs[0] = x;\n this.uvs[1] = y;\n this.uvs[2] = x + (destinationFrame.width / targetTextureFrame.width);\n this.uvs[3] = y;\n this.uvs[4] = x + (destinationFrame.width / targetTextureFrame.width);\n this.uvs[5] = y + (destinationFrame.height / targetTextureFrame.height);\n this.uvs[6] = x;\n this.uvs[7] = y + (destinationFrame.height / targetTextureFrame.height);\n x = destinationFrame.x;\n y = destinationFrame.y;\n this.vertices[0] = x;\n this.vertices[1] = y;\n this.vertices[2] = x + destinationFrame.width;\n this.vertices[3] = y;\n this.vertices[4] = x + destinationFrame.width;\n this.vertices[5] = y + destinationFrame.height;\n this.vertices[6] = x;\n this.vertices[7] = y + destinationFrame.height;\n this.invalidate();\n return this;\n };\n /**\n * Legacy upload method, just marks buffers dirty.\n * @returns - Returns itself.\n */\n QuadUv.prototype.invalidate = function () {\n this.vertexBuffer._updateID++;\n this.uvBuffer._updateID++;\n return this;\n };\n return QuadUv;\n}(Geometry));\n\nvar UID$2 = 0;\n/**\n * Uniform group holds uniform map and some ID's for work\n *\n * `UniformGroup` has two modes:\n *\n * 1: Normal mode\n * Normal mode will upload the uniforms with individual function calls as required\n *\n * 2: Uniform buffer mode\n * This mode will treat the uniforms as a uniform buffer. You can pass in either a buffer that you manually handle, or\n * or a generic object that PixiJS will automatically map to a buffer for you.\n * For maximum benefits, make Ubo UniformGroups static, and only update them each frame.\n *\n * Rules of UBOs:\n * - UBOs only work with WebGL2, so make sure you have a fallback!\n * - Only floats are supported (including vec[2,3,4], mat[2,3,4])\n * - Samplers cannot be used in ubo's (a GPU limitation)\n * - You must ensure that the object you pass in exactly matches in the shader ubo structure.\n * Otherwise, weirdness will ensue!\n * - The name of the ubo object added to the group must match exactly the name of the ubo in the shader.\n *\n * ```\n * // ubo in shader:\n * uniform myCoolData { // declaring a ubo..\n * mat4 uCoolMatrix;\n * float uFloatyMcFloatFace\n *\n *\n * // a new uniform buffer object..\n * const myCoolData = new UniformBufferGroup({\n * uCoolMatrix: new Matrix(),\n * uFloatyMcFloatFace: 23,\n * }}\n *\n * // build a shader...\n * const shader = Shader.from(srcVert, srcFrag, {\n * myCoolData // name matches the ubo name in the shader. will be processed accordingly.\n * })\n *\n * ```\n * @memberof PIXI\n */\nvar UniformGroup = /** @class */ (function () {\n /**\n * @param {object | Buffer} [uniforms] - Custom uniforms to use to augment the built-in ones. Or a pixi buffer.\n * @param isStatic - Uniforms wont be changed after creation.\n * @param isUbo - If true, will treat this uniform group as a uniform buffer object.\n */\n function UniformGroup(uniforms, isStatic, isUbo) {\n this.group = true;\n // lets generate this when the shader ?\n this.syncUniforms = {};\n this.dirtyId = 0;\n this.id = UID$2++;\n this.static = !!isStatic;\n this.ubo = !!isUbo;\n if (uniforms instanceof Buffer) {\n this.buffer = uniforms;\n this.buffer.type = BUFFER_TYPE.UNIFORM_BUFFER;\n this.autoManage = false;\n this.ubo = true;\n }\n else {\n this.uniforms = uniforms;\n if (this.ubo) {\n this.buffer = new Buffer(new Float32Array(1));\n this.buffer.type = BUFFER_TYPE.UNIFORM_BUFFER;\n this.autoManage = true;\n }\n }\n }\n UniformGroup.prototype.update = function () {\n this.dirtyId++;\n if (!this.autoManage && this.buffer) {\n this.buffer.update();\n }\n };\n UniformGroup.prototype.add = function (name, uniforms, _static) {\n if (!this.ubo) {\n this.uniforms[name] = new UniformGroup(uniforms, _static);\n }\n else {\n // eslint-disable-next-line max-len\n throw new Error('[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them');\n }\n };\n UniformGroup.from = function (uniforms, _static, _ubo) {\n return new UniformGroup(uniforms, _static, _ubo);\n };\n /**\n * A short hand function for creating a static UBO UniformGroup.\n * @param uniforms - the ubo item\n * @param _static - should this be updated each time it is used? defaults to true here!\n */\n UniformGroup.uboFrom = function (uniforms, _static) {\n return new UniformGroup(uniforms, _static !== null && _static !== void 0 ? _static : true, true);\n };\n return UniformGroup;\n}());\n\n/**\n * System plugin to the renderer to manage filter states.\n * @ignore\n */\nvar FilterState = /** @class */ (function () {\n function FilterState() {\n this.renderTexture = null;\n this.target = null;\n this.legacy = false;\n this.resolution = 1;\n this.multisample = MSAA_QUALITY.NONE;\n // next three fields are created only for root\n // re-assigned for everything else\n this.sourceFrame = new Rectangle();\n this.destinationFrame = new Rectangle();\n this.bindingSourceFrame = new Rectangle();\n this.bindingDestinationFrame = new Rectangle();\n this.filters = [];\n this.transform = null;\n }\n /** Clears the state */\n FilterState.prototype.clear = function () {\n this.target = null;\n this.filters = null;\n this.renderTexture = null;\n };\n return FilterState;\n}());\n\nvar tempPoints = [new Point(), new Point(), new Point(), new Point()];\nvar tempMatrix$2 = new Matrix();\n/**\n * System plugin to the renderer to manage filters.\n *\n * ## Pipeline\n *\n * The FilterSystem executes the filtering pipeline by rendering the display-object into a texture, applying its\n * [filters]{@link PIXI.Filter} in series, and the last filter outputs into the final render-target.\n *\n * The filter-frame is the rectangle in world space being filtered, and those contents are mapped into\n * `(0, 0, filterFrame.width, filterFrame.height)` into the filter render-texture. The filter-frame is also called\n * the source-frame, as it is used to bind the filter render-textures. The last filter outputs to the `filterFrame`\n * in the final render-target.\n *\n * ## Usage\n *\n * {@link PIXI.Container#renderAdvanced} is an example of how to use the filter system. It is a 3 step process:\n *\n * **push**: Use {@link PIXI.FilterSystem#push} to push the set of filters to be applied on a filter-target.\n * **render**: Render the contents to be filtered using the renderer. The filter-system will only capture the contents\n * inside the bounds of the filter-target. NOTE: Using {@link PIXI.Renderer#render} is\n * illegal during an existing render cycle, and it may reset the filter system.\n * **pop**: Use {@link PIXI.FilterSystem#pop} to pop & execute the filters you initially pushed. It will apply them\n * serially and output to the bounds of the filter-target.\n * @memberof PIXI\n */\nvar FilterSystem = /** @class */ (function () {\n /**\n * @param renderer - The renderer this System works for.\n */\n function FilterSystem(renderer) {\n this.renderer = renderer;\n this.defaultFilterStack = [{}];\n this.texturePool = new RenderTexturePool();\n this.texturePool.setScreenSize(renderer.view);\n this.statePool = [];\n this.quad = new Quad();\n this.quadUv = new QuadUv();\n this.tempRect = new Rectangle();\n this.activeState = {};\n this.globalUniforms = new UniformGroup({\n outputFrame: new Rectangle(),\n inputSize: new Float32Array(4),\n inputPixel: new Float32Array(4),\n inputClamp: new Float32Array(4),\n resolution: 1,\n // legacy variables\n filterArea: new Float32Array(4),\n filterClamp: new Float32Array(4),\n }, true);\n this.forceClear = false;\n this.useMaxPadding = false;\n }\n /**\n * Pushes a set of filters to be applied later to the system. This will redirect further rendering into an\n * input render-texture for the rest of the filtering pipeline.\n * @param {PIXI.DisplayObject} target - The target of the filter to render.\n * @param filters - The filters to apply.\n */\n FilterSystem.prototype.push = function (target, filters) {\n var _a, _b;\n var renderer = this.renderer;\n var filterStack = this.defaultFilterStack;\n var state = this.statePool.pop() || new FilterState();\n var renderTextureSystem = this.renderer.renderTexture;\n var resolution = filters[0].resolution;\n var multisample = filters[0].multisample;\n var padding = filters[0].padding;\n var autoFit = filters[0].autoFit;\n // We don't know whether it's a legacy filter until it was bound for the first time,\n // therefore we have to assume that it is if legacy is undefined.\n var legacy = (_a = filters[0].legacy) !== null && _a !== void 0 ? _a : true;\n for (var i = 1; i < filters.length; i++) {\n var filter = filters[i];\n // let's use the lowest resolution\n resolution = Math.min(resolution, filter.resolution);\n // let's use the lowest number of samples\n multisample = Math.min(multisample, filter.multisample);\n // figure out the padding required for filters\n padding = this.useMaxPadding\n // old behavior: use largest amount of padding!\n ? Math.max(padding, filter.padding)\n // new behavior: sum the padding\n : padding + filter.padding;\n // only auto fit if all filters are autofit\n autoFit = autoFit && filter.autoFit;\n legacy = legacy || ((_b = filter.legacy) !== null && _b !== void 0 ? _b : true);\n }\n if (filterStack.length === 1) {\n this.defaultFilterStack[0].renderTexture = renderTextureSystem.current;\n }\n filterStack.push(state);\n state.resolution = resolution;\n state.multisample = multisample;\n state.legacy = legacy;\n state.target = target;\n state.sourceFrame.copyFrom(target.filterArea || target.getBounds(true));\n state.sourceFrame.pad(padding);\n var sourceFrameProjected = this.tempRect.copyFrom(renderTextureSystem.sourceFrame);\n // Project source frame into world space (if projection is applied)\n if (renderer.projection.transform) {\n this.transformAABB(tempMatrix$2.copyFrom(renderer.projection.transform).invert(), sourceFrameProjected);\n }\n if (autoFit) {\n state.sourceFrame.fit(sourceFrameProjected);\n if (state.sourceFrame.width <= 0 || state.sourceFrame.height <= 0) {\n state.sourceFrame.width = 0;\n state.sourceFrame.height = 0;\n }\n }\n else if (!state.sourceFrame.intersects(sourceFrameProjected)) {\n state.sourceFrame.width = 0;\n state.sourceFrame.height = 0;\n }\n // Round sourceFrame in screen space based on render-texture.\n this.roundFrame(state.sourceFrame, renderTextureSystem.current ? renderTextureSystem.current.resolution : renderer.resolution, renderTextureSystem.sourceFrame, renderTextureSystem.destinationFrame, renderer.projection.transform);\n state.renderTexture = this.getOptimalFilterTexture(state.sourceFrame.width, state.sourceFrame.height, resolution, multisample);\n state.filters = filters;\n state.destinationFrame.width = state.renderTexture.width;\n state.destinationFrame.height = state.renderTexture.height;\n var destinationFrame = this.tempRect;\n destinationFrame.x = 0;\n destinationFrame.y = 0;\n destinationFrame.width = state.sourceFrame.width;\n destinationFrame.height = state.sourceFrame.height;\n state.renderTexture.filterFrame = state.sourceFrame;\n state.bindingSourceFrame.copyFrom(renderTextureSystem.sourceFrame);\n state.bindingDestinationFrame.copyFrom(renderTextureSystem.destinationFrame);\n state.transform = renderer.projection.transform;\n renderer.projection.transform = null;\n renderTextureSystem.bind(state.renderTexture, state.sourceFrame, destinationFrame);\n renderer.framebuffer.clear(0, 0, 0, 0);\n };\n /** Pops off the filter and applies it. */\n FilterSystem.prototype.pop = function () {\n var filterStack = this.defaultFilterStack;\n var state = filterStack.pop();\n var filters = state.filters;\n this.activeState = state;\n var globalUniforms = this.globalUniforms.uniforms;\n globalUniforms.outputFrame = state.sourceFrame;\n globalUniforms.resolution = state.resolution;\n var inputSize = globalUniforms.inputSize;\n var inputPixel = globalUniforms.inputPixel;\n var inputClamp = globalUniforms.inputClamp;\n inputSize[0] = state.destinationFrame.width;\n inputSize[1] = state.destinationFrame.height;\n inputSize[2] = 1.0 / inputSize[0];\n inputSize[3] = 1.0 / inputSize[1];\n inputPixel[0] = Math.round(inputSize[0] * state.resolution);\n inputPixel[1] = Math.round(inputSize[1] * state.resolution);\n inputPixel[2] = 1.0 / inputPixel[0];\n inputPixel[3] = 1.0 / inputPixel[1];\n inputClamp[0] = 0.5 * inputPixel[2];\n inputClamp[1] = 0.5 * inputPixel[3];\n inputClamp[2] = (state.sourceFrame.width * inputSize[2]) - (0.5 * inputPixel[2]);\n inputClamp[3] = (state.sourceFrame.height * inputSize[3]) - (0.5 * inputPixel[3]);\n // only update the rect if its legacy..\n if (state.legacy) {\n var filterArea = globalUniforms.filterArea;\n filterArea[0] = state.destinationFrame.width;\n filterArea[1] = state.destinationFrame.height;\n filterArea[2] = state.sourceFrame.x;\n filterArea[3] = state.sourceFrame.y;\n globalUniforms.filterClamp = globalUniforms.inputClamp;\n }\n this.globalUniforms.update();\n var lastState = filterStack[filterStack.length - 1];\n this.renderer.framebuffer.blit();\n if (filters.length === 1) {\n filters[0].apply(this, state.renderTexture, lastState.renderTexture, CLEAR_MODES.BLEND, state);\n this.returnFilterTexture(state.renderTexture);\n }\n else {\n var flip = state.renderTexture;\n var flop = this.getOptimalFilterTexture(flip.width, flip.height, state.resolution);\n flop.filterFrame = flip.filterFrame;\n var i = 0;\n for (i = 0; i < filters.length - 1; ++i) {\n if (i === 1 && state.multisample > 1) {\n flop = this.getOptimalFilterTexture(flip.width, flip.height, state.resolution);\n flop.filterFrame = flip.filterFrame;\n }\n filters[i].apply(this, flip, flop, CLEAR_MODES.CLEAR, state);\n var t = flip;\n flip = flop;\n flop = t;\n }\n filters[i].apply(this, flip, lastState.renderTexture, CLEAR_MODES.BLEND, state);\n if (i > 1 && state.multisample > 1) {\n this.returnFilterTexture(state.renderTexture);\n }\n this.returnFilterTexture(flip);\n this.returnFilterTexture(flop);\n }\n // lastState.renderTexture is blitted when lastState is popped\n state.clear();\n this.statePool.push(state);\n };\n /**\n * Binds a renderTexture with corresponding `filterFrame`, clears it if mode corresponds.\n * @param filterTexture - renderTexture to bind, should belong to filter pool or filter stack\n * @param clearMode - clearMode, by default its CLEAR/YES. See {@link PIXI.CLEAR_MODES}\n */\n FilterSystem.prototype.bindAndClear = function (filterTexture, clearMode) {\n if (clearMode === void 0) { clearMode = CLEAR_MODES.CLEAR; }\n var _a = this.renderer, renderTextureSystem = _a.renderTexture, stateSystem = _a.state;\n if (filterTexture === this.defaultFilterStack[this.defaultFilterStack.length - 1].renderTexture) {\n // Restore projection transform if rendering into the output render-target.\n this.renderer.projection.transform = this.activeState.transform;\n }\n else {\n // Prevent projection within filtering pipeline.\n this.renderer.projection.transform = null;\n }\n if (filterTexture && filterTexture.filterFrame) {\n var destinationFrame = this.tempRect;\n destinationFrame.x = 0;\n destinationFrame.y = 0;\n destinationFrame.width = filterTexture.filterFrame.width;\n destinationFrame.height = filterTexture.filterFrame.height;\n renderTextureSystem.bind(filterTexture, filterTexture.filterFrame, destinationFrame);\n }\n else if (filterTexture !== this.defaultFilterStack[this.defaultFilterStack.length - 1].renderTexture) {\n renderTextureSystem.bind(filterTexture);\n }\n else {\n // Restore binding for output render-target.\n this.renderer.renderTexture.bind(filterTexture, this.activeState.bindingSourceFrame, this.activeState.bindingDestinationFrame);\n }\n // Clear the texture in BLIT mode if blending is disabled or the forceClear flag is set. The blending\n // is stored in the 0th bit of the state.\n var autoClear = (stateSystem.stateId & 1) || this.forceClear;\n if (clearMode === CLEAR_MODES.CLEAR\n || (clearMode === CLEAR_MODES.BLIT && autoClear)) {\n // Use framebuffer.clear because we want to clear the whole filter texture, not just the filtering\n // area over which the shaders are run. This is because filters may sampling outside of it (e.g. blur)\n // instead of clamping their arithmetic.\n this.renderer.framebuffer.clear(0, 0, 0, 0);\n }\n };\n /**\n * Draws a filter using the default rendering process.\n *\n * This should be called only by {@link Filter#apply}.\n * @param filter - The filter to draw.\n * @param input - The input render target.\n * @param output - The target to output to.\n * @param clearMode - Should the output be cleared before rendering to it\n */\n FilterSystem.prototype.applyFilter = function (filter, input, output, clearMode) {\n var renderer = this.renderer;\n // Set state before binding, so bindAndClear gets the blend mode.\n renderer.state.set(filter.state);\n this.bindAndClear(output, clearMode);\n // set the uniforms..\n filter.uniforms.uSampler = input;\n filter.uniforms.filterGlobals = this.globalUniforms;\n // TODO make it so that the order of this does not matter..\n // because it does at the moment cos of global uniforms.\n // they need to get resynced\n renderer.shader.bind(filter);\n // check to see if the filter is a legacy one..\n filter.legacy = !!filter.program.attributeData.aTextureCoord;\n if (filter.legacy) {\n this.quadUv.map(input._frame, input.filterFrame);\n renderer.geometry.bind(this.quadUv);\n renderer.geometry.draw(DRAW_MODES.TRIANGLES);\n }\n else {\n renderer.geometry.bind(this.quad);\n renderer.geometry.draw(DRAW_MODES.TRIANGLE_STRIP);\n }\n };\n /**\n * Multiply _input normalized coordinates_ to this matrix to get _sprite texture normalized coordinates_.\n *\n * Use `outputMatrix * vTextureCoord` in the shader.\n * @param outputMatrix - The matrix to output to.\n * @param {PIXI.Sprite} sprite - The sprite to map to.\n * @returns The mapped matrix.\n */\n FilterSystem.prototype.calculateSpriteMatrix = function (outputMatrix, sprite) {\n var _a = this.activeState, sourceFrame = _a.sourceFrame, destinationFrame = _a.destinationFrame;\n var orig = sprite._texture.orig;\n var mappedMatrix = outputMatrix.set(destinationFrame.width, 0, 0, destinationFrame.height, sourceFrame.x, sourceFrame.y);\n var worldTransform = sprite.worldTransform.copyTo(Matrix.TEMP_MATRIX);\n worldTransform.invert();\n mappedMatrix.prepend(worldTransform);\n mappedMatrix.scale(1.0 / orig.width, 1.0 / orig.height);\n mappedMatrix.translate(sprite.anchor.x, sprite.anchor.y);\n return mappedMatrix;\n };\n /** Destroys this Filter System. */\n FilterSystem.prototype.destroy = function () {\n this.renderer = null;\n // Those textures has to be destroyed by RenderTextureSystem or FramebufferSystem\n this.texturePool.clear(false);\n };\n /**\n * Gets a Power-of-Two render texture or fullScreen texture\n * @param minWidth - The minimum width of the render texture in real pixels.\n * @param minHeight - The minimum height of the render texture in real pixels.\n * @param resolution - The resolution of the render texture.\n * @param multisample - Number of samples of the render texture.\n * @returns - The new render texture.\n */\n FilterSystem.prototype.getOptimalFilterTexture = function (minWidth, minHeight, resolution, multisample) {\n if (resolution === void 0) { resolution = 1; }\n if (multisample === void 0) { multisample = MSAA_QUALITY.NONE; }\n return this.texturePool.getOptimalTexture(minWidth, minHeight, resolution, multisample);\n };\n /**\n * Gets extra render texture to use inside current filter\n * To be compliant with older filters, you can use params in any order\n * @param input - renderTexture from which size and resolution will be copied\n * @param resolution - override resolution of the renderTexture\n * @param multisample - number of samples of the renderTexture\n */\n FilterSystem.prototype.getFilterTexture = function (input, resolution, multisample) {\n if (typeof input === 'number') {\n var swap = input;\n input = resolution;\n resolution = swap;\n }\n input = input || this.activeState.renderTexture;\n var filterTexture = this.texturePool.getOptimalTexture(input.width, input.height, resolution || input.resolution, multisample || MSAA_QUALITY.NONE);\n filterTexture.filterFrame = input.filterFrame;\n return filterTexture;\n };\n /**\n * Frees a render texture back into the pool.\n * @param renderTexture - The renderTarget to free\n */\n FilterSystem.prototype.returnFilterTexture = function (renderTexture) {\n this.texturePool.returnTexture(renderTexture);\n };\n /** Empties the texture pool. */\n FilterSystem.prototype.emptyPool = function () {\n this.texturePool.clear(true);\n };\n /** Calls `texturePool.resize()`, affects fullScreen renderTextures. */\n FilterSystem.prototype.resize = function () {\n this.texturePool.setScreenSize(this.renderer.view);\n };\n /**\n * @param matrix - first param\n * @param rect - second param\n */\n FilterSystem.prototype.transformAABB = function (matrix, rect) {\n var lt = tempPoints[0];\n var lb = tempPoints[1];\n var rt = tempPoints[2];\n var rb = tempPoints[3];\n lt.set(rect.left, rect.top);\n lb.set(rect.left, rect.bottom);\n rt.set(rect.right, rect.top);\n rb.set(rect.right, rect.bottom);\n matrix.apply(lt, lt);\n matrix.apply(lb, lb);\n matrix.apply(rt, rt);\n matrix.apply(rb, rb);\n var x0 = Math.min(lt.x, lb.x, rt.x, rb.x);\n var y0 = Math.min(lt.y, lb.y, rt.y, rb.y);\n var x1 = Math.max(lt.x, lb.x, rt.x, rb.x);\n var y1 = Math.max(lt.y, lb.y, rt.y, rb.y);\n rect.x = x0;\n rect.y = y0;\n rect.width = x1 - x0;\n rect.height = y1 - y0;\n };\n FilterSystem.prototype.roundFrame = function (frame, resolution, bindingSourceFrame, bindingDestinationFrame, transform) {\n if (frame.width <= 0 || frame.height <= 0 || bindingSourceFrame.width <= 0 || bindingSourceFrame.height <= 0) {\n return;\n }\n if (transform) {\n var a = transform.a, b = transform.b, c = transform.c, d = transform.d;\n // Skip if skew/rotation present in matrix, except for multiple of 90° rotation. If rotation\n // is a multiple of 90°, then either pair of (b,c) or (a,d) will be (0,0).\n if ((Math.abs(b) > 1e-4 || Math.abs(c) > 1e-4)\n && (Math.abs(a) > 1e-4 || Math.abs(d) > 1e-4)) {\n return;\n }\n }\n transform = transform ? tempMatrix$2.copyFrom(transform) : tempMatrix$2.identity();\n // Get forward transform from world space to screen space\n transform\n .translate(-bindingSourceFrame.x, -bindingSourceFrame.y)\n .scale(bindingDestinationFrame.width / bindingSourceFrame.width, bindingDestinationFrame.height / bindingSourceFrame.height)\n .translate(bindingDestinationFrame.x, bindingDestinationFrame.y);\n // Convert frame to screen space\n this.transformAABB(transform, frame);\n // Round frame in screen space\n frame.ceil(resolution);\n // Project back into world space.\n this.transformAABB(transform.invert(), frame);\n };\n return FilterSystem;\n}());\n\n/**\n * Base for a common object renderer that can be used as a\n * system renderer plugin.\n * @memberof PIXI\n */\nvar ObjectRenderer = /** @class */ (function () {\n /**\n * @param renderer - The renderer this manager works for.\n */\n function ObjectRenderer(renderer) {\n this.renderer = renderer;\n }\n /** Stub method that should be used to empty the current batch by rendering objects now. */\n ObjectRenderer.prototype.flush = function () {\n // flush!\n };\n /** Generic destruction method that frees all resources. This should be called by subclasses. */\n ObjectRenderer.prototype.destroy = function () {\n this.renderer = null;\n };\n /**\n * Stub method that initializes any state required before\n * rendering starts. It is different from the `prerender`\n * signal, which occurs every frame, in that it is called\n * whenever an object requests _this_ renderer specifically.\n */\n ObjectRenderer.prototype.start = function () {\n // set the shader..\n };\n /** Stops the renderer. It should free up any state and become dormant. */\n ObjectRenderer.prototype.stop = function () {\n this.flush();\n };\n /**\n * Keeps the object to render. It doesn't have to be\n * rendered immediately.\n * @param {PIXI.DisplayObject} _object - The object to render.\n */\n ObjectRenderer.prototype.render = function (_object) {\n // render the object\n };\n return ObjectRenderer;\n}());\n\n/**\n * System plugin to the renderer to manage batching.\n * @memberof PIXI\n */\nvar BatchSystem = /** @class */ (function () {\n /**\n * @param renderer - The renderer this System works for.\n */\n function BatchSystem(renderer) {\n this.renderer = renderer;\n this.emptyRenderer = new ObjectRenderer(renderer);\n this.currentRenderer = this.emptyRenderer;\n }\n /**\n * Changes the current renderer to the one given in parameter\n * @param objectRenderer - The object renderer to use.\n */\n BatchSystem.prototype.setObjectRenderer = function (objectRenderer) {\n if (this.currentRenderer === objectRenderer) {\n return;\n }\n this.currentRenderer.stop();\n this.currentRenderer = objectRenderer;\n this.currentRenderer.start();\n };\n /**\n * This should be called if you wish to do some custom rendering\n * It will basically render anything that may be batched up such as sprites\n */\n BatchSystem.prototype.flush = function () {\n this.setObjectRenderer(this.emptyRenderer);\n };\n /** Reset the system to an empty renderer */\n BatchSystem.prototype.reset = function () {\n this.setObjectRenderer(this.emptyRenderer);\n };\n /**\n * Handy function for batch renderers: copies bound textures in first maxTextures locations to array\n * sets actual _batchLocation for them\n * @param arr - arr copy destination\n * @param maxTextures - number of copied elements\n */\n BatchSystem.prototype.copyBoundTextures = function (arr, maxTextures) {\n var boundTextures = this.renderer.texture.boundTextures;\n for (var i = maxTextures - 1; i >= 0; --i) {\n arr[i] = boundTextures[i] || null;\n if (arr[i]) {\n arr[i]._batchLocation = i;\n }\n }\n };\n /**\n * Assigns batch locations to textures in array based on boundTextures state.\n * All textures in texArray should have `_batchEnabled = _batchId`,\n * and their count should be less than `maxTextures`.\n * @param texArray - textures to bound\n * @param boundTextures - current state of bound textures\n * @param batchId - marker for _batchEnabled param of textures in texArray\n * @param maxTextures - number of texture locations to manipulate\n */\n BatchSystem.prototype.boundArray = function (texArray, boundTextures, batchId, maxTextures) {\n var elements = texArray.elements, ids = texArray.ids, count = texArray.count;\n var j = 0;\n for (var i = 0; i < count; i++) {\n var tex = elements[i];\n var loc = tex._batchLocation;\n if (loc >= 0 && loc < maxTextures\n && boundTextures[loc] === tex) {\n ids[i] = loc;\n continue;\n }\n while (j < maxTextures) {\n var bound = boundTextures[j];\n if (bound && bound._batchEnabled === batchId\n && bound._batchLocation === j) {\n j++;\n continue;\n }\n ids[i] = j;\n tex._batchLocation = j;\n boundTextures[j] = tex;\n break;\n }\n }\n };\n /**\n * @ignore\n */\n BatchSystem.prototype.destroy = function () {\n this.renderer = null;\n };\n return BatchSystem;\n}());\n\nvar CONTEXT_UID_COUNTER = 0;\n/**\n * System plugin to the renderer to manage the context.\n * @memberof PIXI\n */\nvar ContextSystem = /** @class */ (function () {\n /** @param renderer - The renderer this System works for. */\n function ContextSystem(renderer) {\n this.renderer = renderer;\n this.webGLVersion = 1;\n this.extensions = {};\n this.supports = {\n uint32Indices: false,\n };\n // Bind functions\n this.handleContextLost = this.handleContextLost.bind(this);\n this.handleContextRestored = this.handleContextRestored.bind(this);\n renderer.view.addEventListener('webglcontextlost', this.handleContextLost, false);\n renderer.view.addEventListener('webglcontextrestored', this.handleContextRestored, false);\n }\n Object.defineProperty(ContextSystem.prototype, \"isLost\", {\n /**\n * `true` if the context is lost\n * @readonly\n */\n get: function () {\n return (!this.gl || this.gl.isContextLost());\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Handles the context change event.\n * @param {WebGLRenderingContext} gl - New WebGL context.\n */\n ContextSystem.prototype.contextChange = function (gl) {\n this.gl = gl;\n this.renderer.gl = gl;\n this.renderer.CONTEXT_UID = CONTEXT_UID_COUNTER++;\n };\n /**\n * Initializes the context.\n * @protected\n * @param {WebGLRenderingContext} gl - WebGL context\n */\n ContextSystem.prototype.initFromContext = function (gl) {\n this.gl = gl;\n this.validateContext(gl);\n this.renderer.gl = gl;\n this.renderer.CONTEXT_UID = CONTEXT_UID_COUNTER++;\n this.renderer.runners.contextChange.emit(gl);\n };\n /**\n * Initialize from context options\n * @protected\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext\n * @param {object} options - context attributes\n */\n ContextSystem.prototype.initFromOptions = function (options) {\n var gl = this.createContext(this.renderer.view, options);\n this.initFromContext(gl);\n };\n /**\n * Helper class to create a WebGL Context\n * @param canvas - the canvas element that we will get the context from\n * @param options - An options object that gets passed in to the canvas element containing the\n * context attributes\n * @see https://developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement/getContext\n * @returns {WebGLRenderingContext} the WebGL context\n */\n ContextSystem.prototype.createContext = function (canvas, options) {\n var gl;\n if (settings.PREFER_ENV >= ENV.WEBGL2) {\n gl = canvas.getContext('webgl2', options);\n }\n if (gl) {\n this.webGLVersion = 2;\n }\n else {\n this.webGLVersion = 1;\n gl = canvas.getContext('webgl', options) || canvas.getContext('experimental-webgl', options);\n if (!gl) {\n // fail, not able to get a context\n throw new Error('This browser does not support WebGL. Try using the canvas renderer');\n }\n }\n this.gl = gl;\n this.getExtensions();\n return this.gl;\n };\n /** Auto-populate the {@link PIXI.ContextSystem.extensions extensions}. */\n ContextSystem.prototype.getExtensions = function () {\n // time to set up default extensions that Pixi uses.\n var gl = this.gl;\n var common = {\n loseContext: gl.getExtension('WEBGL_lose_context'),\n anisotropicFiltering: gl.getExtension('EXT_texture_filter_anisotropic'),\n floatTextureLinear: gl.getExtension('OES_texture_float_linear'),\n s3tc: gl.getExtension('WEBGL_compressed_texture_s3tc'),\n s3tc_sRGB: gl.getExtension('WEBGL_compressed_texture_s3tc_srgb'),\n etc: gl.getExtension('WEBGL_compressed_texture_etc'),\n etc1: gl.getExtension('WEBGL_compressed_texture_etc1'),\n pvrtc: gl.getExtension('WEBGL_compressed_texture_pvrtc')\n || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'),\n atc: gl.getExtension('WEBGL_compressed_texture_atc'),\n astc: gl.getExtension('WEBGL_compressed_texture_astc')\n };\n if (this.webGLVersion === 1) {\n Object.assign(this.extensions, common, {\n drawBuffers: gl.getExtension('WEBGL_draw_buffers'),\n depthTexture: gl.getExtension('WEBGL_depth_texture'),\n vertexArrayObject: gl.getExtension('OES_vertex_array_object')\n || gl.getExtension('MOZ_OES_vertex_array_object')\n || gl.getExtension('WEBKIT_OES_vertex_array_object'),\n uint32ElementIndex: gl.getExtension('OES_element_index_uint'),\n // Floats and half-floats\n floatTexture: gl.getExtension('OES_texture_float'),\n floatTextureLinear: gl.getExtension('OES_texture_float_linear'),\n textureHalfFloat: gl.getExtension('OES_texture_half_float'),\n textureHalfFloatLinear: gl.getExtension('OES_texture_half_float_linear'),\n });\n }\n else if (this.webGLVersion === 2) {\n Object.assign(this.extensions, common, {\n // Floats and half-floats\n colorBufferFloat: gl.getExtension('EXT_color_buffer_float')\n });\n }\n };\n /**\n * Handles a lost webgl context\n * @param {WebGLContextEvent} event - The context lost event.\n */\n ContextSystem.prototype.handleContextLost = function (event) {\n var _this = this;\n // Prevent default to be able to restore the context\n event.preventDefault();\n // Restore the context after this event has exited\n setTimeout(function () {\n if (_this.gl.isContextLost() && _this.extensions.loseContext) {\n _this.extensions.loseContext.restoreContext();\n }\n }, 0);\n };\n /** Handles a restored webgl context. */\n ContextSystem.prototype.handleContextRestored = function () {\n this.renderer.runners.contextChange.emit(this.gl);\n };\n ContextSystem.prototype.destroy = function () {\n var view = this.renderer.view;\n this.renderer = null;\n // remove listeners\n view.removeEventListener('webglcontextlost', this.handleContextLost);\n view.removeEventListener('webglcontextrestored', this.handleContextRestored);\n this.gl.useProgram(null);\n if (this.extensions.loseContext) {\n this.extensions.loseContext.loseContext();\n }\n };\n /** Handle the post-render runner event. */\n ContextSystem.prototype.postrender = function () {\n if (this.renderer.renderingToScreen) {\n this.gl.flush();\n }\n };\n /**\n * Validate context.\n * @param {WebGLRenderingContext} gl - Render context.\n */\n ContextSystem.prototype.validateContext = function (gl) {\n var attributes = gl.getContextAttributes();\n var isWebGl2 = 'WebGL2RenderingContext' in globalThis && gl instanceof globalThis.WebGL2RenderingContext;\n if (isWebGl2) {\n this.webGLVersion = 2;\n }\n // this is going to be fairly simple for now.. but at least we have room to grow!\n if (attributes && !attributes.stencil) {\n /* eslint-disable max-len, no-console */\n console.warn('Provided WebGL context does not have a stencil buffer, masks may not render correctly');\n /* eslint-enable max-len, no-console */\n }\n var hasuint32 = isWebGl2 || !!gl.getExtension('OES_element_index_uint');\n this.supports.uint32Indices = hasuint32;\n if (!hasuint32) {\n /* eslint-disable max-len, no-console */\n console.warn('Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly');\n /* eslint-enable max-len, no-console */\n }\n };\n return ContextSystem;\n}());\n\n/**\n * Internal framebuffer for WebGL context.\n * @memberof PIXI\n */\nvar GLFramebuffer = /** @class */ (function () {\n function GLFramebuffer(framebuffer) {\n this.framebuffer = framebuffer;\n this.stencil = null;\n this.dirtyId = -1;\n this.dirtyFormat = -1;\n this.dirtySize = -1;\n this.multisample = MSAA_QUALITY.NONE;\n this.msaaBuffer = null;\n this.blitFramebuffer = null;\n this.mipLevel = 0;\n }\n return GLFramebuffer;\n}());\n\nvar tempRectangle = new Rectangle();\n/**\n * System plugin to the renderer to manage framebuffers.\n * @memberof PIXI\n */\nvar FramebufferSystem = /** @class */ (function () {\n /**\n * @param renderer - The renderer this System works for.\n */\n function FramebufferSystem(renderer) {\n this.renderer = renderer;\n this.managedFramebuffers = [];\n this.unknownFramebuffer = new Framebuffer(10, 10);\n this.msaaSamples = null;\n }\n /** Sets up the renderer context and necessary buffers. */\n FramebufferSystem.prototype.contextChange = function () {\n this.disposeAll(true);\n var gl = this.gl = this.renderer.gl;\n this.CONTEXT_UID = this.renderer.CONTEXT_UID;\n this.current = this.unknownFramebuffer;\n this.viewport = new Rectangle();\n this.hasMRT = true;\n this.writeDepthTexture = true;\n // webgl2\n if (this.renderer.context.webGLVersion === 1) {\n // webgl 1!\n var nativeDrawBuffersExtension_1 = this.renderer.context.extensions.drawBuffers;\n var nativeDepthTextureExtension = this.renderer.context.extensions.depthTexture;\n if (settings.PREFER_ENV === ENV.WEBGL_LEGACY) {\n nativeDrawBuffersExtension_1 = null;\n nativeDepthTextureExtension = null;\n }\n if (nativeDrawBuffersExtension_1) {\n gl.drawBuffers = function (activeTextures) {\n return nativeDrawBuffersExtension_1.drawBuffersWEBGL(activeTextures);\n };\n }\n else {\n this.hasMRT = false;\n gl.drawBuffers = function () {\n // empty\n };\n }\n if (!nativeDepthTextureExtension) {\n this.writeDepthTexture = false;\n }\n }\n else {\n // WebGL2\n // cache possible MSAA samples\n this.msaaSamples = gl.getInternalformatParameter(gl.RENDERBUFFER, gl.RGBA8, gl.SAMPLES);\n }\n };\n /**\n * Bind a framebuffer.\n * @param framebuffer\n * @param frame - frame, default is framebuffer size\n * @param mipLevel - optional mip level to set on the framebuffer - defaults to 0\n */\n FramebufferSystem.prototype.bind = function (framebuffer, frame, mipLevel) {\n if (mipLevel === void 0) { mipLevel = 0; }\n var gl = this.gl;\n if (framebuffer) {\n // TODO caching layer!\n var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID] || this.initFramebuffer(framebuffer);\n if (this.current !== framebuffer) {\n this.current = framebuffer;\n gl.bindFramebuffer(gl.FRAMEBUFFER, fbo.framebuffer);\n }\n // make sure all textures are unbound..\n if (fbo.mipLevel !== mipLevel) {\n framebuffer.dirtyId++;\n framebuffer.dirtyFormat++;\n fbo.mipLevel = mipLevel;\n }\n // now check for updates...\n if (fbo.dirtyId !== framebuffer.dirtyId) {\n fbo.dirtyId = framebuffer.dirtyId;\n if (fbo.dirtyFormat !== framebuffer.dirtyFormat) {\n fbo.dirtyFormat = framebuffer.dirtyFormat;\n fbo.dirtySize = framebuffer.dirtySize;\n this.updateFramebuffer(framebuffer, mipLevel);\n }\n else if (fbo.dirtySize !== framebuffer.dirtySize) {\n fbo.dirtySize = framebuffer.dirtySize;\n this.resizeFramebuffer(framebuffer);\n }\n }\n for (var i = 0; i < framebuffer.colorTextures.length; i++) {\n var tex = framebuffer.colorTextures[i];\n this.renderer.texture.unbind(tex.parentTextureArray || tex);\n }\n if (framebuffer.depthTexture) {\n this.renderer.texture.unbind(framebuffer.depthTexture);\n }\n if (frame) {\n var mipWidth = (frame.width >> mipLevel);\n var mipHeight = (frame.height >> mipLevel);\n var scale = mipWidth / frame.width;\n this.setViewport(frame.x * scale, frame.y * scale, mipWidth, mipHeight);\n }\n else {\n var mipWidth = (framebuffer.width >> mipLevel);\n var mipHeight = (framebuffer.height >> mipLevel);\n this.setViewport(0, 0, mipWidth, mipHeight);\n }\n }\n else {\n if (this.current) {\n this.current = null;\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n }\n if (frame) {\n this.setViewport(frame.x, frame.y, frame.width, frame.height);\n }\n else {\n this.setViewport(0, 0, this.renderer.width, this.renderer.height);\n }\n }\n };\n /**\n * Set the WebGLRenderingContext's viewport.\n * @param x - X position of viewport\n * @param y - Y position of viewport\n * @param width - Width of viewport\n * @param height - Height of viewport\n */\n FramebufferSystem.prototype.setViewport = function (x, y, width, height) {\n var v = this.viewport;\n x = Math.round(x);\n y = Math.round(y);\n width = Math.round(width);\n height = Math.round(height);\n if (v.width !== width || v.height !== height || v.x !== x || v.y !== y) {\n v.x = x;\n v.y = y;\n v.width = width;\n v.height = height;\n this.gl.viewport(x, y, width, height);\n }\n };\n Object.defineProperty(FramebufferSystem.prototype, \"size\", {\n /**\n * Get the size of the current width and height. Returns object with `width` and `height` values.\n * @readonly\n */\n get: function () {\n if (this.current) {\n // TODO store temp\n return { x: 0, y: 0, width: this.current.width, height: this.current.height };\n }\n return { x: 0, y: 0, width: this.renderer.width, height: this.renderer.height };\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Clear the color of the context\n * @param r - Red value from 0 to 1\n * @param g - Green value from 0 to 1\n * @param b - Blue value from 0 to 1\n * @param a - Alpha value from 0 to 1\n * @param {PIXI.BUFFER_BITS} [mask=BUFFER_BITS.COLOR | BUFFER_BITS.DEPTH] - Bitwise OR of masks\n * that indicate the buffers to be cleared, by default COLOR and DEPTH buffers.\n */\n FramebufferSystem.prototype.clear = function (r, g, b, a, mask) {\n if (mask === void 0) { mask = BUFFER_BITS.COLOR | BUFFER_BITS.DEPTH; }\n var gl = this.gl;\n // TODO clear color can be set only one right?\n gl.clearColor(r, g, b, a);\n gl.clear(mask);\n };\n /**\n * Initialize framebuffer for this context\n * @protected\n * @param framebuffer\n * @returns - created GLFramebuffer\n */\n FramebufferSystem.prototype.initFramebuffer = function (framebuffer) {\n var gl = this.gl;\n var fbo = new GLFramebuffer(gl.createFramebuffer());\n fbo.multisample = this.detectSamples(framebuffer.multisample);\n framebuffer.glFramebuffers[this.CONTEXT_UID] = fbo;\n this.managedFramebuffers.push(framebuffer);\n framebuffer.disposeRunner.add(this);\n return fbo;\n };\n /**\n * Resize the framebuffer\n * @param framebuffer\n * @protected\n */\n FramebufferSystem.prototype.resizeFramebuffer = function (framebuffer) {\n var gl = this.gl;\n var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID];\n if (fbo.msaaBuffer) {\n gl.bindRenderbuffer(gl.RENDERBUFFER, fbo.msaaBuffer);\n gl.renderbufferStorageMultisample(gl.RENDERBUFFER, fbo.multisample, gl.RGBA8, framebuffer.width, framebuffer.height);\n }\n if (fbo.stencil) {\n gl.bindRenderbuffer(gl.RENDERBUFFER, fbo.stencil);\n if (fbo.msaaBuffer) {\n gl.renderbufferStorageMultisample(gl.RENDERBUFFER, fbo.multisample, gl.DEPTH24_STENCIL8, framebuffer.width, framebuffer.height);\n }\n else {\n gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, framebuffer.width, framebuffer.height);\n }\n }\n var colorTextures = framebuffer.colorTextures;\n var count = colorTextures.length;\n if (!gl.drawBuffers) {\n count = Math.min(count, 1);\n }\n for (var i = 0; i < count; i++) {\n var texture = colorTextures[i];\n var parentTexture = texture.parentTextureArray || texture;\n this.renderer.texture.bind(parentTexture, 0);\n }\n if (framebuffer.depthTexture && this.writeDepthTexture) {\n this.renderer.texture.bind(framebuffer.depthTexture, 0);\n }\n };\n /**\n * Update the framebuffer\n * @param framebuffer\n * @param mipLevel\n * @protected\n */\n FramebufferSystem.prototype.updateFramebuffer = function (framebuffer, mipLevel) {\n var gl = this.gl;\n var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID];\n // bind the color texture\n var colorTextures = framebuffer.colorTextures;\n var count = colorTextures.length;\n if (!gl.drawBuffers) {\n count = Math.min(count, 1);\n }\n if (fbo.multisample > 1 && this.canMultisampleFramebuffer(framebuffer)) {\n fbo.msaaBuffer = fbo.msaaBuffer || gl.createRenderbuffer();\n gl.bindRenderbuffer(gl.RENDERBUFFER, fbo.msaaBuffer);\n gl.renderbufferStorageMultisample(gl.RENDERBUFFER, fbo.multisample, gl.RGBA8, framebuffer.width, framebuffer.height);\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, fbo.msaaBuffer);\n }\n else if (fbo.msaaBuffer) {\n gl.deleteRenderbuffer(fbo.msaaBuffer);\n fbo.msaaBuffer = null;\n if (fbo.blitFramebuffer) {\n fbo.blitFramebuffer.dispose();\n fbo.blitFramebuffer = null;\n }\n }\n var activeTextures = [];\n for (var i = 0; i < count; i++) {\n var texture = colorTextures[i];\n var parentTexture = texture.parentTextureArray || texture;\n this.renderer.texture.bind(parentTexture, 0);\n if (i === 0 && fbo.msaaBuffer) {\n continue;\n }\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, texture.target, parentTexture._glTextures[this.CONTEXT_UID].texture, mipLevel);\n activeTextures.push(gl.COLOR_ATTACHMENT0 + i);\n }\n if (activeTextures.length > 1) {\n gl.drawBuffers(activeTextures);\n }\n if (framebuffer.depthTexture) {\n var writeDepthTexture = this.writeDepthTexture;\n if (writeDepthTexture) {\n var depthTexture = framebuffer.depthTexture;\n this.renderer.texture.bind(depthTexture, 0);\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._glTextures[this.CONTEXT_UID].texture, mipLevel);\n }\n }\n if ((framebuffer.stencil || framebuffer.depth) && !(framebuffer.depthTexture && this.writeDepthTexture)) {\n fbo.stencil = fbo.stencil || gl.createRenderbuffer();\n gl.bindRenderbuffer(gl.RENDERBUFFER, fbo.stencil);\n if (fbo.msaaBuffer) {\n gl.renderbufferStorageMultisample(gl.RENDERBUFFER, fbo.multisample, gl.DEPTH24_STENCIL8, framebuffer.width, framebuffer.height);\n }\n else {\n gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, framebuffer.width, framebuffer.height);\n }\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, fbo.stencil);\n }\n else if (fbo.stencil) {\n gl.deleteRenderbuffer(fbo.stencil);\n fbo.stencil = null;\n }\n };\n /**\n * Returns true if the frame buffer can be multisampled.\n * @param framebuffer\n */\n FramebufferSystem.prototype.canMultisampleFramebuffer = function (framebuffer) {\n return this.renderer.context.webGLVersion !== 1\n && framebuffer.colorTextures.length <= 1 && !framebuffer.depthTexture;\n };\n /**\n * Detects number of samples that is not more than a param but as close to it as possible\n * @param samples - number of samples\n * @returns - recommended number of samples\n */\n FramebufferSystem.prototype.detectSamples = function (samples) {\n var msaaSamples = this.msaaSamples;\n var res = MSAA_QUALITY.NONE;\n if (samples <= 1 || msaaSamples === null) {\n return res;\n }\n for (var i = 0; i < msaaSamples.length; i++) {\n if (msaaSamples[i] <= samples) {\n res = msaaSamples[i];\n break;\n }\n }\n if (res === 1) {\n res = MSAA_QUALITY.NONE;\n }\n return res;\n };\n /**\n * Only works with WebGL2\n *\n * blits framebuffer to another of the same or bigger size\n * after that target framebuffer is bound\n *\n * Fails with WebGL warning if blits multisample framebuffer to different size\n * @param framebuffer - by default it blits \"into itself\", from renderBuffer to texture.\n * @param sourcePixels - source rectangle in pixels\n * @param destPixels - dest rectangle in pixels, assumed to be the same as sourcePixels\n */\n FramebufferSystem.prototype.blit = function (framebuffer, sourcePixels, destPixels) {\n var _a = this, current = _a.current, renderer = _a.renderer, gl = _a.gl, CONTEXT_UID = _a.CONTEXT_UID;\n if (renderer.context.webGLVersion !== 2) {\n return;\n }\n if (!current) {\n return;\n }\n var fbo = current.glFramebuffers[CONTEXT_UID];\n if (!fbo) {\n return;\n }\n if (!framebuffer) {\n if (!fbo.msaaBuffer) {\n return;\n }\n var colorTexture = current.colorTextures[0];\n if (!colorTexture) {\n return;\n }\n if (!fbo.blitFramebuffer) {\n fbo.blitFramebuffer = new Framebuffer(current.width, current.height);\n fbo.blitFramebuffer.addColorTexture(0, colorTexture);\n }\n framebuffer = fbo.blitFramebuffer;\n if (framebuffer.colorTextures[0] !== colorTexture) {\n framebuffer.colorTextures[0] = colorTexture;\n framebuffer.dirtyId++;\n framebuffer.dirtyFormat++;\n }\n if (framebuffer.width !== current.width || framebuffer.height !== current.height) {\n framebuffer.width = current.width;\n framebuffer.height = current.height;\n framebuffer.dirtyId++;\n framebuffer.dirtySize++;\n }\n }\n if (!sourcePixels) {\n sourcePixels = tempRectangle;\n sourcePixels.width = current.width;\n sourcePixels.height = current.height;\n }\n if (!destPixels) {\n destPixels = sourcePixels;\n }\n var sameSize = sourcePixels.width === destPixels.width && sourcePixels.height === destPixels.height;\n this.bind(framebuffer);\n gl.bindFramebuffer(gl.READ_FRAMEBUFFER, fbo.framebuffer);\n gl.blitFramebuffer(sourcePixels.left, sourcePixels.top, sourcePixels.right, sourcePixels.bottom, destPixels.left, destPixels.top, destPixels.right, destPixels.bottom, gl.COLOR_BUFFER_BIT, sameSize ? gl.NEAREST : gl.LINEAR);\n };\n /**\n * Disposes framebuffer.\n * @param framebuffer - framebuffer that has to be disposed of\n * @param contextLost - If context was lost, we suppress all delete function calls\n */\n FramebufferSystem.prototype.disposeFramebuffer = function (framebuffer, contextLost) {\n var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID];\n var gl = this.gl;\n if (!fbo) {\n return;\n }\n delete framebuffer.glFramebuffers[this.CONTEXT_UID];\n var index = this.managedFramebuffers.indexOf(framebuffer);\n if (index >= 0) {\n this.managedFramebuffers.splice(index, 1);\n }\n framebuffer.disposeRunner.remove(this);\n if (!contextLost) {\n gl.deleteFramebuffer(fbo.framebuffer);\n if (fbo.msaaBuffer) {\n gl.deleteRenderbuffer(fbo.msaaBuffer);\n }\n if (fbo.stencil) {\n gl.deleteRenderbuffer(fbo.stencil);\n }\n }\n if (fbo.blitFramebuffer) {\n fbo.blitFramebuffer.dispose();\n }\n };\n /**\n * Disposes all framebuffers, but not textures bound to them.\n * @param [contextLost=false] - If context was lost, we suppress all delete function calls\n */\n FramebufferSystem.prototype.disposeAll = function (contextLost) {\n var list = this.managedFramebuffers;\n this.managedFramebuffers = [];\n for (var i = 0; i < list.length; i++) {\n this.disposeFramebuffer(list[i], contextLost);\n }\n };\n /**\n * Forcing creation of stencil buffer for current framebuffer, if it wasn't done before.\n * Used by MaskSystem, when its time to use stencil mask for Graphics element.\n *\n * Its an alternative for public lazy `framebuffer.enableStencil`, in case we need stencil without rebind.\n * @private\n */\n FramebufferSystem.prototype.forceStencil = function () {\n var framebuffer = this.current;\n if (!framebuffer) {\n return;\n }\n var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID];\n if (!fbo || fbo.stencil) {\n return;\n }\n framebuffer.stencil = true;\n var w = framebuffer.width;\n var h = framebuffer.height;\n var gl = this.gl;\n var stencil = gl.createRenderbuffer();\n gl.bindRenderbuffer(gl.RENDERBUFFER, stencil);\n if (fbo.msaaBuffer) {\n gl.renderbufferStorageMultisample(gl.RENDERBUFFER, fbo.multisample, gl.DEPTH24_STENCIL8, w, h);\n }\n else {\n gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, w, h);\n }\n fbo.stencil = stencil;\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, stencil);\n };\n /** Resets framebuffer stored state, binds screen framebuffer. Should be called before renderTexture reset(). */\n FramebufferSystem.prototype.reset = function () {\n this.current = this.unknownFramebuffer;\n this.viewport = new Rectangle();\n };\n FramebufferSystem.prototype.destroy = function () {\n this.renderer = null;\n };\n return FramebufferSystem;\n}());\n\nvar byteSizeMap = { 5126: 4, 5123: 2, 5121: 1 };\n/**\n * System plugin to the renderer to manage geometry.\n * @memberof PIXI\n */\nvar GeometrySystem = /** @class */ (function () {\n /** @param renderer - The renderer this System works for. */\n function GeometrySystem(renderer) {\n this.renderer = renderer;\n this._activeGeometry = null;\n this._activeVao = null;\n this.hasVao = true;\n this.hasInstance = true;\n this.canUseUInt32ElementIndex = false;\n this.managedGeometries = {};\n }\n /** Sets up the renderer context and necessary buffers. */\n GeometrySystem.prototype.contextChange = function () {\n this.disposeAll(true);\n var gl = this.gl = this.renderer.gl;\n var context = this.renderer.context;\n this.CONTEXT_UID = this.renderer.CONTEXT_UID;\n // webgl2\n if (context.webGLVersion !== 2) {\n // webgl 1!\n var nativeVaoExtension_1 = this.renderer.context.extensions.vertexArrayObject;\n if (settings.PREFER_ENV === ENV.WEBGL_LEGACY) {\n nativeVaoExtension_1 = null;\n }\n if (nativeVaoExtension_1) {\n gl.createVertexArray = function () {\n return nativeVaoExtension_1.createVertexArrayOES();\n };\n gl.bindVertexArray = function (vao) {\n return nativeVaoExtension_1.bindVertexArrayOES(vao);\n };\n gl.deleteVertexArray = function (vao) {\n return nativeVaoExtension_1.deleteVertexArrayOES(vao);\n };\n }\n else {\n this.hasVao = false;\n gl.createVertexArray = function () {\n return null;\n };\n gl.bindVertexArray = function () {\n return null;\n };\n gl.deleteVertexArray = function () {\n return null;\n };\n }\n }\n if (context.webGLVersion !== 2) {\n var instanceExt_1 = gl.getExtension('ANGLE_instanced_arrays');\n if (instanceExt_1) {\n gl.vertexAttribDivisor = function (a, b) {\n return instanceExt_1.vertexAttribDivisorANGLE(a, b);\n };\n gl.drawElementsInstanced = function (a, b, c, d, e) {\n return instanceExt_1.drawElementsInstancedANGLE(a, b, c, d, e);\n };\n gl.drawArraysInstanced = function (a, b, c, d) {\n return instanceExt_1.drawArraysInstancedANGLE(a, b, c, d);\n };\n }\n else {\n this.hasInstance = false;\n }\n }\n this.canUseUInt32ElementIndex = context.webGLVersion === 2 || !!context.extensions.uint32ElementIndex;\n };\n /**\n * Binds geometry so that is can be drawn. Creating a Vao if required\n * @param geometry - Instance of geometry to bind.\n * @param shader - Instance of shader to use vao for.\n */\n GeometrySystem.prototype.bind = function (geometry, shader) {\n shader = shader || this.renderer.shader.shader;\n var gl = this.gl;\n // not sure the best way to address this..\n // currently different shaders require different VAOs for the same geometry\n // Still mulling over the best way to solve this one..\n // will likely need to modify the shader attribute locations at run time!\n var vaos = geometry.glVertexArrayObjects[this.CONTEXT_UID];\n var incRefCount = false;\n if (!vaos) {\n this.managedGeometries[geometry.id] = geometry;\n geometry.disposeRunner.add(this);\n geometry.glVertexArrayObjects[this.CONTEXT_UID] = vaos = {};\n incRefCount = true;\n }\n var vao = vaos[shader.program.id] || this.initGeometryVao(geometry, shader, incRefCount);\n this._activeGeometry = geometry;\n if (this._activeVao !== vao) {\n this._activeVao = vao;\n if (this.hasVao) {\n gl.bindVertexArray(vao);\n }\n else {\n this.activateVao(geometry, shader.program);\n }\n }\n // TODO - optimise later!\n // don't need to loop through if nothing changed!\n // maybe look to add an 'autoupdate' to geometry?\n this.updateBuffers();\n };\n /** Reset and unbind any active VAO and geometry. */\n GeometrySystem.prototype.reset = function () {\n this.unbind();\n };\n /** Update buffers of the currently bound geometry. */\n GeometrySystem.prototype.updateBuffers = function () {\n var geometry = this._activeGeometry;\n var bufferSystem = this.renderer.buffer;\n for (var i = 0; i < geometry.buffers.length; i++) {\n var buffer = geometry.buffers[i];\n bufferSystem.update(buffer);\n }\n };\n /**\n * Check compatibility between a geometry and a program\n * @param geometry - Geometry instance.\n * @param program - Program instance.\n */\n GeometrySystem.prototype.checkCompatibility = function (geometry, program) {\n // geometry must have at least all the attributes that the shader requires.\n var geometryAttributes = geometry.attributes;\n var shaderAttributes = program.attributeData;\n for (var j in shaderAttributes) {\n if (!geometryAttributes[j]) {\n throw new Error(\"shader and geometry incompatible, geometry missing the \\\"\" + j + \"\\\" attribute\");\n }\n }\n };\n /**\n * Takes a geometry and program and generates a unique signature for them.\n * @param geometry - To get signature from.\n * @param program - To test geometry against.\n * @returns - Unique signature of the geometry and program\n */\n GeometrySystem.prototype.getSignature = function (geometry, program) {\n var attribs = geometry.attributes;\n var shaderAttributes = program.attributeData;\n var strings = ['g', geometry.id];\n for (var i in attribs) {\n if (shaderAttributes[i]) {\n strings.push(i, shaderAttributes[i].location);\n }\n }\n return strings.join('-');\n };\n /**\n * Creates or gets Vao with the same structure as the geometry and stores it on the geometry.\n * If vao is created, it is bound automatically. We use a shader to infer what and how to set up the\n * attribute locations.\n * @param geometry - Instance of geometry to to generate Vao for.\n * @param shader - Instance of the shader.\n * @param incRefCount - Increment refCount of all geometry buffers.\n */\n GeometrySystem.prototype.initGeometryVao = function (geometry, shader, incRefCount) {\n if (incRefCount === void 0) { incRefCount = true; }\n var gl = this.gl;\n var CONTEXT_UID = this.CONTEXT_UID;\n var bufferSystem = this.renderer.buffer;\n var program = shader.program;\n if (!program.glPrograms[CONTEXT_UID]) {\n this.renderer.shader.generateProgram(shader);\n }\n this.checkCompatibility(geometry, program);\n var signature = this.getSignature(geometry, program);\n var vaoObjectHash = geometry.glVertexArrayObjects[this.CONTEXT_UID];\n var vao = vaoObjectHash[signature];\n if (vao) {\n // this will give us easy access to the vao\n vaoObjectHash[program.id] = vao;\n return vao;\n }\n var buffers = geometry.buffers;\n var attributes = geometry.attributes;\n var tempStride = {};\n var tempStart = {};\n for (var j in buffers) {\n tempStride[j] = 0;\n tempStart[j] = 0;\n }\n for (var j in attributes) {\n if (!attributes[j].size && program.attributeData[j]) {\n attributes[j].size = program.attributeData[j].size;\n }\n else if (!attributes[j].size) {\n console.warn(\"PIXI Geometry attribute '\" + j + \"' size cannot be determined (likely the bound shader does not have the attribute)\"); // eslint-disable-line\n }\n tempStride[attributes[j].buffer] += attributes[j].size * byteSizeMap[attributes[j].type];\n }\n for (var j in attributes) {\n var attribute = attributes[j];\n var attribSize = attribute.size;\n if (attribute.stride === undefined) {\n if (tempStride[attribute.buffer] === attribSize * byteSizeMap[attribute.type]) {\n attribute.stride = 0;\n }\n else {\n attribute.stride = tempStride[attribute.buffer];\n }\n }\n if (attribute.start === undefined) {\n attribute.start = tempStart[attribute.buffer];\n tempStart[attribute.buffer] += attribSize * byteSizeMap[attribute.type];\n }\n }\n vao = gl.createVertexArray();\n gl.bindVertexArray(vao);\n // first update - and create the buffers!\n // only create a gl buffer if it actually gets\n for (var i = 0; i < buffers.length; i++) {\n var buffer = buffers[i];\n bufferSystem.bind(buffer);\n if (incRefCount) {\n buffer._glBuffers[CONTEXT_UID].refCount++;\n }\n }\n // TODO - maybe make this a data object?\n // lets wait to see if we need to first!\n this.activateVao(geometry, program);\n this._activeVao = vao;\n // add it to the cache!\n vaoObjectHash[program.id] = vao;\n vaoObjectHash[signature] = vao;\n return vao;\n };\n /**\n * Disposes geometry.\n * @param geometry - Geometry with buffers. Only VAO will be disposed\n * @param [contextLost=false] - If context was lost, we suppress deleteVertexArray\n */\n GeometrySystem.prototype.disposeGeometry = function (geometry, contextLost) {\n var _a;\n if (!this.managedGeometries[geometry.id]) {\n return;\n }\n delete this.managedGeometries[geometry.id];\n var vaos = geometry.glVertexArrayObjects[this.CONTEXT_UID];\n var gl = this.gl;\n var buffers = geometry.buffers;\n var bufferSystem = (_a = this.renderer) === null || _a === void 0 ? void 0 : _a.buffer;\n geometry.disposeRunner.remove(this);\n if (!vaos) {\n return;\n }\n // bufferSystem may have already been destroyed..\n // if this is the case, there is no need to destroy the geometry buffers...\n // they already have been!\n if (bufferSystem) {\n for (var i = 0; i < buffers.length; i++) {\n var buf = buffers[i]._glBuffers[this.CONTEXT_UID];\n // my be null as context may have changed right before the dispose is called\n if (buf) {\n buf.refCount--;\n if (buf.refCount === 0 && !contextLost) {\n bufferSystem.dispose(buffers[i], contextLost);\n }\n }\n }\n }\n if (!contextLost) {\n for (var vaoId in vaos) {\n // delete only signatures, everything else are copies\n if (vaoId[0] === 'g') {\n var vao = vaos[vaoId];\n if (this._activeVao === vao) {\n this.unbind();\n }\n gl.deleteVertexArray(vao);\n }\n }\n }\n delete geometry.glVertexArrayObjects[this.CONTEXT_UID];\n };\n /**\n * Dispose all WebGL resources of all managed geometries.\n * @param [contextLost=false] - If context was lost, we suppress `gl.delete` calls\n */\n GeometrySystem.prototype.disposeAll = function (contextLost) {\n var all = Object.keys(this.managedGeometries);\n for (var i = 0; i < all.length; i++) {\n this.disposeGeometry(this.managedGeometries[all[i]], contextLost);\n }\n };\n /**\n * Activate vertex array object.\n * @param geometry - Geometry instance.\n * @param program - Shader program instance.\n */\n GeometrySystem.prototype.activateVao = function (geometry, program) {\n var gl = this.gl;\n var CONTEXT_UID = this.CONTEXT_UID;\n var bufferSystem = this.renderer.buffer;\n var buffers = geometry.buffers;\n var attributes = geometry.attributes;\n if (geometry.indexBuffer) {\n // first update the index buffer if we have one..\n bufferSystem.bind(geometry.indexBuffer);\n }\n var lastBuffer = null;\n // add a new one!\n for (var j in attributes) {\n var attribute = attributes[j];\n var buffer = buffers[attribute.buffer];\n var glBuffer = buffer._glBuffers[CONTEXT_UID];\n if (program.attributeData[j]) {\n if (lastBuffer !== glBuffer) {\n bufferSystem.bind(buffer);\n lastBuffer = glBuffer;\n }\n var location = program.attributeData[j].location;\n // TODO introduce state again\n // we can optimise this for older devices that have no VAOs\n gl.enableVertexAttribArray(location);\n gl.vertexAttribPointer(location, attribute.size, attribute.type || gl.FLOAT, attribute.normalized, attribute.stride, attribute.start);\n if (attribute.instance) {\n // TODO calculate instance count based of this...\n if (this.hasInstance) {\n gl.vertexAttribDivisor(location, 1);\n }\n else {\n throw new Error('geometry error, GPU Instancing is not supported on this device');\n }\n }\n }\n }\n };\n /**\n * Draws the currently bound geometry.\n * @param type - The type primitive to render.\n * @param size - The number of elements to be rendered. If not specified, all vertices after the\n * starting vertex will be drawn.\n * @param start - The starting vertex in the geometry to start drawing from. If not specified,\n * drawing will start from the first vertex.\n * @param instanceCount - The number of instances of the set of elements to execute. If not specified,\n * all instances will be drawn.\n */\n GeometrySystem.prototype.draw = function (type, size, start, instanceCount) {\n var gl = this.gl;\n var geometry = this._activeGeometry;\n // TODO.. this should not change so maybe cache the function?\n if (geometry.indexBuffer) {\n var byteSize = geometry.indexBuffer.data.BYTES_PER_ELEMENT;\n var glType = byteSize === 2 ? gl.UNSIGNED_SHORT : gl.UNSIGNED_INT;\n if (byteSize === 2 || (byteSize === 4 && this.canUseUInt32ElementIndex)) {\n if (geometry.instanced) {\n /* eslint-disable max-len */\n gl.drawElementsInstanced(type, size || geometry.indexBuffer.data.length, glType, (start || 0) * byteSize, instanceCount || 1);\n /* eslint-enable max-len */\n }\n else {\n /* eslint-disable max-len */\n gl.drawElements(type, size || geometry.indexBuffer.data.length, glType, (start || 0) * byteSize);\n /* eslint-enable max-len */\n }\n }\n else {\n console.warn('unsupported index buffer type: uint32');\n }\n }\n else if (geometry.instanced) {\n // TODO need a better way to calculate size..\n gl.drawArraysInstanced(type, start, size || geometry.getSize(), instanceCount || 1);\n }\n else {\n gl.drawArrays(type, start, size || geometry.getSize());\n }\n return this;\n };\n /** Unbind/reset everything. */\n GeometrySystem.prototype.unbind = function () {\n this.gl.bindVertexArray(null);\n this._activeVao = null;\n this._activeGeometry = null;\n };\n GeometrySystem.prototype.destroy = function () {\n this.renderer = null;\n };\n return GeometrySystem;\n}());\n\n/**\n * Component for masked elements.\n *\n * Holds mask mode and temporary data about current mask.\n * @memberof PIXI\n */\nvar MaskData = /** @class */ (function () {\n /**\n * Create MaskData\n * @param {PIXI.DisplayObject} [maskObject=null] - object that describes the mask\n */\n function MaskData(maskObject) {\n if (maskObject === void 0) { maskObject = null; }\n this.type = MASK_TYPES.NONE;\n this.autoDetect = true;\n this.maskObject = maskObject || null;\n this.pooled = false;\n this.isMaskData = true;\n this.resolution = null;\n this.multisample = settings.FILTER_MULTISAMPLE;\n this.enabled = true;\n this.colorMask = 0xf;\n this._filters = null;\n this._stencilCounter = 0;\n this._scissorCounter = 0;\n this._scissorRect = null;\n this._scissorRectLocal = null;\n this._colorMask = 0xf;\n this._target = null;\n }\n Object.defineProperty(MaskData.prototype, \"filter\", {\n /**\n * The sprite mask filter.\n * If set to `null`, the default sprite mask filter is used.\n * @default null\n */\n get: function () {\n return this._filters ? this._filters[0] : null;\n },\n set: function (value) {\n if (value) {\n if (this._filters) {\n this._filters[0] = value;\n }\n else {\n this._filters = [value];\n }\n }\n else {\n this._filters = null;\n }\n },\n enumerable: false,\n configurable: true\n });\n /** Resets the mask data after popMask(). */\n MaskData.prototype.reset = function () {\n if (this.pooled) {\n this.maskObject = null;\n this.type = MASK_TYPES.NONE;\n this.autoDetect = true;\n }\n this._target = null;\n this._scissorRectLocal = null;\n };\n /**\n * Copies counters from maskData above, called from pushMask().\n * @param maskAbove\n */\n MaskData.prototype.copyCountersOrReset = function (maskAbove) {\n if (maskAbove) {\n this._stencilCounter = maskAbove._stencilCounter;\n this._scissorCounter = maskAbove._scissorCounter;\n this._scissorRect = maskAbove._scissorRect;\n }\n else {\n this._stencilCounter = 0;\n this._scissorCounter = 0;\n this._scissorRect = null;\n }\n };\n return MaskData;\n}());\n\n/**\n * @private\n * @param {WebGLRenderingContext} gl - The current WebGL context {WebGLProgram}\n * @param {number} type - the type, can be either VERTEX_SHADER or FRAGMENT_SHADER\n * @param {string} src - The vertex shader source as an array of strings.\n * @returns {WebGLShader} the shader\n */\nfunction compileShader(gl, type, src) {\n var shader = gl.createShader(type);\n gl.shaderSource(shader, src);\n gl.compileShader(shader);\n return shader;\n}\n\n/**\n * will log a shader error highlighting the lines with the error\n * also will add numbers along the side.\n * @param gl - the WebGLContext\n * @param shader - the shader to log errors for\n */\nfunction logPrettyShaderError(gl, shader) {\n var shaderSrc = gl.getShaderSource(shader)\n .split('\\n')\n .map(function (line, index) { return index + \": \" + line; });\n var shaderLog = gl.getShaderInfoLog(shader);\n var splitShader = shaderLog.split('\\n');\n var dedupe = {};\n var lineNumbers = splitShader.map(function (line) { return parseFloat(line.replace(/^ERROR\\: 0\\:([\\d]+)\\:.*$/, '$1')); })\n .filter(function (n) {\n if (n && !dedupe[n]) {\n dedupe[n] = true;\n return true;\n }\n return false;\n });\n var logArgs = [''];\n lineNumbers.forEach(function (number) {\n shaderSrc[number - 1] = \"%c\" + shaderSrc[number - 1] + \"%c\";\n logArgs.push('background: #FF0000; color:#FFFFFF; font-size: 10px', 'font-size: 10px');\n });\n var fragmentSourceToLog = shaderSrc\n .join('\\n');\n logArgs[0] = fragmentSourceToLog;\n console.error(shaderLog);\n // eslint-disable-next-line no-console\n console.groupCollapsed('click to view full shader code');\n console.warn.apply(console, logArgs);\n // eslint-disable-next-line no-console\n console.groupEnd();\n}\n/**\n *\n * logs out any program errors\n * @param gl - The current WebGL context\n * @param program - the WebGL program to display errors for\n * @param vertexShader - the fragment WebGL shader program\n * @param fragmentShader - the vertex WebGL shader program\n */\nfunction logProgramError(gl, program, vertexShader, fragmentShader) {\n // if linking fails, then log and cleanup\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n logPrettyShaderError(gl, vertexShader);\n }\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n logPrettyShaderError(gl, fragmentShader);\n }\n console.error('PixiJS Error: Could not initialize shader.');\n // if there is a program info log, log it\n if (gl.getProgramInfoLog(program) !== '') {\n console.warn('PixiJS Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program));\n }\n }\n}\n\nfunction booleanArray(size) {\n var array = new Array(size);\n for (var i = 0; i < array.length; i++) {\n array[i] = false;\n }\n return array;\n}\n/**\n * @method defaultValue\n * @memberof PIXI.glCore.shader\n * @param {string} type - Type of value\n * @param {number} size\n * @private\n */\nfunction defaultValue(type, size) {\n switch (type) {\n case 'float':\n return 0;\n case 'vec2':\n return new Float32Array(2 * size);\n case 'vec3':\n return new Float32Array(3 * size);\n case 'vec4':\n return new Float32Array(4 * size);\n case 'int':\n case 'uint':\n case 'sampler2D':\n case 'sampler2DArray':\n return 0;\n case 'ivec2':\n return new Int32Array(2 * size);\n case 'ivec3':\n return new Int32Array(3 * size);\n case 'ivec4':\n return new Int32Array(4 * size);\n case 'uvec2':\n return new Uint32Array(2 * size);\n case 'uvec3':\n return new Uint32Array(3 * size);\n case 'uvec4':\n return new Uint32Array(4 * size);\n case 'bool':\n return false;\n case 'bvec2':\n return booleanArray(2 * size);\n case 'bvec3':\n return booleanArray(3 * size);\n case 'bvec4':\n return booleanArray(4 * size);\n case 'mat2':\n return new Float32Array([1, 0,\n 0, 1]);\n case 'mat3':\n return new Float32Array([1, 0, 0,\n 0, 1, 0,\n 0, 0, 1]);\n case 'mat4':\n return new Float32Array([1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1]);\n }\n return null;\n}\n\nvar unknownContext = {};\nvar context = unknownContext;\n/**\n * returns a little WebGL context to use for program inspection.\n * @static\n * @private\n * @returns {WebGLRenderingContext} a gl context to test with\n */\nfunction getTestContext() {\n if (context === unknownContext || (context && context.isContextLost())) {\n var canvas = settings.ADAPTER.createCanvas();\n var gl = void 0;\n if (settings.PREFER_ENV >= ENV.WEBGL2) {\n gl = canvas.getContext('webgl2', {});\n }\n if (!gl) {\n gl = (canvas.getContext('webgl', {})\n || canvas.getContext('experimental-webgl', {}));\n if (!gl) {\n // fail, not able to get a context\n gl = null;\n }\n else {\n // for shader testing..\n gl.getExtension('WEBGL_draw_buffers');\n }\n }\n context = gl;\n }\n return context;\n}\n\nvar maxFragmentPrecision;\nfunction getMaxFragmentPrecision() {\n if (!maxFragmentPrecision) {\n maxFragmentPrecision = PRECISION.MEDIUM;\n var gl = getTestContext();\n if (gl) {\n if (gl.getShaderPrecisionFormat) {\n var shaderFragment = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);\n maxFragmentPrecision = shaderFragment.precision ? PRECISION.HIGH : PRECISION.MEDIUM;\n }\n }\n }\n return maxFragmentPrecision;\n}\n\n/**\n * Sets the float precision on the shader, ensuring the device supports the request precision.\n * If the precision is already present, it just ensures that the device is able to handle it.\n * @private\n * @param {string} src - The shader source\n * @param {PIXI.PRECISION} requestedPrecision - The request float precision of the shader.\n * @param {PIXI.PRECISION} maxSupportedPrecision - The maximum precision the shader supports.\n * @returns {string} modified shader source\n */\nfunction setPrecision(src, requestedPrecision, maxSupportedPrecision) {\n if (src.substring(0, 9) !== 'precision') {\n // no precision supplied, so PixiJS will add the requested level.\n var precision = requestedPrecision;\n // If highp is requested but not supported, downgrade precision to a level all devices support.\n if (requestedPrecision === PRECISION.HIGH && maxSupportedPrecision !== PRECISION.HIGH) {\n precision = PRECISION.MEDIUM;\n }\n return \"precision \" + precision + \" float;\\n\" + src;\n }\n else if (maxSupportedPrecision !== PRECISION.HIGH && src.substring(0, 15) === 'precision highp') {\n // precision was supplied, but at a level this device does not support, so downgrading to mediump.\n return src.replace('precision highp', 'precision mediump');\n }\n return src;\n}\n\nvar GLSL_TO_SIZE = {\n float: 1,\n vec2: 2,\n vec3: 3,\n vec4: 4,\n int: 1,\n ivec2: 2,\n ivec3: 3,\n ivec4: 4,\n uint: 1,\n uvec2: 2,\n uvec3: 3,\n uvec4: 4,\n bool: 1,\n bvec2: 2,\n bvec3: 3,\n bvec4: 4,\n mat2: 4,\n mat3: 9,\n mat4: 16,\n sampler2D: 1,\n};\n/**\n * @private\n * @method mapSize\n * @memberof PIXI.glCore.shader\n * @param {string} type\n */\nfunction mapSize(type) {\n return GLSL_TO_SIZE[type];\n}\n\nvar GL_TABLE = null;\nvar GL_TO_GLSL_TYPES = {\n FLOAT: 'float',\n FLOAT_VEC2: 'vec2',\n FLOAT_VEC3: 'vec3',\n FLOAT_VEC4: 'vec4',\n INT: 'int',\n INT_VEC2: 'ivec2',\n INT_VEC3: 'ivec3',\n INT_VEC4: 'ivec4',\n UNSIGNED_INT: 'uint',\n UNSIGNED_INT_VEC2: 'uvec2',\n UNSIGNED_INT_VEC3: 'uvec3',\n UNSIGNED_INT_VEC4: 'uvec4',\n BOOL: 'bool',\n BOOL_VEC2: 'bvec2',\n BOOL_VEC3: 'bvec3',\n BOOL_VEC4: 'bvec4',\n FLOAT_MAT2: 'mat2',\n FLOAT_MAT3: 'mat3',\n FLOAT_MAT4: 'mat4',\n SAMPLER_2D: 'sampler2D',\n INT_SAMPLER_2D: 'sampler2D',\n UNSIGNED_INT_SAMPLER_2D: 'sampler2D',\n SAMPLER_CUBE: 'samplerCube',\n INT_SAMPLER_CUBE: 'samplerCube',\n UNSIGNED_INT_SAMPLER_CUBE: 'samplerCube',\n SAMPLER_2D_ARRAY: 'sampler2DArray',\n INT_SAMPLER_2D_ARRAY: 'sampler2DArray',\n UNSIGNED_INT_SAMPLER_2D_ARRAY: 'sampler2DArray',\n};\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nfunction mapType(gl, type) {\n if (!GL_TABLE) {\n var typeNames = Object.keys(GL_TO_GLSL_TYPES);\n GL_TABLE = {};\n for (var i = 0; i < typeNames.length; ++i) {\n var tn = typeNames[i];\n GL_TABLE[gl[tn]] = GL_TO_GLSL_TYPES[tn];\n }\n }\n return GL_TABLE[type];\n}\n\n/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n// Parsers, each one of these will take a look at the type of shader property and uniform.\n// if they pass the test function then the code function is called that returns a the shader upload code for that uniform.\n// Shader upload code is automagically generated with these parsers.\n// If no parser is valid then the default upload functions are used.\n// exposing Parsers means that custom upload logic can be added to pixi's shaders.\n// A good example would be a pixi rectangle can be directly set on a uniform.\n// If the shader sees it it knows how to upload the rectangle structure as a vec4\n// format is as follows:\n//\n// {\n// test: (data, uniform) => {} <--- test is this code should be used for this uniform\n// code: (name, uniform) => {} <--- returns the string of the piece of code that uploads the uniform\n// codeUbo: (name, uniform) => {} <--- returns the string of the piece of code that uploads the\n// uniform to a uniform buffer\n// }\nvar uniformParsers = [\n // a float cache layer\n {\n test: function (data) {\n return data.type === 'float' && data.size === 1 && !data.isArray;\n },\n code: function (name) {\n return \"\\n if(uv[\\\"\" + name + \"\\\"] !== ud[\\\"\" + name + \"\\\"].value)\\n {\\n ud[\\\"\" + name + \"\\\"].value = uv[\\\"\" + name + \"\\\"]\\n gl.uniform1f(ud[\\\"\" + name + \"\\\"].location, uv[\\\"\" + name + \"\\\"])\\n }\\n \";\n },\n },\n // handling samplers\n {\n test: function (data, uniform) {\n // eslint-disable-next-line max-len,no-eq-null,eqeqeq\n return (data.type === 'sampler2D' || data.type === 'samplerCube' || data.type === 'sampler2DArray') && data.size === 1 && !data.isArray && (uniform == null || uniform.castToBaseTexture !== undefined);\n },\n code: function (name) { return \"t = syncData.textureCount++;\\n\\n renderer.texture.bind(uv[\\\"\" + name + \"\\\"], t);\\n\\n if(ud[\\\"\" + name + \"\\\"].value !== t)\\n {\\n ud[\\\"\" + name + \"\\\"].value = t;\\n gl.uniform1i(ud[\\\"\" + name + \"\\\"].location, t);\\n; // eslint-disable-line max-len\\n }\"; },\n },\n // uploading pixi matrix object to mat3\n {\n test: function (data, uniform) {\n return data.type === 'mat3' && data.size === 1 && !data.isArray && uniform.a !== undefined;\n },\n code: function (name) {\n // TODO and some smart caching dirty ids here!\n return \"\\n gl.uniformMatrix3fv(ud[\\\"\" + name + \"\\\"].location, false, uv[\\\"\" + name + \"\\\"].toArray(true));\\n \";\n },\n codeUbo: function (name) {\n return \"\\n var \" + name + \"_matrix = uv.\" + name + \".toArray(true);\\n\\n data[offset] = \" + name + \"_matrix[0];\\n data[offset+1] = \" + name + \"_matrix[1];\\n data[offset+2] = \" + name + \"_matrix[2];\\n \\n data[offset + 4] = \" + name + \"_matrix[3];\\n data[offset + 5] = \" + name + \"_matrix[4];\\n data[offset + 6] = \" + name + \"_matrix[5];\\n \\n data[offset + 8] = \" + name + \"_matrix[6];\\n data[offset + 9] = \" + name + \"_matrix[7];\\n data[offset + 10] = \" + name + \"_matrix[8];\\n \";\n },\n },\n // uploading a pixi point as a vec2 with caching layer\n {\n test: function (data, uniform) {\n return data.type === 'vec2' && data.size === 1 && !data.isArray && uniform.x !== undefined;\n },\n code: function (name) {\n return \"\\n cv = ud[\\\"\" + name + \"\\\"].value;\\n v = uv[\\\"\" + name + \"\\\"];\\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[\\\"\" + name + \"\\\"].location, v.x, v.y);\\n }\";\n },\n codeUbo: function (name) {\n return \"\\n v = uv.\" + name + \";\\n\\n data[offset] = v.x;\\n data[offset+1] = v.y;\\n \";\n }\n },\n // caching layer for a vec2\n {\n test: function (data) {\n return data.type === 'vec2' && data.size === 1 && !data.isArray;\n },\n code: function (name) {\n return \"\\n cv = ud[\\\"\" + name + \"\\\"].value;\\n v = uv[\\\"\" + name + \"\\\"];\\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[\\\"\" + name + \"\\\"].location, v[0], v[1]);\\n }\\n \";\n },\n },\n // upload a pixi rectangle as a vec4 with caching layer\n {\n test: function (data, uniform) {\n return data.type === 'vec4' && data.size === 1 && !data.isArray && uniform.width !== undefined;\n },\n code: function (name) {\n return \"\\n cv = ud[\\\"\" + name + \"\\\"].value;\\n v = uv[\\\"\" + name + \"\\\"];\\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[\\\"\" + name + \"\\\"].location, v.x, v.y, v.width, v.height)\\n }\";\n },\n codeUbo: function (name) {\n return \"\\n v = uv.\" + name + \";\\n\\n data[offset] = v.x;\\n data[offset+1] = v.y;\\n data[offset+2] = v.width;\\n data[offset+3] = v.height;\\n \";\n }\n },\n // a caching layer for vec4 uploading\n {\n test: function (data) {\n return data.type === 'vec4' && data.size === 1 && !data.isArray;\n },\n code: function (name) {\n return \"\\n cv = ud[\\\"\" + name + \"\\\"].value;\\n v = uv[\\\"\" + name + \"\\\"];\\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[\\\"\" + name + \"\\\"].location, v[0], v[1], v[2], v[3])\\n }\";\n },\n } ];\n\n// cu = Cached value's uniform data field\n// cv = Cached value\n// v = value to upload\n// ud = uniformData\n// uv = uniformValue\n// l = location\nvar GLSL_TO_SINGLE_SETTERS_CACHED = {\n float: \"\\n if (cv !== v)\\n {\\n cu.value = v;\\n gl.uniform1f(location, v);\\n }\",\n vec2: \"\\n if (cv[0] !== v[0] || cv[1] !== v[1])\\n {\\n cv[0] = v[0];\\n cv[1] = v[1];\\n\\n gl.uniform2f(location, v[0], v[1])\\n }\",\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 }\",\n vec4: \"\\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(location, v[0], v[1], v[2], v[3]);\\n }\",\n int: \"\\n if (cv !== v)\\n {\\n cu.value = v;\\n\\n gl.uniform1i(location, v);\\n }\",\n ivec2: \"\\n if (cv[0] !== v[0] || cv[1] !== v[1])\\n {\\n cv[0] = v[0];\\n cv[1] = v[1];\\n\\n gl.uniform2i(location, v[0], v[1]);\\n }\",\n ivec3: \"\\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.uniform3i(location, v[0], v[1], v[2]);\\n }\",\n ivec4: \"\\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.uniform4i(location, v[0], v[1], v[2], v[3]);\\n }\",\n uint: \"\\n if (cv !== v)\\n {\\n cu.value = v;\\n\\n gl.uniform1ui(location, v);\\n }\",\n uvec2: \"\\n if (cv[0] !== v[0] || cv[1] !== v[1])\\n {\\n cv[0] = v[0];\\n cv[1] = v[1];\\n\\n gl.uniform2ui(location, v[0], v[1]);\\n }\",\n uvec3: \"\\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.uniform3ui(location, v[0], v[1], v[2]);\\n }\",\n uvec4: \"\\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.uniform4ui(location, v[0], v[1], v[2], v[3]);\\n }\",\n bool: \"\\n if (cv !== v)\\n {\\n cu.value = v;\\n gl.uniform1i(location, v);\\n }\",\n bvec2: \"\\n if (cv[0] != v[0] || cv[1] != v[1])\\n {\\n cv[0] = v[0];\\n cv[1] = v[1];\\n\\n gl.uniform2i(location, v[0], v[1]);\\n }\",\n bvec3: \"\\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.uniform3i(location, v[0], v[1], v[2]);\\n }\",\n bvec4: \"\\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.uniform4i(location, v[0], v[1], v[2], v[3]);\\n }\",\n mat2: 'gl.uniformMatrix2fv(location, false, v)',\n mat3: 'gl.uniformMatrix3fv(location, false, v)',\n mat4: 'gl.uniformMatrix4fv(location, false, v)',\n sampler2D: \"\\n if (cv !== v)\\n {\\n cu.value = v;\\n\\n gl.uniform1i(location, v);\\n }\",\n samplerCube: \"\\n if (cv !== v)\\n {\\n cu.value = v;\\n\\n gl.uniform1i(location, v);\\n }\",\n sampler2DArray: \"\\n if (cv !== v)\\n {\\n cu.value = v;\\n\\n gl.uniform1i(location, v);\\n }\",\n};\nvar GLSL_TO_ARRAY_SETTERS = {\n float: \"gl.uniform1fv(location, v)\",\n vec2: \"gl.uniform2fv(location, v)\",\n vec3: \"gl.uniform3fv(location, v)\",\n vec4: 'gl.uniform4fv(location, v)',\n mat4: 'gl.uniformMatrix4fv(location, false, v)',\n mat3: 'gl.uniformMatrix3fv(location, false, v)',\n mat2: 'gl.uniformMatrix2fv(location, false, v)',\n int: 'gl.uniform1iv(location, v)',\n ivec2: 'gl.uniform2iv(location, v)',\n ivec3: 'gl.uniform3iv(location, v)',\n ivec4: 'gl.uniform4iv(location, v)',\n uint: 'gl.uniform1uiv(location, v)',\n uvec2: 'gl.uniform2uiv(location, v)',\n uvec3: 'gl.uniform3uiv(location, v)',\n uvec4: 'gl.uniform4uiv(location, v)',\n bool: 'gl.uniform1iv(location, v)',\n bvec2: 'gl.uniform2iv(location, v)',\n bvec3: 'gl.uniform3iv(location, v)',\n bvec4: 'gl.uniform4iv(location, v)',\n sampler2D: 'gl.uniform1iv(location, v)',\n samplerCube: 'gl.uniform1iv(location, v)',\n sampler2DArray: 'gl.uniform1iv(location, v)',\n};\nfunction generateUniformsSync(group, uniformData) {\n var _a;\n var funcFragments = [\"\\n var v = null;\\n var cv = null;\\n var cu = null;\\n var t = 0;\\n var gl = renderer.gl;\\n \"];\n for (var i in group.uniforms) {\n var data = uniformData[i];\n if (!data) {\n if ((_a = group.uniforms[i]) === null || _a === void 0 ? void 0 : _a.group) {\n if (group.uniforms[i].ubo) {\n funcFragments.push(\"\\n renderer.shader.syncUniformBufferGroup(uv.\" + i + \", '\" + i + \"');\\n \");\n }\n else {\n funcFragments.push(\"\\n renderer.shader.syncUniformGroup(uv.\" + i + \", syncData);\\n \");\n }\n }\n continue;\n }\n var uniform = group.uniforms[i];\n var parsed = false;\n for (var j = 0; j < uniformParsers.length; j++) {\n if (uniformParsers[j].test(data, uniform)) {\n funcFragments.push(uniformParsers[j].code(i, uniform));\n parsed = true;\n break;\n }\n }\n if (!parsed) {\n var templateType = data.size === 1 && !data.isArray ? GLSL_TO_SINGLE_SETTERS_CACHED : GLSL_TO_ARRAY_SETTERS;\n var template = templateType[data.type].replace('location', \"ud[\\\"\" + i + \"\\\"].location\");\n funcFragments.push(\"\\n cu = ud[\\\"\" + i + \"\\\"];\\n cv = cu.value;\\n v = uv[\\\"\" + i + \"\\\"];\\n \" + template + \";\");\n }\n }\n /*\n * the introduction of syncData is to solve an issue where textures in uniform groups are not set correctly\n * the texture count was always starting from 0 in each group. This needs to increment each time a texture is used\n * no matter which group is being used\n *\n */\n // eslint-disable-next-line no-new-func\n return new Function('ud', 'uv', 'renderer', 'syncData', funcFragments.join('\\n'));\n}\n\nvar fragTemplate = [\n 'precision mediump float;',\n 'void main(void){',\n 'float test = 0.1;',\n '%forloop%',\n 'gl_FragColor = vec4(0.0);',\n '}' ].join('\\n');\nfunction generateIfTestSrc(maxIfs) {\n var src = '';\n for (var i = 0; i < maxIfs; ++i) {\n if (i > 0) {\n src += '\\nelse ';\n }\n if (i < maxIfs - 1) {\n src += \"if(test == \" + i + \".0){}\";\n }\n }\n return src;\n}\nfunction checkMaxIfStatementsInShader(maxIfs, gl) {\n if (maxIfs === 0) {\n throw new Error('Invalid value of `0` passed to `checkMaxIfStatementsInShader`');\n }\n var shader = gl.createShader(gl.FRAGMENT_SHADER);\n while (true) // eslint-disable-line no-constant-condition\n {\n var fragmentSrc = fragTemplate.replace(/%forloop%/gi, generateIfTestSrc(maxIfs));\n gl.shaderSource(shader, fragmentSrc);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n maxIfs = (maxIfs / 2) | 0;\n }\n else {\n // valid!\n break;\n }\n }\n return maxIfs;\n}\n\n// Cache the result to prevent running this over and over\nvar unsafeEval;\n/**\n * Not all platforms allow to generate function code (e.g., `new Function`).\n * this provides the platform-level detection.\n * @private\n * @returns {boolean} `true` if `new Function` is supported.\n */\nfunction unsafeEvalSupported() {\n if (typeof unsafeEval === 'boolean') {\n return unsafeEval;\n }\n try {\n /* eslint-disable no-new-func */\n var func = new Function('param1', 'param2', 'param3', 'return param1[param2] === param3;');\n /* eslint-enable no-new-func */\n unsafeEval = func({ a: 'b' }, 'a', 'b') === true;\n }\n catch (e) {\n unsafeEval = false;\n }\n return unsafeEval;\n}\n\nvar defaultFragment$2 = \"varying vec2 vTextureCoord;\\n\\nuniform sampler2D uSampler;\\n\\nvoid main(void){\\n gl_FragColor *= texture2D(uSampler, vTextureCoord);\\n}\";\n\nvar defaultVertex$3 = \"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\";\n\nvar UID$1 = 0;\nvar nameCache = {};\n/**\n * Helper class to create a shader program.\n * @memberof PIXI\n */\nvar Program = /** @class */ (function () {\n /**\n * @param vertexSrc - The source of the vertex shader.\n * @param fragmentSrc - The source of the fragment shader.\n * @param name - Name for shader\n */\n function Program(vertexSrc, fragmentSrc, name) {\n if (name === void 0) { name = 'pixi-shader'; }\n this.id = UID$1++;\n this.vertexSrc = vertexSrc || Program.defaultVertexSrc;\n this.fragmentSrc = fragmentSrc || Program.defaultFragmentSrc;\n this.vertexSrc = this.vertexSrc.trim();\n this.fragmentSrc = this.fragmentSrc.trim();\n if (this.vertexSrc.substring(0, 8) !== '#version') {\n name = name.replace(/\\s+/g, '-');\n if (nameCache[name]) {\n nameCache[name]++;\n name += \"-\" + nameCache[name];\n }\n else {\n nameCache[name] = 1;\n }\n this.vertexSrc = \"#define SHADER_NAME \" + name + \"\\n\" + this.vertexSrc;\n this.fragmentSrc = \"#define SHADER_NAME \" + name + \"\\n\" + this.fragmentSrc;\n this.vertexSrc = setPrecision(this.vertexSrc, settings.PRECISION_VERTEX, PRECISION.HIGH);\n this.fragmentSrc = setPrecision(this.fragmentSrc, settings.PRECISION_FRAGMENT, getMaxFragmentPrecision());\n }\n // currently this does not extract structs only default types\n // this is where we store shader references..\n this.glPrograms = {};\n this.syncUniforms = null;\n }\n Object.defineProperty(Program, \"defaultVertexSrc\", {\n /**\n * The default vertex shader source.\n * @constant\n */\n get: function () {\n return defaultVertex$3;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Program, \"defaultFragmentSrc\", {\n /**\n * The default fragment shader source.\n * @constant\n */\n get: function () {\n return defaultFragment$2;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * A short hand function to create a program based of a vertex and fragment shader.\n *\n * This method will also check to see if there is a cached program.\n * @param vertexSrc - The source of the vertex shader.\n * @param fragmentSrc - The source of the fragment shader.\n * @param name - Name for shader\n * @returns A shiny new PixiJS shader program!\n */\n Program.from = function (vertexSrc, fragmentSrc, name) {\n var key = vertexSrc + fragmentSrc;\n var program = ProgramCache[key];\n if (!program) {\n ProgramCache[key] = program = new Program(vertexSrc, fragmentSrc, name);\n }\n return program;\n };\n return Program;\n}());\n\n/**\n * A helper class for shaders.\n * @memberof PIXI\n */\nvar Shader = /** @class */ (function () {\n /**\n * @param program - The program the shader will use.\n * @param uniforms - Custom uniforms to use to augment the built-in ones.\n */\n function Shader(program, uniforms) {\n /**\n * Used internally to bind uniform buffer objects.\n * @ignore\n */\n this.uniformBindCount = 0;\n this.program = program;\n // lets see whats been passed in\n // uniforms should be converted to a uniform group\n if (uniforms) {\n if (uniforms instanceof UniformGroup) {\n this.uniformGroup = uniforms;\n }\n else {\n this.uniformGroup = new UniformGroup(uniforms);\n }\n }\n else {\n this.uniformGroup = new UniformGroup({});\n }\n this.disposeRunner = new Runner('disposeShader');\n }\n // TODO move to shader system..\n Shader.prototype.checkUniformExists = function (name, group) {\n if (group.uniforms[name]) {\n return true;\n }\n for (var i in group.uniforms) {\n var uniform = group.uniforms[i];\n if (uniform.group) {\n if (this.checkUniformExists(name, uniform)) {\n return true;\n }\n }\n }\n return false;\n };\n Shader.prototype.destroy = function () {\n // usage count on programs?\n // remove if not used!\n this.uniformGroup = null;\n this.disposeRunner.emit(this);\n this.disposeRunner.destroy();\n };\n Object.defineProperty(Shader.prototype, \"uniforms\", {\n /**\n * Shader uniform values, shortcut for `uniformGroup.uniforms`.\n * @readonly\n */\n get: function () {\n return this.uniformGroup.uniforms;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * A short hand function to create a shader based of a vertex and fragment shader.\n * @param vertexSrc - The source of the vertex shader.\n * @param fragmentSrc - The source of the fragment shader.\n * @param uniforms - Custom uniforms to use to augment the built-in ones.\n * @returns A shiny new PixiJS shader!\n */\n Shader.from = function (vertexSrc, fragmentSrc, uniforms) {\n var program = Program.from(vertexSrc, fragmentSrc);\n return new Shader(program, uniforms);\n };\n return Shader;\n}());\n\n/* eslint-disable max-len */\nvar BLEND$1 = 0;\nvar OFFSET$1 = 1;\nvar CULLING$1 = 2;\nvar DEPTH_TEST$1 = 3;\nvar WINDING$1 = 4;\nvar DEPTH_MASK$1 = 5;\n/**\n * This is a WebGL state, and is is passed to {@link PIXI.StateSystem}.\n *\n * Each mesh rendered may require WebGL to be in a different state.\n * For example you may want different blend mode or to enable polygon offsets\n * @memberof PIXI\n */\nvar State = /** @class */ (function () {\n function State() {\n this.data = 0;\n this.blendMode = BLEND_MODES.NORMAL;\n this.polygonOffset = 0;\n this.blend = true;\n this.depthMask = true;\n // this.depthTest = true;\n }\n Object.defineProperty(State.prototype, \"blend\", {\n /**\n * Activates blending of the computed fragment color values.\n * @default true\n */\n get: function () {\n return !!(this.data & (1 << BLEND$1));\n },\n set: function (value) {\n if (!!(this.data & (1 << BLEND$1)) !== value) {\n this.data ^= (1 << BLEND$1);\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(State.prototype, \"offsets\", {\n /**\n * Activates adding an offset to depth values of polygon's fragments\n * @default false\n */\n get: function () {\n return !!(this.data & (1 << OFFSET$1));\n },\n set: function (value) {\n if (!!(this.data & (1 << OFFSET$1)) !== value) {\n this.data ^= (1 << OFFSET$1);\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(State.prototype, \"culling\", {\n /**\n * Activates culling of polygons.\n * @default false\n */\n get: function () {\n return !!(this.data & (1 << CULLING$1));\n },\n set: function (value) {\n if (!!(this.data & (1 << CULLING$1)) !== value) {\n this.data ^= (1 << CULLING$1);\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(State.prototype, \"depthTest\", {\n /**\n * Activates depth comparisons and updates to the depth buffer.\n * @default false\n */\n get: function () {\n return !!(this.data & (1 << DEPTH_TEST$1));\n },\n set: function (value) {\n if (!!(this.data & (1 << DEPTH_TEST$1)) !== value) {\n this.data ^= (1 << DEPTH_TEST$1);\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(State.prototype, \"depthMask\", {\n /**\n * Enables or disables writing to the depth buffer.\n * @default true\n */\n get: function () {\n return !!(this.data & (1 << DEPTH_MASK$1));\n },\n set: function (value) {\n if (!!(this.data & (1 << DEPTH_MASK$1)) !== value) {\n this.data ^= (1 << DEPTH_MASK$1);\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(State.prototype, \"clockwiseFrontFace\", {\n /**\n * Specifies whether or not front or back-facing polygons can be culled.\n * @default false\n */\n get: function () {\n return !!(this.data & (1 << WINDING$1));\n },\n set: function (value) {\n if (!!(this.data & (1 << WINDING$1)) !== value) {\n this.data ^= (1 << WINDING$1);\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(State.prototype, \"blendMode\", {\n /**\n * The blend mode to be applied when this state is set. Apply a value of `PIXI.BLEND_MODES.NORMAL` to reset the blend mode.\n * Setting this mode to anything other than NO_BLEND will automatically switch blending on.\n * @default PIXI.BLEND_MODES.NORMAL\n */\n get: function () {\n return this._blendMode;\n },\n set: function (value) {\n this.blend = (value !== BLEND_MODES.NONE);\n this._blendMode = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(State.prototype, \"polygonOffset\", {\n /**\n * The polygon offset. Setting this property to anything other than 0 will automatically enable polygon offset fill.\n * @default 0\n */\n get: function () {\n return this._polygonOffset;\n },\n set: function (value) {\n this.offsets = !!value;\n this._polygonOffset = value;\n },\n enumerable: false,\n configurable: true\n });\n State.prototype.toString = function () {\n return \"[@pixi/core:State \"\n + (\"blendMode=\" + this.blendMode + \" \")\n + (\"clockwiseFrontFace=\" + this.clockwiseFrontFace + \" \")\n + (\"culling=\" + this.culling + \" \")\n + (\"depthMask=\" + this.depthMask + \" \")\n + (\"polygonOffset=\" + this.polygonOffset)\n + \"]\";\n };\n State.for2d = function () {\n var state = new State();\n state.depthTest = false;\n state.blend = true;\n return state;\n };\n return State;\n}());\n\nvar defaultFragment$1 = \"varying vec2 vTextureCoord;\\n\\nuniform sampler2D uSampler;\\n\\nvoid main(void){\\n gl_FragColor = texture2D(uSampler, vTextureCoord);\\n}\\n\";\n\nvar defaultVertex$2 = \"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\";\n\n/**\n * A filter is a special shader that applies post-processing effects to an input texture and writes into an output\n * render-target.\n *\n * {@link http://pixijs.io/examples/#/filters/blur-filter.js Example} of the\n * {@link PIXI.filters.BlurFilter BlurFilter}.\n *\n * ### Usage\n * Filters can be applied to any DisplayObject or Container.\n * PixiJS' `FilterSystem` renders the container into temporary Framebuffer,\n * then filter renders it to the screen.\n * Multiple filters can be added to the `filters` array property and stacked on each other.\n *\n * ```\n * const filter = new PIXI.Filter(myShaderVert, myShaderFrag, { myUniform: 0.5 });\n * const container = new PIXI.Container();\n * container.filters = [filter];\n * ```\n *\n * ### Previous Version Differences\n *\n * In PixiJS **v3**, a filter was always applied to _whole screen_.\n *\n * In PixiJS **v4**, a filter can be applied _only part of the screen_.\n * Developers had to create a set of uniforms to deal with coordinates.\n *\n * In PixiJS **v5** combines _both approaches_.\n * Developers can use normal coordinates of v3 and then allow filter to use partial Framebuffers,\n * bringing those extra uniforms into account.\n *\n * Also be aware that we have changed default vertex shader, please consult\n * {@link https://github.com/pixijs/pixi.js/wiki/v5-Creating-filters Wiki}.\n *\n * ### Frames\n *\n * The following table summarizes the coordinate spaces used in the filtering pipeline:\n *\n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n *
Coordinate SpaceDescription
Texture Coordinates\n * The texture (or UV) coordinates in the input base-texture's space. These are normalized into the (0,1) range along\n * both axes.\n *
World Space\n * A point in the same space as the world bounds of any display-object (i.e. in the scene graph's space).\n *
Physical Pixels\n * This is base-texture's space with the origin on the top-left. You can calculate these by multiplying the texture\n * coordinates by the dimensions of the texture.\n *
\n *\n * ### Built-in Uniforms\n *\n * PixiJS viewport uses screen (CSS) coordinates, `(0, 0, renderer.screen.width, renderer.screen.height)`,\n * and `projectionMatrix` uniform maps it to the gl viewport.\n *\n * **uSampler**\n *\n * The most important uniform is the input texture that container was rendered into.\n * _Important note: as with all Framebuffers in PixiJS, both input and output are\n * premultiplied by alpha._\n *\n * By default, input normalized coordinates are passed to fragment shader with `vTextureCoord`.\n * Use it to sample the input.\n *\n * ```\n * const fragment = `\n * varying vec2 vTextureCoord;\n * uniform sampler2D uSampler;\n * void main(void)\n * {\n * gl_FragColor = texture2D(uSampler, vTextureCoord);\n * }\n * `;\n *\n * const myFilter = new PIXI.Filter(null, fragment);\n * ```\n *\n * This filter is just one uniform less than {@link PIXI.filters.AlphaFilter AlphaFilter}.\n *\n * **outputFrame**\n *\n * The `outputFrame` holds the rectangle where filter is applied in screen (CSS) coordinates.\n * It's the same as `renderer.screen` for a fullscreen filter.\n * Only a part of `outputFrame.zw` size of temporary Framebuffer is used,\n * `(0, 0, outputFrame.width, outputFrame.height)`,\n *\n * Filters uses this quad to normalized (0-1) space, its passed into `aVertexPosition` attribute.\n * To calculate vertex position in screen space using normalized (0-1) space:\n *\n * ```\n * vec4 filterVertexPosition( void )\n * {\n * vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n * return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n * }\n * ```\n *\n * **inputSize**\n *\n * Temporary framebuffer is different, it can be either the size of screen, either power-of-two.\n * The `inputSize.xy` are size of temporary framebuffer that holds input.\n * The `inputSize.zw` is inverted, it's a shortcut to evade division inside the shader.\n *\n * Set `inputSize.xy = outputFrame.zw` for a fullscreen filter.\n *\n * To calculate input normalized coordinate, you have to map it to filter normalized space.\n * Multiply by `outputFrame.zw` to get input coordinate.\n * Divide by `inputSize.xy` to get input normalized coordinate.\n *\n * ```\n * vec2 filterTextureCoord( void )\n * {\n * return aVertexPosition * (outputFrame.zw * inputSize.zw); // same as /inputSize.xy\n * }\n * ```\n * **resolution**\n *\n * The `resolution` is the ratio of screen (CSS) pixels to real pixels.\n *\n * **inputPixel**\n *\n * `inputPixel.xy` is the size of framebuffer in real pixels, same as `inputSize.xy * resolution`\n * `inputPixel.zw` is inverted `inputPixel.xy`.\n *\n * It's handy for filters that use neighbour pixels, like {@link PIXI.filters.FXAAFilter FXAAFilter}.\n *\n * **inputClamp**\n *\n * If you try to get info from outside of used part of Framebuffer - you'll get undefined behaviour.\n * For displacements, coordinates has to be clamped.\n *\n * The `inputClamp.xy` is left-top pixel center, you may ignore it, because we use left-top part of Framebuffer\n * `inputClamp.zw` is bottom-right pixel center.\n *\n * ```\n * vec4 color = texture2D(uSampler, clamp(modifiedTextureCoord, inputClamp.xy, inputClamp.zw))\n * ```\n * OR\n * ```\n * vec4 color = texture2D(uSampler, min(modifigedTextureCoord, inputClamp.zw))\n * ```\n *\n * ### Additional Information\n *\n * Complete documentation on Filter usage is located in the\n * {@link https://github.com/pixijs/pixi.js/wiki/v5-Creating-filters Wiki}.\n *\n * Since PixiJS only had a handful of built-in filters, additional filters can be downloaded\n * {@link https://github.com/pixijs/pixi-filters here} from the PixiJS Filters repository.\n * @memberof PIXI\n */\nvar Filter = /** @class */ (function (_super) {\n __extends(Filter, _super);\n /**\n * @param vertexSrc - The source of the vertex shader.\n * @param fragmentSrc - The source of the fragment shader.\n * @param uniforms - Custom uniforms to use to augment the built-in ones.\n */\n function Filter(vertexSrc, fragmentSrc, uniforms) {\n var _this = this;\n var program = Program.from(vertexSrc || Filter.defaultVertexSrc, fragmentSrc || Filter.defaultFragmentSrc);\n _this = _super.call(this, program, uniforms) || this;\n _this.padding = 0;\n _this.resolution = settings.FILTER_RESOLUTION;\n _this.multisample = settings.FILTER_MULTISAMPLE;\n _this.enabled = true;\n _this.autoFit = true;\n _this.state = new State();\n return _this;\n }\n /**\n * Applies the filter\n * @param {PIXI.FilterSystem} filterManager - The renderer to retrieve the filter from\n * @param {PIXI.RenderTexture} input - The input render target.\n * @param {PIXI.RenderTexture} output - The target to output to.\n * @param {PIXI.CLEAR_MODES} [clearMode] - Should the output be cleared before rendering to it.\n * @param {object} [_currentState] - It's current state of filter.\n * There are some useful properties in the currentState :\n * target, filters, sourceFrame, destinationFrame, renderTarget, resolution\n */\n Filter.prototype.apply = function (filterManager, input, output, clearMode, _currentState) {\n // do as you please!\n filterManager.applyFilter(this, input, output, clearMode);\n // or just do a regular render..\n };\n Object.defineProperty(Filter.prototype, \"blendMode\", {\n /**\n * Sets the blend mode of the filter.\n * @default PIXI.BLEND_MODES.NORMAL\n */\n get: function () {\n return this.state.blendMode;\n },\n set: function (value) {\n this.state.blendMode = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Filter.prototype, \"resolution\", {\n /**\n * The resolution of the filter. Setting this to be lower will lower the quality but\n * increase the performance of the filter.\n */\n get: function () {\n return this._resolution;\n },\n set: function (value) {\n this._resolution = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Filter, \"defaultVertexSrc\", {\n /**\n * The default vertex shader source\n * @constant\n */\n get: function () {\n return defaultVertex$2;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Filter, \"defaultFragmentSrc\", {\n /**\n * The default fragment shader source\n * @constant\n */\n get: function () {\n return defaultFragment$1;\n },\n enumerable: false,\n configurable: true\n });\n return Filter;\n}(Shader));\n\nvar 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\";\n\nvar 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\";\n\nvar tempMat = new Matrix();\n/**\n * Class controls uv mapping from Texture normal space to BaseTexture normal space.\n *\n * Takes `trim` and `rotate` into account. May contain clamp settings for Meshes and TilingSprite.\n *\n * Can be used in Texture `uvMatrix` field, or separately, you can use different clamp settings on the same texture.\n * If you want to add support for texture region of certain feature or filter, that's what you're looking for.\n *\n * Takes track of Texture changes through `_lastTextureID` private field.\n * Use `update()` method call to track it from outside.\n * @see PIXI.Texture\n * @see PIXI.Mesh\n * @see PIXI.TilingSprite\n * @memberof PIXI\n */\nvar TextureMatrix = /** @class */ (function () {\n /**\n * @param texture - observed texture\n * @param clampMargin - Changes frame clamping, 0.5 by default. Use -0.5 for extra border.\n */\n function TextureMatrix(texture, clampMargin) {\n this._texture = texture;\n this.mapCoord = new Matrix();\n this.uClampFrame = new Float32Array(4);\n this.uClampOffset = new Float32Array(2);\n this._textureID = -1;\n this._updateID = 0;\n this.clampOffset = 0;\n this.clampMargin = (typeof clampMargin === 'undefined') ? 0.5 : clampMargin;\n this.isSimple = false;\n }\n Object.defineProperty(TextureMatrix.prototype, \"texture\", {\n /** Texture property. */\n get: function () {\n return this._texture;\n },\n set: function (value) {\n this._texture = value;\n this._textureID = -1;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Multiplies uvs array to transform\n * @param uvs - mesh uvs\n * @param [out=uvs] - output\n * @returns - output\n */\n TextureMatrix.prototype.multiplyUvs = function (uvs, out) {\n if (out === undefined) {\n out = uvs;\n }\n var mat = this.mapCoord;\n for (var i = 0; i < uvs.length; i += 2) {\n var x = uvs[i];\n var y = uvs[i + 1];\n out[i] = (x * mat.a) + (y * mat.c) + mat.tx;\n out[i + 1] = (x * mat.b) + (y * mat.d) + mat.ty;\n }\n return out;\n };\n /**\n * Updates matrices if texture was changed.\n * @param [forceUpdate=false] - if true, matrices will be updated any case\n * @returns - Whether or not it was updated\n */\n TextureMatrix.prototype.update = function (forceUpdate) {\n var tex = this._texture;\n if (!tex || !tex.valid) {\n return false;\n }\n if (!forceUpdate\n && this._textureID === tex._updateID) {\n return false;\n }\n this._textureID = tex._updateID;\n this._updateID++;\n var uvs = tex._uvs;\n this.mapCoord.set(uvs.x1 - uvs.x0, uvs.y1 - uvs.y0, uvs.x3 - uvs.x0, uvs.y3 - uvs.y0, uvs.x0, uvs.y0);\n var orig = tex.orig;\n var trim = tex.trim;\n if (trim) {\n tempMat.set(orig.width / trim.width, 0, 0, orig.height / trim.height, -trim.x / trim.width, -trim.y / trim.height);\n this.mapCoord.append(tempMat);\n }\n var texBase = tex.baseTexture;\n var frame = this.uClampFrame;\n var margin = this.clampMargin / texBase.resolution;\n var offset = this.clampOffset;\n frame[0] = (tex._frame.x + margin + offset) / texBase.width;\n frame[1] = (tex._frame.y + margin + offset) / texBase.height;\n frame[2] = (tex._frame.x + tex._frame.width - margin + offset) / texBase.width;\n frame[3] = (tex._frame.y + tex._frame.height - margin + offset) / texBase.height;\n this.uClampOffset[0] = offset / texBase.realWidth;\n this.uClampOffset[1] = offset / texBase.realHeight;\n this.isSimple = tex._frame.width === texBase.width\n && tex._frame.height === texBase.height\n && tex.rotate === 0;\n return true;\n };\n return TextureMatrix;\n}());\n\n/**\n * This handles a Sprite acting as a mask, as opposed to a Graphic.\n *\n * WebGL only.\n * @memberof PIXI\n */\nvar SpriteMaskFilter = /** @class */ (function (_super) {\n __extends(SpriteMaskFilter, _super);\n /** @ignore */\n function SpriteMaskFilter(vertexSrc, fragmentSrc, uniforms) {\n var _this = this;\n var sprite = null;\n if (typeof vertexSrc !== 'string' && fragmentSrc === undefined && uniforms === undefined) {\n sprite = vertexSrc;\n vertexSrc = undefined;\n fragmentSrc = undefined;\n uniforms = undefined;\n }\n _this = _super.call(this, vertexSrc || vertex, fragmentSrc || fragment, uniforms) || this;\n _this.maskSprite = sprite;\n _this.maskMatrix = new Matrix();\n return _this;\n }\n Object.defineProperty(SpriteMaskFilter.prototype, \"maskSprite\", {\n /**\n * Sprite mask\n * @type {PIXI.DisplayObject}\n */\n get: function () {\n return this._maskSprite;\n },\n set: function (value) {\n this._maskSprite = value;\n if (this._maskSprite) {\n this._maskSprite.renderable = false;\n }\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Applies the filter\n * @param filterManager - The renderer to retrieve the filter from\n * @param input - The input render target.\n * @param output - The target to output to.\n * @param clearMode - Should the output be cleared before rendering to it.\n */\n SpriteMaskFilter.prototype.apply = function (filterManager, input, output, clearMode) {\n var maskSprite = this._maskSprite;\n var tex = maskSprite._texture;\n if (!tex.valid) {\n return;\n }\n if (!tex.uvMatrix) {\n // margin = 0.0, let it bleed a bit, shader code becomes easier\n // assuming that atlas textures were made with 1-pixel padding\n tex.uvMatrix = new TextureMatrix(tex, 0.0);\n }\n tex.uvMatrix.update();\n this.uniforms.npmAlpha = tex.baseTexture.alphaMode ? 0.0 : 1.0;\n this.uniforms.mask = tex;\n // get _normalized sprite texture coords_ and convert them to _normalized atlas texture coords_ with `prepend`\n this.uniforms.otherMatrix = filterManager.calculateSpriteMatrix(this.maskMatrix, maskSprite)\n .prepend(tex.uvMatrix.mapCoord);\n this.uniforms.alpha = maskSprite.worldAlpha;\n this.uniforms.maskClamp = tex.uvMatrix.uClampFrame;\n filterManager.applyFilter(this, input, output, clearMode);\n };\n return SpriteMaskFilter;\n}(Filter));\n\n/**\n * System plugin to the renderer to manage masks.\n *\n * There are three built-in types of masking:\n * **Scissor Masking**: Scissor masking discards pixels that are outside of a rectangle called the scissor box. It is\n * the most performant as the scissor test is inexpensive. However, it can only be used when the mask is rectangular.\n * **Stencil Masking**: Stencil masking discards pixels that don't overlap with the pixels rendered into the stencil\n * buffer. It is the next fastest option as it does not require rendering into a separate framebuffer. However, it does\n * cause the mask to be rendered **twice** for each masking operation; hence, minimize the rendering cost of your masks.\n * **Sprite Mask Filtering**: Sprite mask filtering discards pixels based on the red channel of the sprite-mask's\n * texture. (Generally, the masking texture is grayscale). Using advanced techniques, you might be able to embed this\n * type of masking in a custom shader - and hence, bypassing the masking system fully for performance wins.\n *\n * The best type of masking is auto-detected when you `push` one. To use scissor masking, you must pass in a `Graphics`\n * object with just a rectangle drawn.\n *\n * ## Mask Stacks\n *\n * In the scene graph, masks can be applied recursively, i.e. a mask can be applied during a masking operation. The mask\n * stack stores the currently applied masks in order. Each {@link PIXI.BaseRenderTexture} holds its own mask stack, i.e.\n * when you switch render-textures, the old masks only applied when you switch back to rendering to the old render-target.\n * @memberof PIXI\n */\nvar MaskSystem = /** @class */ (function () {\n /**\n * @param renderer - The renderer this System works for.\n */\n function MaskSystem(renderer) {\n this.renderer = renderer;\n this.enableScissor = true;\n this.alphaMaskPool = [];\n this.maskDataPool = [];\n this.maskStack = [];\n this.alphaMaskIndex = 0;\n }\n /**\n * Changes the mask stack that is used by this System.\n * @param maskStack - The mask stack\n */\n MaskSystem.prototype.setMaskStack = function (maskStack) {\n this.maskStack = maskStack;\n this.renderer.scissor.setMaskStack(maskStack);\n this.renderer.stencil.setMaskStack(maskStack);\n };\n /**\n * Enables the mask and appends it to the current mask stack.\n *\n * NOTE: The batch renderer should be flushed beforehand to prevent pending renders from being masked.\n * @param {PIXI.DisplayObject} target - Display Object to push the mask to\n * @param {PIXI.MaskData|PIXI.Sprite|PIXI.Graphics|PIXI.DisplayObject} maskDataOrTarget - The masking data.\n */\n MaskSystem.prototype.push = function (target, maskDataOrTarget) {\n var maskData = maskDataOrTarget;\n if (!maskData.isMaskData) {\n var d = this.maskDataPool.pop() || new MaskData();\n d.pooled = true;\n d.maskObject = maskDataOrTarget;\n maskData = d;\n }\n var maskAbove = this.maskStack.length !== 0 ? this.maskStack[this.maskStack.length - 1] : null;\n maskData.copyCountersOrReset(maskAbove);\n maskData._colorMask = maskAbove ? maskAbove._colorMask : 0xf;\n if (maskData.autoDetect) {\n this.detect(maskData);\n }\n maskData._target = target;\n if (maskData.type !== MASK_TYPES.SPRITE) {\n this.maskStack.push(maskData);\n }\n if (maskData.enabled) {\n switch (maskData.type) {\n case MASK_TYPES.SCISSOR:\n this.renderer.scissor.push(maskData);\n break;\n case MASK_TYPES.STENCIL:\n this.renderer.stencil.push(maskData);\n break;\n case MASK_TYPES.SPRITE:\n maskData.copyCountersOrReset(null);\n this.pushSpriteMask(maskData);\n break;\n case MASK_TYPES.COLOR:\n this.pushColorMask(maskData);\n break;\n }\n }\n if (maskData.type === MASK_TYPES.SPRITE) {\n this.maskStack.push(maskData);\n }\n };\n /**\n * Removes the last mask from the mask stack and doesn't return it.\n *\n * NOTE: The batch renderer should be flushed beforehand to render the masked contents before the mask is removed.\n * @param {PIXI.IMaskTarget} target - Display Object to pop the mask from\n */\n MaskSystem.prototype.pop = function (target) {\n var maskData = this.maskStack.pop();\n if (!maskData || maskData._target !== target) {\n // TODO: add an assert when we have it\n return;\n }\n if (maskData.enabled) {\n switch (maskData.type) {\n case MASK_TYPES.SCISSOR:\n this.renderer.scissor.pop(maskData);\n break;\n case MASK_TYPES.STENCIL:\n this.renderer.stencil.pop(maskData.maskObject);\n break;\n case MASK_TYPES.SPRITE:\n this.popSpriteMask(maskData);\n break;\n case MASK_TYPES.COLOR:\n this.popColorMask(maskData);\n break;\n }\n }\n maskData.reset();\n if (maskData.pooled) {\n this.maskDataPool.push(maskData);\n }\n if (this.maskStack.length !== 0) {\n var maskCurrent = this.maskStack[this.maskStack.length - 1];\n if (maskCurrent.type === MASK_TYPES.SPRITE && maskCurrent._filters) {\n maskCurrent._filters[0].maskSprite = maskCurrent.maskObject;\n }\n }\n };\n /**\n * Sets type of MaskData based on its maskObject.\n * @param maskData\n */\n MaskSystem.prototype.detect = function (maskData) {\n var maskObject = maskData.maskObject;\n if (!maskObject) {\n maskData.type = MASK_TYPES.COLOR;\n }\n else if (maskObject.isSprite) {\n maskData.type = MASK_TYPES.SPRITE;\n }\n else if (this.enableScissor && this.renderer.scissor.testScissor(maskData)) {\n maskData.type = MASK_TYPES.SCISSOR;\n }\n else {\n maskData.type = MASK_TYPES.STENCIL;\n }\n };\n /**\n * Applies the Mask and adds it to the current filter stack.\n * @param maskData - Sprite to be used as the mask.\n */\n MaskSystem.prototype.pushSpriteMask = function (maskData) {\n var _a, _b;\n var maskObject = maskData.maskObject;\n var target = maskData._target;\n var alphaMaskFilter = maskData._filters;\n if (!alphaMaskFilter) {\n alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex];\n if (!alphaMaskFilter) {\n alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex] = [new SpriteMaskFilter()];\n }\n }\n var renderer = this.renderer;\n var renderTextureSystem = renderer.renderTexture;\n var resolution;\n var multisample;\n if (renderTextureSystem.current) {\n var renderTexture = renderTextureSystem.current;\n resolution = maskData.resolution || renderTexture.resolution;\n multisample = (_a = maskData.multisample) !== null && _a !== void 0 ? _a : renderTexture.multisample;\n }\n else {\n resolution = maskData.resolution || renderer.resolution;\n multisample = (_b = maskData.multisample) !== null && _b !== void 0 ? _b : renderer.multisample;\n }\n alphaMaskFilter[0].resolution = resolution;\n alphaMaskFilter[0].multisample = multisample;\n alphaMaskFilter[0].maskSprite = maskObject;\n var stashFilterArea = target.filterArea;\n target.filterArea = maskObject.getBounds(true);\n renderer.filter.push(target, alphaMaskFilter);\n target.filterArea = stashFilterArea;\n if (!maskData._filters) {\n this.alphaMaskIndex++;\n }\n };\n /**\n * Removes the last filter from the filter stack and doesn't return it.\n * @param maskData - Sprite to be used as the mask.\n */\n MaskSystem.prototype.popSpriteMask = function (maskData) {\n this.renderer.filter.pop();\n if (maskData._filters) {\n maskData._filters[0].maskSprite = null;\n }\n else {\n this.alphaMaskIndex--;\n this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite = null;\n }\n };\n /**\n * Pushes the color mask.\n * @param maskData - The mask data\n */\n MaskSystem.prototype.pushColorMask = function (maskData) {\n var currColorMask = maskData._colorMask;\n var nextColorMask = maskData._colorMask = currColorMask & maskData.colorMask;\n if (nextColorMask !== currColorMask) {\n this.renderer.gl.colorMask((nextColorMask & 0x1) !== 0, (nextColorMask & 0x2) !== 0, (nextColorMask & 0x4) !== 0, (nextColorMask & 0x8) !== 0);\n }\n };\n /**\n * Pops the color mask.\n * @param maskData - The mask data\n */\n MaskSystem.prototype.popColorMask = function (maskData) {\n var currColorMask = maskData._colorMask;\n var nextColorMask = this.maskStack.length > 0\n ? this.maskStack[this.maskStack.length - 1]._colorMask : 0xf;\n if (nextColorMask !== currColorMask) {\n this.renderer.gl.colorMask((nextColorMask & 0x1) !== 0, (nextColorMask & 0x2) !== 0, (nextColorMask & 0x4) !== 0, (nextColorMask & 0x8) !== 0);\n }\n };\n MaskSystem.prototype.destroy = function () {\n this.renderer = null;\n };\n return MaskSystem;\n}());\n\n/**\n * System plugin to the renderer to manage specific types of masking operations.\n * @memberof PIXI\n */\nvar AbstractMaskSystem = /** @class */ (function () {\n /**\n * @param renderer - The renderer this System works for.\n */\n function AbstractMaskSystem(renderer) {\n this.renderer = renderer;\n this.maskStack = [];\n this.glConst = 0;\n }\n /** Gets count of masks of certain type. */\n AbstractMaskSystem.prototype.getStackLength = function () {\n return this.maskStack.length;\n };\n /**\n * Changes the mask stack that is used by this System.\n * @param {PIXI.MaskData[]} maskStack - The mask stack\n */\n AbstractMaskSystem.prototype.setMaskStack = function (maskStack) {\n var gl = this.renderer.gl;\n var curStackLen = this.getStackLength();\n this.maskStack = maskStack;\n var newStackLen = this.getStackLength();\n if (newStackLen !== curStackLen) {\n if (newStackLen === 0) {\n gl.disable(this.glConst);\n }\n else {\n gl.enable(this.glConst);\n this._useCurrent();\n }\n }\n };\n /**\n * Setup renderer to use the current mask data.\n * @private\n */\n AbstractMaskSystem.prototype._useCurrent = function () {\n // OVERWRITE;\n };\n /** Destroys the mask stack. */\n AbstractMaskSystem.prototype.destroy = function () {\n this.renderer = null;\n this.maskStack = null;\n };\n return AbstractMaskSystem;\n}());\n\nvar tempMatrix$1 = new Matrix();\nvar rectPool = [];\n/**\n * System plugin to the renderer to manage scissor masking.\n *\n * Scissor masking discards pixels outside of a rectangle called the scissor box. The scissor box is in the framebuffer\n * viewport's space; however, the mask's rectangle is projected from world-space to viewport space automatically\n * by this system.\n * @memberof PIXI\n */\nvar ScissorSystem = /** @class */ (function (_super) {\n __extends(ScissorSystem, _super);\n /**\n * @param {PIXI.Renderer} renderer - The renderer this System works for.\n */\n function ScissorSystem(renderer) {\n var _this = _super.call(this, renderer) || this;\n _this.glConst = settings.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST;\n return _this;\n }\n ScissorSystem.prototype.getStackLength = function () {\n var maskData = this.maskStack[this.maskStack.length - 1];\n if (maskData) {\n return maskData._scissorCounter;\n }\n return 0;\n };\n /**\n * evaluates _boundsTransformed, _scissorRect for MaskData\n * @param maskData\n */\n ScissorSystem.prototype.calcScissorRect = function (maskData) {\n var _a;\n if (maskData._scissorRectLocal) {\n return;\n }\n var prevData = maskData._scissorRect;\n var maskObject = maskData.maskObject;\n var renderer = this.renderer;\n var renderTextureSystem = renderer.renderTexture;\n var rect = maskObject.getBounds(true, (_a = rectPool.pop()) !== null && _a !== void 0 ? _a : new Rectangle());\n this.roundFrameToPixels(rect, renderTextureSystem.current ? renderTextureSystem.current.resolution : renderer.resolution, renderTextureSystem.sourceFrame, renderTextureSystem.destinationFrame, renderer.projection.transform);\n if (prevData) {\n rect.fit(prevData);\n }\n maskData._scissorRectLocal = rect;\n };\n ScissorSystem.isMatrixRotated = function (matrix) {\n if (!matrix) {\n return false;\n }\n var a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d;\n // Skip if skew/rotation present in matrix, except for multiple of 90° rotation. If rotation\n // is a multiple of 90°, then either pair of (b,c) or (a,d) will be (0,0).\n return ((Math.abs(b) > 1e-4 || Math.abs(c) > 1e-4)\n && (Math.abs(a) > 1e-4 || Math.abs(d) > 1e-4));\n };\n /**\n * Test, whether the object can be scissor mask with current renderer projection.\n * Calls \"calcScissorRect()\" if its true.\n * @param maskData - mask data\n * @returns whether Whether the object can be scissor mask\n */\n ScissorSystem.prototype.testScissor = function (maskData) {\n var maskObject = maskData.maskObject;\n if (!maskObject.isFastRect || !maskObject.isFastRect()) {\n return false;\n }\n if (ScissorSystem.isMatrixRotated(maskObject.worldTransform)) {\n return false;\n }\n if (ScissorSystem.isMatrixRotated(this.renderer.projection.transform)) {\n return false;\n }\n this.calcScissorRect(maskData);\n var rect = maskData._scissorRectLocal;\n return rect.width > 0 && rect.height > 0;\n };\n ScissorSystem.prototype.roundFrameToPixels = function (frame, resolution, bindingSourceFrame, bindingDestinationFrame, transform) {\n if (ScissorSystem.isMatrixRotated(transform)) {\n return;\n }\n transform = transform ? tempMatrix$1.copyFrom(transform) : tempMatrix$1.identity();\n // Get forward transform from world space to screen space\n transform\n .translate(-bindingSourceFrame.x, -bindingSourceFrame.y)\n .scale(bindingDestinationFrame.width / bindingSourceFrame.width, bindingDestinationFrame.height / bindingSourceFrame.height)\n .translate(bindingDestinationFrame.x, bindingDestinationFrame.y);\n // Convert frame to screen space\n this.renderer.filter.transformAABB(transform, frame);\n frame.fit(bindingDestinationFrame);\n frame.x = Math.round(frame.x * resolution);\n frame.y = Math.round(frame.y * resolution);\n frame.width = Math.round(frame.width * resolution);\n frame.height = Math.round(frame.height * resolution);\n };\n /**\n * Applies the Mask and adds it to the current stencil stack.\n * @author alvin\n * @param maskData - The mask data.\n */\n ScissorSystem.prototype.push = function (maskData) {\n if (!maskData._scissorRectLocal) {\n this.calcScissorRect(maskData);\n }\n var gl = this.renderer.gl;\n if (!maskData._scissorRect) {\n gl.enable(gl.SCISSOR_TEST);\n }\n maskData._scissorCounter++;\n maskData._scissorRect = maskData._scissorRectLocal;\n this._useCurrent();\n };\n /**\n * This should be called after a mask is popped off the mask stack. It will rebind the scissor box to be latest with the\n * last mask in the stack.\n *\n * This can also be called when you directly modify the scissor box and want to restore PixiJS state.\n * @param maskData - The mask data.\n */\n ScissorSystem.prototype.pop = function (maskData) {\n var gl = this.renderer.gl;\n if (maskData) {\n rectPool.push(maskData._scissorRectLocal);\n }\n if (this.getStackLength() > 0) {\n this._useCurrent();\n }\n else {\n gl.disable(gl.SCISSOR_TEST);\n }\n };\n /**\n * Setup renderer to use the current scissor data.\n * @private\n */\n ScissorSystem.prototype._useCurrent = function () {\n var rect = this.maskStack[this.maskStack.length - 1]._scissorRect;\n var y;\n if (this.renderer.renderTexture.current) {\n y = rect.y;\n }\n else {\n // flipY. In future we'll have it over renderTextures as an option\n y = this.renderer.height - rect.height - rect.y;\n }\n this.renderer.gl.scissor(rect.x, y, rect.width, rect.height);\n };\n return ScissorSystem;\n}(AbstractMaskSystem));\n\n/**\n * System plugin to the renderer to manage stencils (used for masks).\n * @memberof PIXI\n */\nvar StencilSystem = /** @class */ (function (_super) {\n __extends(StencilSystem, _super);\n /**\n * @param renderer - The renderer this System works for.\n */\n function StencilSystem(renderer) {\n var _this = _super.call(this, renderer) || this;\n _this.glConst = settings.ADAPTER.getWebGLRenderingContext().STENCIL_TEST;\n return _this;\n }\n StencilSystem.prototype.getStackLength = function () {\n var maskData = this.maskStack[this.maskStack.length - 1];\n if (maskData) {\n return maskData._stencilCounter;\n }\n return 0;\n };\n /**\n * Applies the Mask and adds it to the current stencil stack.\n * @param maskData - The mask data\n */\n StencilSystem.prototype.push = function (maskData) {\n var maskObject = maskData.maskObject;\n var gl = this.renderer.gl;\n var prevMaskCount = maskData._stencilCounter;\n if (prevMaskCount === 0) {\n // force use stencil texture in current framebuffer\n this.renderer.framebuffer.forceStencil();\n gl.clearStencil(0);\n gl.clear(gl.STENCIL_BUFFER_BIT);\n gl.enable(gl.STENCIL_TEST);\n }\n maskData._stencilCounter++;\n var colorMask = maskData._colorMask;\n if (colorMask !== 0) {\n maskData._colorMask = 0;\n gl.colorMask(false, false, false, false);\n }\n // Increment the reference stencil value where the new mask overlaps with the old ones.\n gl.stencilFunc(gl.EQUAL, prevMaskCount, 0xFFFFFFFF);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR);\n maskObject.renderable = true;\n maskObject.render(this.renderer);\n this.renderer.batch.flush();\n maskObject.renderable = false;\n if (colorMask !== 0) {\n maskData._colorMask = colorMask;\n gl.colorMask((colorMask & 1) !== 0, (colorMask & 2) !== 0, (colorMask & 4) !== 0, (colorMask & 8) !== 0);\n }\n this._useCurrent();\n };\n /**\n * Pops stencil mask. MaskData is already removed from stack\n * @param {PIXI.DisplayObject} maskObject - object of popped mask data\n */\n StencilSystem.prototype.pop = function (maskObject) {\n var gl = this.renderer.gl;\n if (this.getStackLength() === 0) {\n // the stack is empty!\n gl.disable(gl.STENCIL_TEST);\n }\n else {\n var maskData = this.maskStack.length !== 0 ? this.maskStack[this.maskStack.length - 1] : null;\n var colorMask = maskData ? maskData._colorMask : 0xf;\n if (colorMask !== 0) {\n maskData._colorMask = 0;\n gl.colorMask(false, false, false, false);\n }\n // Decrement the reference stencil value where the popped mask overlaps with the other ones\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.DECR);\n maskObject.renderable = true;\n maskObject.render(this.renderer);\n this.renderer.batch.flush();\n maskObject.renderable = false;\n if (colorMask !== 0) {\n maskData._colorMask = colorMask;\n gl.colorMask((colorMask & 0x1) !== 0, (colorMask & 0x2) !== 0, (colorMask & 0x4) !== 0, (colorMask & 0x8) !== 0);\n }\n this._useCurrent();\n }\n };\n /**\n * Setup renderer to use the current stencil data.\n * @private\n */\n StencilSystem.prototype._useCurrent = function () {\n var gl = this.renderer.gl;\n gl.stencilFunc(gl.EQUAL, this.getStackLength(), 0xFFFFFFFF);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);\n };\n return StencilSystem;\n}(AbstractMaskSystem));\n\n/**\n * System plugin to the renderer to manage the projection matrix.\n *\n * The `projectionMatrix` is a global uniform provided to all shaders. It is used to transform points in world space to\n * normalized device coordinates.\n * @memberof PIXI\n */\nvar ProjectionSystem = /** @class */ (function () {\n /** @param renderer - The renderer this System works for. */\n function ProjectionSystem(renderer) {\n this.renderer = renderer;\n this.destinationFrame = null;\n this.sourceFrame = null;\n this.defaultFrame = null;\n this.projectionMatrix = new Matrix();\n this.transform = null;\n }\n /**\n * Updates the projection-matrix based on the sourceFrame → destinationFrame mapping provided.\n *\n * NOTE: It is expected you call `renderer.framebuffer.setViewport(destinationFrame)` after this. This is because\n * the framebuffer viewport converts shader vertex output in normalized device coordinates to window coordinates.\n *\n * NOTE-2: {@link RenderTextureSystem#bind} updates the projection-matrix when you bind a render-texture. It is expected\n * that you dirty the current bindings when calling this manually.\n * @param destinationFrame - The rectangle in the render-target to render the contents into. If rendering to the canvas,\n * the origin is on the top-left; if rendering to a render-texture, the origin is on the bottom-left.\n * @param sourceFrame - The rectangle in world space that contains the contents being rendered.\n * @param resolution - The resolution of the render-target, which is the ratio of\n * world-space (or CSS) pixels to physical pixels.\n * @param root - Whether the render-target is the screen. This is required because rendering to textures\n * is y-flipped (i.e. upside down relative to the screen).\n */\n ProjectionSystem.prototype.update = function (destinationFrame, sourceFrame, resolution, root) {\n this.destinationFrame = destinationFrame || this.destinationFrame || this.defaultFrame;\n this.sourceFrame = sourceFrame || this.sourceFrame || destinationFrame;\n // Calculate object-space to clip-space projection\n this.calculateProjection(this.destinationFrame, this.sourceFrame, resolution, root);\n if (this.transform) {\n this.projectionMatrix.append(this.transform);\n }\n var renderer = this.renderer;\n renderer.globalUniforms.uniforms.projectionMatrix = this.projectionMatrix;\n renderer.globalUniforms.update();\n // this will work for now\n // but would be sweet to stick and even on the global uniforms..\n if (renderer.shader.shader) {\n renderer.shader.syncUniformGroup(renderer.shader.shader.uniforms.globals);\n }\n };\n /**\n * Calculates the `projectionMatrix` to map points inside `sourceFrame` to inside `destinationFrame`.\n * @param _destinationFrame - The destination frame in the render-target.\n * @param sourceFrame - The source frame in world space.\n * @param _resolution - The render-target's resolution, i.e. ratio of CSS to physical pixels.\n * @param root - Whether rendering into the screen. Otherwise, if rendering to a framebuffer, the projection\n * is y-flipped.\n */\n ProjectionSystem.prototype.calculateProjection = function (_destinationFrame, sourceFrame, _resolution, root) {\n var pm = this.projectionMatrix;\n var sign = !root ? 1 : -1;\n pm.identity();\n pm.a = (1 / sourceFrame.width * 2);\n pm.d = sign * (1 / sourceFrame.height * 2);\n pm.tx = -1 - (sourceFrame.x * pm.a);\n pm.ty = -sign - (sourceFrame.y * pm.d);\n };\n /**\n * Sets the transform of the active render target to the given matrix.\n * @param _matrix - The transformation matrix\n */\n ProjectionSystem.prototype.setTransform = function (_matrix) {\n // this._activeRenderTarget.transform = matrix;\n };\n ProjectionSystem.prototype.destroy = function () {\n this.renderer = null;\n };\n return ProjectionSystem;\n}());\n\n// Temporary rectangle for assigned sourceFrame or destinationFrame\nvar tempRect = new Rectangle();\n// Temporary rectangle for renderTexture destinationFrame\nvar tempRect2 = new Rectangle();\n/* eslint-disable max-len */\n/**\n * System plugin to the renderer to manage render textures.\n *\n * Should be added after FramebufferSystem\n *\n * ### Frames\n *\n * The `RenderTextureSystem` holds a sourceFrame → destinationFrame projection. The following table explains the different\n * coordinate spaces used:\n *\n * | Frame | Description | Coordinate System |\n * | ---------------------- | ---------------------------------------------------------------- | ------------------------------------------------------- |\n * | sourceFrame | The rectangle inside of which display-objects are being rendered | **World Space**: The origin on the top-left |\n * | destinationFrame | The rectangle in the render-target (canvas or texture) into which contents should be rendered | If rendering to the canvas, this is in screen space and the origin is on the top-left. If rendering to a render-texture, this is in its base-texture's space with the origin on the bottom-left. |\n * | viewportFrame | The framebuffer viewport corresponding to the destination-frame | **Window Coordinates**: The origin is always on the bottom-left. |\n * @memberof PIXI\n */\nvar RenderTextureSystem = /** @class */ (function () {\n /**\n * @param renderer - The renderer this System works for.\n */\n function RenderTextureSystem(renderer) {\n this.renderer = renderer;\n this.clearColor = renderer._backgroundColorRgba;\n this.defaultMaskStack = [];\n this.current = null;\n this.sourceFrame = new Rectangle();\n this.destinationFrame = new Rectangle();\n this.viewportFrame = new Rectangle();\n }\n /**\n * Bind the current render texture.\n * @param renderTexture - RenderTexture to bind, by default its `null` - the screen.\n * @param sourceFrame - Part of world that is mapped to the renderTexture.\n * @param destinationFrame - Part of renderTexture, by default it has the same size as sourceFrame.\n */\n RenderTextureSystem.prototype.bind = function (renderTexture, sourceFrame, destinationFrame) {\n if (renderTexture === void 0) { renderTexture = null; }\n var renderer = this.renderer;\n this.current = renderTexture;\n var baseTexture;\n var framebuffer;\n var resolution;\n if (renderTexture) {\n baseTexture = renderTexture.baseTexture;\n resolution = baseTexture.resolution;\n if (!sourceFrame) {\n tempRect.width = renderTexture.frame.width;\n tempRect.height = renderTexture.frame.height;\n sourceFrame = tempRect;\n }\n if (!destinationFrame) {\n tempRect2.x = renderTexture.frame.x;\n tempRect2.y = renderTexture.frame.y;\n tempRect2.width = sourceFrame.width;\n tempRect2.height = sourceFrame.height;\n destinationFrame = tempRect2;\n }\n framebuffer = baseTexture.framebuffer;\n }\n else {\n resolution = renderer.resolution;\n if (!sourceFrame) {\n tempRect.width = renderer.screen.width;\n tempRect.height = renderer.screen.height;\n sourceFrame = tempRect;\n }\n if (!destinationFrame) {\n destinationFrame = tempRect;\n destinationFrame.width = sourceFrame.width;\n destinationFrame.height = sourceFrame.height;\n }\n }\n var viewportFrame = this.viewportFrame;\n viewportFrame.x = destinationFrame.x * resolution;\n viewportFrame.y = destinationFrame.y * resolution;\n viewportFrame.width = destinationFrame.width * resolution;\n viewportFrame.height = destinationFrame.height * resolution;\n if (!renderTexture) {\n viewportFrame.y = renderer.view.height - (viewportFrame.y + viewportFrame.height);\n }\n viewportFrame.ceil();\n this.renderer.framebuffer.bind(framebuffer, viewportFrame);\n this.renderer.projection.update(destinationFrame, sourceFrame, resolution, !framebuffer);\n if (renderTexture) {\n this.renderer.mask.setMaskStack(baseTexture.maskStack);\n }\n else {\n this.renderer.mask.setMaskStack(this.defaultMaskStack);\n }\n this.sourceFrame.copyFrom(sourceFrame);\n this.destinationFrame.copyFrom(destinationFrame);\n };\n /**\n * Erases the render texture and fills the drawing area with a colour.\n * @param clearColor - The color as rgba, default to use the renderer backgroundColor\n * @param [mask=BUFFER_BITS.COLOR | BUFFER_BITS.DEPTH] - Bitwise OR of masks\n * that indicate the buffers to be cleared, by default COLOR and DEPTH buffers.\n */\n RenderTextureSystem.prototype.clear = function (clearColor, mask) {\n if (this.current) {\n clearColor = clearColor || this.current.baseTexture.clearColor;\n }\n else {\n clearColor = clearColor || this.clearColor;\n }\n var destinationFrame = this.destinationFrame;\n var baseFrame = this.current ? this.current.baseTexture : this.renderer.screen;\n var clearMask = destinationFrame.width !== baseFrame.width || destinationFrame.height !== baseFrame.height;\n if (clearMask) {\n var _a = this.viewportFrame, x = _a.x, y = _a.y, width = _a.width, height = _a.height;\n x = Math.round(x);\n y = Math.round(y);\n width = Math.round(width);\n height = Math.round(height);\n // TODO: ScissorSystem should cache whether the scissor test is enabled or not.\n this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST);\n this.renderer.gl.scissor(x, y, width, height);\n }\n this.renderer.framebuffer.clear(clearColor[0], clearColor[1], clearColor[2], clearColor[3], mask);\n if (clearMask) {\n // Restore the scissor box\n this.renderer.scissor.pop();\n }\n };\n RenderTextureSystem.prototype.resize = function () {\n // resize the root only!\n this.bind(null);\n };\n /** Resets render-texture state. */\n RenderTextureSystem.prototype.reset = function () {\n this.bind(null);\n };\n RenderTextureSystem.prototype.destroy = function () {\n this.renderer = null;\n };\n return RenderTextureSystem;\n}());\n\nfunction uboUpdate(_ud, _uv, _renderer, _syncData, buffer) {\n _renderer.buffer.update(buffer);\n}\n// cv = CachedValue\n// v = value\n// ud = uniformData\n// uv = uniformValue\n// l = location\nvar UBO_TO_SINGLE_SETTERS = {\n float: \"\\n data[offset] = v;\\n \",\n vec2: \"\\n data[offset] = v[0];\\n data[offset+1] = v[1];\\n \",\n vec3: \"\\n data[offset] = v[0];\\n data[offset+1] = v[1];\\n data[offset+2] = v[2];\\n\\n \",\n vec4: \"\\n data[offset] = v[0];\\n data[offset+1] = v[1];\\n data[offset+2] = v[2];\\n data[offset+3] = v[3];\\n \",\n mat2: \"\\n data[offset] = v[0];\\n data[offset+1] = v[1];\\n\\n data[offset+4] = v[2];\\n data[offset+5] = v[3];\\n \",\n mat3: \"\\n data[offset] = v[0];\\n data[offset+1] = v[1];\\n data[offset+2] = v[2];\\n\\n data[offset + 4] = v[3];\\n data[offset + 5] = v[4];\\n data[offset + 6] = v[5];\\n\\n data[offset + 8] = v[6];\\n data[offset + 9] = v[7];\\n data[offset + 10] = v[8];\\n \",\n mat4: \"\\n for(var i = 0; i < 16; i++)\\n {\\n data[offset + i] = v[i];\\n }\\n \"\n};\nvar GLSL_TO_STD40_SIZE = {\n float: 4,\n vec2: 8,\n vec3: 12,\n vec4: 16,\n int: 4,\n ivec2: 8,\n ivec3: 12,\n ivec4: 16,\n uint: 4,\n uvec2: 8,\n uvec3: 12,\n uvec4: 16,\n bool: 4,\n bvec2: 8,\n bvec3: 12,\n bvec4: 16,\n mat2: 16 * 2,\n mat3: 16 * 3,\n mat4: 16 * 4,\n};\n/**\n * logic originally from here: https://github.com/sketchpunk/FunWithWebGL2/blob/master/lesson_022/Shaders.js\n * rewrote it, but this was a great starting point to get a solid understanding of whats going on :)\n * @ignore\n * @param uniformData\n */\nfunction createUBOElements(uniformData) {\n var uboElements = uniformData.map(function (data) {\n return ({\n data: data,\n offset: 0,\n dataLen: 0,\n dirty: 0\n });\n });\n var size = 0;\n var chunkSize = 0;\n var offset = 0;\n for (var i = 0; i < uboElements.length; i++) {\n var uboElement = uboElements[i];\n size = GLSL_TO_STD40_SIZE[uboElement.data.type];\n if (uboElement.data.size > 1) {\n size = Math.max(size, 16) * uboElement.data.size;\n }\n uboElement.dataLen = size;\n // add some size offset..\n // must align to the nearest 16 bytes or internally nearest round size\n if (chunkSize % size !== 0 && chunkSize < 16) {\n // diff required to line up..\n var lineUpValue = (chunkSize % size) % 16;\n chunkSize += lineUpValue;\n offset += lineUpValue;\n }\n if ((chunkSize + size) > 16) {\n offset = Math.ceil(offset / 16) * 16;\n uboElement.offset = offset;\n offset += size;\n chunkSize = size;\n }\n else {\n uboElement.offset = offset;\n chunkSize += size;\n offset += size;\n }\n }\n offset = Math.ceil(offset / 16) * 16;\n return { uboElements: uboElements, size: offset };\n}\nfunction getUBOData(uniforms, uniformData) {\n var usedUniformDatas = [];\n // build..\n for (var i in uniforms) {\n if (uniformData[i]) {\n usedUniformDatas.push(uniformData[i]);\n }\n }\n // sort them out by index!\n usedUniformDatas.sort(function (a, b) { return a.index - b.index; });\n return usedUniformDatas;\n}\nfunction generateUniformBufferSync(group, uniformData) {\n if (!group.autoManage) {\n // if the group is nott automatically managed, we don't need to generate a special function for it...\n return { size: 0, syncFunc: uboUpdate };\n }\n var usedUniformDatas = getUBOData(group.uniforms, uniformData);\n var _a = createUBOElements(usedUniformDatas), uboElements = _a.uboElements, size = _a.size;\n var funcFragments = [\"\\n var v = null;\\n var v2 = null;\\n var cv = null;\\n var t = 0;\\n var gl = renderer.gl\\n var index = 0;\\n var data = buffer.data;\\n \"];\n for (var i = 0; i < uboElements.length; i++) {\n var uboElement = uboElements[i];\n var uniform = group.uniforms[uboElement.data.name];\n var name = uboElement.data.name;\n var parsed = false;\n for (var j = 0; j < uniformParsers.length; j++) {\n var uniformParser = uniformParsers[j];\n if (uniformParser.codeUbo && uniformParser.test(uboElement.data, uniform)) {\n funcFragments.push(\"offset = \" + uboElement.offset / 4 + \";\", uniformParsers[j].codeUbo(uboElement.data.name, uniform));\n parsed = true;\n break;\n }\n }\n if (!parsed) {\n if (uboElement.data.size > 1) {\n var size_1 = mapSize(uboElement.data.type);\n var rowSize = Math.max(GLSL_TO_STD40_SIZE[uboElement.data.type] / 16, 1);\n var elementSize = size_1 / rowSize;\n var remainder = (4 - (elementSize % 4)) % 4;\n funcFragments.push(\"\\n cv = ud.\" + name + \".value;\\n v = uv.\" + name + \";\\n offset = \" + uboElement.offset / 4 + \";\\n\\n t = 0;\\n\\n for(var i=0; i < \" + uboElement.data.size * rowSize + \"; i++)\\n {\\n for(var j = 0; j < \" + elementSize + \"; j++)\\n {\\n data[offset++] = v[t++];\\n }\\n offset += \" + remainder + \";\\n }\\n\\n \");\n }\n else {\n var template = UBO_TO_SINGLE_SETTERS[uboElement.data.type];\n funcFragments.push(\"\\n cv = ud.\" + name + \".value;\\n v = uv.\" + name + \";\\n offset = \" + uboElement.offset / 4 + \";\\n \" + template + \";\\n \");\n }\n }\n }\n funcFragments.push(\"\\n renderer.buffer.update(buffer);\\n \");\n return {\n size: size,\n // eslint-disable-next-line no-new-func\n syncFunc: new Function('ud', 'uv', 'renderer', 'syncData', 'buffer', funcFragments.join('\\n'))\n };\n}\n\n/**\n * @private\n */\nvar IGLUniformData = /** @class */ (function () {\n function IGLUniformData() {\n }\n return IGLUniformData;\n}());\n/**\n * Helper class to create a WebGL Program\n * @memberof PIXI\n */\nvar GLProgram = /** @class */ (function () {\n /**\n * Makes a new Pixi program.\n * @param program - webgl program\n * @param uniformData - uniforms\n */\n function GLProgram(program, uniformData) {\n this.program = program;\n this.uniformData = uniformData;\n this.uniformGroups = {};\n this.uniformDirtyGroups = {};\n this.uniformBufferBindings = {};\n }\n /** Destroys this program. */\n GLProgram.prototype.destroy = function () {\n this.uniformData = null;\n this.uniformGroups = null;\n this.uniformDirtyGroups = null;\n this.uniformBufferBindings = null;\n this.program = null;\n };\n return GLProgram;\n}());\n\n/**\n * returns the attribute data from the program\n * @private\n * @param {WebGLProgram} [program] - the WebGL program\n * @param {WebGLRenderingContext} [gl] - the WebGL context\n * @returns {object} the attribute data for this program\n */\nfunction getAttributeData(program, gl) {\n var attributes = {};\n var totalAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);\n for (var i = 0; i < totalAttributes; i++) {\n var attribData = gl.getActiveAttrib(program, i);\n if (attribData.name.indexOf('gl_') === 0) {\n continue;\n }\n var type = mapType(gl, attribData.type);\n var data = {\n type: type,\n name: attribData.name,\n size: mapSize(type),\n location: gl.getAttribLocation(program, attribData.name),\n };\n attributes[attribData.name] = data;\n }\n return attributes;\n}\n\n/**\n * returns the uniform data from the program\n * @private\n * @param program - the webgl program\n * @param gl - the WebGL context\n * @returns {object} the uniform data for this program\n */\nfunction getUniformData(program, gl) {\n var uniforms = {};\n var totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);\n for (var i = 0; i < totalUniforms; i++) {\n var uniformData = gl.getActiveUniform(program, i);\n var name = uniformData.name.replace(/\\[.*?\\]$/, '');\n var isArray = !!(uniformData.name.match(/\\[.*?\\]$/));\n var type = mapType(gl, uniformData.type);\n uniforms[name] = {\n name: name,\n index: i,\n type: type,\n size: uniformData.size,\n isArray: isArray,\n value: defaultValue(type, uniformData.size),\n };\n }\n return uniforms;\n}\n\n/**\n * generates a WebGL Program object from a high level Pixi Program.\n * @param gl - a rendering context on which to generate the program\n * @param program - the high level Pixi Program.\n */\nfunction generateProgram(gl, program) {\n var glVertShader = compileShader(gl, gl.VERTEX_SHADER, program.vertexSrc);\n var glFragShader = compileShader(gl, gl.FRAGMENT_SHADER, program.fragmentSrc);\n var webGLProgram = gl.createProgram();\n gl.attachShader(webGLProgram, glVertShader);\n gl.attachShader(webGLProgram, glFragShader);\n gl.linkProgram(webGLProgram);\n if (!gl.getProgramParameter(webGLProgram, gl.LINK_STATUS)) {\n logProgramError(gl, webGLProgram, glVertShader, glFragShader);\n }\n program.attributeData = getAttributeData(webGLProgram, gl);\n program.uniformData = getUniformData(webGLProgram, gl);\n // GLSL 1.00: bind attributes sorted by name in ascending order\n // GLSL 3.00: don't change the attribute locations that where chosen by the compiler\n // or assigned by the layout specifier in the shader source code\n if (!(/^[ \\t]*#[ \\t]*version[ \\t]+300[ \\t]+es[ \\t]*$/m).test(program.vertexSrc)) {\n var keys = Object.keys(program.attributeData);\n keys.sort(function (a, b) { return (a > b) ? 1 : -1; }); // eslint-disable-line no-confusing-arrow\n for (var i = 0; i < keys.length; i++) {\n program.attributeData[keys[i]].location = i;\n gl.bindAttribLocation(webGLProgram, i, keys[i]);\n }\n gl.linkProgram(webGLProgram);\n }\n gl.deleteShader(glVertShader);\n gl.deleteShader(glFragShader);\n var uniformData = {};\n for (var i in program.uniformData) {\n var data = program.uniformData[i];\n uniformData[i] = {\n location: gl.getUniformLocation(webGLProgram, i),\n value: defaultValue(data.type, data.size),\n };\n }\n var glProgram = new GLProgram(webGLProgram, uniformData);\n return glProgram;\n}\n\nvar UID = 0;\n// default sync data so we don't create a new one each time!\nvar defaultSyncData = { textureCount: 0, uboCount: 0 };\n/**\n * System plugin to the renderer to manage shaders.\n * @memberof PIXI\n */\nvar ShaderSystem = /** @class */ (function () {\n /** @param renderer - The renderer this System works for. */\n function ShaderSystem(renderer) {\n this.destroyed = false;\n this.renderer = renderer;\n // Validation check that this environment support `new Function`\n this.systemCheck();\n this.gl = null;\n this.shader = null;\n this.program = null;\n this.cache = {};\n this._uboCache = {};\n this.id = UID++;\n }\n /**\n * Overrideable function by `@pixi/unsafe-eval` to silence\n * throwing an error if platform doesn't support unsafe-evals.\n * @private\n */\n ShaderSystem.prototype.systemCheck = function () {\n if (!unsafeEvalSupported()) {\n throw new Error('Current environment does not allow unsafe-eval, '\n + 'please use @pixi/unsafe-eval module to enable support.');\n }\n };\n ShaderSystem.prototype.contextChange = function (gl) {\n this.gl = gl;\n this.reset();\n };\n /**\n * Changes the current shader to the one given in parameter.\n * @param shader - the new shader\n * @param dontSync - false if the shader should automatically sync its uniforms.\n * @returns the glProgram that belongs to the shader.\n */\n ShaderSystem.prototype.bind = function (shader, dontSync) {\n shader.disposeRunner.add(this);\n shader.uniforms.globals = this.renderer.globalUniforms;\n var program = shader.program;\n var glProgram = program.glPrograms[this.renderer.CONTEXT_UID] || this.generateProgram(shader);\n this.shader = shader;\n // TODO - some current Pixi plugins bypass this.. so it not safe to use yet..\n if (this.program !== program) {\n this.program = program;\n this.gl.useProgram(glProgram.program);\n }\n if (!dontSync) {\n defaultSyncData.textureCount = 0;\n defaultSyncData.uboCount = 0;\n this.syncUniformGroup(shader.uniformGroup, defaultSyncData);\n }\n return glProgram;\n };\n /**\n * Uploads the uniforms values to the currently bound shader.\n * @param uniforms - the uniforms values that be applied to the current shader\n */\n ShaderSystem.prototype.setUniforms = function (uniforms) {\n var shader = this.shader.program;\n var glProgram = shader.glPrograms[this.renderer.CONTEXT_UID];\n shader.syncUniforms(glProgram.uniformData, uniforms, this.renderer);\n };\n /* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n /**\n * Syncs uniforms on the group\n * @param group - the uniform group to sync\n * @param syncData - this is data that is passed to the sync function and any nested sync functions\n */\n ShaderSystem.prototype.syncUniformGroup = function (group, syncData) {\n var glProgram = this.getGlProgram();\n if (!group.static || group.dirtyId !== glProgram.uniformDirtyGroups[group.id]) {\n glProgram.uniformDirtyGroups[group.id] = group.dirtyId;\n this.syncUniforms(group, glProgram, syncData);\n }\n };\n /**\n * Overrideable by the @pixi/unsafe-eval package to use static syncUniforms instead.\n * @param group\n * @param glProgram\n * @param syncData\n */\n ShaderSystem.prototype.syncUniforms = function (group, glProgram, syncData) {\n var syncFunc = group.syncUniforms[this.shader.program.id] || this.createSyncGroups(group);\n syncFunc(glProgram.uniformData, group.uniforms, this.renderer, syncData);\n };\n ShaderSystem.prototype.createSyncGroups = function (group) {\n var id = this.getSignature(group, this.shader.program.uniformData, 'u');\n if (!this.cache[id]) {\n this.cache[id] = generateUniformsSync(group, this.shader.program.uniformData);\n }\n group.syncUniforms[this.shader.program.id] = this.cache[id];\n return group.syncUniforms[this.shader.program.id];\n };\n /**\n * Syncs uniform buffers\n * @param group - the uniform buffer group to sync\n * @param name - the name of the uniform buffer\n */\n ShaderSystem.prototype.syncUniformBufferGroup = function (group, name) {\n var glProgram = this.getGlProgram();\n if (!group.static || group.dirtyId !== 0 || !glProgram.uniformGroups[group.id]) {\n group.dirtyId = 0;\n var syncFunc = glProgram.uniformGroups[group.id]\n || this.createSyncBufferGroup(group, glProgram, name);\n // TODO wrap update in a cache??\n group.buffer.update();\n syncFunc(glProgram.uniformData, group.uniforms, this.renderer, defaultSyncData, group.buffer);\n }\n this.renderer.buffer.bindBufferBase(group.buffer, glProgram.uniformBufferBindings[name]);\n };\n /**\n * Will create a function that uploads a uniform buffer using the STD140 standard.\n * The upload function will then be cached for future calls\n * If a group is manually managed, then a simple upload function is generated\n * @param group - the uniform buffer group to sync\n * @param glProgram - the gl program to attach the uniform bindings to\n * @param name - the name of the uniform buffer (must exist on the shader)\n */\n ShaderSystem.prototype.createSyncBufferGroup = function (group, glProgram, name) {\n var gl = this.renderer.gl;\n this.renderer.buffer.bind(group.buffer);\n // bind them...\n var uniformBlockIndex = this.gl.getUniformBlockIndex(glProgram.program, name);\n glProgram.uniformBufferBindings[name] = this.shader.uniformBindCount;\n gl.uniformBlockBinding(glProgram.program, uniformBlockIndex, this.shader.uniformBindCount);\n this.shader.uniformBindCount++;\n var id = this.getSignature(group, this.shader.program.uniformData, 'ubo');\n var uboData = this._uboCache[id];\n if (!uboData) {\n uboData = this._uboCache[id] = generateUniformBufferSync(group, this.shader.program.uniformData);\n }\n if (group.autoManage) {\n var data = new Float32Array(uboData.size / 4);\n group.buffer.update(data);\n }\n glProgram.uniformGroups[group.id] = uboData.syncFunc;\n return glProgram.uniformGroups[group.id];\n };\n /**\n * Takes a uniform group and data and generates a unique signature for them.\n * @param group - The uniform group to get signature of\n * @param group.uniforms\n * @param uniformData - Uniform information generated by the shader\n * @param preFix\n * @returns Unique signature of the uniform group\n */\n ShaderSystem.prototype.getSignature = function (group, uniformData, preFix) {\n var uniforms = group.uniforms;\n var strings = [preFix + \"-\"];\n for (var i in uniforms) {\n strings.push(i);\n if (uniformData[i]) {\n strings.push(uniformData[i].type);\n }\n }\n return strings.join('-');\n };\n /**\n * Returns the underlying GLShade rof the currently bound shader.\n *\n * This can be handy for when you to have a little more control over the setting of your uniforms.\n * @returns The glProgram for the currently bound Shader for this context\n */\n ShaderSystem.prototype.getGlProgram = function () {\n if (this.shader) {\n return this.shader.program.glPrograms[this.renderer.CONTEXT_UID];\n }\n return null;\n };\n /**\n * Generates a glProgram version of the Shader provided.\n * @param shader - The shader that the glProgram will be based on.\n * @returns A shiny new glProgram!\n */\n ShaderSystem.prototype.generateProgram = function (shader) {\n var gl = this.gl;\n var program = shader.program;\n var glProgram = generateProgram(gl, program);\n program.glPrograms[this.renderer.CONTEXT_UID] = glProgram;\n return glProgram;\n };\n /** Resets ShaderSystem state, does not affect WebGL state. */\n ShaderSystem.prototype.reset = function () {\n this.program = null;\n this.shader = null;\n };\n /**\n * Disposes shader.\n * If disposing one equals with current shader, set current as null.\n * @param shader - Shader object\n */\n ShaderSystem.prototype.disposeShader = function (shader) {\n if (this.shader === shader) {\n this.shader = null;\n }\n };\n /** Destroys this System and removes all its textures. */\n ShaderSystem.prototype.destroy = function () {\n this.renderer = null;\n // TODO implement destroy method for ShaderSystem\n this.destroyed = true;\n };\n return ShaderSystem;\n}());\n\n/**\n * Maps gl blend combinations to WebGL.\n * @memberof PIXI\n * @function mapWebGLBlendModesToPixi\n * @private\n * @param {WebGLRenderingContext} gl - The rendering context.\n * @param {number[][]} [array=[]] - The array to output into.\n * @returns {number[][]} Mapped modes.\n */\nfunction mapWebGLBlendModesToPixi(gl, array) {\n if (array === void 0) { array = []; }\n // TODO - premultiply alpha would be different.\n // add a boolean for that!\n array[BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.ADD] = [gl.ONE, gl.ONE];\n array[BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.SCREEN] = [gl.ONE, gl.ONE_MINUS_SRC_COLOR, gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.NONE] = [0, 0];\n // not-premultiplied blend modes\n array[BLEND_MODES.NORMAL_NPM] = [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.ADD_NPM] = [gl.SRC_ALPHA, gl.ONE, gl.ONE, gl.ONE];\n array[BLEND_MODES.SCREEN_NPM] = [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_COLOR, gl.ONE, gl.ONE_MINUS_SRC_ALPHA];\n // composite operations\n array[BLEND_MODES.SRC_IN] = [gl.DST_ALPHA, gl.ZERO];\n array[BLEND_MODES.SRC_OUT] = [gl.ONE_MINUS_DST_ALPHA, gl.ZERO];\n array[BLEND_MODES.SRC_ATOP] = [gl.DST_ALPHA, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.DST_OVER] = [gl.ONE_MINUS_DST_ALPHA, gl.ONE];\n array[BLEND_MODES.DST_IN] = [gl.ZERO, gl.SRC_ALPHA];\n array[BLEND_MODES.DST_OUT] = [gl.ZERO, gl.ONE_MINUS_SRC_ALPHA];\n array[BLEND_MODES.DST_ATOP] = [gl.ONE_MINUS_DST_ALPHA, gl.SRC_ALPHA];\n array[BLEND_MODES.XOR] = [gl.ONE_MINUS_DST_ALPHA, gl.ONE_MINUS_SRC_ALPHA];\n // SUBTRACT from flash\n array[BLEND_MODES.SUBTRACT] = [gl.ONE, gl.ONE, gl.ONE, gl.ONE, gl.FUNC_REVERSE_SUBTRACT, gl.FUNC_ADD];\n return array;\n}\n\nvar BLEND = 0;\nvar OFFSET = 1;\nvar CULLING = 2;\nvar DEPTH_TEST = 3;\nvar WINDING = 4;\nvar DEPTH_MASK = 5;\n/**\n * System plugin to the renderer to manage WebGL state machines.\n * @memberof PIXI\n */\nvar StateSystem = /** @class */ (function () {\n function StateSystem() {\n this.gl = null;\n this.stateId = 0;\n this.polygonOffset = 0;\n this.blendMode = BLEND_MODES.NONE;\n this._blendEq = false;\n // map functions for when we set state..\n this.map = [];\n this.map[BLEND] = this.setBlend;\n this.map[OFFSET] = this.setOffset;\n this.map[CULLING] = this.setCullFace;\n this.map[DEPTH_TEST] = this.setDepthTest;\n this.map[WINDING] = this.setFrontFace;\n this.map[DEPTH_MASK] = this.setDepthMask;\n this.checks = [];\n this.defaultState = new State();\n this.defaultState.blend = true;\n }\n StateSystem.prototype.contextChange = function (gl) {\n this.gl = gl;\n this.blendModes = mapWebGLBlendModesToPixi(gl);\n this.set(this.defaultState);\n this.reset();\n };\n /**\n * Sets the current state\n * @param {*} state - The state to set.\n */\n StateSystem.prototype.set = function (state) {\n state = state || this.defaultState;\n // TODO maybe to an object check? ( this.state === state )?\n if (this.stateId !== state.data) {\n var diff = this.stateId ^ state.data;\n var i = 0;\n // order from least to most common\n while (diff) {\n if (diff & 1) {\n // state change!\n this.map[i].call(this, !!(state.data & (1 << i)));\n }\n diff = diff >> 1;\n i++;\n }\n this.stateId = state.data;\n }\n // based on the above settings we check for specific modes..\n // for example if blend is active we check and set the blend modes\n // or of polygon offset is active we check the poly depth.\n for (var i = 0; i < this.checks.length; i++) {\n this.checks[i](this, state);\n }\n };\n /**\n * Sets the state, when previous state is unknown.\n * @param {*} state - The state to set\n */\n StateSystem.prototype.forceState = function (state) {\n state = state || this.defaultState;\n for (var i = 0; i < this.map.length; i++) {\n this.map[i].call(this, !!(state.data & (1 << i)));\n }\n for (var i = 0; i < this.checks.length; i++) {\n this.checks[i](this, state);\n }\n this.stateId = state.data;\n };\n /**\n * Sets whether to enable or disable blending.\n * @param value - Turn on or off WebGl blending.\n */\n StateSystem.prototype.setBlend = function (value) {\n this.updateCheck(StateSystem.checkBlendMode, value);\n this.gl[value ? 'enable' : 'disable'](this.gl.BLEND);\n };\n /**\n * Sets whether to enable or disable polygon offset fill.\n * @param value - Turn on or off webgl polygon offset testing.\n */\n StateSystem.prototype.setOffset = function (value) {\n this.updateCheck(StateSystem.checkPolygonOffset, value);\n this.gl[value ? 'enable' : 'disable'](this.gl.POLYGON_OFFSET_FILL);\n };\n /**\n * Sets whether to enable or disable depth test.\n * @param value - Turn on or off webgl depth testing.\n */\n StateSystem.prototype.setDepthTest = function (value) {\n this.gl[value ? 'enable' : 'disable'](this.gl.DEPTH_TEST);\n };\n /**\n * Sets whether to enable or disable depth mask.\n * @param value - Turn on or off webgl depth mask.\n */\n StateSystem.prototype.setDepthMask = function (value) {\n this.gl.depthMask(value);\n };\n /**\n * Sets whether to enable or disable cull face.\n * @param {boolean} value - Turn on or off webgl cull face.\n */\n StateSystem.prototype.setCullFace = function (value) {\n this.gl[value ? 'enable' : 'disable'](this.gl.CULL_FACE);\n };\n /**\n * Sets the gl front face.\n * @param {boolean} value - true is clockwise and false is counter-clockwise\n */\n StateSystem.prototype.setFrontFace = function (value) {\n this.gl.frontFace(this.gl[value ? 'CW' : 'CCW']);\n };\n /**\n * Sets the blend mode.\n * @param {number} value - The blend mode to set to.\n */\n StateSystem.prototype.setBlendMode = function (value) {\n if (value === this.blendMode) {\n return;\n }\n this.blendMode = value;\n var mode = this.blendModes[value];\n var gl = this.gl;\n if (mode.length === 2) {\n gl.blendFunc(mode[0], mode[1]);\n }\n else {\n gl.blendFuncSeparate(mode[0], mode[1], mode[2], mode[3]);\n }\n if (mode.length === 6) {\n this._blendEq = true;\n gl.blendEquationSeparate(mode[4], mode[5]);\n }\n else if (this._blendEq) {\n this._blendEq = false;\n gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD);\n }\n };\n /**\n * Sets the polygon offset.\n * @param {number} value - the polygon offset\n * @param {number} scale - the polygon offset scale\n */\n StateSystem.prototype.setPolygonOffset = function (value, scale) {\n this.gl.polygonOffset(value, scale);\n };\n // used\n /** Resets all the logic and disables the VAOs. */\n StateSystem.prototype.reset = function () {\n this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, false);\n this.forceState(this.defaultState);\n this._blendEq = true;\n this.blendMode = -1;\n this.setBlendMode(0);\n };\n /**\n * Checks to see which updates should be checked based on which settings have been activated.\n *\n * For example, if blend is enabled then we should check the blend modes each time the state is changed\n * or if polygon fill is activated then we need to check if the polygon offset changes.\n * The idea is that we only check what we have too.\n * @param func - the checking function to add or remove\n * @param value - should the check function be added or removed.\n */\n StateSystem.prototype.updateCheck = function (func, value) {\n var index = this.checks.indexOf(func);\n if (value && index === -1) {\n this.checks.push(func);\n }\n else if (!value && index !== -1) {\n this.checks.splice(index, 1);\n }\n };\n /**\n * A private little wrapper function that we call to check the blend mode.\n * @param system - the System to perform the state check on\n * @param state - the state that the blendMode will pulled from\n */\n StateSystem.checkBlendMode = function (system, state) {\n system.setBlendMode(state.blendMode);\n };\n /**\n * A private little wrapper function that we call to check the polygon offset.\n * @param system - the System to perform the state check on\n * @param state - the state that the blendMode will pulled from\n */\n StateSystem.checkPolygonOffset = function (system, state) {\n system.setPolygonOffset(1, state.polygonOffset);\n };\n /**\n * @ignore\n */\n StateSystem.prototype.destroy = function () {\n this.gl = null;\n };\n return StateSystem;\n}());\n\n/**\n * System plugin to the renderer to manage texture garbage collection on the GPU,\n * ensuring that it does not get clogged up with textures that are no longer being used.\n * @memberof PIXI\n */\nvar TextureGCSystem = /** @class */ (function () {\n /** @param renderer - The renderer this System works for. */\n function TextureGCSystem(renderer) {\n this.renderer = renderer;\n this.count = 0;\n this.checkCount = 0;\n this.maxIdle = settings.GC_MAX_IDLE;\n this.checkCountMax = settings.GC_MAX_CHECK_COUNT;\n this.mode = settings.GC_MODE;\n }\n /**\n * Checks to see when the last time a texture was used\n * if the texture has not been used for a specified amount of time it will be removed from the GPU\n */\n TextureGCSystem.prototype.postrender = function () {\n if (!this.renderer.renderingToScreen) {\n return;\n }\n this.count++;\n if (this.mode === GC_MODES.MANUAL) {\n return;\n }\n this.checkCount++;\n if (this.checkCount > this.checkCountMax) {\n this.checkCount = 0;\n this.run();\n }\n };\n /**\n * Checks to see when the last time a texture was used\n * if the texture has not been used for a specified amount of time it will be removed from the GPU\n */\n TextureGCSystem.prototype.run = function () {\n var tm = this.renderer.texture;\n var managedTextures = tm.managedTextures;\n var wasRemoved = false;\n for (var i = 0; i < managedTextures.length; i++) {\n var texture = managedTextures[i];\n // only supports non generated textures at the moment!\n if (!texture.framebuffer && this.count - texture.touched > this.maxIdle) {\n tm.destroyTexture(texture, true);\n managedTextures[i] = null;\n wasRemoved = true;\n }\n }\n if (wasRemoved) {\n var j = 0;\n for (var i = 0; i < managedTextures.length; i++) {\n if (managedTextures[i] !== null) {\n managedTextures[j++] = managedTextures[i];\n }\n }\n managedTextures.length = j;\n }\n };\n /**\n * Removes all the textures within the specified displayObject and its children from the GPU\n * @param {PIXI.DisplayObject} displayObject - the displayObject to remove the textures from.\n */\n TextureGCSystem.prototype.unload = function (displayObject) {\n var tm = this.renderer.texture;\n var texture = displayObject._texture;\n // only destroy non generated textures\n if (texture && !texture.framebuffer) {\n tm.destroyTexture(texture);\n }\n for (var i = displayObject.children.length - 1; i >= 0; i--) {\n this.unload(displayObject.children[i]);\n }\n };\n TextureGCSystem.prototype.destroy = function () {\n this.renderer = null;\n };\n return TextureGCSystem;\n}());\n\n/**\n * Returns a lookup table that maps each type-format pair to a compatible internal format.\n * @memberof PIXI\n * @function mapTypeAndFormatToInternalFormat\n * @private\n * @param {WebGLRenderingContext} gl - The rendering context.\n * @returns Lookup table.\n */\nfunction mapTypeAndFormatToInternalFormat(gl) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;\n var table;\n if ('WebGL2RenderingContext' in globalThis && gl instanceof globalThis.WebGL2RenderingContext) {\n table = (_a = {},\n _a[TYPES.UNSIGNED_BYTE] = (_b = {},\n _b[FORMATS.RGBA] = gl.RGBA8,\n _b[FORMATS.RGB] = gl.RGB8,\n _b[FORMATS.RG] = gl.RG8,\n _b[FORMATS.RED] = gl.R8,\n _b[FORMATS.RGBA_INTEGER] = gl.RGBA8UI,\n _b[FORMATS.RGB_INTEGER] = gl.RGB8UI,\n _b[FORMATS.RG_INTEGER] = gl.RG8UI,\n _b[FORMATS.RED_INTEGER] = gl.R8UI,\n _b[FORMATS.ALPHA] = gl.ALPHA,\n _b[FORMATS.LUMINANCE] = gl.LUMINANCE,\n _b[FORMATS.LUMINANCE_ALPHA] = gl.LUMINANCE_ALPHA,\n _b),\n _a[TYPES.BYTE] = (_c = {},\n _c[FORMATS.RGBA] = gl.RGBA8_SNORM,\n _c[FORMATS.RGB] = gl.RGB8_SNORM,\n _c[FORMATS.RG] = gl.RG8_SNORM,\n _c[FORMATS.RED] = gl.R8_SNORM,\n _c[FORMATS.RGBA_INTEGER] = gl.RGBA8I,\n _c[FORMATS.RGB_INTEGER] = gl.RGB8I,\n _c[FORMATS.RG_INTEGER] = gl.RG8I,\n _c[FORMATS.RED_INTEGER] = gl.R8I,\n _c),\n _a[TYPES.UNSIGNED_SHORT] = (_d = {},\n _d[FORMATS.RGBA_INTEGER] = gl.RGBA16UI,\n _d[FORMATS.RGB_INTEGER] = gl.RGB16UI,\n _d[FORMATS.RG_INTEGER] = gl.RG16UI,\n _d[FORMATS.RED_INTEGER] = gl.R16UI,\n _d[FORMATS.DEPTH_COMPONENT] = gl.DEPTH_COMPONENT16,\n _d),\n _a[TYPES.SHORT] = (_e = {},\n _e[FORMATS.RGBA_INTEGER] = gl.RGBA16I,\n _e[FORMATS.RGB_INTEGER] = gl.RGB16I,\n _e[FORMATS.RG_INTEGER] = gl.RG16I,\n _e[FORMATS.RED_INTEGER] = gl.R16I,\n _e),\n _a[TYPES.UNSIGNED_INT] = (_f = {},\n _f[FORMATS.RGBA_INTEGER] = gl.RGBA32UI,\n _f[FORMATS.RGB_INTEGER] = gl.RGB32UI,\n _f[FORMATS.RG_INTEGER] = gl.RG32UI,\n _f[FORMATS.RED_INTEGER] = gl.R32UI,\n _f[FORMATS.DEPTH_COMPONENT] = gl.DEPTH_COMPONENT24,\n _f),\n _a[TYPES.INT] = (_g = {},\n _g[FORMATS.RGBA_INTEGER] = gl.RGBA32I,\n _g[FORMATS.RGB_INTEGER] = gl.RGB32I,\n _g[FORMATS.RG_INTEGER] = gl.RG32I,\n _g[FORMATS.RED_INTEGER] = gl.R32I,\n _g),\n _a[TYPES.FLOAT] = (_h = {},\n _h[FORMATS.RGBA] = gl.RGBA32F,\n _h[FORMATS.RGB] = gl.RGB32F,\n _h[FORMATS.RG] = gl.RG32F,\n _h[FORMATS.RED] = gl.R32F,\n _h[FORMATS.DEPTH_COMPONENT] = gl.DEPTH_COMPONENT32F,\n _h),\n _a[TYPES.HALF_FLOAT] = (_j = {},\n _j[FORMATS.RGBA] = gl.RGBA16F,\n _j[FORMATS.RGB] = gl.RGB16F,\n _j[FORMATS.RG] = gl.RG16F,\n _j[FORMATS.RED] = gl.R16F,\n _j),\n _a[TYPES.UNSIGNED_SHORT_5_6_5] = (_k = {},\n _k[FORMATS.RGB] = gl.RGB565,\n _k),\n _a[TYPES.UNSIGNED_SHORT_4_4_4_4] = (_l = {},\n _l[FORMATS.RGBA] = gl.RGBA4,\n _l),\n _a[TYPES.UNSIGNED_SHORT_5_5_5_1] = (_m = {},\n _m[FORMATS.RGBA] = gl.RGB5_A1,\n _m),\n _a[TYPES.UNSIGNED_INT_2_10_10_10_REV] = (_o = {},\n _o[FORMATS.RGBA] = gl.RGB10_A2,\n _o[FORMATS.RGBA_INTEGER] = gl.RGB10_A2UI,\n _o),\n _a[TYPES.UNSIGNED_INT_10F_11F_11F_REV] = (_p = {},\n _p[FORMATS.RGB] = gl.R11F_G11F_B10F,\n _p),\n _a[TYPES.UNSIGNED_INT_5_9_9_9_REV] = (_q = {},\n _q[FORMATS.RGB] = gl.RGB9_E5,\n _q),\n _a[TYPES.UNSIGNED_INT_24_8] = (_r = {},\n _r[FORMATS.DEPTH_STENCIL] = gl.DEPTH24_STENCIL8,\n _r),\n _a[TYPES.FLOAT_32_UNSIGNED_INT_24_8_REV] = (_s = {},\n _s[FORMATS.DEPTH_STENCIL] = gl.DEPTH32F_STENCIL8,\n _s),\n _a);\n }\n else {\n table = (_t = {},\n _t[TYPES.UNSIGNED_BYTE] = (_u = {},\n _u[FORMATS.RGBA] = gl.RGBA,\n _u[FORMATS.RGB] = gl.RGB,\n _u[FORMATS.ALPHA] = gl.ALPHA,\n _u[FORMATS.LUMINANCE] = gl.LUMINANCE,\n _u[FORMATS.LUMINANCE_ALPHA] = gl.LUMINANCE_ALPHA,\n _u),\n _t[TYPES.UNSIGNED_SHORT_5_6_5] = (_v = {},\n _v[FORMATS.RGB] = gl.RGB,\n _v),\n _t[TYPES.UNSIGNED_SHORT_4_4_4_4] = (_w = {},\n _w[FORMATS.RGBA] = gl.RGBA,\n _w),\n _t[TYPES.UNSIGNED_SHORT_5_5_5_1] = (_x = {},\n _x[FORMATS.RGBA] = gl.RGBA,\n _x),\n _t);\n }\n return table;\n}\n\n/**\n * Internal texture for WebGL context.\n * @memberof PIXI\n */\nvar GLTexture = /** @class */ (function () {\n function GLTexture(texture) {\n this.texture = texture;\n this.width = -1;\n this.height = -1;\n this.dirtyId = -1;\n this.dirtyStyleId = -1;\n this.mipmap = false;\n this.wrapMode = 33071;\n this.type = TYPES.UNSIGNED_BYTE;\n this.internalFormat = FORMATS.RGBA;\n this.samplerType = 0;\n }\n return GLTexture;\n}());\n\n/**\n * System plugin to the renderer to manage textures.\n * @memberof PIXI\n */\nvar TextureSystem = /** @class */ (function () {\n /**\n * @param renderer - The renderer this system works for.\n */\n function TextureSystem(renderer) {\n this.renderer = renderer;\n // TODO set to max textures...\n this.boundTextures = [];\n this.currentLocation = -1;\n this.managedTextures = [];\n this._unknownBoundTextures = false;\n this.unknownTexture = new BaseTexture();\n this.hasIntegerTextures = false;\n }\n /** Sets up the renderer context and necessary buffers. */\n TextureSystem.prototype.contextChange = function () {\n var gl = this.gl = this.renderer.gl;\n this.CONTEXT_UID = this.renderer.CONTEXT_UID;\n this.webGLVersion = this.renderer.context.webGLVersion;\n this.internalFormats = mapTypeAndFormatToInternalFormat(gl);\n var maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);\n this.boundTextures.length = maxTextures;\n for (var i = 0; i < maxTextures; i++) {\n this.boundTextures[i] = null;\n }\n // TODO move this.. to a nice make empty textures class..\n this.emptyTextures = {};\n var emptyTexture2D = new GLTexture(gl.createTexture());\n gl.bindTexture(gl.TEXTURE_2D, emptyTexture2D.texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(4));\n this.emptyTextures[gl.TEXTURE_2D] = emptyTexture2D;\n this.emptyTextures[gl.TEXTURE_CUBE_MAP] = new GLTexture(gl.createTexture());\n gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.emptyTextures[gl.TEXTURE_CUBE_MAP].texture);\n for (var i = 0; i < 6; i++) {\n gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n }\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n for (var i = 0; i < this.boundTextures.length; i++) {\n this.bind(null, i);\n }\n };\n /**\n * Bind a texture to a specific location\n *\n * If you want to unbind something, please use `unbind(texture)` instead of `bind(null, textureLocation)`\n * @param texture - Texture to bind\n * @param [location=0] - Location to bind at\n */\n TextureSystem.prototype.bind = function (texture, location) {\n if (location === void 0) { location = 0; }\n var gl = this.gl;\n texture = texture === null || texture === void 0 ? void 0 : texture.castToBaseTexture();\n // cannot bind partial texture\n // TODO: report a warning\n if (texture && texture.valid && !texture.parentTextureArray) {\n texture.touched = this.renderer.textureGC.count;\n var glTexture = texture._glTextures[this.CONTEXT_UID] || this.initTexture(texture);\n if (this.boundTextures[location] !== texture) {\n if (this.currentLocation !== location) {\n this.currentLocation = location;\n gl.activeTexture(gl.TEXTURE0 + location);\n }\n gl.bindTexture(texture.target, glTexture.texture);\n }\n if (glTexture.dirtyId !== texture.dirtyId) {\n if (this.currentLocation !== location) {\n this.currentLocation = location;\n gl.activeTexture(gl.TEXTURE0 + location);\n }\n this.updateTexture(texture);\n }\n else if (glTexture.dirtyStyleId !== texture.dirtyStyleId) {\n this.updateTextureStyle(texture);\n }\n this.boundTextures[location] = texture;\n }\n else {\n if (this.currentLocation !== location) {\n this.currentLocation = location;\n gl.activeTexture(gl.TEXTURE0 + location);\n }\n gl.bindTexture(gl.TEXTURE_2D, this.emptyTextures[gl.TEXTURE_2D].texture);\n this.boundTextures[location] = null;\n }\n };\n /** Resets texture location and bound textures Actual `bind(null, i)` calls will be performed at next `unbind()` call */\n TextureSystem.prototype.reset = function () {\n this._unknownBoundTextures = true;\n this.hasIntegerTextures = false;\n this.currentLocation = -1;\n for (var i = 0; i < this.boundTextures.length; i++) {\n this.boundTextures[i] = this.unknownTexture;\n }\n };\n /**\n * Unbind a texture.\n * @param texture - Texture to bind\n */\n TextureSystem.prototype.unbind = function (texture) {\n var _a = this, gl = _a.gl, boundTextures = _a.boundTextures;\n if (this._unknownBoundTextures) {\n this._unknownBoundTextures = false;\n // someone changed webGL state,\n // we have to be sure that our texture does not appear in multi-texture renderer samplers\n for (var i = 0; i < boundTextures.length; i++) {\n if (boundTextures[i] === this.unknownTexture) {\n this.bind(null, i);\n }\n }\n }\n for (var i = 0; i < boundTextures.length; i++) {\n if (boundTextures[i] === texture) {\n if (this.currentLocation !== i) {\n gl.activeTexture(gl.TEXTURE0 + i);\n this.currentLocation = i;\n }\n gl.bindTexture(texture.target, this.emptyTextures[texture.target].texture);\n boundTextures[i] = null;\n }\n }\n };\n /**\n * Ensures that current boundTextures all have FLOAT sampler type,\n * see {@link PIXI.SAMPLER_TYPES} for explanation.\n * @param maxTextures - number of locations to check\n */\n TextureSystem.prototype.ensureSamplerType = function (maxTextures) {\n var _a = this, boundTextures = _a.boundTextures, hasIntegerTextures = _a.hasIntegerTextures, CONTEXT_UID = _a.CONTEXT_UID;\n if (!hasIntegerTextures) {\n return;\n }\n for (var i = maxTextures - 1; i >= 0; --i) {\n var tex = boundTextures[i];\n if (tex) {\n var glTexture = tex._glTextures[CONTEXT_UID];\n if (glTexture.samplerType !== SAMPLER_TYPES.FLOAT) {\n this.renderer.texture.unbind(tex);\n }\n }\n }\n };\n /**\n * Initialize a texture\n * @private\n * @param texture - Texture to initialize\n */\n TextureSystem.prototype.initTexture = function (texture) {\n var glTexture = new GLTexture(this.gl.createTexture());\n // guarantee an update..\n glTexture.dirtyId = -1;\n texture._glTextures[this.CONTEXT_UID] = glTexture;\n this.managedTextures.push(texture);\n texture.on('dispose', this.destroyTexture, this);\n return glTexture;\n };\n TextureSystem.prototype.initTextureType = function (texture, glTexture) {\n var _a, _b;\n glTexture.internalFormat = (_b = (_a = this.internalFormats[texture.type]) === null || _a === void 0 ? void 0 : _a[texture.format]) !== null && _b !== void 0 ? _b : texture.format;\n if (this.webGLVersion === 2 && texture.type === TYPES.HALF_FLOAT) {\n // TYPES.HALF_FLOAT is WebGL1 HALF_FLOAT_OES\n // we have to convert it to WebGL HALF_FLOAT\n glTexture.type = this.gl.HALF_FLOAT;\n }\n else {\n glTexture.type = texture.type;\n }\n };\n /**\n * Update a texture\n * @private\n * @param {PIXI.BaseTexture} texture - Texture to initialize\n */\n TextureSystem.prototype.updateTexture = function (texture) {\n var glTexture = texture._glTextures[this.CONTEXT_UID];\n if (!glTexture) {\n return;\n }\n var renderer = this.renderer;\n this.initTextureType(texture, glTexture);\n if (texture.resource && texture.resource.upload(renderer, texture, glTexture)) {\n // texture is uploaded, dont do anything!\n if (glTexture.samplerType !== SAMPLER_TYPES.FLOAT) {\n this.hasIntegerTextures = true;\n }\n }\n else {\n // default, renderTexture-like logic\n var width = texture.realWidth;\n var height = texture.realHeight;\n var gl = renderer.gl;\n if (glTexture.width !== width\n || glTexture.height !== height\n || glTexture.dirtyId < 0) {\n glTexture.width = width;\n glTexture.height = height;\n gl.texImage2D(texture.target, 0, glTexture.internalFormat, width, height, 0, texture.format, glTexture.type, null);\n }\n }\n // lets only update what changes..\n if (texture.dirtyStyleId !== glTexture.dirtyStyleId) {\n this.updateTextureStyle(texture);\n }\n glTexture.dirtyId = texture.dirtyId;\n };\n /**\n * Deletes the texture from WebGL\n * @private\n * @param texture - the texture to destroy\n * @param [skipRemove=false] - Whether to skip removing the texture from the TextureManager.\n */\n TextureSystem.prototype.destroyTexture = function (texture, skipRemove) {\n var gl = this.gl;\n texture = texture.castToBaseTexture();\n if (texture._glTextures[this.CONTEXT_UID]) {\n this.unbind(texture);\n gl.deleteTexture(texture._glTextures[this.CONTEXT_UID].texture);\n texture.off('dispose', this.destroyTexture, this);\n delete texture._glTextures[this.CONTEXT_UID];\n if (!skipRemove) {\n var i = this.managedTextures.indexOf(texture);\n if (i !== -1) {\n removeItems(this.managedTextures, i, 1);\n }\n }\n }\n };\n /**\n * Update texture style such as mipmap flag\n * @private\n * @param {PIXI.BaseTexture} texture - Texture to update\n */\n TextureSystem.prototype.updateTextureStyle = function (texture) {\n var glTexture = texture._glTextures[this.CONTEXT_UID];\n if (!glTexture) {\n return;\n }\n if ((texture.mipmap === MIPMAP_MODES.POW2 || this.webGLVersion !== 2) && !texture.isPowerOfTwo) {\n glTexture.mipmap = false;\n }\n else {\n glTexture.mipmap = texture.mipmap >= 1;\n }\n if (this.webGLVersion !== 2 && !texture.isPowerOfTwo) {\n glTexture.wrapMode = WRAP_MODES.CLAMP;\n }\n else {\n glTexture.wrapMode = texture.wrapMode;\n }\n if (texture.resource && texture.resource.style(this.renderer, texture, glTexture)) ;\n else {\n this.setStyle(texture, glTexture);\n }\n glTexture.dirtyStyleId = texture.dirtyStyleId;\n };\n /**\n * Set style for texture\n * @private\n * @param texture - Texture to update\n * @param glTexture\n */\n TextureSystem.prototype.setStyle = function (texture, glTexture) {\n var gl = this.gl;\n if (glTexture.mipmap && texture.mipmap !== MIPMAP_MODES.ON_MANUAL) {\n gl.generateMipmap(texture.target);\n }\n gl.texParameteri(texture.target, gl.TEXTURE_WRAP_S, glTexture.wrapMode);\n gl.texParameteri(texture.target, gl.TEXTURE_WRAP_T, glTexture.wrapMode);\n if (glTexture.mipmap) {\n /* eslint-disable max-len */\n gl.texParameteri(texture.target, gl.TEXTURE_MIN_FILTER, texture.scaleMode === SCALE_MODES.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST);\n /* eslint-disable max-len */\n var anisotropicExt = this.renderer.context.extensions.anisotropicFiltering;\n if (anisotropicExt && texture.anisotropicLevel > 0 && texture.scaleMode === SCALE_MODES.LINEAR) {\n var level = Math.min(texture.anisotropicLevel, gl.getParameter(anisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT));\n gl.texParameterf(texture.target, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, level);\n }\n }\n else {\n gl.texParameteri(texture.target, gl.TEXTURE_MIN_FILTER, texture.scaleMode === SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST);\n }\n gl.texParameteri(texture.target, gl.TEXTURE_MAG_FILTER, texture.scaleMode === SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST);\n };\n TextureSystem.prototype.destroy = function () {\n this.renderer = null;\n };\n return TextureSystem;\n}());\n\nvar _systems = {\n __proto__: null,\n FilterSystem: FilterSystem,\n BatchSystem: BatchSystem,\n ContextSystem: ContextSystem,\n FramebufferSystem: FramebufferSystem,\n GeometrySystem: GeometrySystem,\n MaskSystem: MaskSystem,\n ScissorSystem: ScissorSystem,\n StencilSystem: StencilSystem,\n ProjectionSystem: ProjectionSystem,\n RenderTextureSystem: RenderTextureSystem,\n ShaderSystem: ShaderSystem,\n StateSystem: StateSystem,\n TextureGCSystem: TextureGCSystem,\n TextureSystem: TextureSystem\n};\n\nvar tempMatrix = new Matrix();\n/**\n * The AbstractRenderer is the base for a PixiJS Renderer. It is extended by the {@link PIXI.CanvasRenderer}\n * and {@link PIXI.Renderer} which can be used for rendering a PixiJS scene.\n * @abstract\n * @class\n * @extends PIXI.utils.EventEmitter\n * @memberof PIXI\n */\nvar AbstractRenderer = /** @class */ (function (_super) {\n __extends(AbstractRenderer, _super);\n /**\n * @param type - The renderer type.\n * @param {PIXI.IRendererOptions} [options] - The optional renderer parameters.\n * @param {boolean} [options.antialias=false] -\n * **WebGL Only.** Whether to enable anti-aliasing. This may affect performance.\n * @param {boolean} [options.autoDensity=false] -\n * Whether the CSS dimensions of the renderer's view should be resized automatically.\n * @param {number} [options.backgroundAlpha=1] -\n * Transparency of the background color, value from `0` (fully transparent) to `1` (fully opaque).\n * @param {number} [options.backgroundColor=0x000000] -\n * The background color used to clear the canvas. It accepts hex numbers (e.g. `0xff0000`).\n * @param {boolean} [options.clearBeforeRender=true] - Whether to clear the canvas before new render passes.\n * @param {PIXI.IRenderingContext} [options.context] - **WebGL Only.** User-provided WebGL rendering context object.\n * @param {number} [options.height=600] - The height of the renderer's view.\n * @param {string} [options.powerPreference] -\n * **WebGL Only.** A hint indicating what configuration of GPU is suitable for the WebGL context,\n * can be `'default'`, `'high-performance'` or `'low-power'`.\n * Setting to `'high-performance'` will prioritize rendering performance over power consumption,\n * while setting to `'low-power'` will prioritize power saving over rendering performance.\n * @param {boolean} [options.premultipliedAlpha=true] -\n * **WebGL Only.** Whether the compositor will assume the drawing buffer contains colors with premultiplied alpha.\n * @param {boolean} [options.preserveDrawingBuffer=false] -\n * **WebGL Only.** Whether to enable drawing buffer preservation. If enabled, the drawing buffer will preserve\n * its value until cleared or overwritten. Enable this if you need to call `toDataUrl` on the WebGL context.\n * @param {number} [options.resolution=PIXI.settings.RESOLUTION] -\n * The resolution / device pixel ratio of the renderer.\n * @param {boolean} [options.transparent] -\n * **Deprecated since 6.0.0, Use `backgroundAlpha` instead.** \\\n * `true` sets `backgroundAlpha` to `0`, `false` sets `backgroundAlpha` to `1`.\n * @param {boolean|'notMultiplied'} [options.useContextAlpha=true] -\n * Pass-through value for canvas' context attribute `alpha`. This option is for cases where the\n * canvas needs to be opaque, possibly for performance reasons on some older devices.\n * If you want to set transparency, please use `backgroundAlpha`. \\\n * **WebGL Only:** When set to `'notMultiplied'`, the canvas' context attribute `alpha` will be\n * set to `true` and `premultipliedAlpha` will be to `false`.\n * @param {HTMLCanvasElement} [options.view=null] -\n * The canvas to use as the view. If omitted, a new canvas will be created.\n * @param {number} [options.width=800] - The width of the renderer's view.\n */\n function AbstractRenderer(type, options) {\n if (type === void 0) { type = RENDERER_TYPE.UNKNOWN; }\n var _this = _super.call(this) || this;\n // Add the default render options\n options = Object.assign({}, settings.RENDER_OPTIONS, options);\n /**\n * The supplied constructor options.\n * @member {object}\n * @readonly\n */\n _this.options = options;\n /**\n * The type of the renderer.\n * @member {number}\n * @default PIXI.RENDERER_TYPE.UNKNOWN\n * @see PIXI.RENDERER_TYPE\n */\n _this.type = type;\n /**\n * Measurements of the screen. (0, 0, screenWidth, screenHeight).\n *\n * Its safe to use as filterArea or hitArea for the whole stage.\n * @member {PIXI.Rectangle}\n */\n _this.screen = new Rectangle(0, 0, options.width, options.height);\n /**\n * The canvas element that everything is drawn to.\n * @member {HTMLCanvasElement}\n */\n _this.view = options.view || settings.ADAPTER.createCanvas();\n /**\n * The resolution / device pixel ratio of the renderer.\n * @member {number}\n * @default PIXI.settings.RESOLUTION\n */\n _this.resolution = options.resolution || settings.RESOLUTION;\n /**\n * Pass-thru setting for the canvas' context `alpha` property. This is typically\n * not something you need to fiddle with. If you want transparency, use `backgroundAlpha`.\n * @member {boolean}\n */\n _this.useContextAlpha = options.useContextAlpha;\n /**\n * Whether CSS dimensions of canvas view should be resized to screen dimensions automatically.\n * @member {boolean}\n */\n _this.autoDensity = !!options.autoDensity;\n /**\n * The value of the preserveDrawingBuffer flag affects whether or not the contents of\n * the stencil buffer is retained after rendering.\n * @member {boolean}\n */\n _this.preserveDrawingBuffer = options.preserveDrawingBuffer;\n /**\n * This sets if the CanvasRenderer will clear the canvas or not before the new render pass.\n * If the scene is NOT transparent PixiJS will use a canvas sized fillRect operation every\n * frame to set the canvas background color. If the scene is transparent PixiJS will use clearRect\n * to clear the canvas every frame. Disable this by setting this to false. For example, if\n * your game has a canvas filling background image you often don't need this set.\n * @member {boolean}\n * @default\n */\n _this.clearBeforeRender = options.clearBeforeRender;\n /**\n * The background color as a number.\n * @member {number}\n * @protected\n */\n _this._backgroundColor = 0x000000;\n /**\n * The background color as an [R, G, B, A] array.\n * @member {number[]}\n * @protected\n */\n _this._backgroundColorRgba = [0, 0, 0, 1];\n /**\n * The background color as a string.\n * @member {string}\n * @protected\n */\n _this._backgroundColorString = '#000000';\n _this.backgroundColor = options.backgroundColor || _this._backgroundColor; // run bg color setter\n _this.backgroundAlpha = options.backgroundAlpha;\n // @deprecated\n if (options.transparent !== undefined) {\n deprecation('6.0.0', 'Option transparent is deprecated, please use backgroundAlpha instead.');\n _this.useContextAlpha = options.transparent;\n _this.backgroundAlpha = options.transparent ? 0 : 1;\n }\n /**\n * The last root object that the renderer tried to render.\n * @member {PIXI.DisplayObject}\n * @protected\n */\n _this._lastObjectRendered = null;\n /**\n * Collection of plugins.\n * @readonly\n * @member {object}\n */\n _this.plugins = {};\n return _this;\n }\n /**\n * Initialize the plugins.\n * @protected\n * @param {object} staticMap - The dictionary of statically saved plugins.\n */\n AbstractRenderer.prototype.initPlugins = function (staticMap) {\n for (var o in staticMap) {\n this.plugins[o] = new (staticMap[o])(this);\n }\n };\n Object.defineProperty(AbstractRenderer.prototype, \"width\", {\n /**\n * Same as view.width, actual number of pixels in the canvas by horizontal.\n * @member {number}\n * @readonly\n * @default 800\n */\n get: function () {\n return this.view.width;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(AbstractRenderer.prototype, \"height\", {\n /**\n * Same as view.height, actual number of pixels in the canvas by vertical.\n * @member {number}\n * @readonly\n * @default 600\n */\n get: function () {\n return this.view.height;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Resizes the screen and canvas as close as possible to the specified width and height.\n * Canvas dimensions are multiplied by resolution and rounded to the nearest integers.\n * The new canvas dimensions divided by the resolution become the new screen dimensions.\n * @param desiredScreenWidth - The desired width of the screen.\n * @param desiredScreenHeight - The desired height of the screen.\n */\n AbstractRenderer.prototype.resize = function (desiredScreenWidth, desiredScreenHeight) {\n this.view.width = Math.round(desiredScreenWidth * this.resolution);\n this.view.height = Math.round(desiredScreenHeight * this.resolution);\n var screenWidth = this.view.width / this.resolution;\n var screenHeight = this.view.height / this.resolution;\n this.screen.width = screenWidth;\n this.screen.height = screenHeight;\n if (this.autoDensity) {\n this.view.style.width = screenWidth + \"px\";\n this.view.style.height = screenHeight + \"px\";\n }\n /**\n * Fired after view has been resized.\n * @event PIXI.Renderer#resize\n * @param {number} screenWidth - The new width of the screen.\n * @param {number} screenHeight - The new height of the screen.\n */\n this.emit('resize', screenWidth, screenHeight);\n };\n /**\n * @ignore\n */\n AbstractRenderer.prototype.generateTexture = function (displayObject, options, resolution, region) {\n if (options === void 0) { options = {}; }\n // @deprecated parameters spread, use options instead\n if (typeof options === 'number') {\n deprecation('6.1.0', 'generateTexture options (scaleMode, resolution, region) are now object options.');\n options = { scaleMode: options, resolution: resolution, region: region };\n }\n var manualRegion = options.region, textureOptions = __rest(options, [\"region\"]);\n region = manualRegion || displayObject.getLocalBounds(null, true);\n // minimum texture size is 1x1, 0x0 will throw an error\n if (region.width === 0)\n { region.width = 1; }\n if (region.height === 0)\n { region.height = 1; }\n var renderTexture = RenderTexture.create(__assign({ width: region.width, height: region.height }, textureOptions));\n tempMatrix.tx = -region.x;\n tempMatrix.ty = -region.y;\n this.render(displayObject, {\n renderTexture: renderTexture,\n clear: false,\n transform: tempMatrix,\n skipUpdateTransform: !!displayObject.parent\n });\n return renderTexture;\n };\n /**\n * Removes everything from the renderer and optionally removes the Canvas DOM element.\n * @param [removeView=false] - Removes the Canvas element from the DOM.\n */\n AbstractRenderer.prototype.destroy = function (removeView) {\n for (var o in this.plugins) {\n this.plugins[o].destroy();\n this.plugins[o] = null;\n }\n if (removeView && this.view.parentNode) {\n this.view.parentNode.removeChild(this.view);\n }\n var thisAny = this;\n // null-ing all objects, that's a tradition!\n thisAny.plugins = null;\n thisAny.type = RENDERER_TYPE.UNKNOWN;\n thisAny.view = null;\n thisAny.screen = null;\n thisAny._tempDisplayObjectParent = null;\n thisAny.options = null;\n this._backgroundColorRgba = null;\n this._backgroundColorString = null;\n this._lastObjectRendered = null;\n };\n Object.defineProperty(AbstractRenderer.prototype, \"backgroundColor\", {\n /**\n * The background color to fill if not transparent\n * @member {number}\n */\n get: function () {\n return this._backgroundColor;\n },\n set: function (value) {\n this._backgroundColor = value;\n this._backgroundColorString = hex2string(value);\n hex2rgb(value, this._backgroundColorRgba);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(AbstractRenderer.prototype, \"backgroundAlpha\", {\n /**\n * The background color alpha. Setting this to 0 will make the canvas transparent.\n * @member {number}\n */\n get: function () {\n return this._backgroundColorRgba[3];\n },\n set: function (value) {\n this._backgroundColorRgba[3] = value;\n },\n enumerable: false,\n configurable: true\n });\n return AbstractRenderer;\n}(EventEmitter));\n\nvar GLBuffer = /** @class */ (function () {\n function GLBuffer(buffer) {\n this.buffer = buffer || null;\n this.updateID = -1;\n this.byteLength = -1;\n this.refCount = 0;\n }\n return GLBuffer;\n}());\n\n/**\n * System plugin to the renderer to manage buffers.\n *\n * WebGL uses Buffers as a way to store objects to the GPU.\n * This system makes working with them a lot easier.\n *\n * Buffers are used in three main places in WebGL\n * - geometry information\n * - Uniform information (via uniform buffer objects - a WebGL 2 only feature)\n * - Transform feedback information. (WebGL 2 only feature)\n *\n * This system will handle the binding of buffers to the GPU as well as uploading\n * them. With this system, you never need to work directly with GPU buffers, but instead work with\n * the PIXI.Buffer class.\n * @class\n * @memberof PIXI\n */\nvar BufferSystem = /** @class */ (function () {\n /**\n * @param {PIXI.Renderer} renderer - The renderer this System works for.\n */\n function BufferSystem(renderer) {\n this.renderer = renderer;\n this.managedBuffers = {};\n this.boundBufferBases = {};\n }\n /**\n * @ignore\n */\n BufferSystem.prototype.destroy = function () {\n this.renderer = null;\n };\n /** Sets up the renderer context and necessary buffers. */\n BufferSystem.prototype.contextChange = function () {\n this.disposeAll(true);\n this.gl = this.renderer.gl;\n // TODO fill out...\n this.CONTEXT_UID = this.renderer.CONTEXT_UID;\n };\n /**\n * This binds specified buffer. On first run, it will create the webGL buffers for the context too\n * @param buffer - the buffer to bind to the renderer\n */\n BufferSystem.prototype.bind = function (buffer) {\n var _a = this, gl = _a.gl, CONTEXT_UID = _a.CONTEXT_UID;\n var glBuffer = buffer._glBuffers[CONTEXT_UID] || this.createGLBuffer(buffer);\n gl.bindBuffer(buffer.type, glBuffer.buffer);\n };\n /**\n * Binds an uniform buffer to at the given index.\n *\n * A cache is used so a buffer will not be bound again if already bound.\n * @param buffer - the buffer to bind\n * @param index - the base index to bind it to.\n */\n BufferSystem.prototype.bindBufferBase = function (buffer, index) {\n var _a = this, gl = _a.gl, CONTEXT_UID = _a.CONTEXT_UID;\n if (this.boundBufferBases[index] !== buffer) {\n var glBuffer = buffer._glBuffers[CONTEXT_UID] || this.createGLBuffer(buffer);\n this.boundBufferBases[index] = buffer;\n gl.bindBufferBase(gl.UNIFORM_BUFFER, index, glBuffer.buffer);\n }\n };\n /**\n * Binds a buffer whilst also binding its range.\n * This will make the buffer start from the offset supplied rather than 0 when it is read.\n * @param buffer - the buffer to bind\n * @param index - the base index to bind at, defaults to 0\n * @param offset - the offset to bind at (this is blocks of 256). 0 = 0, 1 = 256, 2 = 512 etc\n */\n BufferSystem.prototype.bindBufferRange = function (buffer, index, offset) {\n var _a = this, gl = _a.gl, CONTEXT_UID = _a.CONTEXT_UID;\n offset = offset || 0;\n var glBuffer = buffer._glBuffers[CONTEXT_UID] || this.createGLBuffer(buffer);\n gl.bindBufferRange(gl.UNIFORM_BUFFER, index || 0, glBuffer.buffer, offset * 256, 256);\n };\n /**\n * Will ensure the data in the buffer is uploaded to the GPU.\n * @param {PIXI.Buffer} buffer - the buffer to update\n */\n BufferSystem.prototype.update = function (buffer) {\n var _a = this, gl = _a.gl, CONTEXT_UID = _a.CONTEXT_UID;\n var glBuffer = buffer._glBuffers[CONTEXT_UID];\n if (buffer._updateID === glBuffer.updateID) {\n return;\n }\n glBuffer.updateID = buffer._updateID;\n gl.bindBuffer(buffer.type, glBuffer.buffer);\n if (glBuffer.byteLength >= buffer.data.byteLength) {\n // offset is always zero for now!\n gl.bufferSubData(buffer.type, 0, buffer.data);\n }\n else {\n var drawType = buffer.static ? gl.STATIC_DRAW : gl.DYNAMIC_DRAW;\n glBuffer.byteLength = buffer.data.byteLength;\n gl.bufferData(buffer.type, buffer.data, drawType);\n }\n };\n /**\n * Disposes buffer\n * @param {PIXI.Buffer} buffer - buffer with data\n * @param {boolean} [contextLost=false] - If context was lost, we suppress deleteVertexArray\n */\n BufferSystem.prototype.dispose = function (buffer, contextLost) {\n if (!this.managedBuffers[buffer.id]) {\n return;\n }\n delete this.managedBuffers[buffer.id];\n var glBuffer = buffer._glBuffers[this.CONTEXT_UID];\n var gl = this.gl;\n buffer.disposeRunner.remove(this);\n if (!glBuffer) {\n return;\n }\n if (!contextLost) {\n gl.deleteBuffer(glBuffer.buffer);\n }\n delete buffer._glBuffers[this.CONTEXT_UID];\n };\n /**\n * dispose all WebGL resources of all managed buffers\n * @param {boolean} [contextLost=false] - If context was lost, we suppress `gl.delete` calls\n */\n BufferSystem.prototype.disposeAll = function (contextLost) {\n var all = Object.keys(this.managedBuffers);\n for (var i = 0; i < all.length; i++) {\n this.dispose(this.managedBuffers[all[i]], contextLost);\n }\n };\n /**\n * creates and attaches a GLBuffer object tied to the current context.\n * @param buffer\n * @protected\n */\n BufferSystem.prototype.createGLBuffer = function (buffer) {\n var _a = this, CONTEXT_UID = _a.CONTEXT_UID, gl = _a.gl;\n buffer._glBuffers[CONTEXT_UID] = new GLBuffer(gl.createBuffer());\n this.managedBuffers[buffer.id] = buffer;\n buffer.disposeRunner.add(this);\n return buffer._glBuffers[CONTEXT_UID];\n };\n return BufferSystem;\n}());\n\n/**\n * The Renderer draws the scene and all its content onto a WebGL enabled canvas.\n *\n * This renderer should be used for browsers that support WebGL.\n *\n * This renderer works by automatically managing WebGLBatchesm, so no need for Sprite Batches or Sprite Clouds.\n * Don't forget to add the view to your DOM or you will not see anything!\n *\n * Renderer is composed of systems that manage specific tasks. The following systems are added by default\n * whenever you create a renderer:\n *\n * | System | Description |\n * | ------------------------------------ | ----------------------------------------------------------------------------- |\n * | {@link PIXI.BatchSystem} | This manages object renderers that defer rendering until a flush. |\n * | {@link PIXI.ContextSystem} | This manages the WebGL context and extensions. |\n * | {@link PIXI.EventSystem} | This manages UI events. |\n * | {@link PIXI.FilterSystem} | This manages the filtering pipeline for post-processing effects. |\n * | {@link PIXI.FramebufferSystem} | This manages framebuffers, which are used for offscreen rendering. |\n * | {@link PIXI.GeometrySystem} | This manages geometries & buffers, which are used to draw object meshes. |\n * | {@link PIXI.MaskSystem} | This manages masking operations. |\n * | {@link PIXI.ProjectionSystem} | This manages the `projectionMatrix`, used by shaders to get NDC coordinates. |\n * | {@link PIXI.RenderTextureSystem} | This manages render-textures, which are an abstraction over framebuffers. |\n * | {@link PIXI.ScissorSystem} | This handles scissor masking, and is used internally by {@link MaskSystem} |\n * | {@link PIXI.ShaderSystem} | This manages shaders, programs that run on the GPU to calculate 'em pixels. |\n * | {@link PIXI.StateSystem} | This manages the WebGL state variables like blend mode, depth testing, etc. |\n * | {@link PIXI.StencilSystem} | This handles stencil masking, and is used internally by {@link MaskSystem} |\n * | {@link PIXI.TextureSystem} | This manages textures and their resources on the GPU. |\n * | {@link PIXI.TextureGCSystem} | This will automatically remove textures from the GPU if they are not used. |\n *\n * The breadth of the API surface provided by the renderer is contained within these systems.\n * @memberof PIXI\n */\nvar Renderer = /** @class */ (function (_super) {\n __extends(Renderer, _super);\n /**\n * @param {PIXI.IRendererOptions} [options] - The optional renderer parameters.\n * @param {boolean} [options.antialias=false] -\n * **WebGL Only.** Whether to enable anti-aliasing. This may affect performance.\n * @param {boolean} [options.autoDensity=false] -\n * Whether the CSS dimensions of the renderer's view should be resized automatically.\n * @param {number} [options.backgroundAlpha=1] -\n * Transparency of the background color, value from `0` (fully transparent) to `1` (fully opaque).\n * @param {number} [options.backgroundColor=0x000000] -\n * The background color used to clear the canvas. It accepts hex numbers (e.g. `0xff0000`).\n * @param {boolean} [options.clearBeforeRender=true] - Whether to clear the canvas before new render passes.\n * @param {PIXI.IRenderingContext} [options.context] - **WebGL Only.** User-provided WebGL rendering context object.\n * @param {number} [options.height=600] - The height of the renderer's view.\n * @param {string} [options.powerPreference] -\n * **WebGL Only.** A hint indicating what configuration of GPU is suitable for the WebGL context,\n * can be `'default'`, `'high-performance'` or `'low-power'`.\n * Setting to `'high-performance'` will prioritize rendering performance over power consumption,\n * while setting to `'low-power'` will prioritize power saving over rendering performance.\n * @param {boolean} [options.premultipliedAlpha=true] -\n * **WebGL Only.** Whether the compositor will assume the drawing buffer contains colors with premultiplied alpha.\n * @param {boolean} [options.preserveDrawingBuffer=false] -\n * **WebGL Only.** Whether to enable drawing buffer preservation. If enabled, the drawing buffer will preserve\n * its value until cleared or overwritten. Enable this if you need to call `toDataUrl` on the WebGL context.\n * @param {number} [options.resolution=PIXI.settings.RESOLUTION] -\n * The resolution / device pixel ratio of the renderer.\n * @param {boolean} [options.transparent] -\n * **Deprecated since 6.0.0, Use `backgroundAlpha` instead.** \\\n * `true` sets `backgroundAlpha` to `0`, `false` sets `backgroundAlpha` to `1`.\n * @param {boolean|'notMultiplied'} [options.useContextAlpha=true] -\n * Pass-through value for canvas' context attribute `alpha`. This option is for cases where the\n * canvas needs to be opaque, possibly for performance reasons on some older devices.\n * If you want to set transparency, please use `backgroundAlpha`. \\\n * **WebGL Only:** When set to `'notMultiplied'`, the canvas' context attribute `alpha` will be\n * set to `true` and `premultipliedAlpha` will be to `false`.\n * @param {HTMLCanvasElement} [options.view=null] -\n * The canvas to use as the view. If omitted, a new canvas will be created.\n * @param {number} [options.width=800] - The width of the renderer's view.\n */\n function Renderer(options) {\n var _this = _super.call(this, RENDERER_TYPE.WEBGL, options) || this;\n // the options will have been modified here in the super constructor with pixi's default settings..\n options = _this.options;\n _this.gl = null;\n _this.CONTEXT_UID = 0;\n _this.runners = {\n destroy: new Runner('destroy'),\n contextChange: new Runner('contextChange'),\n reset: new Runner('reset'),\n update: new Runner('update'),\n postrender: new Runner('postrender'),\n prerender: new Runner('prerender'),\n resize: new Runner('resize'),\n };\n _this.runners.contextChange.add(_this);\n _this.globalUniforms = new UniformGroup({\n projectionMatrix: new Matrix(),\n }, true);\n _this.addSystem(MaskSystem, 'mask')\n .addSystem(ContextSystem, 'context')\n .addSystem(StateSystem, 'state')\n .addSystem(ShaderSystem, 'shader')\n .addSystem(TextureSystem, 'texture')\n .addSystem(BufferSystem, 'buffer')\n .addSystem(GeometrySystem, 'geometry')\n .addSystem(FramebufferSystem, 'framebuffer')\n .addSystem(ScissorSystem, 'scissor')\n .addSystem(StencilSystem, 'stencil')\n .addSystem(ProjectionSystem, 'projection')\n .addSystem(TextureGCSystem, 'textureGC')\n .addSystem(FilterSystem, 'filter')\n .addSystem(RenderTextureSystem, 'renderTexture')\n .addSystem(BatchSystem, 'batch');\n _this.initPlugins(Renderer.__plugins);\n _this.multisample = undefined;\n /*\n * The options passed in to create a new WebGL context.\n */\n if (options.context) {\n _this.context.initFromContext(options.context);\n }\n else {\n _this.context.initFromOptions({\n alpha: !!_this.useContextAlpha,\n antialias: options.antialias,\n premultipliedAlpha: _this.useContextAlpha && _this.useContextAlpha !== 'notMultiplied',\n stencil: true,\n preserveDrawingBuffer: options.preserveDrawingBuffer,\n powerPreference: _this.options.powerPreference,\n });\n }\n _this.renderingToScreen = true;\n sayHello(_this.context.webGLVersion === 2 ? 'WebGL 2' : 'WebGL 1');\n _this.resize(_this.options.width, _this.options.height);\n return _this;\n }\n /**\n * Create renderer if WebGL is available. Overrideable\n * by the **@pixi/canvas-renderer** package to allow fallback.\n * throws error if WebGL is not available.\n * @param options\n * @private\n */\n Renderer.create = function (options) {\n if (isWebGLSupported()) {\n return new Renderer(options);\n }\n throw new Error('WebGL unsupported in this browser, use \"pixi.js-legacy\" for fallback canvas2d support.');\n };\n Renderer.prototype.contextChange = function () {\n var gl = this.gl;\n var samples;\n if (this.context.webGLVersion === 1) {\n var framebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n samples = gl.getParameter(gl.SAMPLES);\n gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);\n }\n else {\n var framebuffer = gl.getParameter(gl.DRAW_FRAMEBUFFER_BINDING);\n gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null);\n samples = gl.getParameter(gl.SAMPLES);\n gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, framebuffer);\n }\n if (samples >= MSAA_QUALITY.HIGH) {\n this.multisample = MSAA_QUALITY.HIGH;\n }\n else if (samples >= MSAA_QUALITY.MEDIUM) {\n this.multisample = MSAA_QUALITY.MEDIUM;\n }\n else if (samples >= MSAA_QUALITY.LOW) {\n this.multisample = MSAA_QUALITY.LOW;\n }\n else {\n this.multisample = MSAA_QUALITY.NONE;\n }\n };\n /**\n * Add a new system to the renderer.\n * @param ClassRef - Class reference\n * @param name - Property name for system, if not specified\n * will use a static `name` property on the class itself. This\n * name will be assigned as s property on the Renderer so make\n * sure it doesn't collide with properties on Renderer.\n * @returns Return instance of renderer\n */\n Renderer.prototype.addSystem = function (ClassRef, name) {\n var system = new ClassRef(this);\n if (this[name]) {\n throw new Error(\"Whoops! The name \\\"\" + name + \"\\\" is already in use\");\n }\n this[name] = system;\n for (var i in this.runners) {\n this.runners[i].add(system);\n }\n /**\n * Fired after rendering finishes.\n * @event PIXI.Renderer#postrender\n */\n /**\n * Fired before rendering starts.\n * @event PIXI.Renderer#prerender\n */\n /**\n * Fired when the WebGL context is set.\n * @event PIXI.Renderer#context\n * @param {WebGLRenderingContext} gl - WebGL context.\n */\n return this;\n };\n /**\n * @ignore\n */\n Renderer.prototype.render = function (displayObject, options) {\n var renderTexture;\n var clear;\n var transform;\n var skipUpdateTransform;\n if (options) {\n if (options instanceof RenderTexture) {\n deprecation('6.0.0', 'Renderer#render arguments changed, use options instead.');\n /* eslint-disable prefer-rest-params */\n renderTexture = options;\n clear = arguments[2];\n transform = arguments[3];\n skipUpdateTransform = arguments[4];\n /* eslint-enable prefer-rest-params */\n }\n else {\n renderTexture = options.renderTexture;\n clear = options.clear;\n transform = options.transform;\n skipUpdateTransform = options.skipUpdateTransform;\n }\n }\n // can be handy to know!\n this.renderingToScreen = !renderTexture;\n this.runners.prerender.emit();\n this.emit('prerender');\n // apply a transform at a GPU level\n this.projection.transform = transform;\n // no point rendering if our context has been blown up!\n if (this.context.isLost) {\n return;\n }\n if (!renderTexture) {\n this._lastObjectRendered = displayObject;\n }\n if (!skipUpdateTransform) {\n // update the scene graph\n var cacheParent = displayObject.enableTempParent();\n displayObject.updateTransform();\n displayObject.disableTempParent(cacheParent);\n // displayObject.hitArea = //TODO add a temp hit area\n }\n this.renderTexture.bind(renderTexture);\n this.batch.currentRenderer.start();\n if (clear !== undefined ? clear : this.clearBeforeRender) {\n this.renderTexture.clear();\n }\n displayObject.render(this);\n // apply transform..\n this.batch.currentRenderer.flush();\n if (renderTexture) {\n renderTexture.baseTexture.update();\n }\n this.runners.postrender.emit();\n // reset transform after render\n this.projection.transform = null;\n this.emit('postrender');\n };\n /**\n * @override\n * @ignore\n */\n Renderer.prototype.generateTexture = function (displayObject, options, resolution, region) {\n if (options === void 0) { options = {}; }\n var renderTexture = _super.prototype.generateTexture.call(this, displayObject, options, resolution, region);\n this.framebuffer.blit();\n return renderTexture;\n };\n /**\n * Resizes the WebGL view to the specified width and height.\n * @param desiredScreenWidth - The desired width of the screen.\n * @param desiredScreenHeight - The desired height of the screen.\n */\n Renderer.prototype.resize = function (desiredScreenWidth, desiredScreenHeight) {\n _super.prototype.resize.call(this, desiredScreenWidth, desiredScreenHeight);\n this.runners.resize.emit(this.screen.height, this.screen.width);\n };\n /**\n * Resets the WebGL state so you can render things however you fancy!\n * @returns Returns itself.\n */\n Renderer.prototype.reset = function () {\n this.runners.reset.emit();\n return this;\n };\n /** Clear the frame buffer. */\n Renderer.prototype.clear = function () {\n this.renderTexture.bind();\n this.renderTexture.clear();\n };\n /**\n * Removes everything from the renderer (event listeners, spritebatch, etc...)\n * @param [removeView=false] - Removes the Canvas element from the DOM.\n * See: https://github.com/pixijs/pixi.js/issues/2233\n */\n Renderer.prototype.destroy = function (removeView) {\n this.runners.destroy.emit();\n for (var r in this.runners) {\n this.runners[r].destroy();\n }\n // call base destroy\n _super.prototype.destroy.call(this, removeView);\n // TODO nullify all the managers..\n this.gl = null;\n };\n Object.defineProperty(Renderer.prototype, \"extract\", {\n /**\n * Please use `plugins.extract` instead.\n * @member {PIXI.Extract} extract\n * @deprecated since 6.0.0\n * @readonly\n */\n get: function () {\n deprecation('6.0.0', 'Renderer#extract has been deprecated, please use Renderer#plugins.extract instead.');\n return this.plugins.extract;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Use the {@link PIXI.extensions.add} API to register plugins.\n * @deprecated since 6.5.0\n * @param pluginName - The name of the plugin.\n * @param ctor - The constructor function or class for the plugin.\n */\n Renderer.registerPlugin = function (pluginName, ctor) {\n deprecation('6.5.0', 'Renderer.registerPlugin() has been deprecated, please use extensions.add() instead.');\n extensions$1.add({\n name: pluginName,\n type: ExtensionType.RendererPlugin,\n ref: ctor,\n });\n };\n /**\n * Collection of installed plugins. These are included by default in PIXI, but can be excluded\n * by creating a custom build. Consult the README for more information about creating custom\n * builds and excluding plugins.\n * @readonly\n * @property {PIXI.AccessibilityManager} accessibility Support tabbing interactive elements.\n * @property {PIXI.Extract} extract Extract image data from renderer.\n * @property {PIXI.InteractionManager} interaction Handles mouse, touch and pointer events.\n * @property {PIXI.ParticleRenderer} particle Renderer for ParticleContainer objects.\n * @property {PIXI.Prepare} prepare Pre-render display objects.\n * @property {PIXI.BatchRenderer} batch Batching of Sprite, Graphics and Mesh objects.\n * @property {PIXI.TilingSpriteRenderer} tilingSprite Renderer for TilingSprite objects.\n */\n Renderer.__plugins = {};\n return Renderer;\n}(AbstractRenderer));\n// Handle registration of extensions\nextensions$1.handleByMap(ExtensionType.RendererPlugin, Renderer.__plugins);\n\n/**\n * This helper function will automatically detect which renderer you should be using.\n * WebGL is the preferred renderer as it is a lot faster. If WebGL is not supported by\n * the browser then this function will return a canvas renderer.\n * @memberof PIXI\n * @function autoDetectRenderer\n * @param {PIXI.IRendererOptionsAuto} [options] - The optional renderer parameters.\n * @param {boolean} [options.antialias=false] -\n * **WebGL Only.** Whether to enable anti-aliasing. This may affect performance.\n * @param {boolean} [options.autoDensity=false] -\n * Whether the CSS dimensions of the renderer's view should be resized automatically.\n * @param {number} [options.backgroundAlpha=1] -\n * Transparency of the background color, value from `0` (fully transparent) to `1` (fully opaque).\n * @param {number} [options.backgroundColor=0x000000] -\n * The background color used to clear the canvas. It accepts hex numbers (e.g. `0xff0000`).\n * @param {boolean} [options.clearBeforeRender=true] - Whether to clear the canvas before new render passes.\n * @param {PIXI.IRenderingContext} [options.context] - **WebGL Only.** User-provided WebGL rendering context object.\n * @param {boolean} [options.forceCanvas=false] -\n * Force using {@link PIXI.CanvasRenderer}, even if WebGL is available. This option only is available when\n * using **pixi.js-legacy** or **@pixi/canvas-renderer** packages, otherwise it is ignored.\n * @param {number} [options.height=600] - The height of the renderer's view.\n * @param {string} [options.powerPreference] -\n * **WebGL Only.** A hint indicating what configuration of GPU is suitable for the WebGL context,\n * can be `'default'`, `'high-performance'` or `'low-power'`.\n * Setting to `'high-performance'` will prioritize rendering performance over power consumption,\n * while setting to `'low-power'` will prioritize power saving over rendering performance.\n * @param {boolean} [options.premultipliedAlpha=true] -\n * **WebGL Only.** Whether the compositor will assume the drawing buffer contains colors with premultiplied alpha.\n * @param {boolean} [options.preserveDrawingBuffer=false] -\n * **WebGL Only.** Whether to enable drawing buffer preservation. If enabled, the drawing buffer will preserve\n * its value until cleared or overwritten. Enable this if you need to call `toDataUrl` on the WebGL context.\n * @param {number} [options.resolution=PIXI.settings.RESOLUTION] -\n * The resolution / device pixel ratio of the renderer.\n * @param {boolean} [options.transparent] -\n * **Deprecated since 6.0.0, Use `backgroundAlpha` instead.** \\\n * `true` sets `backgroundAlpha` to `0`, `false` sets `backgroundAlpha` to `1`.\n * @param {boolean|'notMultiplied'} [options.useContextAlpha=true] -\n * Pass-through value for canvas' context attribute `alpha`. This option is for cases where the\n * canvas needs to be opaque, possibly for performance reasons on some older devices.\n * If you want to set transparency, please use `backgroundAlpha`. \\\n * **WebGL Only:** When set to `'notMultiplied'`, the canvas' context attribute `alpha` will be\n * set to `true` and `premultipliedAlpha` will be to `false`.\n * @param {HTMLCanvasElement} [options.view=null] -\n * The canvas to use as the view. If omitted, a new canvas will be created.\n * @param {number} [options.width=800] - The width of the renderer's view.\n * @returns {PIXI.Renderer|PIXI.CanvasRenderer}\n * Returns {@link PIXI.Renderer} if WebGL is available, otherwise {@link PIXI.CanvasRenderer}.\n */\nfunction autoDetectRenderer(options) {\n return Renderer.create(options);\n}\n\nvar $defaultVertex = \"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}\";\n\nvar $defaultFilterVertex = \"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\";\n\n/**\n * Default vertex shader\n * @memberof PIXI\n * @member {string} defaultVertex\n */\n/**\n * Default filter vertex shader\n * @memberof PIXI\n * @member {string} defaultFilterVertex\n */\n// NOTE: This black magic is so that @microsoft/api-extractor does not complain! This explicitly specifies the types\n// of defaultVertex, defaultFilterVertex.\nvar defaultVertex$1 = $defaultVertex;\nvar defaultFilterVertex = $defaultFilterVertex;\n\n/**\n * Use the ISystem interface instead.\n * @deprecated since 6.1.0\n * @memberof PIXI\n */\nvar System = /** @class */ (function () {\n /**\n * @param renderer - Reference to Renderer\n */\n function System(renderer) {\n deprecation('6.1.0', 'System class is deprecated, implemement ISystem interface instead.');\n this.renderer = renderer;\n }\n /** Destroy and don't use after this. */\n System.prototype.destroy = function () {\n this.renderer = null;\n };\n return System;\n}());\n\n/**\n * Used by the batcher to draw batches.\n * Each one of these contains all information required to draw a bound geometry.\n * @memberof PIXI\n */\nvar BatchDrawCall = /** @class */ (function () {\n function BatchDrawCall() {\n this.texArray = null;\n this.blend = 0;\n this.type = DRAW_MODES.TRIANGLES;\n this.start = 0;\n this.size = 0;\n this.data = null;\n }\n return BatchDrawCall;\n}());\n\n/**\n * Used by the batcher to build texture batches.\n * Holds list of textures and their respective locations.\n * @memberof PIXI\n */\nvar BatchTextureArray = /** @class */ (function () {\n function BatchTextureArray() {\n this.elements = [];\n this.ids = [];\n this.count = 0;\n }\n BatchTextureArray.prototype.clear = function () {\n for (var i = 0; i < this.count; i++) {\n this.elements[i] = null;\n }\n this.count = 0;\n };\n return BatchTextureArray;\n}());\n\n/**\n * Flexible wrapper around `ArrayBuffer` that also provides typed array views on demand.\n * @memberof PIXI\n */\nvar ViewableBuffer = /** @class */ (function () {\n function ViewableBuffer(sizeOrBuffer) {\n if (typeof sizeOrBuffer === 'number') {\n this.rawBinaryData = new ArrayBuffer(sizeOrBuffer);\n }\n else if (sizeOrBuffer instanceof Uint8Array) {\n this.rawBinaryData = sizeOrBuffer.buffer;\n }\n else {\n this.rawBinaryData = sizeOrBuffer;\n }\n this.uint32View = new Uint32Array(this.rawBinaryData);\n this.float32View = new Float32Array(this.rawBinaryData);\n }\n Object.defineProperty(ViewableBuffer.prototype, \"int8View\", {\n /** View on the raw binary data as a `Int8Array`. */\n get: function () {\n if (!this._int8View) {\n this._int8View = new Int8Array(this.rawBinaryData);\n }\n return this._int8View;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(ViewableBuffer.prototype, \"uint8View\", {\n /** View on the raw binary data as a `Uint8Array`. */\n get: function () {\n if (!this._uint8View) {\n this._uint8View = new Uint8Array(this.rawBinaryData);\n }\n return this._uint8View;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(ViewableBuffer.prototype, \"int16View\", {\n /** View on the raw binary data as a `Int16Array`. */\n get: function () {\n if (!this._int16View) {\n this._int16View = new Int16Array(this.rawBinaryData);\n }\n return this._int16View;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(ViewableBuffer.prototype, \"uint16View\", {\n /** View on the raw binary data as a `Uint16Array`. */\n get: function () {\n if (!this._uint16View) {\n this._uint16View = new Uint16Array(this.rawBinaryData);\n }\n return this._uint16View;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(ViewableBuffer.prototype, \"int32View\", {\n /** View on the raw binary data as a `Int32Array`. */\n get: function () {\n if (!this._int32View) {\n this._int32View = new Int32Array(this.rawBinaryData);\n }\n return this._int32View;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Returns the view of the given type.\n * @param type - One of `int8`, `uint8`, `int16`,\n * `uint16`, `int32`, `uint32`, and `float32`.\n * @returns - typed array of given type\n */\n ViewableBuffer.prototype.view = function (type) {\n return this[type + \"View\"];\n };\n /** Destroys all buffer references. Do not use after calling this. */\n ViewableBuffer.prototype.destroy = function () {\n this.rawBinaryData = null;\n this._int8View = null;\n this._uint8View = null;\n this._int16View = null;\n this._uint16View = null;\n this._int32View = null;\n this.uint32View = null;\n this.float32View = null;\n };\n ViewableBuffer.sizeOf = function (type) {\n switch (type) {\n case 'int8':\n case 'uint8':\n return 1;\n case 'int16':\n case 'uint16':\n return 2;\n case 'int32':\n case 'uint32':\n case 'float32':\n return 4;\n default:\n throw new Error(type + \" isn't a valid view type\");\n }\n };\n return ViewableBuffer;\n}());\n\n/**\n * Renderer dedicated to drawing and batching sprites.\n *\n * This is the default batch renderer. It buffers objects\n * with texture-based geometries and renders them in\n * batches. It uploads multiple textures to the GPU to\n * reduce to the number of draw calls.\n * @memberof PIXI\n */\nvar AbstractBatchRenderer = /** @class */ (function (_super) {\n __extends(AbstractBatchRenderer, _super);\n /**\n * This will hook onto the renderer's `contextChange`\n * and `prerender` signals.\n * @param {PIXI.Renderer} renderer - The renderer this works for.\n */\n function AbstractBatchRenderer(renderer) {\n var _this = _super.call(this, renderer) || this;\n _this.shaderGenerator = null;\n _this.geometryClass = null;\n _this.vertexSize = null;\n _this.state = State.for2d();\n _this.size = settings.SPRITE_BATCH_SIZE * 4;\n _this._vertexCount = 0;\n _this._indexCount = 0;\n _this._bufferedElements = [];\n _this._bufferedTextures = [];\n _this._bufferSize = 0;\n _this._shader = null;\n _this._packedGeometries = [];\n _this._packedGeometryPoolSize = 2;\n _this._flushId = 0;\n _this._aBuffers = {};\n _this._iBuffers = {};\n _this.MAX_TEXTURES = 1;\n _this.renderer.on('prerender', _this.onPrerender, _this);\n renderer.runners.contextChange.add(_this);\n _this._dcIndex = 0;\n _this._aIndex = 0;\n _this._iIndex = 0;\n _this._attributeBuffer = null;\n _this._indexBuffer = null;\n _this._tempBoundTextures = [];\n return _this;\n }\n /**\n * Handles the `contextChange` signal.\n *\n * It calculates `this.MAX_TEXTURES` and allocating the packed-geometry object pool.\n */\n AbstractBatchRenderer.prototype.contextChange = function () {\n var gl = this.renderer.gl;\n if (settings.PREFER_ENV === ENV.WEBGL_LEGACY) {\n this.MAX_TEXTURES = 1;\n }\n else {\n // step 1: first check max textures the GPU can handle.\n this.MAX_TEXTURES = Math.min(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS), settings.SPRITE_MAX_TEXTURES);\n // step 2: check the maximum number of if statements the shader can have too..\n this.MAX_TEXTURES = checkMaxIfStatementsInShader(this.MAX_TEXTURES, gl);\n }\n this._shader = this.shaderGenerator.generateShader(this.MAX_TEXTURES);\n // we use the second shader as the first one depending on your browser\n // may omit aTextureId as it is not used by the shader so is optimized out.\n for (var i = 0; i < this._packedGeometryPoolSize; i++) {\n /* eslint-disable max-len */\n this._packedGeometries[i] = new (this.geometryClass)();\n }\n this.initFlushBuffers();\n };\n /** Makes sure that static and dynamic flush pooled objects have correct dimensions. */\n AbstractBatchRenderer.prototype.initFlushBuffers = function () {\n var _drawCallPool = AbstractBatchRenderer._drawCallPool, _textureArrayPool = AbstractBatchRenderer._textureArrayPool;\n // max draw calls\n var MAX_SPRITES = this.size / 4;\n // max texture arrays\n var MAX_TA = Math.floor(MAX_SPRITES / this.MAX_TEXTURES) + 1;\n while (_drawCallPool.length < MAX_SPRITES) {\n _drawCallPool.push(new BatchDrawCall());\n }\n while (_textureArrayPool.length < MAX_TA) {\n _textureArrayPool.push(new BatchTextureArray());\n }\n for (var i = 0; i < this.MAX_TEXTURES; i++) {\n this._tempBoundTextures[i] = null;\n }\n };\n /** Handles the `prerender` signal. It ensures that flushes start from the first geometry object again. */\n AbstractBatchRenderer.prototype.onPrerender = function () {\n this._flushId = 0;\n };\n /**\n * Buffers the \"batchable\" object. It need not be rendered immediately.\n * @param {PIXI.DisplayObject} element - the element to render when\n * using this renderer\n */\n AbstractBatchRenderer.prototype.render = function (element) {\n if (!element._texture.valid) {\n return;\n }\n if (this._vertexCount + (element.vertexData.length / 2) > this.size) {\n this.flush();\n }\n this._vertexCount += element.vertexData.length / 2;\n this._indexCount += element.indices.length;\n this._bufferedTextures[this._bufferSize] = element._texture.baseTexture;\n this._bufferedElements[this._bufferSize++] = element;\n };\n AbstractBatchRenderer.prototype.buildTexturesAndDrawCalls = function () {\n var _a = this, textures = _a._bufferedTextures, MAX_TEXTURES = _a.MAX_TEXTURES;\n var textureArrays = AbstractBatchRenderer._textureArrayPool;\n var batch = this.renderer.batch;\n var boundTextures = this._tempBoundTextures;\n var touch = this.renderer.textureGC.count;\n var TICK = ++BaseTexture._globalBatch;\n var countTexArrays = 0;\n var texArray = textureArrays[0];\n var start = 0;\n batch.copyBoundTextures(boundTextures, MAX_TEXTURES);\n for (var i = 0; i < this._bufferSize; ++i) {\n var tex = textures[i];\n textures[i] = null;\n if (tex._batchEnabled === TICK) {\n continue;\n }\n if (texArray.count >= MAX_TEXTURES) {\n batch.boundArray(texArray, boundTextures, TICK, MAX_TEXTURES);\n this.buildDrawCalls(texArray, start, i);\n start = i;\n texArray = textureArrays[++countTexArrays];\n ++TICK;\n }\n tex._batchEnabled = TICK;\n tex.touched = touch;\n texArray.elements[texArray.count++] = tex;\n }\n if (texArray.count > 0) {\n batch.boundArray(texArray, boundTextures, TICK, MAX_TEXTURES);\n this.buildDrawCalls(texArray, start, this._bufferSize);\n ++countTexArrays;\n ++TICK;\n }\n // Clean-up\n for (var i = 0; i < boundTextures.length; i++) {\n boundTextures[i] = null;\n }\n BaseTexture._globalBatch = TICK;\n };\n /**\n * Populating drawcalls for rendering\n * @param texArray\n * @param start\n * @param finish\n */\n AbstractBatchRenderer.prototype.buildDrawCalls = function (texArray, start, finish) {\n var _a = this, elements = _a._bufferedElements, _attributeBuffer = _a._attributeBuffer, _indexBuffer = _a._indexBuffer, vertexSize = _a.vertexSize;\n var drawCalls = AbstractBatchRenderer._drawCallPool;\n var dcIndex = this._dcIndex;\n var aIndex = this._aIndex;\n var iIndex = this._iIndex;\n var drawCall = drawCalls[dcIndex];\n drawCall.start = this._iIndex;\n drawCall.texArray = texArray;\n for (var i = start; i < finish; ++i) {\n var sprite = elements[i];\n var tex = sprite._texture.baseTexture;\n var spriteBlendMode = premultiplyBlendMode[tex.alphaMode ? 1 : 0][sprite.blendMode];\n elements[i] = null;\n if (start < i && drawCall.blend !== spriteBlendMode) {\n drawCall.size = iIndex - drawCall.start;\n start = i;\n drawCall = drawCalls[++dcIndex];\n drawCall.texArray = texArray;\n drawCall.start = iIndex;\n }\n this.packInterleavedGeometry(sprite, _attributeBuffer, _indexBuffer, aIndex, iIndex);\n aIndex += sprite.vertexData.length / 2 * vertexSize;\n iIndex += sprite.indices.length;\n drawCall.blend = spriteBlendMode;\n }\n if (start < finish) {\n drawCall.size = iIndex - drawCall.start;\n ++dcIndex;\n }\n this._dcIndex = dcIndex;\n this._aIndex = aIndex;\n this._iIndex = iIndex;\n };\n /**\n * Bind textures for current rendering\n * @param texArray\n */\n AbstractBatchRenderer.prototype.bindAndClearTexArray = function (texArray) {\n var textureSystem = this.renderer.texture;\n for (var j = 0; j < texArray.count; j++) {\n textureSystem.bind(texArray.elements[j], texArray.ids[j]);\n texArray.elements[j] = null;\n }\n texArray.count = 0;\n };\n AbstractBatchRenderer.prototype.updateGeometry = function () {\n var _a = this, packedGeometries = _a._packedGeometries, attributeBuffer = _a._attributeBuffer, indexBuffer = _a._indexBuffer;\n if (!settings.CAN_UPLOAD_SAME_BUFFER) { /* Usually on iOS devices, where the browser doesn't\n like uploads to the same buffer in a single frame. */\n if (this._packedGeometryPoolSize <= this._flushId) {\n this._packedGeometryPoolSize++;\n packedGeometries[this._flushId] = new (this.geometryClass)();\n }\n packedGeometries[this._flushId]._buffer.update(attributeBuffer.rawBinaryData);\n packedGeometries[this._flushId]._indexBuffer.update(indexBuffer);\n this.renderer.geometry.bind(packedGeometries[this._flushId]);\n this.renderer.geometry.updateBuffers();\n this._flushId++;\n }\n else {\n // lets use the faster option, always use buffer number 0\n packedGeometries[this._flushId]._buffer.update(attributeBuffer.rawBinaryData);\n packedGeometries[this._flushId]._indexBuffer.update(indexBuffer);\n this.renderer.geometry.updateBuffers();\n }\n };\n AbstractBatchRenderer.prototype.drawBatches = function () {\n var dcCount = this._dcIndex;\n var _a = this.renderer, gl = _a.gl, stateSystem = _a.state;\n var drawCalls = AbstractBatchRenderer._drawCallPool;\n var curTexArray = null;\n // Upload textures and do the draw calls\n for (var i = 0; i < dcCount; i++) {\n var _b = drawCalls[i], texArray = _b.texArray, type = _b.type, size = _b.size, start = _b.start, blend = _b.blend;\n if (curTexArray !== texArray) {\n curTexArray = texArray;\n this.bindAndClearTexArray(texArray);\n }\n this.state.blendMode = blend;\n stateSystem.set(this.state);\n gl.drawElements(type, size, gl.UNSIGNED_SHORT, start * 2);\n }\n };\n /** Renders the content _now_ and empties the current batch. */\n AbstractBatchRenderer.prototype.flush = function () {\n if (this._vertexCount === 0) {\n return;\n }\n this._attributeBuffer = this.getAttributeBuffer(this._vertexCount);\n this._indexBuffer = this.getIndexBuffer(this._indexCount);\n this._aIndex = 0;\n this._iIndex = 0;\n this._dcIndex = 0;\n this.buildTexturesAndDrawCalls();\n this.updateGeometry();\n this.drawBatches();\n // reset elements buffer for the next flush\n this._bufferSize = 0;\n this._vertexCount = 0;\n this._indexCount = 0;\n };\n /** Starts a new sprite batch. */\n AbstractBatchRenderer.prototype.start = function () {\n this.renderer.state.set(this.state);\n this.renderer.texture.ensureSamplerType(this.MAX_TEXTURES);\n this.renderer.shader.bind(this._shader);\n if (settings.CAN_UPLOAD_SAME_BUFFER) {\n // bind buffer #0, we don't need others\n this.renderer.geometry.bind(this._packedGeometries[this._flushId]);\n }\n };\n /** Stops and flushes the current batch. */\n AbstractBatchRenderer.prototype.stop = function () {\n this.flush();\n };\n /** Destroys this `AbstractBatchRenderer`. It cannot be used again. */\n AbstractBatchRenderer.prototype.destroy = function () {\n for (var i = 0; i < this._packedGeometryPoolSize; i++) {\n if (this._packedGeometries[i]) {\n this._packedGeometries[i].destroy();\n }\n }\n this.renderer.off('prerender', this.onPrerender, this);\n this._aBuffers = null;\n this._iBuffers = null;\n this._packedGeometries = null;\n this._attributeBuffer = null;\n this._indexBuffer = null;\n if (this._shader) {\n this._shader.destroy();\n this._shader = null;\n }\n _super.prototype.destroy.call(this);\n };\n /**\n * Fetches an attribute buffer from `this._aBuffers` that can hold atleast `size` floats.\n * @param size - minimum capacity required\n * @returns - buffer than can hold atleast `size` floats\n */\n AbstractBatchRenderer.prototype.getAttributeBuffer = function (size) {\n // 8 vertices is enough for 2 quads\n var roundedP2 = nextPow2(Math.ceil(size / 8));\n var roundedSizeIndex = log2(roundedP2);\n var roundedSize = roundedP2 * 8;\n if (this._aBuffers.length <= roundedSizeIndex) {\n this._iBuffers.length = roundedSizeIndex + 1;\n }\n var buffer = this._aBuffers[roundedSize];\n if (!buffer) {\n this._aBuffers[roundedSize] = buffer = new ViewableBuffer(roundedSize * this.vertexSize * 4);\n }\n return buffer;\n };\n /**\n * Fetches an index buffer from `this._iBuffers` that can\n * have at least `size` capacity.\n * @param size - minimum required capacity\n * @returns - buffer that can fit `size` indices.\n */\n AbstractBatchRenderer.prototype.getIndexBuffer = function (size) {\n // 12 indices is enough for 2 quads\n var roundedP2 = nextPow2(Math.ceil(size / 12));\n var roundedSizeIndex = log2(roundedP2);\n var roundedSize = roundedP2 * 12;\n if (this._iBuffers.length <= roundedSizeIndex) {\n this._iBuffers.length = roundedSizeIndex + 1;\n }\n var buffer = this._iBuffers[roundedSizeIndex];\n if (!buffer) {\n this._iBuffers[roundedSizeIndex] = buffer = new Uint16Array(roundedSize);\n }\n return buffer;\n };\n /**\n * Takes the four batching parameters of `element`, interleaves\n * and pushes them into the batching attribute/index buffers given.\n *\n * It uses these properties: `vertexData` `uvs`, `textureId` and\n * `indicies`. It also uses the \"tint\" of the base-texture, if\n * present.\n * @param {PIXI.DisplayObject} element - element being rendered\n * @param attributeBuffer - attribute buffer.\n * @param indexBuffer - index buffer\n * @param aIndex - number of floats already in the attribute buffer\n * @param iIndex - number of indices already in `indexBuffer`\n */\n AbstractBatchRenderer.prototype.packInterleavedGeometry = function (element, attributeBuffer, indexBuffer, aIndex, iIndex) {\n var uint32View = attributeBuffer.uint32View, float32View = attributeBuffer.float32View;\n var packedVertices = aIndex / this.vertexSize;\n var uvs = element.uvs;\n var indicies = element.indices;\n var vertexData = element.vertexData;\n var textureId = element._texture.baseTexture._batchLocation;\n var alpha = Math.min(element.worldAlpha, 1.0);\n var argb = (alpha < 1.0\n && element._texture.baseTexture.alphaMode)\n ? premultiplyTint(element._tintRGB, alpha)\n : element._tintRGB + (alpha * 255 << 24);\n // lets not worry about tint! for now..\n for (var i = 0; i < vertexData.length; i += 2) {\n float32View[aIndex++] = vertexData[i];\n float32View[aIndex++] = vertexData[i + 1];\n float32View[aIndex++] = uvs[i];\n float32View[aIndex++] = uvs[i + 1];\n uint32View[aIndex++] = argb;\n float32View[aIndex++] = textureId;\n }\n for (var i = 0; i < indicies.length; i++) {\n indexBuffer[iIndex++] = packedVertices + indicies[i];\n }\n };\n /**\n * Pool of `BatchDrawCall` objects that `flush` used\n * to create \"batches\" of the objects being rendered.\n *\n * These are never re-allocated again.\n * Shared between all batch renderers because it can be only one \"flush\" working at the moment.\n * @member {PIXI.BatchDrawCall[]}\n */\n AbstractBatchRenderer._drawCallPool = [];\n /**\n * Pool of `BatchDrawCall` objects that `flush` used\n * to create \"batches\" of the objects being rendered.\n *\n * These are never re-allocated again.\n * Shared between all batch renderers because it can be only one \"flush\" working at the moment.\n * @member {PIXI.BatchTextureArray[]}\n */\n AbstractBatchRenderer._textureArrayPool = [];\n return AbstractBatchRenderer;\n}(ObjectRenderer));\n\n/**\n * Helper that generates batching multi-texture shader. Use it with your new BatchRenderer\n * @memberof PIXI\n */\nvar BatchShaderGenerator = /** @class */ (function () {\n /**\n * @param vertexSrc - Vertex shader\n * @param fragTemplate - Fragment shader template\n */\n function BatchShaderGenerator(vertexSrc, fragTemplate) {\n this.vertexSrc = vertexSrc;\n this.fragTemplate = fragTemplate;\n this.programCache = {};\n this.defaultGroupCache = {};\n if (fragTemplate.indexOf('%count%') < 0) {\n throw new Error('Fragment template must contain \"%count%\".');\n }\n if (fragTemplate.indexOf('%forloop%') < 0) {\n throw new Error('Fragment template must contain \"%forloop%\".');\n }\n }\n BatchShaderGenerator.prototype.generateShader = function (maxTextures) {\n if (!this.programCache[maxTextures]) {\n var sampleValues = new Int32Array(maxTextures);\n for (var i = 0; i < maxTextures; i++) {\n sampleValues[i] = i;\n }\n this.defaultGroupCache[maxTextures] = UniformGroup.from({ uSamplers: sampleValues }, true);\n var fragmentSrc = this.fragTemplate;\n fragmentSrc = fragmentSrc.replace(/%count%/gi, \"\" + maxTextures);\n fragmentSrc = fragmentSrc.replace(/%forloop%/gi, this.generateSampleSrc(maxTextures));\n this.programCache[maxTextures] = new Program(this.vertexSrc, fragmentSrc);\n }\n var uniforms = {\n tint: new Float32Array([1, 1, 1, 1]),\n translationMatrix: new Matrix(),\n default: this.defaultGroupCache[maxTextures],\n };\n return new Shader(this.programCache[maxTextures], uniforms);\n };\n BatchShaderGenerator.prototype.generateSampleSrc = function (maxTextures) {\n var src = '';\n src += '\\n';\n src += '\\n';\n for (var i = 0; i < maxTextures; i++) {\n if (i > 0) {\n src += '\\nelse ';\n }\n if (i < maxTextures - 1) {\n src += \"if(vTextureId < \" + i + \".5)\";\n }\n src += '\\n{';\n src += \"\\n\\tcolor = texture2D(uSamplers[\" + i + \"], vTextureCoord);\";\n src += '\\n}';\n }\n src += '\\n';\n src += '\\n';\n return src;\n };\n return BatchShaderGenerator;\n}());\n\n/**\n * Geometry used to batch standard PIXI content (e.g. Mesh, Sprite, Graphics objects).\n * @memberof PIXI\n */\nvar BatchGeometry = /** @class */ (function (_super) {\n __extends(BatchGeometry, _super);\n /**\n * @param {boolean} [_static=false] - Optimization flag, where `false`\n * is updated every frame, `true` doesn't change frame-to-frame.\n */\n function BatchGeometry(_static) {\n if (_static === void 0) { _static = false; }\n var _this = _super.call(this) || this;\n _this._buffer = new Buffer(null, _static, false);\n _this._indexBuffer = new Buffer(null, _static, true);\n _this.addAttribute('aVertexPosition', _this._buffer, 2, false, TYPES.FLOAT)\n .addAttribute('aTextureCoord', _this._buffer, 2, false, TYPES.FLOAT)\n .addAttribute('aColor', _this._buffer, 4, true, TYPES.UNSIGNED_BYTE)\n .addAttribute('aTextureId', _this._buffer, 1, true, TYPES.FLOAT)\n .addIndex(_this._indexBuffer);\n return _this;\n }\n return BatchGeometry;\n}(Geometry));\n\nvar defaultVertex = \"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\";\n\nvar defaultFragment = \"varying vec2 vTextureCoord;\\nvarying vec4 vColor;\\nvarying float vTextureId;\\nuniform sampler2D uSamplers[%count%];\\n\\nvoid main(void){\\n vec4 color;\\n %forloop%\\n gl_FragColor = color * vColor;\\n}\\n\";\n\n/** @memberof PIXI */\nvar BatchPluginFactory = /** @class */ (function () {\n function BatchPluginFactory() {\n }\n /**\n * Create a new BatchRenderer plugin for Renderer. this convenience can provide an easy way\n * to extend BatchRenderer with all the necessary pieces.\n * @example\n * const fragment = `\n * varying vec2 vTextureCoord;\n * varying vec4 vColor;\n * varying float vTextureId;\n * uniform sampler2D uSamplers[%count%];\n *\n * void main(void){\n * vec4 color;\n * %forloop%\n * gl_FragColor = vColor * vec4(color.a - color.rgb, color.a);\n * }\n * `;\n * const InvertBatchRenderer = PIXI.BatchPluginFactory.create({ fragment });\n * PIXI.extensions.add({\n * name: 'invert',\n * ref: InvertBatchRenderer,\n * type: PIXI.ExtensionType.RendererPlugin,\n * });\n * const sprite = new PIXI.Sprite();\n * sprite.pluginName = 'invert';\n * @param {object} [options]\n * @param {string} [options.vertex=PIXI.BatchPluginFactory.defaultVertexSrc] - Vertex shader source\n * @param {string} [options.fragment=PIXI.BatchPluginFactory.defaultFragmentTemplate] - Fragment shader template\n * @param {number} [options.vertexSize=6] - Vertex size\n * @param {object} [options.geometryClass=PIXI.BatchGeometry]\n * @returns {*} New batch renderer plugin\n */\n BatchPluginFactory.create = function (options) {\n var _a = Object.assign({\n vertex: defaultVertex,\n fragment: defaultFragment,\n geometryClass: BatchGeometry,\n vertexSize: 6,\n }, options), vertex = _a.vertex, fragment = _a.fragment, vertexSize = _a.vertexSize, geometryClass = _a.geometryClass;\n return /** @class */ (function (_super) {\n __extends(BatchPlugin, _super);\n function BatchPlugin(renderer) {\n var _this = _super.call(this, renderer) || this;\n _this.shaderGenerator = new BatchShaderGenerator(vertex, fragment);\n _this.geometryClass = geometryClass;\n _this.vertexSize = vertexSize;\n return _this;\n }\n return BatchPlugin;\n }(AbstractBatchRenderer));\n };\n Object.defineProperty(BatchPluginFactory, \"defaultVertexSrc\", {\n /**\n * The default vertex shader source\n * @readonly\n */\n get: function () {\n return defaultVertex;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BatchPluginFactory, \"defaultFragmentTemplate\", {\n /**\n * The default fragment shader source\n * @readonly\n */\n get: function () {\n return defaultFragment;\n },\n enumerable: false,\n configurable: true\n });\n return BatchPluginFactory;\n}());\n// Setup the default BatchRenderer plugin, this is what\n// we'll actually export at the root level\nvar BatchRenderer = BatchPluginFactory.create();\nObject.assign(BatchRenderer, {\n extension: {\n name: 'batch',\n type: ExtensionType.RendererPlugin,\n },\n});\n\n/**\n * @memberof PIXI\n * @namespace resources\n * @see PIXI\n * @deprecated since 6.0.0\n */\nvar resources = {};\nvar _loop_1 = function (name) {\n Object.defineProperty(resources, name, {\n get: function () {\n deprecation('6.0.0', \"PIXI.systems.\" + name + \" has moved to PIXI.\" + name);\n return _resources[name];\n },\n });\n};\nfor (var name in _resources) {\n _loop_1(name);\n}\n/**\n * @memberof PIXI\n * @namespace systems\n * @see PIXI\n * @deprecated since 6.0.0\n */\nvar systems = {};\nvar _loop_2 = function (name) {\n Object.defineProperty(systems, name, {\n get: function () {\n deprecation('6.0.0', \"PIXI.resources.\" + name + \" has moved to PIXI.\" + name);\n return _systems[name];\n },\n });\n};\nfor (var name in _systems) {\n _loop_2(name);\n}\n\n/**\n * @namespace PIXI\n */\n/**\n * String of the current PIXI version.\n * @memberof PIXI\n */\nvar VERSION = '6.5.10';\n\nexport { AbstractBatchRenderer, AbstractMultiResource, AbstractRenderer, ArrayResource, Attribute, BaseImageResource, BaseRenderTexture, BaseTexture, BatchDrawCall, BatchGeometry, BatchPluginFactory, BatchRenderer, BatchShaderGenerator, BatchSystem, BatchTextureArray, Buffer, BufferResource, CanvasResource, ContextSystem, CubeResource, Filter, FilterState, FilterSystem, Framebuffer, FramebufferSystem, GLFramebuffer, GLProgram, GLTexture, Geometry, GeometrySystem, IGLUniformData, INSTALLED, ImageBitmapResource, ImageResource, MaskData, MaskSystem, ObjectRenderer, Program, ProjectionSystem, Quad, QuadUv, RenderTexture, RenderTexturePool, RenderTextureSystem, Renderer, Resource, SVGResource, ScissorSystem, Shader, ShaderSystem, SpriteMaskFilter, State, StateSystem, StencilSystem, System, Texture, TextureGCSystem, TextureMatrix, TextureSystem, TextureUvs, UniformGroup, VERSION, VideoResource, ViewableBuffer, autoDetectRenderer, autoDetectResource, checkMaxIfStatementsInShader, createUBOElements, defaultFilterVertex, defaultVertex$1 as defaultVertex, generateProgram, generateUniformBufferSync, getTestContext, getUBOData, resources, systems, uniformParsers };\n//# sourceMappingURL=core.mjs.map\n","/*!\n * @pixi/accessibility - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/accessibility is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { DisplayObject } from '@pixi/display';\nimport { isMobile, removeItems } from '@pixi/utils';\nimport { ExtensionType } from '@pixi/core';\n\n/**\n * Default property values of accessible objects\n * used by {@link PIXI.AccessibilityManager}.\n * @private\n * @function accessibleTarget\n * @memberof PIXI\n * @type {object}\n * @example\n * function MyObject() {}\n *\n * Object.assign(\n * MyObject.prototype,\n * PIXI.accessibleTarget\n * );\n */\nvar accessibleTarget = {\n /**\n * Flag for if the object is accessible. If true AccessibilityManager will overlay a\n * shadow div with attributes set\n * @member {boolean}\n * @memberof PIXI.DisplayObject#\n */\n accessible: false,\n /**\n * Sets the title attribute of the shadow div\n * If accessibleTitle AND accessibleHint has not been this will default to 'displayObject [tabIndex]'\n * @member {?string}\n * @memberof PIXI.DisplayObject#\n */\n accessibleTitle: null,\n /**\n * Sets the aria-label attribute of the shadow div\n * @member {string}\n * @memberof PIXI.DisplayObject#\n */\n accessibleHint: null,\n /**\n * @member {number}\n * @memberof PIXI.DisplayObject#\n * @private\n * @todo Needs docs.\n */\n tabIndex: 0,\n /**\n * @member {boolean}\n * @memberof PIXI.DisplayObject#\n * @todo Needs docs.\n */\n _accessibleActive: false,\n /**\n * @member {boolean}\n * @memberof PIXI.DisplayObject#\n * @todo Needs docs.\n */\n _accessibleDiv: null,\n /**\n * Specify the type of div the accessible layer is. Screen readers treat the element differently\n * depending on this type. Defaults to button.\n * @member {string}\n * @memberof PIXI.DisplayObject#\n * @default 'button'\n */\n accessibleType: 'button',\n /**\n * Specify the pointer-events the accessible div will use\n * Defaults to auto.\n * @member {string}\n * @memberof PIXI.DisplayObject#\n * @default 'auto'\n */\n accessiblePointerEvents: 'auto',\n /**\n * Setting to false will prevent any children inside this container to\n * be accessible. Defaults to true.\n * @member {boolean}\n * @memberof PIXI.DisplayObject#\n * @default true\n */\n accessibleChildren: true,\n renderId: -1,\n};\n\n// add some extra variables to the container..\nDisplayObject.mixin(accessibleTarget);\nvar KEY_CODE_TAB = 9;\nvar DIV_TOUCH_SIZE = 100;\nvar DIV_TOUCH_POS_X = 0;\nvar DIV_TOUCH_POS_Y = 0;\nvar DIV_TOUCH_ZINDEX = 2;\nvar DIV_HOOK_SIZE = 1;\nvar DIV_HOOK_POS_X = -1000;\nvar DIV_HOOK_POS_Y = -1000;\nvar DIV_HOOK_ZINDEX = 2;\n/**\n * The Accessibility manager recreates the ability to tab and have content read by screen readers.\n * This is very important as it can possibly help people with disabilities access PixiJS content.\n *\n * A DisplayObject can be made accessible just like it can be made interactive. This manager will map the\n * events as if the mouse was being used, minimizing the effort required to implement.\n *\n * An instance of this class is automatically created by default, and can be found at `renderer.plugins.accessibility`\n * @class\n * @memberof PIXI\n */\nvar AccessibilityManager = /** @class */ (function () {\n /**\n * @param {PIXI.CanvasRenderer|PIXI.Renderer} renderer - A reference to the current renderer\n */\n function AccessibilityManager(renderer) {\n /** Setting this to true will visually show the divs. */\n this.debug = false;\n /** Internal variable, see isActive getter. */\n this._isActive = false;\n /** Internal variable, see isMobileAccessibility getter. */\n this._isMobileAccessibility = false;\n /** A simple pool for storing divs. */\n this.pool = [];\n /** This is a tick used to check if an object is no longer being rendered. */\n this.renderId = 0;\n /** The array of currently active accessible items. */\n this.children = [];\n /** Count to throttle div updates on android devices. */\n this.androidUpdateCount = 0;\n /** The frequency to update the div elements. */\n this.androidUpdateFrequency = 500; // 2fps\n this._hookDiv = null;\n if (isMobile.tablet || isMobile.phone) {\n this.createTouchHook();\n }\n // first we create a div that will sit over the PixiJS element. This is where the div overlays will go.\n var div = document.createElement('div');\n div.style.width = DIV_TOUCH_SIZE + \"px\";\n div.style.height = DIV_TOUCH_SIZE + \"px\";\n div.style.position = 'absolute';\n div.style.top = DIV_TOUCH_POS_X + \"px\";\n div.style.left = DIV_TOUCH_POS_Y + \"px\";\n div.style.zIndex = DIV_TOUCH_ZINDEX.toString();\n this.div = div;\n this.renderer = renderer;\n /**\n * pre-bind the functions\n * @type {Function}\n * @private\n */\n this._onKeyDown = this._onKeyDown.bind(this);\n /**\n * pre-bind the functions\n * @type {Function}\n * @private\n */\n this._onMouseMove = this._onMouseMove.bind(this);\n // let listen for tab.. once pressed we can fire up and show the accessibility layer\n globalThis.addEventListener('keydown', this._onKeyDown, false);\n }\n Object.defineProperty(AccessibilityManager.prototype, \"isActive\", {\n /**\n * Value of `true` if accessibility is currently active and accessibility layers are showing.\n * @member {boolean}\n * @readonly\n */\n get: function () {\n return this._isActive;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(AccessibilityManager.prototype, \"isMobileAccessibility\", {\n /**\n * Value of `true` if accessibility is enabled for touch devices.\n * @member {boolean}\n * @readonly\n */\n get: function () {\n return this._isMobileAccessibility;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Creates the touch hooks.\n * @private\n */\n AccessibilityManager.prototype.createTouchHook = function () {\n var _this = this;\n var hookDiv = document.createElement('button');\n hookDiv.style.width = DIV_HOOK_SIZE + \"px\";\n hookDiv.style.height = DIV_HOOK_SIZE + \"px\";\n hookDiv.style.position = 'absolute';\n hookDiv.style.top = DIV_HOOK_POS_X + \"px\";\n hookDiv.style.left = DIV_HOOK_POS_Y + \"px\";\n hookDiv.style.zIndex = DIV_HOOK_ZINDEX.toString();\n hookDiv.style.backgroundColor = '#FF0000';\n hookDiv.title = 'select to enable accessibility for this content';\n hookDiv.addEventListener('focus', function () {\n _this._isMobileAccessibility = true;\n _this.activate();\n _this.destroyTouchHook();\n });\n document.body.appendChild(hookDiv);\n this._hookDiv = hookDiv;\n };\n /**\n * Destroys the touch hooks.\n * @private\n */\n AccessibilityManager.prototype.destroyTouchHook = function () {\n if (!this._hookDiv) {\n return;\n }\n document.body.removeChild(this._hookDiv);\n this._hookDiv = null;\n };\n /**\n * Activating will cause the Accessibility layer to be shown.\n * This is called when a user presses the tab key.\n * @private\n */\n AccessibilityManager.prototype.activate = function () {\n var _a;\n if (this._isActive) {\n return;\n }\n this._isActive = true;\n globalThis.document.addEventListener('mousemove', this._onMouseMove, true);\n globalThis.removeEventListener('keydown', this._onKeyDown, false);\n this.renderer.on('postrender', this.update, this);\n (_a = this.renderer.view.parentNode) === null || _a === void 0 ? void 0 : _a.appendChild(this.div);\n };\n /**\n * Deactivating will cause the Accessibility layer to be hidden.\n * This is called when a user moves the mouse.\n * @private\n */\n AccessibilityManager.prototype.deactivate = function () {\n var _a;\n if (!this._isActive || this._isMobileAccessibility) {\n return;\n }\n this._isActive = false;\n globalThis.document.removeEventListener('mousemove', this._onMouseMove, true);\n globalThis.addEventListener('keydown', this._onKeyDown, false);\n this.renderer.off('postrender', this.update);\n (_a = this.div.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this.div);\n };\n /**\n * This recursive function will run through the scene graph and add any new accessible objects to the DOM layer.\n * @private\n * @param {PIXI.Container} displayObject - The DisplayObject to check.\n */\n AccessibilityManager.prototype.updateAccessibleObjects = function (displayObject) {\n if (!displayObject.visible || !displayObject.accessibleChildren) {\n return;\n }\n if (displayObject.accessible && displayObject.interactive) {\n if (!displayObject._accessibleActive) {\n this.addChild(displayObject);\n }\n displayObject.renderId = this.renderId;\n }\n var children = displayObject.children;\n if (children) {\n for (var i = 0; i < children.length; i++) {\n this.updateAccessibleObjects(children[i]);\n }\n }\n };\n /**\n * Before each render this function will ensure that all divs are mapped correctly to their DisplayObjects.\n * @private\n */\n AccessibilityManager.prototype.update = function () {\n /* On Android default web browser, tab order seems to be calculated by position rather than tabIndex,\n * moving buttons can cause focus to flicker between two buttons making it hard/impossible to navigate,\n * so I am just running update every half a second, seems to fix it.\n */\n var now = performance.now();\n if (isMobile.android.device && now < this.androidUpdateCount) {\n return;\n }\n this.androidUpdateCount = now + this.androidUpdateFrequency;\n if (!this.renderer.renderingToScreen) {\n return;\n }\n // update children...\n if (this.renderer._lastObjectRendered) {\n this.updateAccessibleObjects(this.renderer._lastObjectRendered);\n }\n var _a = this.renderer.view.getBoundingClientRect(), left = _a.left, top = _a.top, width = _a.width, height = _a.height;\n var _b = this.renderer, viewWidth = _b.width, viewHeight = _b.height, resolution = _b.resolution;\n var sx = (width / viewWidth) * resolution;\n var sy = (height / viewHeight) * resolution;\n var div = this.div;\n div.style.left = left + \"px\";\n div.style.top = top + \"px\";\n div.style.width = viewWidth + \"px\";\n div.style.height = viewHeight + \"px\";\n for (var i = 0; i < this.children.length; i++) {\n var child = this.children[i];\n if (child.renderId !== this.renderId) {\n child._accessibleActive = false;\n removeItems(this.children, i, 1);\n this.div.removeChild(child._accessibleDiv);\n this.pool.push(child._accessibleDiv);\n child._accessibleDiv = null;\n i--;\n }\n else {\n // map div to display..\n div = child._accessibleDiv;\n var hitArea = child.hitArea;\n var wt = child.worldTransform;\n if (child.hitArea) {\n div.style.left = (wt.tx + (hitArea.x * wt.a)) * sx + \"px\";\n div.style.top = (wt.ty + (hitArea.y * wt.d)) * sy + \"px\";\n div.style.width = hitArea.width * wt.a * sx + \"px\";\n div.style.height = hitArea.height * wt.d * sy + \"px\";\n }\n else {\n hitArea = child.getBounds();\n this.capHitArea(hitArea);\n div.style.left = hitArea.x * sx + \"px\";\n div.style.top = hitArea.y * sy + \"px\";\n div.style.width = hitArea.width * sx + \"px\";\n div.style.height = hitArea.height * sy + \"px\";\n // update button titles and hints if they exist and they've changed\n if (div.title !== child.accessibleTitle && child.accessibleTitle !== null) {\n div.title = child.accessibleTitle;\n }\n if (div.getAttribute('aria-label') !== child.accessibleHint\n && child.accessibleHint !== null) {\n div.setAttribute('aria-label', child.accessibleHint);\n }\n }\n // the title or index may have changed, if so lets update it!\n if (child.accessibleTitle !== div.title || child.tabIndex !== div.tabIndex) {\n div.title = child.accessibleTitle;\n div.tabIndex = child.tabIndex;\n if (this.debug)\n { this.updateDebugHTML(div); }\n }\n }\n }\n // increment the render id..\n this.renderId++;\n };\n /**\n * private function that will visually add the information to the\n * accessability div\n * @param {HTMLElement} div -\n */\n AccessibilityManager.prototype.updateDebugHTML = function (div) {\n div.innerHTML = \"type: \" + div.type + \"
title : \" + div.title + \"
tabIndex: \" + div.tabIndex;\n };\n /**\n * Adjust the hit area based on the bounds of a display object\n * @param {PIXI.Rectangle} hitArea - Bounds of the child\n */\n AccessibilityManager.prototype.capHitArea = function (hitArea) {\n if (hitArea.x < 0) {\n hitArea.width += hitArea.x;\n hitArea.x = 0;\n }\n if (hitArea.y < 0) {\n hitArea.height += hitArea.y;\n hitArea.y = 0;\n }\n var _a = this.renderer, viewWidth = _a.width, viewHeight = _a.height;\n if (hitArea.x + hitArea.width > viewWidth) {\n hitArea.width = viewWidth - hitArea.x;\n }\n if (hitArea.y + hitArea.height > viewHeight) {\n hitArea.height = viewHeight - hitArea.y;\n }\n };\n /**\n * Adds a DisplayObject to the accessibility manager\n * @private\n * @param {PIXI.DisplayObject} displayObject - The child to make accessible.\n */\n AccessibilityManager.prototype.addChild = function (displayObject) {\n // this.activate();\n var div = this.pool.pop();\n if (!div) {\n div = document.createElement('button');\n div.style.width = DIV_TOUCH_SIZE + \"px\";\n div.style.height = DIV_TOUCH_SIZE + \"px\";\n div.style.backgroundColor = this.debug ? 'rgba(255,255,255,0.5)' : 'transparent';\n div.style.position = 'absolute';\n div.style.zIndex = DIV_TOUCH_ZINDEX.toString();\n div.style.borderStyle = 'none';\n // ARIA attributes ensure that button title and hint updates are announced properly\n if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {\n // Chrome doesn't need aria-live to work as intended; in fact it just gets more confused.\n div.setAttribute('aria-live', 'off');\n }\n else {\n div.setAttribute('aria-live', 'polite');\n }\n if (navigator.userAgent.match(/rv:.*Gecko\\//)) {\n // FireFox needs this to announce only the new button name\n div.setAttribute('aria-relevant', 'additions');\n }\n else {\n // required by IE, other browsers don't much care\n div.setAttribute('aria-relevant', 'text');\n }\n div.addEventListener('click', this._onClick.bind(this));\n div.addEventListener('focus', this._onFocus.bind(this));\n div.addEventListener('focusout', this._onFocusOut.bind(this));\n }\n // set pointer events\n div.style.pointerEvents = displayObject.accessiblePointerEvents;\n // set the type, this defaults to button!\n div.type = displayObject.accessibleType;\n if (displayObject.accessibleTitle && displayObject.accessibleTitle !== null) {\n div.title = displayObject.accessibleTitle;\n }\n else if (!displayObject.accessibleHint\n || displayObject.accessibleHint === null) {\n div.title = \"displayObject \" + displayObject.tabIndex;\n }\n if (displayObject.accessibleHint\n && displayObject.accessibleHint !== null) {\n div.setAttribute('aria-label', displayObject.accessibleHint);\n }\n if (this.debug)\n { this.updateDebugHTML(div); }\n displayObject._accessibleActive = true;\n displayObject._accessibleDiv = div;\n div.displayObject = displayObject;\n this.children.push(displayObject);\n this.div.appendChild(displayObject._accessibleDiv);\n displayObject._accessibleDiv.tabIndex = displayObject.tabIndex;\n };\n /**\n * Maps the div button press to pixi's InteractionManager (click)\n * @private\n * @param {MouseEvent} e - The click event.\n */\n AccessibilityManager.prototype._onClick = function (e) {\n var interactionManager = this.renderer.plugins.interaction;\n var displayObject = e.target.displayObject;\n var eventData = interactionManager.eventData;\n interactionManager.dispatchEvent(displayObject, 'click', eventData);\n interactionManager.dispatchEvent(displayObject, 'pointertap', eventData);\n interactionManager.dispatchEvent(displayObject, 'tap', eventData);\n };\n /**\n * Maps the div focus events to pixi's InteractionManager (mouseover)\n * @private\n * @param {FocusEvent} e - The focus event.\n */\n AccessibilityManager.prototype._onFocus = function (e) {\n if (!e.target.getAttribute('aria-live')) {\n e.target.setAttribute('aria-live', 'assertive');\n }\n var interactionManager = this.renderer.plugins.interaction;\n var displayObject = e.target.displayObject;\n var eventData = interactionManager.eventData;\n interactionManager.dispatchEvent(displayObject, 'mouseover', eventData);\n };\n /**\n * Maps the div focus events to pixi's InteractionManager (mouseout)\n * @private\n * @param {FocusEvent} e - The focusout event.\n */\n AccessibilityManager.prototype._onFocusOut = function (e) {\n if (!e.target.getAttribute('aria-live')) {\n e.target.setAttribute('aria-live', 'polite');\n }\n var interactionManager = this.renderer.plugins.interaction;\n var displayObject = e.target.displayObject;\n var eventData = interactionManager.eventData;\n interactionManager.dispatchEvent(displayObject, 'mouseout', eventData);\n };\n /**\n * Is called when a key is pressed\n * @private\n * @param {KeyboardEvent} e - The keydown event.\n */\n AccessibilityManager.prototype._onKeyDown = function (e) {\n if (e.keyCode !== KEY_CODE_TAB) {\n return;\n }\n this.activate();\n };\n /**\n * Is called when the mouse moves across the renderer element\n * @private\n * @param {MouseEvent} e - The mouse event.\n */\n AccessibilityManager.prototype._onMouseMove = function (e) {\n if (e.movementX === 0 && e.movementY === 0) {\n return;\n }\n this.deactivate();\n };\n /** Destroys the accessibility manager */\n AccessibilityManager.prototype.destroy = function () {\n this.destroyTouchHook();\n this.div = null;\n globalThis.document.removeEventListener('mousemove', this._onMouseMove, true);\n globalThis.removeEventListener('keydown', this._onKeyDown);\n this.pool = null;\n this.children = null;\n this.renderer = null;\n };\n /** @ignore */\n AccessibilityManager.extension = {\n name: 'accessibility',\n type: [\n ExtensionType.RendererPlugin,\n ExtensionType.CanvasRendererPlugin ],\n };\n return AccessibilityManager;\n}());\n\nexport { AccessibilityManager, accessibleTarget };\n//# sourceMappingURL=accessibility.mjs.map\n","/*!\n * @pixi/interaction - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/interaction is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { Point } from '@pixi/math';\nimport { Ticker, UPDATE_PRIORITY } from '@pixi/ticker';\nimport { DisplayObject, TemporaryDisplayObject } from '@pixi/display';\nimport { EventEmitter } from '@pixi/utils';\nimport { ExtensionType } from '@pixi/core';\n\n/**\n * Holds all information related to an Interaction event\n * @memberof PIXI\n */\nvar InteractionData = /** @class */ (function () {\n function InteractionData() {\n /**\n * Pressure applied by the pointing device during the event. A Touch's force property\n * will be represented by this value.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure\n */\n this.pressure = 0;\n /**\n * From TouchEvents (not PointerEvents triggered by touches), the rotationAngle of the Touch.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Touch/rotationAngle\n */\n this.rotationAngle = 0;\n /**\n * Twist of a stylus pointer.\n * @see https://w3c.github.io/pointerevents/#pointerevent-interface\n */\n this.twist = 0;\n /**\n * Barrel pressure on a stylus pointer.\n * @see https://w3c.github.io/pointerevents/#pointerevent-interface\n */\n this.tangentialPressure = 0;\n this.global = new Point();\n this.target = null;\n this.originalEvent = null;\n this.identifier = null;\n this.isPrimary = false;\n this.button = 0;\n this.buttons = 0;\n this.width = 0;\n this.height = 0;\n this.tiltX = 0;\n this.tiltY = 0;\n this.pointerType = null;\n this.pressure = 0;\n this.rotationAngle = 0;\n this.twist = 0;\n this.tangentialPressure = 0;\n }\n Object.defineProperty(InteractionData.prototype, \"pointerId\", {\n /**\n * The unique identifier of the pointer. It will be the same as `identifier`.\n * @readonly\n * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId\n */\n get: function () {\n return this.identifier;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * This will return the local coordinates of the specified displayObject for this InteractionData\n * @param displayObject - The DisplayObject that you would like the local\n * coords off\n * @param point - A Point object in which to store the value, optional (otherwise\n * will create a new point)\n * @param globalPos - A Point object containing your custom global coords, optional\n * (otherwise will use the current global coords)\n * @returns - A point containing the coordinates of the InteractionData position relative\n * to the DisplayObject\n */\n InteractionData.prototype.getLocalPosition = function (displayObject, point, globalPos) {\n return displayObject.worldTransform.applyInverse(globalPos || this.global, point);\n };\n /**\n * Copies properties from normalized event data.\n * @param {Touch|MouseEvent|PointerEvent} event - The normalized event data\n */\n InteractionData.prototype.copyEvent = function (event) {\n // isPrimary should only change on touchstart/pointerdown, so we don't want to overwrite\n // it with \"false\" on later events when our shim for it on touch events might not be\n // accurate\n if ('isPrimary' in event && event.isPrimary) {\n this.isPrimary = true;\n }\n this.button = 'button' in event && event.button;\n // event.buttons is not available in all browsers (ie. Safari), but it does have a non-standard\n // event.which property instead, which conveys the same information.\n var buttons = 'buttons' in event && event.buttons;\n this.buttons = Number.isInteger(buttons) ? buttons : 'which' in event && event.which;\n this.width = 'width' in event && event.width;\n this.height = 'height' in event && event.height;\n this.tiltX = 'tiltX' in event && event.tiltX;\n this.tiltY = 'tiltY' in event && event.tiltY;\n this.pointerType = 'pointerType' in event && event.pointerType;\n this.pressure = 'pressure' in event && event.pressure;\n this.rotationAngle = 'rotationAngle' in event && event.rotationAngle;\n this.twist = ('twist' in event && event.twist) || 0;\n this.tangentialPressure = ('tangentialPressure' in event && event.tangentialPressure) || 0;\n };\n /** Resets the data for pooling. */\n InteractionData.prototype.reset = function () {\n // isPrimary is the only property that we really need to reset - everything else is\n // guaranteed to be overwritten\n this.isPrimary = false;\n };\n return InteractionData;\n}());\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\n/**\n * Event class that mimics native DOM events.\n * @memberof PIXI\n */\nvar InteractionEvent = /** @class */ (function () {\n function InteractionEvent() {\n this.stopped = false;\n this.stopsPropagatingAt = null;\n this.stopPropagationHint = false;\n this.target = null;\n this.currentTarget = null;\n this.type = null;\n this.data = null;\n }\n /** Prevents event from reaching any objects other than the current object. */\n InteractionEvent.prototype.stopPropagation = function () {\n this.stopped = true;\n this.stopPropagationHint = true;\n this.stopsPropagatingAt = this.currentTarget;\n };\n /** Resets the event. */\n InteractionEvent.prototype.reset = function () {\n this.stopped = false;\n this.stopsPropagatingAt = null;\n this.stopPropagationHint = false;\n this.currentTarget = null;\n this.target = null;\n };\n return InteractionEvent;\n}());\n\n/**\n * DisplayObjects with the {@link PIXI.interactiveTarget} mixin use this class to track interactions\n * @class\n * @private\n * @memberof PIXI\n */\nvar InteractionTrackingData = /** @class */ (function () {\n /**\n * @param {number} pointerId - Unique pointer id of the event\n * @private\n */\n function InteractionTrackingData(pointerId) {\n this._pointerId = pointerId;\n this._flags = InteractionTrackingData.FLAGS.NONE;\n }\n /**\n *\n * @private\n * @param {number} flag - The interaction flag to set\n * @param {boolean} yn - Should the flag be set or unset\n */\n InteractionTrackingData.prototype._doSet = function (flag, yn) {\n if (yn) {\n this._flags = this._flags | flag;\n }\n else {\n this._flags = this._flags & (~flag);\n }\n };\n Object.defineProperty(InteractionTrackingData.prototype, \"pointerId\", {\n /**\n * Unique pointer id of the event\n * @readonly\n * @private\n * @member {number}\n */\n get: function () {\n return this._pointerId;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(InteractionTrackingData.prototype, \"flags\", {\n /**\n * State of the tracking data, expressed as bit flags\n * @private\n * @member {number}\n */\n get: function () {\n return this._flags;\n },\n set: function (flags) {\n this._flags = flags;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(InteractionTrackingData.prototype, \"none\", {\n /**\n * Is the tracked event inactive (not over or down)?\n * @private\n * @member {number}\n */\n get: function () {\n return this._flags === InteractionTrackingData.FLAGS.NONE;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(InteractionTrackingData.prototype, \"over\", {\n /**\n * Is the tracked event over the DisplayObject?\n * @private\n * @member {boolean}\n */\n get: function () {\n return (this._flags & InteractionTrackingData.FLAGS.OVER) !== 0;\n },\n set: function (yn) {\n this._doSet(InteractionTrackingData.FLAGS.OVER, yn);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(InteractionTrackingData.prototype, \"rightDown\", {\n /**\n * Did the right mouse button come down in the DisplayObject?\n * @private\n * @member {boolean}\n */\n get: function () {\n return (this._flags & InteractionTrackingData.FLAGS.RIGHT_DOWN) !== 0;\n },\n set: function (yn) {\n this._doSet(InteractionTrackingData.FLAGS.RIGHT_DOWN, yn);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(InteractionTrackingData.prototype, \"leftDown\", {\n /**\n * Did the left mouse button come down in the DisplayObject?\n * @private\n * @member {boolean}\n */\n get: function () {\n return (this._flags & InteractionTrackingData.FLAGS.LEFT_DOWN) !== 0;\n },\n set: function (yn) {\n this._doSet(InteractionTrackingData.FLAGS.LEFT_DOWN, yn);\n },\n enumerable: false,\n configurable: true\n });\n InteractionTrackingData.FLAGS = Object.freeze({\n NONE: 0,\n OVER: 1 << 0,\n LEFT_DOWN: 1 << 1,\n RIGHT_DOWN: 1 << 2,\n });\n return InteractionTrackingData;\n}());\n\n/**\n * Strategy how to search through stage tree for interactive objects\n * @memberof PIXI\n */\nvar TreeSearch = /** @class */ (function () {\n function TreeSearch() {\n this._tempPoint = new Point();\n }\n /**\n * Recursive implementation for findHit\n * @private\n * @param interactionEvent - event containing the point that\n * is tested for collision\n * @param displayObject - the displayObject\n * that will be hit test (recursively crawls its children)\n * @param func - the function that will be called on each interactive object. The\n * interactionEvent, displayObject and hit will be passed to the function\n * @param hitTest - this indicates if the objects inside should be hit test against the point\n * @param interactive - Whether the displayObject is interactive\n * @returns - Returns true if the displayObject hit the point\n */\n TreeSearch.prototype.recursiveFindHit = function (interactionEvent, displayObject, func, hitTest, interactive) {\n var _a;\n if (!displayObject || !displayObject.visible) {\n return false;\n }\n var point = interactionEvent.data.global;\n // Took a little while to rework this function correctly! But now it is done and nice and optimized! ^_^\n //\n // This function will now loop through all objects and then only hit test the objects it HAS\n // to, not all of them. MUCH faster..\n // An object will be hit test if the following is true:\n //\n // 1: It is interactive.\n // 2: It belongs to a parent that is interactive AND one of the parents children have not already been hit.\n //\n // As another little optimization once an interactive object has been hit we can carry on\n // through the scenegraph, but we know that there will be no more hits! So we can avoid extra hit tests\n // A final optimization is that an object is not hit test directly if a child has already been hit.\n interactive = displayObject.interactive || interactive;\n var hit = false;\n var interactiveParent = interactive;\n // Flag here can set to false if the event is outside the parents hitArea or mask\n var hitTestChildren = true;\n // If there is a hitArea, no need to test against anything else if the pointer is not within the hitArea\n // There is also no longer a need to hitTest children.\n if (displayObject.hitArea) {\n if (hitTest) {\n displayObject.worldTransform.applyInverse(point, this._tempPoint);\n if (!displayObject.hitArea.contains(this._tempPoint.x, this._tempPoint.y)) {\n hitTest = false;\n hitTestChildren = false;\n }\n else {\n hit = true;\n }\n }\n interactiveParent = false;\n }\n // If there is a mask, no need to hitTest against anything else if the pointer is not within the mask.\n // We still want to hitTestChildren, however, to ensure a mouseout can still be generated.\n // https://github.com/pixijs/pixi.js/issues/5135\n else if (displayObject._mask) {\n if (hitTest) {\n var maskObject = (displayObject._mask.isMaskData\n ? displayObject._mask.maskObject : displayObject._mask);\n if (maskObject && !((_a = maskObject.containsPoint) === null || _a === void 0 ? void 0 : _a.call(maskObject, point))) {\n hitTest = false;\n }\n }\n }\n // ** FREE TIP **! If an object is not interactive or has no buttons in it\n // (such as a game scene!) set interactiveChildren to false for that displayObject.\n // This will allow PixiJS to completely ignore and bypass checking the displayObjects children.\n if (hitTestChildren && displayObject.interactiveChildren && displayObject.children) {\n var children = displayObject.children;\n for (var i = children.length - 1; i >= 0; i--) {\n var child = children[i];\n // time to get recursive.. if this function will return if something is hit..\n var childHit = this.recursiveFindHit(interactionEvent, child, func, hitTest, interactiveParent);\n if (childHit) {\n // its a good idea to check if a child has lost its parent.\n // this means it has been removed whilst looping so its best\n if (!child.parent) {\n continue;\n }\n // we no longer need to hit test any more objects in this container as we we\n // now know the parent has been hit\n interactiveParent = false;\n // If the child is interactive , that means that the object hit was actually\n // interactive and not just the child of an interactive object.\n // This means we no longer need to hit test anything else. We still need to run\n // through all objects, but we don't need to perform any hit tests.\n if (childHit) {\n if (interactionEvent.target) {\n hitTest = false;\n }\n hit = true;\n }\n }\n }\n }\n // no point running this if the item is not interactive or does not have an interactive parent.\n if (interactive) {\n // if we are hit testing (as in we have no hit any objects yet)\n // We also don't need to worry about hit testing if once of the displayObjects children\n // has already been hit - but only if it was interactive, otherwise we need to keep\n // looking for an interactive child, just in case we hit one\n if (hitTest && !interactionEvent.target) {\n // already tested against hitArea if it is defined\n if (!displayObject.hitArea && displayObject.containsPoint) {\n if (displayObject.containsPoint(point)) {\n hit = true;\n }\n }\n }\n if (displayObject.interactive) {\n if (hit && !interactionEvent.target) {\n interactionEvent.target = displayObject;\n }\n if (func) {\n func(interactionEvent, displayObject, !!hit);\n }\n }\n }\n return hit;\n };\n /**\n * This function is provides a neat way of crawling through the scene graph and running a\n * specified function on all interactive objects it finds. It will also take care of hit\n * testing the interactive objects and passes the hit across in the function.\n * @private\n * @param interactionEvent - event containing the point that\n * is tested for collision\n * @param displayObject - the displayObject\n * that will be hit test (recursively crawls its children)\n * @param func - the function that will be called on each interactive object. The\n * interactionEvent, displayObject and hit will be passed to the function\n * @param hitTest - this indicates if the objects inside should be hit test against the point\n * @returns - Returns true if the displayObject hit the point\n */\n TreeSearch.prototype.findHit = function (interactionEvent, displayObject, func, hitTest) {\n this.recursiveFindHit(interactionEvent, displayObject, func, hitTest, false);\n };\n return TreeSearch;\n}());\n\n/**\n * Interface for classes that represent a hit area.\n *\n * It is implemented by the following classes:\n * - {@link PIXI.Circle}\n * - {@link PIXI.Ellipse}\n * - {@link PIXI.Polygon}\n * - {@link PIXI.RoundedRectangle}\n * @interface IHitArea\n * @memberof PIXI\n */\n/**\n * Checks whether the x and y coordinates given are contained within this area\n * @method\n * @name contains\n * @memberof PIXI.IHitArea#\n * @param {number} x - The X coordinate of the point to test\n * @param {number} y - The Y coordinate of the point to test\n * @returns {boolean} Whether the x/y coordinates are within this area\n */\n/**\n * Default property values of interactive objects\n * Used by {@link PIXI.InteractionManager} to automatically give all DisplayObjects these properties\n * @private\n * @name interactiveTarget\n * @type {object}\n * @memberof PIXI\n * @example\n * function MyObject() {}\n *\n * Object.assign(\n * DisplayObject.prototype,\n * PIXI.interactiveTarget\n * );\n */\nvar interactiveTarget = {\n interactive: false,\n interactiveChildren: true,\n hitArea: null,\n /**\n * If enabled, the mouse cursor use the pointer behavior when hovered over the displayObject if it is interactive\n * Setting this changes the 'cursor' property to `'pointer'`.\n * @example\n * const sprite = new PIXI.Sprite(texture);\n * sprite.interactive = true;\n * sprite.buttonMode = true;\n * @member {boolean}\n * @memberof PIXI.DisplayObject#\n */\n get buttonMode() {\n return this.cursor === 'pointer';\n },\n set buttonMode(value) {\n if (value) {\n this.cursor = 'pointer';\n }\n else if (this.cursor === 'pointer') {\n this.cursor = null;\n }\n },\n /**\n * This defines what cursor mode is used when the mouse cursor\n * is hovered over the displayObject.\n * @example\n * const sprite = new PIXI.Sprite(texture);\n * sprite.interactive = true;\n * sprite.cursor = 'wait';\n * @see https://developer.mozilla.org/en/docs/Web/CSS/cursor\n * @member {string}\n * @memberof PIXI.DisplayObject#\n */\n cursor: null,\n /**\n * Internal set of all active pointers, by identifier\n * @member {Map}\n * @memberof PIXI.DisplayObject#\n * @private\n */\n get trackedPointers() {\n if (this._trackedPointers === undefined)\n { this._trackedPointers = {}; }\n return this._trackedPointers;\n },\n /**\n * Map of all tracked pointers, by identifier. Use trackedPointers to access.\n * @private\n * @type {Map}\n */\n _trackedPointers: undefined,\n};\n\n// Mix interactiveTarget into DisplayObject.prototype\nDisplayObject.mixin(interactiveTarget);\nvar MOUSE_POINTER_ID = 1;\n// helpers for hitTest() - only used inside hitTest()\nvar hitTestEvent = {\n target: null,\n data: {\n global: null,\n },\n};\n/**\n * The interaction manager deals with mouse, touch and pointer events.\n *\n * Any DisplayObject can be interactive if its `interactive` property is set to true.\n *\n * This manager also supports multitouch.\n *\n * An instance of this class is automatically created by default, and can be found at `renderer.plugins.interaction`\n * @memberof PIXI\n */\nvar InteractionManager = /** @class */ (function (_super) {\n __extends(InteractionManager, _super);\n /**\n * @param {PIXI.CanvasRenderer|PIXI.Renderer} renderer - A reference to the current renderer\n * @param options - The options for the manager.\n * @param {boolean} [options.autoPreventDefault=true] - Should the manager automatically prevent default browser actions.\n * @param {number} [options.interactionFrequency=10] - Maximum frequency (ms) at pointer over/out states will be checked.\n * @param {number} [options.useSystemTicker=true] - Whether to add {@link tickerUpdate} to {@link PIXI.Ticker.system}.\n */\n function InteractionManager(renderer, options) {\n var _this = _super.call(this) || this;\n options = options || {};\n _this.renderer = renderer;\n _this.autoPreventDefault = options.autoPreventDefault !== undefined ? options.autoPreventDefault : true;\n _this.interactionFrequency = options.interactionFrequency || 10;\n _this.mouse = new InteractionData();\n _this.mouse.identifier = MOUSE_POINTER_ID;\n // setting the mouse to start off far off screen will mean that mouse over does\n // not get called before we even move the mouse.\n _this.mouse.global.set(-999999);\n _this.activeInteractionData = {};\n _this.activeInteractionData[MOUSE_POINTER_ID] = _this.mouse;\n _this.interactionDataPool = [];\n _this.eventData = new InteractionEvent();\n _this.interactionDOMElement = null;\n _this.moveWhenInside = false;\n _this.eventsAdded = false;\n _this.tickerAdded = false;\n _this.mouseOverRenderer = !('PointerEvent' in globalThis);\n _this.supportsTouchEvents = 'ontouchstart' in globalThis;\n _this.supportsPointerEvents = !!globalThis.PointerEvent;\n // this will make it so that you don't have to call bind all the time\n _this.onPointerUp = _this.onPointerUp.bind(_this);\n _this.processPointerUp = _this.processPointerUp.bind(_this);\n _this.onPointerCancel = _this.onPointerCancel.bind(_this);\n _this.processPointerCancel = _this.processPointerCancel.bind(_this);\n _this.onPointerDown = _this.onPointerDown.bind(_this);\n _this.processPointerDown = _this.processPointerDown.bind(_this);\n _this.onPointerMove = _this.onPointerMove.bind(_this);\n _this.processPointerMove = _this.processPointerMove.bind(_this);\n _this.onPointerOut = _this.onPointerOut.bind(_this);\n _this.processPointerOverOut = _this.processPointerOverOut.bind(_this);\n _this.onPointerOver = _this.onPointerOver.bind(_this);\n _this.cursorStyles = {\n default: 'inherit',\n pointer: 'pointer',\n };\n _this.currentCursorMode = null;\n _this.cursor = null;\n _this.resolution = 1;\n _this.delayedEvents = [];\n _this.search = new TreeSearch();\n _this._tempDisplayObject = new TemporaryDisplayObject();\n _this._eventListenerOptions = { capture: true, passive: false };\n /**\n * Fired when a pointer device button (usually a mouse left-button) is pressed on the display\n * object.\n * @event PIXI.InteractionManager#mousedown\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device secondary button (usually a mouse right-button) is pressed\n * on the display object.\n * @event PIXI.InteractionManager#rightdown\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button (usually a mouse left-button) is released over the display\n * object.\n * @event PIXI.InteractionManager#mouseup\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device secondary button (usually a mouse right-button) is released\n * over the display object.\n * @event PIXI.InteractionManager#rightup\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button (usually a mouse left-button) is pressed and released on\n * the display object.\n * @event PIXI.InteractionManager#click\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device secondary button (usually a mouse right-button) is pressed\n * and released on the display object.\n * @event PIXI.InteractionManager#rightclick\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button (usually a mouse left-button) is released outside the\n * display object that initially registered a\n * [mousedown]{@link PIXI.InteractionManager#event:mousedown}.\n * @event PIXI.InteractionManager#mouseupoutside\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device secondary button (usually a mouse right-button) is released\n * outside the display object that initially registered a\n * [rightdown]{@link PIXI.InteractionManager#event:rightdown}.\n * @event PIXI.InteractionManager#rightupoutside\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device (usually a mouse) is moved while over the display object\n * @event PIXI.InteractionManager#mousemove\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device (usually a mouse) is moved onto the display object\n * @event PIXI.InteractionManager#mouseover\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device (usually a mouse) is moved off the display object\n * @event PIXI.InteractionManager#mouseout\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button is pressed on the display object.\n * @event PIXI.InteractionManager#pointerdown\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button is released over the display object.\n * Not always fired when some buttons are held down while others are released. In those cases,\n * use [mousedown]{@link PIXI.InteractionManager#event:mousedown} and\n * [mouseup]{@link PIXI.InteractionManager#event:mouseup} instead.\n * @event PIXI.InteractionManager#pointerup\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when the operating system cancels a pointer event\n * @event PIXI.InteractionManager#pointercancel\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button is pressed and released on the display object.\n * @event PIXI.InteractionManager#pointertap\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button is released outside the display object that initially\n * registered a [pointerdown]{@link PIXI.InteractionManager#event:pointerdown}.\n * @event PIXI.InteractionManager#pointerupoutside\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device is moved while over the display object\n * @event PIXI.InteractionManager#pointermove\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device is moved onto the display object\n * @event PIXI.InteractionManager#pointerover\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device is moved off the display object\n * @event PIXI.InteractionManager#pointerout\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a touch point is placed on the display object.\n * @event PIXI.InteractionManager#touchstart\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a touch point is removed from the display object.\n * @event PIXI.InteractionManager#touchend\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when the operating system cancels a touch\n * @event PIXI.InteractionManager#touchcancel\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a touch point is placed and removed from the display object.\n * @event PIXI.InteractionManager#tap\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a touch point is removed outside of the display object that initially\n * registered a [touchstart]{@link PIXI.InteractionManager#event:touchstart}.\n * @event PIXI.InteractionManager#touchendoutside\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a touch point is moved along the display object.\n * @event PIXI.InteractionManager#touchmove\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button (usually a mouse left-button) is pressed on the display.\n * object. DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#mousedown\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device secondary button (usually a mouse right-button) is pressed\n * on the display object. DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#rightdown\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button (usually a mouse left-button) is released over the display\n * object. DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#mouseup\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device secondary button (usually a mouse right-button) is released\n * over the display object. DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#rightup\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button (usually a mouse left-button) is pressed and released on\n * the display object. DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#click\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device secondary button (usually a mouse right-button) is pressed\n * and released on the display object. DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#rightclick\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button (usually a mouse left-button) is released outside the\n * display object that initially registered a\n * [mousedown]{@link PIXI.DisplayObject#event:mousedown}.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#mouseupoutside\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device secondary button (usually a mouse right-button) is released\n * outside the display object that initially registered a\n * [rightdown]{@link PIXI.DisplayObject#event:rightdown}.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#rightupoutside\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device (usually a mouse) is moved while over the display object.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#mousemove\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device (usually a mouse) is moved onto the display object.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#mouseover\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device (usually a mouse) is moved off the display object.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#mouseout\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button is pressed on the display object.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#pointerdown\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button is released over the display object.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#pointerup\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when the operating system cancels a pointer event.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#pointercancel\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button is pressed and released on the display object.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#pointertap\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device button is released outside the display object that initially\n * registered a [pointerdown]{@link PIXI.DisplayObject#event:pointerdown}.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#pointerupoutside\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device is moved while over the display object.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#pointermove\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device is moved onto the display object.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#pointerover\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a pointer device is moved off the display object.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#pointerout\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a touch point is placed on the display object.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#touchstart\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a touch point is removed from the display object.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#touchend\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when the operating system cancels a touch.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#touchcancel\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a touch point is placed and removed from the display object.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#tap\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a touch point is removed outside of the display object that initially\n * registered a [touchstart]{@link PIXI.DisplayObject#event:touchstart}.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#touchendoutside\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n /**\n * Fired when a touch point is moved along the display object.\n * DisplayObject's `interactive` property must be set to `true` to fire event.\n *\n * This comes from the @pixi/interaction package.\n * @event PIXI.DisplayObject#touchmove\n * @param {PIXI.InteractionEvent} event - Interaction event\n */\n _this._useSystemTicker = options.useSystemTicker !== undefined ? options.useSystemTicker : true;\n _this.setTargetElement(_this.renderer.view, _this.renderer.resolution);\n return _this;\n }\n Object.defineProperty(InteractionManager.prototype, \"useSystemTicker\", {\n /**\n * Should the InteractionManager automatically add {@link tickerUpdate} to {@link PIXI.Ticker.system}.\n * @default true\n */\n get: function () {\n return this._useSystemTicker;\n },\n set: function (useSystemTicker) {\n this._useSystemTicker = useSystemTicker;\n if (useSystemTicker) {\n this.addTickerListener();\n }\n else {\n this.removeTickerListener();\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(InteractionManager.prototype, \"lastObjectRendered\", {\n /**\n * Last rendered object or temp object.\n * @readonly\n * @protected\n */\n get: function () {\n return this.renderer._lastObjectRendered || this._tempDisplayObject;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Hit tests a point against the display tree, returning the first interactive object that is hit.\n * @param globalPoint - A point to hit test with, in global space.\n * @param root - The root display object to start from. If omitted, defaults\n * to the last rendered root of the associated renderer.\n * @returns - The hit display object, if any.\n */\n InteractionManager.prototype.hitTest = function (globalPoint, root) {\n // clear the target for our hit test\n hitTestEvent.target = null;\n // assign the global point\n hitTestEvent.data.global = globalPoint;\n // ensure safety of the root\n if (!root) {\n root = this.lastObjectRendered;\n }\n // run the hit test\n this.processInteractive(hitTestEvent, root, null, true);\n // return our found object - it'll be null if we didn't hit anything\n return hitTestEvent.target;\n };\n /**\n * Sets the DOM element which will receive mouse/touch events. This is useful for when you have\n * other DOM elements on top of the renderers Canvas element. With this you'll be bale to delegate\n * another DOM element to receive those events.\n * @param element - the DOM element which will receive mouse and touch events.\n * @param resolution - The resolution / device pixel ratio of the new element (relative to the canvas).\n */\n InteractionManager.prototype.setTargetElement = function (element, resolution) {\n if (resolution === void 0) { resolution = 1; }\n this.removeTickerListener();\n this.removeEvents();\n this.interactionDOMElement = element;\n this.resolution = resolution;\n this.addEvents();\n this.addTickerListener();\n };\n /** Adds the ticker listener. */\n InteractionManager.prototype.addTickerListener = function () {\n if (this.tickerAdded || !this.interactionDOMElement || !this._useSystemTicker) {\n return;\n }\n Ticker.system.add(this.tickerUpdate, this, UPDATE_PRIORITY.INTERACTION);\n this.tickerAdded = true;\n };\n /** Removes the ticker listener. */\n InteractionManager.prototype.removeTickerListener = function () {\n if (!this.tickerAdded) {\n return;\n }\n Ticker.system.remove(this.tickerUpdate, this);\n this.tickerAdded = false;\n };\n /** Registers all the DOM events. */\n InteractionManager.prototype.addEvents = function () {\n if (this.eventsAdded || !this.interactionDOMElement) {\n return;\n }\n var style = this.interactionDOMElement.style;\n if (globalThis.navigator.msPointerEnabled) {\n style.msContentZooming = 'none';\n style.msTouchAction = 'none';\n }\n else if (this.supportsPointerEvents) {\n style.touchAction = 'none';\n }\n /*\n * These events are added first, so that if pointer events are normalized, they are fired\n * in the same order as non-normalized events. ie. pointer event 1st, mouse / touch 2nd\n */\n if (this.supportsPointerEvents) {\n globalThis.document.addEventListener('pointermove', this.onPointerMove, this._eventListenerOptions);\n this.interactionDOMElement.addEventListener('pointerdown', this.onPointerDown, this._eventListenerOptions);\n // pointerout is fired in addition to pointerup (for touch events) and pointercancel\n // we already handle those, so for the purposes of what we do in onPointerOut, we only\n // care about the pointerleave event\n this.interactionDOMElement.addEventListener('pointerleave', this.onPointerOut, this._eventListenerOptions);\n this.interactionDOMElement.addEventListener('pointerover', this.onPointerOver, this._eventListenerOptions);\n globalThis.addEventListener('pointercancel', this.onPointerCancel, this._eventListenerOptions);\n globalThis.addEventListener('pointerup', this.onPointerUp, this._eventListenerOptions);\n }\n else {\n globalThis.document.addEventListener('mousemove', this.onPointerMove, this._eventListenerOptions);\n this.interactionDOMElement.addEventListener('mousedown', this.onPointerDown, this._eventListenerOptions);\n this.interactionDOMElement.addEventListener('mouseout', this.onPointerOut, this._eventListenerOptions);\n this.interactionDOMElement.addEventListener('mouseover', this.onPointerOver, this._eventListenerOptions);\n globalThis.addEventListener('mouseup', this.onPointerUp, this._eventListenerOptions);\n }\n // always look directly for touch events so that we can provide original data\n // In a future version we should change this to being just a fallback and rely solely on\n // PointerEvents whenever available\n if (this.supportsTouchEvents) {\n this.interactionDOMElement.addEventListener('touchstart', this.onPointerDown, this._eventListenerOptions);\n this.interactionDOMElement.addEventListener('touchcancel', this.onPointerCancel, this._eventListenerOptions);\n this.interactionDOMElement.addEventListener('touchend', this.onPointerUp, this._eventListenerOptions);\n this.interactionDOMElement.addEventListener('touchmove', this.onPointerMove, this._eventListenerOptions);\n }\n this.eventsAdded = true;\n };\n /** Removes all the DOM events that were previously registered. */\n InteractionManager.prototype.removeEvents = function () {\n if (!this.eventsAdded || !this.interactionDOMElement) {\n return;\n }\n var style = this.interactionDOMElement.style;\n if (globalThis.navigator.msPointerEnabled) {\n style.msContentZooming = '';\n style.msTouchAction = '';\n }\n else if (this.supportsPointerEvents) {\n style.touchAction = '';\n }\n if (this.supportsPointerEvents) {\n globalThis.document.removeEventListener('pointermove', this.onPointerMove, this._eventListenerOptions);\n this.interactionDOMElement.removeEventListener('pointerdown', this.onPointerDown, this._eventListenerOptions);\n this.interactionDOMElement.removeEventListener('pointerleave', this.onPointerOut, this._eventListenerOptions);\n this.interactionDOMElement.removeEventListener('pointerover', this.onPointerOver, this._eventListenerOptions);\n globalThis.removeEventListener('pointercancel', this.onPointerCancel, this._eventListenerOptions);\n globalThis.removeEventListener('pointerup', this.onPointerUp, this._eventListenerOptions);\n }\n else {\n globalThis.document.removeEventListener('mousemove', this.onPointerMove, this._eventListenerOptions);\n this.interactionDOMElement.removeEventListener('mousedown', this.onPointerDown, this._eventListenerOptions);\n this.interactionDOMElement.removeEventListener('mouseout', this.onPointerOut, this._eventListenerOptions);\n this.interactionDOMElement.removeEventListener('mouseover', this.onPointerOver, this._eventListenerOptions);\n globalThis.removeEventListener('mouseup', this.onPointerUp, this._eventListenerOptions);\n }\n if (this.supportsTouchEvents) {\n this.interactionDOMElement.removeEventListener('touchstart', this.onPointerDown, this._eventListenerOptions);\n this.interactionDOMElement.removeEventListener('touchcancel', this.onPointerCancel, this._eventListenerOptions);\n this.interactionDOMElement.removeEventListener('touchend', this.onPointerUp, this._eventListenerOptions);\n this.interactionDOMElement.removeEventListener('touchmove', this.onPointerMove, this._eventListenerOptions);\n }\n this.interactionDOMElement = null;\n this.eventsAdded = false;\n };\n /**\n * Updates the state of interactive objects if at least {@link interactionFrequency}\n * milliseconds have passed since the last invocation.\n *\n * Invoked by a throttled ticker update from {@link PIXI.Ticker.system}.\n * @param deltaTime - time delta since the last call\n */\n InteractionManager.prototype.tickerUpdate = function (deltaTime) {\n this._deltaTime += deltaTime;\n if (this._deltaTime < this.interactionFrequency) {\n return;\n }\n this._deltaTime = 0;\n this.update();\n };\n /** Updates the state of interactive objects. */\n InteractionManager.prototype.update = function () {\n if (!this.interactionDOMElement) {\n return;\n }\n // if the user move the mouse this check has already been done using the mouse move!\n if (this._didMove) {\n this._didMove = false;\n return;\n }\n this.cursor = null;\n // Resets the flag as set by a stopPropagation call. This flag is usually reset by a user interaction of any kind,\n // but there was a scenario of a display object moving under a static mouse cursor.\n // In this case, mouseover and mouseevents would not pass the flag test in dispatchEvent function\n for (var k in this.activeInteractionData) {\n // eslint-disable-next-line no-prototype-builtins\n if (this.activeInteractionData.hasOwnProperty(k)) {\n var interactionData = this.activeInteractionData[k];\n if (interactionData.originalEvent && interactionData.pointerType !== 'touch') {\n var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, interactionData.originalEvent, interactionData);\n this.processInteractive(interactionEvent, this.lastObjectRendered, this.processPointerOverOut, true);\n }\n }\n }\n this.setCursorMode(this.cursor);\n };\n /**\n * Sets the current cursor mode, handling any callbacks or CSS style changes.\n * @param mode - cursor mode, a key from the cursorStyles dictionary\n */\n InteractionManager.prototype.setCursorMode = function (mode) {\n mode = mode || 'default';\n var applyStyles = true;\n // offscreen canvas does not support setting styles, but cursor modes can be functions,\n // in order to handle pixi rendered cursors, so we can't bail\n if (globalThis.OffscreenCanvas && this.interactionDOMElement instanceof OffscreenCanvas) {\n applyStyles = false;\n }\n // if the mode didn't actually change, bail early\n if (this.currentCursorMode === mode) {\n return;\n }\n this.currentCursorMode = mode;\n var style = this.cursorStyles[mode];\n // only do things if there is a cursor style for it\n if (style) {\n switch (typeof style) {\n case 'string':\n // string styles are handled as cursor CSS\n if (applyStyles) {\n this.interactionDOMElement.style.cursor = style;\n }\n break;\n case 'function':\n // functions are just called, and passed the cursor mode\n style(mode);\n break;\n case 'object':\n // if it is an object, assume that it is a dictionary of CSS styles,\n // apply it to the interactionDOMElement\n if (applyStyles) {\n Object.assign(this.interactionDOMElement.style, style);\n }\n break;\n }\n }\n else if (applyStyles && typeof mode === 'string' && !Object.prototype.hasOwnProperty.call(this.cursorStyles, mode)) {\n // if it mode is a string (not a Symbol) and cursorStyles doesn't have any entry\n // for the mode, then assume that the dev wants it to be CSS for the cursor.\n this.interactionDOMElement.style.cursor = mode;\n }\n };\n /**\n * Dispatches an event on the display object that was interacted with.\n * @param displayObject - the display object in question\n * @param eventString - the name of the event (e.g, mousedown)\n * @param eventData - the event data object\n */\n InteractionManager.prototype.dispatchEvent = function (displayObject, eventString, eventData) {\n // Even if the event was stopped, at least dispatch any remaining events\n // for the same display object.\n if (!eventData.stopPropagationHint || displayObject === eventData.stopsPropagatingAt) {\n eventData.currentTarget = displayObject;\n eventData.type = eventString;\n displayObject.emit(eventString, eventData);\n if (displayObject[eventString]) {\n displayObject[eventString](eventData);\n }\n }\n };\n /**\n * Puts a event on a queue to be dispatched later. This is used to guarantee correct\n * ordering of over/out events.\n * @param displayObject - the display object in question\n * @param eventString - the name of the event (e.g, mousedown)\n * @param eventData - the event data object\n */\n InteractionManager.prototype.delayDispatchEvent = function (displayObject, eventString, eventData) {\n this.delayedEvents.push({ displayObject: displayObject, eventString: eventString, eventData: eventData });\n };\n /**\n * Maps x and y coords from a DOM object and maps them correctly to the PixiJS view. The\n * resulting value is stored in the point. This takes into account the fact that the DOM\n * element could be scaled and positioned anywhere on the screen.\n * @param point - the point that the result will be stored in\n * @param x - the x coord of the position to map\n * @param y - the y coord of the position to map\n */\n InteractionManager.prototype.mapPositionToPoint = function (point, x, y) {\n var rect;\n // IE 11 fix\n if (!this.interactionDOMElement.parentElement) {\n rect = {\n x: 0,\n y: 0,\n width: this.interactionDOMElement.width,\n height: this.interactionDOMElement.height,\n left: 0,\n top: 0\n };\n }\n else {\n rect = this.interactionDOMElement.getBoundingClientRect();\n }\n var resolutionMultiplier = 1.0 / this.resolution;\n point.x = ((x - rect.left) * (this.interactionDOMElement.width / rect.width)) * resolutionMultiplier;\n point.y = ((y - rect.top) * (this.interactionDOMElement.height / rect.height)) * resolutionMultiplier;\n };\n /**\n * This function is provides a neat way of crawling through the scene graph and running a\n * specified function on all interactive objects it finds. It will also take care of hit\n * testing the interactive objects and passes the hit across in the function.\n * @protected\n * @param interactionEvent - event containing the point that\n * is tested for collision\n * @param displayObject - the displayObject\n * that will be hit test (recursively crawls its children)\n * @param func - the function that will be called on each interactive object. The\n * interactionEvent, displayObject and hit will be passed to the function\n * @param hitTest - indicates whether we want to calculate hits\n * or just iterate through all interactive objects\n */\n InteractionManager.prototype.processInteractive = function (interactionEvent, displayObject, func, hitTest) {\n var hit = this.search.findHit(interactionEvent, displayObject, func, hitTest);\n var delayedEvents = this.delayedEvents;\n if (!delayedEvents.length) {\n return hit;\n }\n // Reset the propagation hint, because we start deeper in the tree again.\n interactionEvent.stopPropagationHint = false;\n var delayedLen = delayedEvents.length;\n this.delayedEvents = [];\n for (var i = 0; i < delayedLen; i++) {\n var _a = delayedEvents[i], displayObject_1 = _a.displayObject, eventString = _a.eventString, eventData = _a.eventData;\n // When we reach the object we wanted to stop propagating at,\n // set the propagation hint.\n if (eventData.stopsPropagatingAt === displayObject_1) {\n eventData.stopPropagationHint = true;\n }\n this.dispatchEvent(displayObject_1, eventString, eventData);\n }\n return hit;\n };\n /**\n * Is called when the pointer button is pressed down on the renderer element\n * @param originalEvent - The DOM event of a pointer button being pressed down\n */\n InteractionManager.prototype.onPointerDown = function (originalEvent) {\n // if we support touch events, then only use those for touch events, not pointer events\n if (this.supportsTouchEvents && originalEvent.pointerType === 'touch')\n { return; }\n var events = this.normalizeToPointerData(originalEvent);\n /*\n * No need to prevent default on natural pointer events, as there are no side effects\n * Normalized events, however, may have the double mousedown/touchstart issue on the native android browser,\n * so still need to be prevented.\n */\n // Guaranteed that there will be at least one event in events, and all events must have the same pointer type\n if (this.autoPreventDefault && events[0].isNormalized) {\n var cancelable = originalEvent.cancelable || !('cancelable' in originalEvent);\n if (cancelable) {\n originalEvent.preventDefault();\n }\n }\n var eventLen = events.length;\n for (var i = 0; i < eventLen; i++) {\n var event = events[i];\n var interactionData = this.getInteractionDataForPointerId(event);\n var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);\n interactionEvent.data.originalEvent = originalEvent;\n this.processInteractive(interactionEvent, this.lastObjectRendered, this.processPointerDown, true);\n this.emit('pointerdown', interactionEvent);\n if (event.pointerType === 'touch') {\n this.emit('touchstart', interactionEvent);\n }\n // emit a mouse event for \"pen\" pointers, the way a browser would emit a fallback event\n else if (event.pointerType === 'mouse' || event.pointerType === 'pen') {\n var isRightButton = event.button === 2;\n this.emit(isRightButton ? 'rightdown' : 'mousedown', this.eventData);\n }\n }\n };\n /**\n * Processes the result of the pointer down check and dispatches the event if need be\n * @param interactionEvent - The interaction event wrapping the DOM event\n * @param displayObject - The display object that was tested\n * @param hit - the result of the hit test on the display object\n */\n InteractionManager.prototype.processPointerDown = function (interactionEvent, displayObject, hit) {\n var data = interactionEvent.data;\n var id = interactionEvent.data.identifier;\n if (hit) {\n if (!displayObject.trackedPointers[id]) {\n displayObject.trackedPointers[id] = new InteractionTrackingData(id);\n }\n this.dispatchEvent(displayObject, 'pointerdown', interactionEvent);\n if (data.pointerType === 'touch') {\n this.dispatchEvent(displayObject, 'touchstart', interactionEvent);\n }\n else if (data.pointerType === 'mouse' || data.pointerType === 'pen') {\n var isRightButton = data.button === 2;\n if (isRightButton) {\n displayObject.trackedPointers[id].rightDown = true;\n }\n else {\n displayObject.trackedPointers[id].leftDown = true;\n }\n this.dispatchEvent(displayObject, isRightButton ? 'rightdown' : 'mousedown', interactionEvent);\n }\n }\n };\n /**\n * Is called when the pointer button is released on the renderer element\n * @param originalEvent - The DOM event of a pointer button being released\n * @param cancelled - true if the pointer is cancelled\n * @param func - Function passed to {@link processInteractive}\n */\n InteractionManager.prototype.onPointerComplete = function (originalEvent, cancelled, func) {\n var events = this.normalizeToPointerData(originalEvent);\n var eventLen = events.length;\n // if the event wasn't targeting our canvas, then consider it to be pointerupoutside\n // in all cases (unless it was a pointercancel)\n var target = originalEvent.target;\n // if in shadow DOM use composedPath to access target\n if (originalEvent.composedPath && originalEvent.composedPath().length > 0) {\n target = originalEvent.composedPath()[0];\n }\n var eventAppend = target !== this.interactionDOMElement ? 'outside' : '';\n for (var i = 0; i < eventLen; i++) {\n var event = events[i];\n var interactionData = this.getInteractionDataForPointerId(event);\n var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);\n interactionEvent.data.originalEvent = originalEvent;\n // perform hit testing for events targeting our canvas or cancel events\n this.processInteractive(interactionEvent, this.lastObjectRendered, func, cancelled || !eventAppend);\n this.emit(cancelled ? 'pointercancel' : \"pointerup\" + eventAppend, interactionEvent);\n if (event.pointerType === 'mouse' || event.pointerType === 'pen') {\n var isRightButton = event.button === 2;\n this.emit(isRightButton ? \"rightup\" + eventAppend : \"mouseup\" + eventAppend, interactionEvent);\n }\n else if (event.pointerType === 'touch') {\n this.emit(cancelled ? 'touchcancel' : \"touchend\" + eventAppend, interactionEvent);\n this.releaseInteractionDataForPointerId(event.pointerId);\n }\n }\n };\n /**\n * Is called when the pointer button is cancelled\n * @param event - The DOM event of a pointer button being released\n */\n InteractionManager.prototype.onPointerCancel = function (event) {\n // if we support touch events, then only use those for touch events, not pointer events\n if (this.supportsTouchEvents && event.pointerType === 'touch')\n { return; }\n this.onPointerComplete(event, true, this.processPointerCancel);\n };\n /**\n * Processes the result of the pointer cancel check and dispatches the event if need be\n * @param interactionEvent - The interaction event wrapping the DOM event\n * @param displayObject - The display object that was tested\n */\n InteractionManager.prototype.processPointerCancel = function (interactionEvent, displayObject) {\n var data = interactionEvent.data;\n var id = interactionEvent.data.identifier;\n if (displayObject.trackedPointers[id] !== undefined) {\n delete displayObject.trackedPointers[id];\n this.dispatchEvent(displayObject, 'pointercancel', interactionEvent);\n if (data.pointerType === 'touch') {\n this.dispatchEvent(displayObject, 'touchcancel', interactionEvent);\n }\n }\n };\n /**\n * Is called when the pointer button is released on the renderer element\n * @param event - The DOM event of a pointer button being released\n */\n InteractionManager.prototype.onPointerUp = function (event) {\n // if we support touch events, then only use those for touch events, not pointer events\n if (this.supportsTouchEvents && event.pointerType === 'touch')\n { return; }\n this.onPointerComplete(event, false, this.processPointerUp);\n };\n /**\n * Processes the result of the pointer up check and dispatches the event if need be\n * @param interactionEvent - The interaction event wrapping the DOM event\n * @param displayObject - The display object that was tested\n * @param hit - the result of the hit test on the display object\n */\n InteractionManager.prototype.processPointerUp = function (interactionEvent, displayObject, hit) {\n var data = interactionEvent.data;\n var id = interactionEvent.data.identifier;\n var trackingData = displayObject.trackedPointers[id];\n var isTouch = data.pointerType === 'touch';\n var isMouse = (data.pointerType === 'mouse' || data.pointerType === 'pen');\n // need to track mouse down status in the mouse block so that we can emit\n // event in a later block\n var isMouseTap = false;\n // Mouse only\n if (isMouse) {\n var isRightButton = data.button === 2;\n var flags = InteractionTrackingData.FLAGS;\n var test = isRightButton ? flags.RIGHT_DOWN : flags.LEFT_DOWN;\n var isDown = trackingData !== undefined && (trackingData.flags & test);\n if (hit) {\n this.dispatchEvent(displayObject, isRightButton ? 'rightup' : 'mouseup', interactionEvent);\n if (isDown) {\n this.dispatchEvent(displayObject, isRightButton ? 'rightclick' : 'click', interactionEvent);\n // because we can confirm that the mousedown happened on this object, flag for later emit of pointertap\n isMouseTap = true;\n }\n }\n else if (isDown) {\n this.dispatchEvent(displayObject, isRightButton ? 'rightupoutside' : 'mouseupoutside', interactionEvent);\n }\n // update the down state of the tracking data\n if (trackingData) {\n if (isRightButton) {\n trackingData.rightDown = false;\n }\n else {\n trackingData.leftDown = false;\n }\n }\n }\n // Pointers and Touches, and Mouse\n if (hit) {\n this.dispatchEvent(displayObject, 'pointerup', interactionEvent);\n if (isTouch)\n { this.dispatchEvent(displayObject, 'touchend', interactionEvent); }\n if (trackingData) {\n // emit pointertap if not a mouse, or if the mouse block decided it was a tap\n if (!isMouse || isMouseTap) {\n this.dispatchEvent(displayObject, 'pointertap', interactionEvent);\n }\n if (isTouch) {\n this.dispatchEvent(displayObject, 'tap', interactionEvent);\n // touches are no longer over (if they ever were) when we get the touchend\n // so we should ensure that we don't keep pretending that they are\n trackingData.over = false;\n }\n }\n }\n else if (trackingData) {\n this.dispatchEvent(displayObject, 'pointerupoutside', interactionEvent);\n if (isTouch)\n { this.dispatchEvent(displayObject, 'touchendoutside', interactionEvent); }\n }\n // Only remove the tracking data if there is no over/down state still associated with it\n if (trackingData && trackingData.none) {\n delete displayObject.trackedPointers[id];\n }\n };\n /**\n * Is called when the pointer moves across the renderer element\n * @param originalEvent - The DOM event of a pointer moving\n */\n InteractionManager.prototype.onPointerMove = function (originalEvent) {\n // if we support touch events, then only use those for touch events, not pointer events\n if (this.supportsTouchEvents && originalEvent.pointerType === 'touch')\n { return; }\n var events = this.normalizeToPointerData(originalEvent);\n if (events[0].pointerType === 'mouse' || events[0].pointerType === 'pen') {\n this._didMove = true;\n this.cursor = null;\n }\n var eventLen = events.length;\n for (var i = 0; i < eventLen; i++) {\n var event = events[i];\n var interactionData = this.getInteractionDataForPointerId(event);\n var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);\n interactionEvent.data.originalEvent = originalEvent;\n this.processInteractive(interactionEvent, this.lastObjectRendered, this.processPointerMove, true);\n this.emit('pointermove', interactionEvent);\n if (event.pointerType === 'touch')\n { this.emit('touchmove', interactionEvent); }\n if (event.pointerType === 'mouse' || event.pointerType === 'pen')\n { this.emit('mousemove', interactionEvent); }\n }\n if (events[0].pointerType === 'mouse') {\n this.setCursorMode(this.cursor);\n // TODO BUG for parents interactive object (border order issue)\n }\n };\n /**\n * Processes the result of the pointer move check and dispatches the event if need be\n * @param interactionEvent - The interaction event wrapping the DOM event\n * @param displayObject - The display object that was tested\n * @param hit - the result of the hit test on the display object\n */\n InteractionManager.prototype.processPointerMove = function (interactionEvent, displayObject, hit) {\n var data = interactionEvent.data;\n var isTouch = data.pointerType === 'touch';\n var isMouse = (data.pointerType === 'mouse' || data.pointerType === 'pen');\n if (isMouse) {\n this.processPointerOverOut(interactionEvent, displayObject, hit);\n }\n if (!this.moveWhenInside || hit) {\n this.dispatchEvent(displayObject, 'pointermove', interactionEvent);\n if (isTouch)\n { this.dispatchEvent(displayObject, 'touchmove', interactionEvent); }\n if (isMouse)\n { this.dispatchEvent(displayObject, 'mousemove', interactionEvent); }\n }\n };\n /**\n * Is called when the pointer is moved out of the renderer element\n * @private\n * @param {PointerEvent} originalEvent - The DOM event of a pointer being moved out\n */\n InteractionManager.prototype.onPointerOut = function (originalEvent) {\n // if we support touch events, then only use those for touch events, not pointer events\n if (this.supportsTouchEvents && originalEvent.pointerType === 'touch')\n { return; }\n var events = this.normalizeToPointerData(originalEvent);\n // Only mouse and pointer can call onPointerOut, so events will always be length 1\n var event = events[0];\n if (event.pointerType === 'mouse') {\n this.mouseOverRenderer = false;\n this.setCursorMode(null);\n }\n var interactionData = this.getInteractionDataForPointerId(event);\n var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);\n interactionEvent.data.originalEvent = event;\n this.processInteractive(interactionEvent, this.lastObjectRendered, this.processPointerOverOut, false);\n this.emit('pointerout', interactionEvent);\n if (event.pointerType === 'mouse' || event.pointerType === 'pen') {\n this.emit('mouseout', interactionEvent);\n }\n else {\n // we can get touchleave events after touchend, so we want to make sure we don't\n // introduce memory leaks\n this.releaseInteractionDataForPointerId(interactionData.identifier);\n }\n };\n /**\n * Processes the result of the pointer over/out check and dispatches the event if need be.\n * @param interactionEvent - The interaction event wrapping the DOM event\n * @param displayObject - The display object that was tested\n * @param hit - the result of the hit test on the display object\n */\n InteractionManager.prototype.processPointerOverOut = function (interactionEvent, displayObject, hit) {\n var data = interactionEvent.data;\n var id = interactionEvent.data.identifier;\n var isMouse = (data.pointerType === 'mouse' || data.pointerType === 'pen');\n var trackingData = displayObject.trackedPointers[id];\n // if we just moused over the display object, then we need to track that state\n if (hit && !trackingData) {\n trackingData = displayObject.trackedPointers[id] = new InteractionTrackingData(id);\n }\n if (trackingData === undefined)\n { return; }\n if (hit && this.mouseOverRenderer) {\n if (!trackingData.over) {\n trackingData.over = true;\n this.delayDispatchEvent(displayObject, 'pointerover', interactionEvent);\n if (isMouse) {\n this.delayDispatchEvent(displayObject, 'mouseover', interactionEvent);\n }\n }\n // only change the cursor if it has not already been changed (by something deeper in the\n // display tree)\n if (isMouse && this.cursor === null) {\n this.cursor = displayObject.cursor;\n }\n }\n else if (trackingData.over) {\n trackingData.over = false;\n this.dispatchEvent(displayObject, 'pointerout', this.eventData);\n if (isMouse) {\n this.dispatchEvent(displayObject, 'mouseout', interactionEvent);\n }\n // if there is no mouse down information for the pointer, then it is safe to delete\n if (trackingData.none) {\n delete displayObject.trackedPointers[id];\n }\n }\n };\n /**\n * Is called when the pointer is moved into the renderer element.\n * @param originalEvent - The DOM event of a pointer button being moved into the renderer view.\n */\n InteractionManager.prototype.onPointerOver = function (originalEvent) {\n if (this.supportsTouchEvents && originalEvent.pointerType === 'touch')\n { return; }\n var events = this.normalizeToPointerData(originalEvent);\n // Only mouse and pointer can call onPointerOver, so events will always be length 1\n var event = events[0];\n var interactionData = this.getInteractionDataForPointerId(event);\n var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);\n interactionEvent.data.originalEvent = event;\n if (event.pointerType === 'mouse') {\n this.mouseOverRenderer = true;\n }\n this.emit('pointerover', interactionEvent);\n if (event.pointerType === 'mouse' || event.pointerType === 'pen') {\n this.emit('mouseover', interactionEvent);\n }\n };\n /**\n * Get InteractionData for a given pointerId. Store that data as well.\n * @param event - Normalized pointer event, output from normalizeToPointerData.\n * @returns - Interaction data for the given pointer identifier.\n */\n InteractionManager.prototype.getInteractionDataForPointerId = function (event) {\n var pointerId = event.pointerId;\n var interactionData;\n if (pointerId === MOUSE_POINTER_ID || event.pointerType === 'mouse') {\n interactionData = this.mouse;\n }\n else if (this.activeInteractionData[pointerId]) {\n interactionData = this.activeInteractionData[pointerId];\n }\n else {\n interactionData = this.interactionDataPool.pop() || new InteractionData();\n interactionData.identifier = pointerId;\n this.activeInteractionData[pointerId] = interactionData;\n }\n // copy properties from the event, so that we can make sure that touch/pointer specific\n // data is available\n interactionData.copyEvent(event);\n return interactionData;\n };\n /**\n * Return unused InteractionData to the pool, for a given pointerId\n * @param pointerId - Identifier from a pointer event\n */\n InteractionManager.prototype.releaseInteractionDataForPointerId = function (pointerId) {\n var interactionData = this.activeInteractionData[pointerId];\n if (interactionData) {\n delete this.activeInteractionData[pointerId];\n interactionData.reset();\n this.interactionDataPool.push(interactionData);\n }\n };\n /**\n * Configure an InteractionEvent to wrap a DOM PointerEvent and InteractionData\n * @param interactionEvent - The event to be configured\n * @param pointerEvent - The DOM event that will be paired with the InteractionEvent\n * @param interactionData - The InteractionData that will be paired\n * with the InteractionEvent\n * @returns - the interaction event that was passed in\n */\n InteractionManager.prototype.configureInteractionEventForDOMEvent = function (interactionEvent, pointerEvent, interactionData) {\n interactionEvent.data = interactionData;\n this.mapPositionToPoint(interactionData.global, pointerEvent.clientX, pointerEvent.clientY);\n // Not really sure why this is happening, but it's how a previous version handled things\n if (pointerEvent.pointerType === 'touch') {\n pointerEvent.globalX = interactionData.global.x;\n pointerEvent.globalY = interactionData.global.y;\n }\n interactionData.originalEvent = pointerEvent;\n interactionEvent.reset();\n return interactionEvent;\n };\n /**\n * Ensures that the original event object contains all data that a regular pointer event would have\n * @param {TouchEvent|MouseEvent|PointerEvent} event - The original event data from a touch or mouse event\n * @returns - An array containing a single normalized pointer event, in the case of a pointer\n * or mouse event, or a multiple normalized pointer events if there are multiple changed touches\n */\n InteractionManager.prototype.normalizeToPointerData = function (event) {\n var normalizedEvents = [];\n if (this.supportsTouchEvents && event instanceof TouchEvent) {\n for (var i = 0, li = event.changedTouches.length; i < li; i++) {\n var touch = event.changedTouches[i];\n if (typeof touch.button === 'undefined')\n { touch.button = event.touches.length ? 1 : 0; }\n if (typeof touch.buttons === 'undefined')\n { touch.buttons = event.touches.length ? 1 : 0; }\n if (typeof touch.isPrimary === 'undefined') {\n touch.isPrimary = event.touches.length === 1 && event.type === 'touchstart';\n }\n if (typeof touch.width === 'undefined')\n { touch.width = touch.radiusX || 1; }\n if (typeof touch.height === 'undefined')\n { touch.height = touch.radiusY || 1; }\n if (typeof touch.tiltX === 'undefined')\n { touch.tiltX = 0; }\n if (typeof touch.tiltY === 'undefined')\n { touch.tiltY = 0; }\n if (typeof touch.pointerType === 'undefined')\n { touch.pointerType = 'touch'; }\n if (typeof touch.pointerId === 'undefined')\n { touch.pointerId = touch.identifier || 0; }\n if (typeof touch.pressure === 'undefined')\n { touch.pressure = touch.force || 0.5; }\n if (typeof touch.twist === 'undefined')\n { touch.twist = 0; }\n if (typeof touch.tangentialPressure === 'undefined')\n { touch.tangentialPressure = 0; }\n // TODO: Remove these, as layerX/Y is not a standard, is deprecated, has uneven\n // support, and the fill ins are not quite the same\n // offsetX/Y might be okay, but is not the same as clientX/Y when the canvas's top\n // left is not 0,0 on the page\n if (typeof touch.layerX === 'undefined')\n { touch.layerX = touch.offsetX = touch.clientX; }\n if (typeof touch.layerY === 'undefined')\n { touch.layerY = touch.offsetY = touch.clientY; }\n // mark the touch as normalized, just so that we know we did it\n touch.isNormalized = true;\n normalizedEvents.push(touch);\n }\n }\n // apparently PointerEvent subclasses MouseEvent, so yay\n else if (!globalThis.MouseEvent\n || (event instanceof MouseEvent && (!this.supportsPointerEvents || !(event instanceof globalThis.PointerEvent)))) {\n var tempEvent = event;\n if (typeof tempEvent.isPrimary === 'undefined')\n { tempEvent.isPrimary = true; }\n if (typeof tempEvent.width === 'undefined')\n { tempEvent.width = 1; }\n if (typeof tempEvent.height === 'undefined')\n { tempEvent.height = 1; }\n if (typeof tempEvent.tiltX === 'undefined')\n { tempEvent.tiltX = 0; }\n if (typeof tempEvent.tiltY === 'undefined')\n { tempEvent.tiltY = 0; }\n if (typeof tempEvent.pointerType === 'undefined')\n { tempEvent.pointerType = 'mouse'; }\n if (typeof tempEvent.pointerId === 'undefined')\n { tempEvent.pointerId = MOUSE_POINTER_ID; }\n if (typeof tempEvent.pressure === 'undefined')\n { tempEvent.pressure = 0.5; }\n if (typeof tempEvent.twist === 'undefined')\n { tempEvent.twist = 0; }\n if (typeof tempEvent.tangentialPressure === 'undefined')\n { tempEvent.tangentialPressure = 0; }\n // mark the mouse event as normalized, just so that we know we did it\n tempEvent.isNormalized = true;\n normalizedEvents.push(tempEvent);\n }\n else {\n normalizedEvents.push(event);\n }\n return normalizedEvents;\n };\n /** Destroys the interaction manager. */\n InteractionManager.prototype.destroy = function () {\n this.removeEvents();\n this.removeTickerListener();\n this.removeAllListeners();\n this.renderer = null;\n this.mouse = null;\n this.eventData = null;\n this.interactionDOMElement = null;\n this.onPointerDown = null;\n this.processPointerDown = null;\n this.onPointerUp = null;\n this.processPointerUp = null;\n this.onPointerCancel = null;\n this.processPointerCancel = null;\n this.onPointerMove = null;\n this.processPointerMove = null;\n this.onPointerOut = null;\n this.processPointerOverOut = null;\n this.onPointerOver = null;\n this.search = null;\n };\n /** @ignore */\n InteractionManager.extension = {\n name: 'interaction',\n type: [\n ExtensionType.RendererPlugin,\n ExtensionType.CanvasRendererPlugin ],\n };\n return InteractionManager;\n}(EventEmitter));\n\nexport { InteractionData, InteractionEvent, InteractionManager, InteractionTrackingData, interactiveTarget };\n//# sourceMappingURL=interaction.mjs.map\n","/*!\n * @pixi/extract - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/extract is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { MSAA_QUALITY } from '@pixi/constants';\nimport { CanvasRenderTarget } from '@pixi/utils';\nimport { Rectangle } from '@pixi/math';\nimport { ExtensionType, RenderTexture } from '@pixi/core';\n\nvar TEMP_RECT = new Rectangle();\nvar BYTES_PER_PIXEL = 4;\n/**\n * This class provides renderer-specific plugins for exporting content from a renderer.\n * For instance, these plugins can be used for saving an Image, Canvas element or for exporting the raw image data (pixels).\n *\n * Do not instantiate these plugins directly. It is available from the `renderer.plugins` property.\n * See {@link PIXI.CanvasRenderer#plugins} or {@link PIXI.Renderer#plugins}.\n * @example\n * // Create a new app (will auto-add extract plugin to renderer)\n * const app = new PIXI.Application();\n *\n * // Draw a red circle\n * const graphics = new PIXI.Graphics()\n * .beginFill(0xFF0000)\n * .drawCircle(0, 0, 50);\n *\n * // Render the graphics as an HTMLImageElement\n * const image = app.renderer.plugins.extract.image(graphics);\n * document.body.appendChild(image);\n * @memberof PIXI\n */\nvar Extract = /** @class */ (function () {\n /**\n * @param renderer - A reference to the current renderer\n */\n function Extract(renderer) {\n this.renderer = renderer;\n }\n /**\n * Will return a HTML Image of the target\n * @param target - A displayObject or renderTexture\n * to convert. If left empty will use the main renderer\n * @param format - Image format, e.g. \"image/jpeg\" or \"image/webp\".\n * @param quality - JPEG or Webp compression from 0 to 1. Default is 0.92.\n * @returns - HTML Image of the target\n */\n Extract.prototype.image = function (target, format, quality) {\n var image = new Image();\n image.src = this.base64(target, format, quality);\n return image;\n };\n /**\n * Will return a base64 encoded string of this target. It works by calling\n * `Extract.getCanvas` and then running toDataURL on that.\n * @param target - A displayObject or renderTexture\n * to convert. If left empty will use the main renderer\n * @param format - Image format, e.g. \"image/jpeg\" or \"image/webp\".\n * @param quality - JPEG or Webp compression from 0 to 1. Default is 0.92.\n * @returns - A base64 encoded string of the texture.\n */\n Extract.prototype.base64 = function (target, format, quality) {\n return this.canvas(target).toDataURL(format, quality);\n };\n /**\n * Creates a Canvas element, renders this target to it and then returns it.\n * @param target - A displayObject or renderTexture\n * to convert. If left empty will use the main renderer\n * @param frame - The frame the extraction is restricted to.\n * @returns - A Canvas element with the texture rendered on.\n */\n Extract.prototype.canvas = function (target, frame) {\n var _a = this._rawPixels(target, frame), pixels = _a.pixels, width = _a.width, height = _a.height, flipY = _a.flipY;\n var canvasBuffer = new CanvasRenderTarget(width, height, 1);\n // Add the pixels to the canvas\n var canvasData = canvasBuffer.context.getImageData(0, 0, width, height);\n Extract.arrayPostDivide(pixels, canvasData.data);\n canvasBuffer.context.putImageData(canvasData, 0, 0);\n // Flipping pixels\n if (flipY) {\n var target_1 = new CanvasRenderTarget(canvasBuffer.width, canvasBuffer.height, 1);\n target_1.context.scale(1, -1);\n // We can't render to itself because we should be empty before render.\n target_1.context.drawImage(canvasBuffer.canvas, 0, -height);\n canvasBuffer.destroy();\n canvasBuffer = target_1;\n }\n // Send the canvas back\n return canvasBuffer.canvas;\n };\n /**\n * Will return a one-dimensional array containing the pixel data of the entire texture in RGBA\n * order, with integer values between 0 and 255 (included).\n * @param target - A displayObject or renderTexture\n * to convert. If left empty will use the main renderer\n * @param frame - The frame the extraction is restricted to.\n * @returns - One-dimensional array containing the pixel data of the entire texture\n */\n Extract.prototype.pixels = function (target, frame) {\n var pixels = this._rawPixels(target, frame).pixels;\n Extract.arrayPostDivide(pixels, pixels);\n return pixels;\n };\n Extract.prototype._rawPixels = function (target, frame) {\n var renderer = this.renderer;\n var resolution;\n var flipY = false;\n var renderTexture;\n var generated = false;\n if (target) {\n if (target instanceof RenderTexture) {\n renderTexture = target;\n }\n else {\n var multisample = renderer.context.webGLVersion >= 2 ? renderer.multisample : MSAA_QUALITY.NONE;\n renderTexture = this.renderer.generateTexture(target, { multisample: multisample });\n if (multisample !== MSAA_QUALITY.NONE) {\n // Resolve the multisampled texture to a non-multisampled texture\n var resolvedTexture = RenderTexture.create({\n width: renderTexture.width,\n height: renderTexture.height,\n });\n renderer.framebuffer.bind(renderTexture.framebuffer);\n renderer.framebuffer.blit(resolvedTexture.framebuffer);\n renderer.framebuffer.bind(null);\n renderTexture.destroy(true);\n renderTexture = resolvedTexture;\n }\n generated = true;\n }\n }\n if (renderTexture) {\n resolution = renderTexture.baseTexture.resolution;\n frame = frame !== null && frame !== void 0 ? frame : renderTexture.frame;\n flipY = false;\n renderer.renderTexture.bind(renderTexture);\n }\n else {\n resolution = renderer.resolution;\n if (!frame) {\n frame = TEMP_RECT;\n frame.width = renderer.width;\n frame.height = renderer.height;\n }\n flipY = true;\n renderer.renderTexture.bind(null);\n }\n var width = Math.round(frame.width * resolution);\n var height = Math.round(frame.height * resolution);\n var pixels = new Uint8Array(BYTES_PER_PIXEL * width * height);\n // Read pixels to the array\n var gl = renderer.gl;\n gl.readPixels(Math.round(frame.x * resolution), Math.round(frame.y * resolution), width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);\n if (generated) {\n renderTexture.destroy(true);\n }\n return { pixels: pixels, width: width, height: height, flipY: flipY };\n };\n /** Destroys the extract. */\n Extract.prototype.destroy = function () {\n this.renderer = null;\n };\n /**\n * Takes premultiplied pixel data and produces regular pixel data\n * @private\n * @param pixels - array of pixel data\n * @param out - output array\n */\n Extract.arrayPostDivide = function (pixels, out) {\n for (var i = 0; i < pixels.length; i += 4) {\n var alpha = out[i + 3] = pixels[i + 3];\n if (alpha !== 0) {\n out[i] = Math.round(Math.min(pixels[i] * 255.0 / alpha, 255.0));\n out[i + 1] = Math.round(Math.min(pixels[i + 1] * 255.0 / alpha, 255.0));\n out[i + 2] = Math.round(Math.min(pixels[i + 2] * 255.0 / alpha, 255.0));\n }\n else {\n out[i] = pixels[i];\n out[i + 1] = pixels[i + 1];\n out[i + 2] = pixels[i + 2];\n }\n }\n };\n /** @ignore */\n Extract.extension = {\n name: 'extract',\n type: ExtensionType.RendererPlugin,\n };\n return Extract;\n}());\n\nexport { Extract };\n//# sourceMappingURL=extract.mjs.map\n","/*!\n * @pixi/loaders - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/loaders is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { extensions, ExtensionType, Texture } from '@pixi/core';\nimport { deprecation } from '@pixi/utils';\n\n/* jshint -W097 */\n/**\n * @memberof PIXI\n */\nvar SignalBinding = /** @class */ (function () {\n /**\n * SignalBinding constructor.\n * @constructs SignalBinding\n * @param {Function} fn - Event handler to be called.\n * @param {boolean} [once=false] - Should this listener be removed after dispatch\n * @param {object} [thisArg] - The context of the callback function.\n * @api private\n */\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n function SignalBinding(fn, once, thisArg) {\n if (once === void 0) { once = false; }\n this._fn = fn;\n this._once = once;\n this._thisArg = thisArg;\n this._next = this._prev = this._owner = null;\n }\n SignalBinding.prototype.detach = function () {\n if (this._owner === null)\n { return false; }\n this._owner.detach(this);\n return true;\n };\n return SignalBinding;\n}());\n/**\n * @param self\n * @param node\n * @private\n */\nfunction _addSignalBinding(self, node) {\n if (!self._head) {\n self._head = node;\n self._tail = node;\n }\n else {\n self._tail._next = node;\n node._prev = self._tail;\n self._tail = node;\n }\n node._owner = self;\n return node;\n}\n/**\n * @memberof PIXI\n */\nvar Signal = /** @class */ (function () {\n /**\n * MiniSignal constructor.\n * @example\n * let mySignal = new Signal();\n * let binding = mySignal.add(onSignal);\n * mySignal.dispatch('foo', 'bar');\n * mySignal.detach(binding);\n */\n function Signal() {\n this._head = this._tail = undefined;\n }\n /**\n * Return an array of attached SignalBinding.\n * @param {boolean} [exists=false] - We only need to know if there are handlers.\n * @returns {PIXI.SignalBinding[] | boolean} Array of attached SignalBinding or Boolean if called with exists = true\n * @api public\n */\n Signal.prototype.handlers = function (exists) {\n if (exists === void 0) { exists = false; }\n var node = this._head;\n if (exists)\n { return !!node; }\n var ee = [];\n while (node) {\n ee.push(node);\n node = node._next;\n }\n return ee;\n };\n /**\n * Return true if node is a SignalBinding attached to this MiniSignal\n * @param {PIXI.SignalBinding} node - Node to check.\n * @returns {boolean} True if node is attache to mini-signal\n */\n Signal.prototype.has = function (node) {\n if (!(node instanceof SignalBinding)) {\n throw new Error('MiniSignal#has(): First arg must be a SignalBinding object.');\n }\n return node._owner === this;\n };\n /**\n * Dispaches a signal to all registered listeners.\n * @param {...any} args\n * @returns {boolean} Indication if we've emitted an event.\n */\n Signal.prototype.dispatch = function () {\n var arguments$1 = arguments;\n\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments$1[_i];\n }\n var node = this._head;\n if (!node)\n { return false; }\n while (node) {\n if (node._once)\n { this.detach(node); }\n node._fn.apply(node._thisArg, args);\n node = node._next;\n }\n return true;\n };\n /**\n * Register a new listener.\n * @param {Function} fn - Callback function.\n * @param {object} [thisArg] - The context of the callback function.\n * @returns {PIXI.SignalBinding} The SignalBinding node that was added.\n */\n Signal.prototype.add = function (fn, thisArg) {\n if (thisArg === void 0) { thisArg = null; }\n if (typeof fn !== 'function') {\n throw new Error('MiniSignal#add(): First arg must be a Function.');\n }\n return _addSignalBinding(this, new SignalBinding(fn, false, thisArg));\n };\n /**\n * Register a new listener that will be executed only once.\n * @param {Function} fn - Callback function.\n * @param {object} [thisArg] - The context of the callback function.\n * @returns {PIXI.SignalBinding} The SignalBinding node that was added.\n */\n Signal.prototype.once = function (fn, thisArg) {\n if (thisArg === void 0) { thisArg = null; }\n if (typeof fn !== 'function') {\n throw new Error('MiniSignal#once(): First arg must be a Function.');\n }\n return _addSignalBinding(this, new SignalBinding(fn, true, thisArg));\n };\n /**\n * Remove binding object.\n * @param {PIXI.SignalBinding} node - The binding node that will be removed.\n * @returns {Signal} The instance on which this method was called.\n @api public */\n Signal.prototype.detach = function (node) {\n if (!(node instanceof SignalBinding)) {\n throw new Error('MiniSignal#detach(): First arg must be a SignalBinding object.');\n }\n if (node._owner !== this)\n { return this; } // todo: or error?\n if (node._prev)\n { node._prev._next = node._next; }\n if (node._next)\n { node._next._prev = node._prev; }\n if (node === this._head) { // first node\n this._head = node._next;\n if (node._next === null) {\n this._tail = null;\n }\n }\n else if (node === this._tail) { // last node\n this._tail = node._prev;\n this._tail._next = null;\n }\n node._owner = null;\n return this;\n };\n /**\n * Detach all listeners.\n * @returns {Signal} The instance on which this method was called.\n */\n Signal.prototype.detachAll = function () {\n var node = this._head;\n if (!node)\n { return this; }\n this._head = this._tail = null;\n while (node) {\n node._owner = null;\n node = node._next;\n }\n return this;\n };\n return Signal;\n}());\n\n/**\n * function from npm package `parseUri`, converted to TS to avoid leftpad incident\n * @param {string} str\n * @param [opts] - options\n * @param {boolean} [opts.strictMode] - type of parser\n */\nfunction parseUri(str, opts) {\n opts = opts || {};\n var o = {\n // eslint-disable-next-line max-len\n key: ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'],\n q: {\n name: 'queryKey',\n parser: /(?:^|&)([^&=]*)=?([^&]*)/g\n },\n parser: {\n // eslint-disable-next-line max-len\n strict: /^(?:([^:\\/?#]+):)?(?:\\/\\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?))?((((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/,\n // eslint-disable-next-line max-len\n loose: /^(?:(?![^:@]+:[^:@\\/]*@)([^:\\/?#.]+):)?(?:\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/\n }\n };\n var m = o.parser[opts.strictMode ? 'strict' : 'loose'].exec(str);\n var uri = {};\n var i = 14;\n while (i--)\n { uri[o.key[i]] = m[i] || ''; }\n uri[o.q.name] = {};\n uri[o.key[12]].replace(o.q.parser, function (_t0, t1, t2) {\n if (t1)\n { uri[o.q.name][t1] = t2; }\n });\n return uri;\n}\n\n// tests if CORS is supported in XHR, if not we need to use XDR\nvar useXdr;\nvar tempAnchor = null;\n// some status constants\nvar STATUS_NONE = 0;\nvar STATUS_OK = 200;\nvar STATUS_EMPTY = 204;\nvar STATUS_IE_BUG_EMPTY = 1223;\nvar STATUS_TYPE_OK = 2;\n// noop\nfunction _noop$1() { }\n/**\n * Quick helper to set a value on one of the extension maps. Ensures there is no\n * dot at the start of the extension.\n * @ignore\n * @param map - The map to set on.\n * @param extname - The extension (or key) to set.\n * @param val - The value to set.\n */\nfunction setExtMap(map, extname, val) {\n if (extname && extname.indexOf('.') === 0) {\n extname = extname.substring(1);\n }\n if (!extname) {\n return;\n }\n map[extname] = val;\n}\n/**\n * Quick helper to get string xhr type.\n * @ignore\n * @param xhr - The request to check.\n * @returns The type.\n */\nfunction reqType(xhr) {\n return xhr.toString().replace('object ', '');\n}\n/**\n * Manages the state and loading of a resource and all child resources.\n *\n * Can be extended in `GlobalMixins.LoaderResource`.\n * @memberof PIXI\n */\nvar LoaderResource = /** @class */ (function () {\n /**\n * @param {string} name - The name of the resource to load.\n * @param {string|string[]} url - The url for this resource, for audio/video loads you can pass\n * an array of sources.\n * @param {object} [options] - The options for the load.\n * @param {string|boolean} [options.crossOrigin] - Is this request cross-origin? Default is to\n * determine automatically.\n * @param {number} [options.timeout=0] - A timeout in milliseconds for the load. If the load takes\n * longer than this time it is cancelled and the load is considered a failure. If this value is\n * set to `0` then there is no explicit timeout.\n * @param {PIXI.LoaderResource.LOAD_TYPE} [options.loadType=LOAD_TYPE.XHR] - How should this resource\n * be loaded?\n * @param {PIXI.LoaderResource.XHR_RESPONSE_TYPE} [options.xhrType=XHR_RESPONSE_TYPE.DEFAULT] - How\n * should the data being loaded be interpreted when using XHR?\n * @param {PIXI.LoaderResource.IMetadata} [options.metadata] - Extra configuration for middleware\n * and the Resource object.\n */\n function LoaderResource(name, url, options) {\n /**\n * The `dequeue` method that will be used a storage place for the async queue dequeue method\n * used privately by the loader.\n * @private\n * @member {Function}\n */\n this._dequeue = _noop$1;\n /**\n * Used a storage place for the on load binding used privately by the loader.\n * @private\n * @member {Function}\n */\n this._onLoadBinding = null;\n /**\n * The timer for element loads to check if they timeout.\n * @private\n */\n this._elementTimer = 0;\n /**\n * The `complete` function bound to this resource's context.\n * @private\n * @type {Function}\n */\n this._boundComplete = null;\n /**\n * The `_onError` function bound to this resource's context.\n * @private\n * @type {Function}\n */\n this._boundOnError = null;\n /**\n * The `_onProgress` function bound to this resource's context.\n * @private\n * @type {Function}\n */\n this._boundOnProgress = null;\n /**\n * The `_onTimeout` function bound to this resource's context.\n * @private\n * @type {Function}\n */\n this._boundOnTimeout = null;\n this._boundXhrOnError = null;\n this._boundXhrOnTimeout = null;\n this._boundXhrOnAbort = null;\n this._boundXhrOnLoad = null;\n if (typeof name !== 'string' || typeof url !== 'string') {\n throw new Error('Both name and url are required for constructing a resource.');\n }\n options = options || {};\n this._flags = 0;\n // set data url flag, needs to be set early for some _determineX checks to work.\n this._setFlag(LoaderResource.STATUS_FLAGS.DATA_URL, url.indexOf('data:') === 0);\n this.name = name;\n this.url = url;\n this.extension = this._getExtension();\n this.data = null;\n this.crossOrigin = options.crossOrigin === true ? 'anonymous' : options.crossOrigin;\n this.timeout = options.timeout || 0;\n this.loadType = options.loadType || this._determineLoadType();\n // The type used to load the resource via XHR. If unset, determined automatically.\n this.xhrType = options.xhrType;\n // Extra info for middleware, and controlling specifics about how the resource loads.\n // Note that if you pass in a `loadElement`, the Resource class takes ownership of it.\n // Meaning it will modify it as it sees fit.\n this.metadata = options.metadata || {};\n // The error that occurred while loading (if any).\n this.error = null;\n // The XHR object that was used to load this resource. This is only set\n // when `loadType` is `LoaderResource.LOAD_TYPE.XHR`.\n this.xhr = null;\n // The child resources this resource owns.\n this.children = [];\n // The resource type.\n this.type = LoaderResource.TYPE.UNKNOWN;\n // The progress chunk owned by this resource.\n this.progressChunk = 0;\n // The `dequeue` method that will be used a storage place for the async queue dequeue method\n // used privately by the loader.\n this._dequeue = _noop$1;\n // Used a storage place for the on load binding used privately by the loader.\n this._onLoadBinding = null;\n // The timer for element loads to check if they timeout.\n this._elementTimer = 0;\n this._boundComplete = this.complete.bind(this);\n this._boundOnError = this._onError.bind(this);\n this._boundOnProgress = this._onProgress.bind(this);\n this._boundOnTimeout = this._onTimeout.bind(this);\n // xhr callbacks\n this._boundXhrOnError = this._xhrOnError.bind(this);\n this._boundXhrOnTimeout = this._xhrOnTimeout.bind(this);\n this._boundXhrOnAbort = this._xhrOnAbort.bind(this);\n this._boundXhrOnLoad = this._xhrOnLoad.bind(this);\n // Dispatched when the resource beings to load.\n this.onStart = new Signal();\n // Dispatched each time progress of this resource load updates.\n // Not all resources types and loader systems can support this event\n // so sometimes it may not be available. If the resource\n // is being loaded on a modern browser, using XHR, and the remote server\n // properly sets Content-Length headers, then this will be available.\n this.onProgress = new Signal();\n // Dispatched once this resource has loaded, if there was an error it will\n // be in the `error` property.\n this.onComplete = new Signal();\n // Dispatched after this resource has had all the *after* middleware run on it.\n this.onAfterMiddleware = new Signal();\n }\n /**\n * Sets the load type to be used for a specific extension.\n * @static\n * @param {string} extname - The extension to set the type for, e.g. \"png\" or \"fnt\"\n * @param {PIXI.LoaderResource.LOAD_TYPE} loadType - The load type to set it to.\n */\n LoaderResource.setExtensionLoadType = function (extname, loadType) {\n setExtMap(LoaderResource._loadTypeMap, extname, loadType);\n };\n /**\n * Sets the load type to be used for a specific extension.\n * @static\n * @param {string} extname - The extension to set the type for, e.g. \"png\" or \"fnt\"\n * @param {PIXI.LoaderResource.XHR_RESPONSE_TYPE} xhrType - The xhr type to set it to.\n */\n LoaderResource.setExtensionXhrType = function (extname, xhrType) {\n setExtMap(LoaderResource._xhrTypeMap, extname, xhrType);\n };\n Object.defineProperty(LoaderResource.prototype, \"isDataUrl\", {\n /**\n * When the resource starts to load.\n * @memberof PIXI.LoaderResource\n * @callback OnStartSignal\n * @param {PIXI.Resource} resource - The resource that the event happened on.\n */\n /**\n * When the resource reports loading progress.\n * @memberof PIXI.LoaderResource\n * @callback OnProgressSignal\n * @param {PIXI.Resource} resource - The resource that the event happened on.\n * @param {number} percentage - The progress of the load in the range [0, 1].\n */\n /**\n * When the resource finishes loading.\n * @memberof PIXI.LoaderResource\n * @callback OnCompleteSignal\n * @param {PIXI.Resource} resource - The resource that the event happened on.\n */\n /**\n * @memberof PIXI.LoaderResource\n * @typedef {object} IMetadata\n * @property {HTMLImageElement|HTMLAudioElement|HTMLVideoElement} [loadElement=null] - The\n * element to use for loading, instead of creating one.\n * @property {boolean} [skipSource=false] - Skips adding source(s) to the load element. This\n * is useful if you want to pass in a `loadElement` that you already added load sources to.\n * @property {string|string[]} [mimeType] - The mime type to use for the source element\n * of a video/audio elment. If the urls are an array, you can pass this as an array as well\n * where each index is the mime type to use for the corresponding url index.\n */\n /**\n * Stores whether or not this url is a data url.\n * @readonly\n * @member {boolean}\n */\n get: function () {\n return this._hasFlag(LoaderResource.STATUS_FLAGS.DATA_URL);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(LoaderResource.prototype, \"isComplete\", {\n /**\n * Describes if this resource has finished loading. Is true when the resource has completely\n * loaded.\n * @readonly\n * @member {boolean}\n */\n get: function () {\n return this._hasFlag(LoaderResource.STATUS_FLAGS.COMPLETE);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(LoaderResource.prototype, \"isLoading\", {\n /**\n * Describes if this resource is currently loading. Is true when the resource starts loading,\n * and is false again when complete.\n * @readonly\n * @member {boolean}\n */\n get: function () {\n return this._hasFlag(LoaderResource.STATUS_FLAGS.LOADING);\n },\n enumerable: false,\n configurable: true\n });\n /** Marks the resource as complete. */\n LoaderResource.prototype.complete = function () {\n this._clearEvents();\n this._finish();\n };\n /**\n * Aborts the loading of this resource, with an optional message.\n * @param {string} message - The message to use for the error\n */\n LoaderResource.prototype.abort = function (message) {\n // abort can be called multiple times, ignore subsequent calls.\n if (this.error) {\n return;\n }\n // store error\n this.error = new Error(message);\n // clear events before calling aborts\n this._clearEvents();\n // abort the actual loading\n if (this.xhr) {\n this.xhr.abort();\n }\n else if (this.xdr) {\n this.xdr.abort();\n }\n else if (this.data) {\n // single source\n if (this.data.src) {\n this.data.src = LoaderResource.EMPTY_GIF;\n }\n // multi-source\n else {\n while (this.data.firstChild) {\n this.data.removeChild(this.data.firstChild);\n }\n }\n }\n // done now.\n this._finish();\n };\n /**\n * Kicks off loading of this resource. This method is asynchronous.\n * @param {PIXI.LoaderResource.OnCompleteSignal} [cb] - Optional callback to call once the resource is loaded.\n */\n LoaderResource.prototype.load = function (cb) {\n var _this = this;\n if (this.isLoading) {\n return;\n }\n if (this.isComplete) {\n if (cb) {\n setTimeout(function () { return cb(_this); }, 1);\n }\n return;\n }\n else if (cb) {\n this.onComplete.once(cb);\n }\n this._setFlag(LoaderResource.STATUS_FLAGS.LOADING, true);\n this.onStart.dispatch(this);\n // if unset, determine the value\n if (this.crossOrigin === false || typeof this.crossOrigin !== 'string') {\n this.crossOrigin = this._determineCrossOrigin(this.url);\n }\n switch (this.loadType) {\n case LoaderResource.LOAD_TYPE.IMAGE:\n this.type = LoaderResource.TYPE.IMAGE;\n this._loadElement('image');\n break;\n case LoaderResource.LOAD_TYPE.AUDIO:\n this.type = LoaderResource.TYPE.AUDIO;\n this._loadSourceElement('audio');\n break;\n case LoaderResource.LOAD_TYPE.VIDEO:\n this.type = LoaderResource.TYPE.VIDEO;\n this._loadSourceElement('video');\n break;\n case LoaderResource.LOAD_TYPE.XHR:\n /* falls through */\n default:\n if (typeof useXdr === 'undefined') {\n useXdr = !!(globalThis.XDomainRequest && !('withCredentials' in (new XMLHttpRequest())));\n }\n if (useXdr && this.crossOrigin) {\n this._loadXdr();\n }\n else {\n this._loadXhr();\n }\n break;\n }\n };\n /**\n * Checks if the flag is set.\n * @param flag - The flag to check.\n * @returns True if the flag is set.\n */\n LoaderResource.prototype._hasFlag = function (flag) {\n return (this._flags & flag) !== 0;\n };\n /**\n * (Un)Sets the flag.\n * @param flag - The flag to (un)set.\n * @param value - Whether to set or (un)set the flag.\n */\n LoaderResource.prototype._setFlag = function (flag, value) {\n this._flags = value ? (this._flags | flag) : (this._flags & ~flag);\n };\n /** Clears all the events from the underlying loading source. */\n LoaderResource.prototype._clearEvents = function () {\n clearTimeout(this._elementTimer);\n if (this.data && this.data.removeEventListener) {\n this.data.removeEventListener('error', this._boundOnError, false);\n this.data.removeEventListener('load', this._boundComplete, false);\n this.data.removeEventListener('progress', this._boundOnProgress, false);\n this.data.removeEventListener('canplaythrough', this._boundComplete, false);\n }\n if (this.xhr) {\n if (this.xhr.removeEventListener) {\n this.xhr.removeEventListener('error', this._boundXhrOnError, false);\n this.xhr.removeEventListener('timeout', this._boundXhrOnTimeout, false);\n this.xhr.removeEventListener('abort', this._boundXhrOnAbort, false);\n this.xhr.removeEventListener('progress', this._boundOnProgress, false);\n this.xhr.removeEventListener('load', this._boundXhrOnLoad, false);\n }\n else {\n this.xhr.onerror = null;\n this.xhr.ontimeout = null;\n this.xhr.onprogress = null;\n this.xhr.onload = null;\n }\n }\n };\n /** Finalizes the load. */\n LoaderResource.prototype._finish = function () {\n if (this.isComplete) {\n throw new Error('Complete called again for an already completed resource.');\n }\n this._setFlag(LoaderResource.STATUS_FLAGS.COMPLETE, true);\n this._setFlag(LoaderResource.STATUS_FLAGS.LOADING, false);\n this.onComplete.dispatch(this);\n };\n /**\n * Loads this resources using an element that has a single source,\n * like an HTMLImageElement.\n * @private\n * @param type - The type of element to use.\n */\n LoaderResource.prototype._loadElement = function (type) {\n if (this.metadata.loadElement) {\n this.data = this.metadata.loadElement;\n }\n else if (type === 'image' && typeof globalThis.Image !== 'undefined') {\n this.data = new Image();\n }\n else {\n this.data = document.createElement(type);\n }\n if (this.crossOrigin) {\n this.data.crossOrigin = this.crossOrigin;\n }\n if (!this.metadata.skipSource) {\n this.data.src = this.url;\n }\n this.data.addEventListener('error', this._boundOnError, false);\n this.data.addEventListener('load', this._boundComplete, false);\n this.data.addEventListener('progress', this._boundOnProgress, false);\n if (this.timeout) {\n this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout);\n }\n };\n /**\n * Loads this resources using an element that has multiple sources,\n * like an HTMLAudioElement or HTMLVideoElement.\n * @param type - The type of element to use.\n */\n LoaderResource.prototype._loadSourceElement = function (type) {\n if (this.metadata.loadElement) {\n this.data = this.metadata.loadElement;\n }\n else if (type === 'audio' && typeof globalThis.Audio !== 'undefined') {\n this.data = new Audio();\n }\n else {\n this.data = document.createElement(type);\n }\n if (this.data === null) {\n this.abort(\"Unsupported element: \" + type);\n return;\n }\n if (this.crossOrigin) {\n this.data.crossOrigin = this.crossOrigin;\n }\n if (!this.metadata.skipSource) {\n // support for CocoonJS Canvas+ runtime, lacks document.createElement('source')\n if (navigator.isCocoonJS) {\n this.data.src = Array.isArray(this.url) ? this.url[0] : this.url;\n }\n else if (Array.isArray(this.url)) {\n var mimeTypes = this.metadata.mimeType;\n for (var i = 0; i < this.url.length; ++i) {\n this.data.appendChild(this._createSource(type, this.url[i], Array.isArray(mimeTypes) ? mimeTypes[i] : mimeTypes));\n }\n }\n else {\n var mimeTypes = this.metadata.mimeType;\n this.data.appendChild(this._createSource(type, this.url, Array.isArray(mimeTypes) ? mimeTypes[0] : mimeTypes));\n }\n }\n this.data.addEventListener('error', this._boundOnError, false);\n this.data.addEventListener('load', this._boundComplete, false);\n this.data.addEventListener('progress', this._boundOnProgress, false);\n this.data.addEventListener('canplaythrough', this._boundComplete, false);\n this.data.load();\n if (this.timeout) {\n this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout);\n }\n };\n /** Loads this resources using an XMLHttpRequest. */\n LoaderResource.prototype._loadXhr = function () {\n // if unset, determine the value\n if (typeof this.xhrType !== 'string') {\n this.xhrType = this._determineXhrType();\n }\n var xhr = this.xhr = new XMLHttpRequest();\n // send credentials when crossOrigin with credentials requested\n if (this.crossOrigin === 'use-credentials') {\n xhr.withCredentials = true;\n }\n // set the request type and url\n xhr.open('GET', this.url, true);\n xhr.timeout = this.timeout;\n // load json as text and parse it ourselves. We do this because some browsers\n // *cough* safari *cough* can't deal with it.\n if (this.xhrType === LoaderResource.XHR_RESPONSE_TYPE.JSON\n || this.xhrType === LoaderResource.XHR_RESPONSE_TYPE.DOCUMENT) {\n xhr.responseType = LoaderResource.XHR_RESPONSE_TYPE.TEXT;\n }\n else {\n xhr.responseType = this.xhrType;\n }\n xhr.addEventListener('error', this._boundXhrOnError, false);\n xhr.addEventListener('timeout', this._boundXhrOnTimeout, false);\n xhr.addEventListener('abort', this._boundXhrOnAbort, false);\n xhr.addEventListener('progress', this._boundOnProgress, false);\n xhr.addEventListener('load', this._boundXhrOnLoad, false);\n xhr.send();\n };\n /** Loads this resources using an XDomainRequest. This is here because we need to support IE9 (gross). */\n LoaderResource.prototype._loadXdr = function () {\n // if unset, determine the value\n if (typeof this.xhrType !== 'string') {\n this.xhrType = this._determineXhrType();\n }\n var xdr = this.xhr = new globalThis.XDomainRequest(); // eslint-disable-line no-undef\n // XDomainRequest has a few quirks. Occasionally it will abort requests\n // A way to avoid this is to make sure ALL callbacks are set even if not used\n // More info here: http://stackoverflow.com/questions/15786966/xdomainrequest-aborts-post-on-ie-9\n xdr.timeout = this.timeout || 5000; // XDR needs a timeout value or it breaks in IE9\n xdr.onerror = this._boundXhrOnError;\n xdr.ontimeout = this._boundXhrOnTimeout;\n xdr.onprogress = this._boundOnProgress;\n xdr.onload = this._boundXhrOnLoad;\n xdr.open('GET', this.url, true);\n // Note: The xdr.send() call is wrapped in a timeout to prevent an\n // issue with the interface where some requests are lost if multiple\n // XDomainRequests are being sent at the same time.\n // Some info here: https://github.com/photonstorm/phaser/issues/1248\n setTimeout(function () { return xdr.send(); }, 1);\n };\n /**\n * Creates a source used in loading via an element.\n * @param type - The element type (video or audio).\n * @param url - The source URL to load from.\n * @param [mime] - The mime type of the video\n * @returns The source element.\n */\n LoaderResource.prototype._createSource = function (type, url, mime) {\n if (!mime) {\n mime = type + \"/\" + this._getExtension(url);\n }\n var source = document.createElement('source');\n source.src = url;\n source.type = mime;\n return source;\n };\n /**\n * Called if a load errors out.\n * @param event - The error event from the element that emits it.\n */\n LoaderResource.prototype._onError = function (event) {\n this.abort(\"Failed to load element using: \" + event.target.nodeName);\n };\n /**\n * Called if a load progress event fires for an element or xhr/xdr.\n * @param event - Progress event.\n */\n LoaderResource.prototype._onProgress = function (event) {\n if (event && event.lengthComputable) {\n this.onProgress.dispatch(this, event.loaded / event.total);\n }\n };\n /** Called if a timeout event fires for an element. */\n LoaderResource.prototype._onTimeout = function () {\n this.abort(\"Load timed out.\");\n };\n /** Called if an error event fires for xhr/xdr. */\n LoaderResource.prototype._xhrOnError = function () {\n var xhr = this.xhr;\n this.abort(reqType(xhr) + \" Request failed. Status: \" + xhr.status + \", text: \\\"\" + xhr.statusText + \"\\\"\");\n };\n /** Called if an error event fires for xhr/xdr. */\n LoaderResource.prototype._xhrOnTimeout = function () {\n var xhr = this.xhr;\n this.abort(reqType(xhr) + \" Request timed out.\");\n };\n /** Called if an abort event fires for xhr/xdr. */\n LoaderResource.prototype._xhrOnAbort = function () {\n var xhr = this.xhr;\n this.abort(reqType(xhr) + \" Request was aborted by the user.\");\n };\n /** Called when data successfully loads from an xhr/xdr request. */\n LoaderResource.prototype._xhrOnLoad = function () {\n var xhr = this.xhr;\n var text = '';\n var status = typeof xhr.status === 'undefined' ? STATUS_OK : xhr.status; // XDR has no `.status`, assume 200.\n // responseText is accessible only if responseType is '' or 'text' and on older browsers\n if (xhr.responseType === '' || xhr.responseType === 'text' || typeof xhr.responseType === 'undefined') {\n text = xhr.responseText;\n }\n // status can be 0 when using the `file://` protocol so we also check if a response is set.\n // If it has a response, we assume 200; otherwise a 0 status code with no contents is an aborted request.\n if (status === STATUS_NONE && (text.length > 0 || xhr.responseType === LoaderResource.XHR_RESPONSE_TYPE.BUFFER)) {\n status = STATUS_OK;\n }\n // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request\n else if (status === STATUS_IE_BUG_EMPTY) {\n status = STATUS_EMPTY;\n }\n var statusType = (status / 100) | 0;\n if (statusType === STATUS_TYPE_OK) {\n // if text, just return it\n if (this.xhrType === LoaderResource.XHR_RESPONSE_TYPE.TEXT) {\n this.data = text;\n this.type = LoaderResource.TYPE.TEXT;\n }\n // if json, parse into json object\n else if (this.xhrType === LoaderResource.XHR_RESPONSE_TYPE.JSON) {\n try {\n this.data = JSON.parse(text);\n this.type = LoaderResource.TYPE.JSON;\n }\n catch (e) {\n this.abort(\"Error trying to parse loaded json: \" + e);\n return;\n }\n }\n // if xml, parse into an xml document or div element\n else if (this.xhrType === LoaderResource.XHR_RESPONSE_TYPE.DOCUMENT) {\n try {\n if (globalThis.DOMParser) {\n var domparser = new DOMParser();\n this.data = domparser.parseFromString(text, 'text/xml');\n }\n else {\n var div = document.createElement('div');\n div.innerHTML = text;\n this.data = div;\n }\n this.type = LoaderResource.TYPE.XML;\n }\n catch (e$1) {\n this.abort(\"Error trying to parse loaded xml: \" + e$1);\n return;\n }\n }\n // other types just return the response\n else {\n this.data = xhr.response || text;\n }\n }\n else {\n this.abort(\"[\" + xhr.status + \"] \" + xhr.statusText + \": \" + xhr.responseURL);\n return;\n }\n this.complete();\n };\n /**\n * Sets the `crossOrigin` property for this resource based on if the url\n * for this resource is cross-origin. If crossOrigin was manually set, this\n * function does nothing.\n * @private\n * @param url - The url to test.\n * @param [loc=globalThis.location] - The location object to test against.\n * @returns The crossOrigin value to use (or empty string for none).\n */\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n LoaderResource.prototype._determineCrossOrigin = function (url, loc) {\n // data: and javascript: urls are considered same-origin\n if (url.indexOf('data:') === 0) {\n return '';\n }\n // A sandboxed iframe without the 'allow-same-origin' attribute will have a special\n // origin designed not to match globalThis.location.origin, and will always require\n // crossOrigin requests regardless of whether the location matches.\n if (globalThis.origin !== globalThis.location.origin) {\n return 'anonymous';\n }\n // default is globalThis.location\n loc = loc || globalThis.location;\n if (!tempAnchor) {\n tempAnchor = document.createElement('a');\n }\n // let the browser determine the full href for the url of this resource and then\n // parse with the node url lib, we can't use the properties of the anchor element\n // because they don't work in IE9 :(\n tempAnchor.href = url;\n var parsedUrl = parseUri(tempAnchor.href, { strictMode: true });\n var samePort = (!parsedUrl.port && loc.port === '') || (parsedUrl.port === loc.port);\n var protocol = parsedUrl.protocol ? parsedUrl.protocol + \":\" : '';\n // if cross origin\n if (parsedUrl.host !== loc.hostname || !samePort || protocol !== loc.protocol) {\n return 'anonymous';\n }\n return '';\n };\n /**\n * Determines the responseType of an XHR request based on the extension of the\n * resource being loaded.\n * @private\n * @returns {PIXI.LoaderResource.XHR_RESPONSE_TYPE} The responseType to use.\n */\n LoaderResource.prototype._determineXhrType = function () {\n return LoaderResource._xhrTypeMap[this.extension] || LoaderResource.XHR_RESPONSE_TYPE.TEXT;\n };\n /**\n * Determines the loadType of a resource based on the extension of the\n * resource being loaded.\n * @private\n * @returns {PIXI.LoaderResource.LOAD_TYPE} The loadType to use.\n */\n LoaderResource.prototype._determineLoadType = function () {\n return LoaderResource._loadTypeMap[this.extension] || LoaderResource.LOAD_TYPE.XHR;\n };\n /**\n * Extracts the extension (sans '.') of the file being loaded by the resource.\n * @param [url] - url to parse, `this.url` by default.\n * @returns The extension.\n */\n LoaderResource.prototype._getExtension = function (url) {\n if (url === void 0) { url = this.url; }\n var ext = '';\n if (this.isDataUrl) {\n var slashIndex = url.indexOf('/');\n ext = url.substring(slashIndex + 1, url.indexOf(';', slashIndex));\n }\n else {\n var queryStart = url.indexOf('?');\n var hashStart = url.indexOf('#');\n var index = Math.min(queryStart > -1 ? queryStart : url.length, hashStart > -1 ? hashStart : url.length);\n url = url.substring(0, index);\n ext = url.substring(url.lastIndexOf('.') + 1);\n }\n return ext.toLowerCase();\n };\n /**\n * Determines the mime type of an XHR request based on the responseType of\n * resource being loaded.\n * @param type - The type to get a mime type for.\n * @private\n * @returns The mime type to use.\n */\n LoaderResource.prototype._getMimeFromXhrType = function (type) {\n switch (type) {\n case LoaderResource.XHR_RESPONSE_TYPE.BUFFER:\n return 'application/octet-binary';\n case LoaderResource.XHR_RESPONSE_TYPE.BLOB:\n return 'application/blob';\n case LoaderResource.XHR_RESPONSE_TYPE.DOCUMENT:\n return 'application/xml';\n case LoaderResource.XHR_RESPONSE_TYPE.JSON:\n return 'application/json';\n case LoaderResource.XHR_RESPONSE_TYPE.DEFAULT:\n case LoaderResource.XHR_RESPONSE_TYPE.TEXT:\n /* falls through */\n default:\n return 'text/plain';\n }\n };\n return LoaderResource;\n}());\n// eslint-disable-next-line @typescript-eslint/no-namespace\n(function (LoaderResource) {\n (function (STATUS_FLAGS) {\n /** None */\n STATUS_FLAGS[STATUS_FLAGS[\"NONE\"] = 0] = \"NONE\";\n /** Data URL */\n STATUS_FLAGS[STATUS_FLAGS[\"DATA_URL\"] = 1] = \"DATA_URL\";\n /** Complete */\n STATUS_FLAGS[STATUS_FLAGS[\"COMPLETE\"] = 2] = \"COMPLETE\";\n /** Loading */\n STATUS_FLAGS[STATUS_FLAGS[\"LOADING\"] = 4] = \"LOADING\";\n })(LoaderResource.STATUS_FLAGS || (LoaderResource.STATUS_FLAGS = {}));\n (function (TYPE) {\n /** Unknown */\n TYPE[TYPE[\"UNKNOWN\"] = 0] = \"UNKNOWN\";\n /** JSON */\n TYPE[TYPE[\"JSON\"] = 1] = \"JSON\";\n /** XML */\n TYPE[TYPE[\"XML\"] = 2] = \"XML\";\n /** Image */\n TYPE[TYPE[\"IMAGE\"] = 3] = \"IMAGE\";\n /** Audio */\n TYPE[TYPE[\"AUDIO\"] = 4] = \"AUDIO\";\n /** Video */\n TYPE[TYPE[\"VIDEO\"] = 5] = \"VIDEO\";\n /** Plain text */\n TYPE[TYPE[\"TEXT\"] = 6] = \"TEXT\";\n })(LoaderResource.TYPE || (LoaderResource.TYPE = {}));\n (function (LOAD_TYPE) {\n /** Uses XMLHttpRequest to load the resource. */\n LOAD_TYPE[LOAD_TYPE[\"XHR\"] = 1] = \"XHR\";\n /** Uses an `Image` object to load the resource. */\n LOAD_TYPE[LOAD_TYPE[\"IMAGE\"] = 2] = \"IMAGE\";\n /** Uses an `Audio` object to load the resource. */\n LOAD_TYPE[LOAD_TYPE[\"AUDIO\"] = 3] = \"AUDIO\";\n /** Uses a `Video` object to load the resource. */\n LOAD_TYPE[LOAD_TYPE[\"VIDEO\"] = 4] = \"VIDEO\";\n })(LoaderResource.LOAD_TYPE || (LoaderResource.LOAD_TYPE = {}));\n (function (XHR_RESPONSE_TYPE) {\n /** string */\n XHR_RESPONSE_TYPE[\"DEFAULT\"] = \"text\";\n /** ArrayBuffer */\n XHR_RESPONSE_TYPE[\"BUFFER\"] = \"arraybuffer\";\n /** Blob */\n XHR_RESPONSE_TYPE[\"BLOB\"] = \"blob\";\n /** Document */\n XHR_RESPONSE_TYPE[\"DOCUMENT\"] = \"document\";\n /** Object */\n XHR_RESPONSE_TYPE[\"JSON\"] = \"json\";\n /** String */\n XHR_RESPONSE_TYPE[\"TEXT\"] = \"text\";\n })(LoaderResource.XHR_RESPONSE_TYPE || (LoaderResource.XHR_RESPONSE_TYPE = {}));\n LoaderResource._loadTypeMap = {\n // images\n gif: LoaderResource.LOAD_TYPE.IMAGE,\n png: LoaderResource.LOAD_TYPE.IMAGE,\n bmp: LoaderResource.LOAD_TYPE.IMAGE,\n jpg: LoaderResource.LOAD_TYPE.IMAGE,\n jpeg: LoaderResource.LOAD_TYPE.IMAGE,\n tif: LoaderResource.LOAD_TYPE.IMAGE,\n tiff: LoaderResource.LOAD_TYPE.IMAGE,\n webp: LoaderResource.LOAD_TYPE.IMAGE,\n tga: LoaderResource.LOAD_TYPE.IMAGE,\n avif: LoaderResource.LOAD_TYPE.IMAGE,\n svg: LoaderResource.LOAD_TYPE.IMAGE,\n 'svg+xml': LoaderResource.LOAD_TYPE.IMAGE,\n // audio\n mp3: LoaderResource.LOAD_TYPE.AUDIO,\n ogg: LoaderResource.LOAD_TYPE.AUDIO,\n wav: LoaderResource.LOAD_TYPE.AUDIO,\n // videos\n mp4: LoaderResource.LOAD_TYPE.VIDEO,\n webm: LoaderResource.LOAD_TYPE.VIDEO,\n };\n LoaderResource._xhrTypeMap = {\n // xml\n xhtml: LoaderResource.XHR_RESPONSE_TYPE.DOCUMENT,\n html: LoaderResource.XHR_RESPONSE_TYPE.DOCUMENT,\n htm: LoaderResource.XHR_RESPONSE_TYPE.DOCUMENT,\n xml: LoaderResource.XHR_RESPONSE_TYPE.DOCUMENT,\n tmx: LoaderResource.XHR_RESPONSE_TYPE.DOCUMENT,\n svg: LoaderResource.XHR_RESPONSE_TYPE.DOCUMENT,\n // This was added to handle Tiled Tileset XML, but .tsx is also a TypeScript React Component.\n // Since it is way less likely for people to be loading TypeScript files instead of Tiled files,\n // this should probably be fine.\n tsx: LoaderResource.XHR_RESPONSE_TYPE.DOCUMENT,\n // images\n gif: LoaderResource.XHR_RESPONSE_TYPE.BLOB,\n png: LoaderResource.XHR_RESPONSE_TYPE.BLOB,\n bmp: LoaderResource.XHR_RESPONSE_TYPE.BLOB,\n jpg: LoaderResource.XHR_RESPONSE_TYPE.BLOB,\n jpeg: LoaderResource.XHR_RESPONSE_TYPE.BLOB,\n tif: LoaderResource.XHR_RESPONSE_TYPE.BLOB,\n tiff: LoaderResource.XHR_RESPONSE_TYPE.BLOB,\n webp: LoaderResource.XHR_RESPONSE_TYPE.BLOB,\n tga: LoaderResource.XHR_RESPONSE_TYPE.BLOB,\n avif: LoaderResource.XHR_RESPONSE_TYPE.BLOB,\n // json\n json: LoaderResource.XHR_RESPONSE_TYPE.JSON,\n // text\n text: LoaderResource.XHR_RESPONSE_TYPE.TEXT,\n txt: LoaderResource.XHR_RESPONSE_TYPE.TEXT,\n // fonts\n ttf: LoaderResource.XHR_RESPONSE_TYPE.BUFFER,\n otf: LoaderResource.XHR_RESPONSE_TYPE.BUFFER,\n };\n // We can't set the `src` attribute to empty string, so on abort we set it to this 1px transparent gif\n LoaderResource.EMPTY_GIF = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';\n})(LoaderResource || (LoaderResource = {}));\n\n/**\n * Smaller version of the async library constructs.\n * @ignore\n */\nfunction _noop() {\n}\n/**\n * Ensures a function is only called once.\n * @ignore\n * @param {Function} fn - The function to wrap.\n * @returns {Function} The wrapping function.\n */\nfunction onlyOnce(fn) {\n return function onceWrapper() {\n var arguments$1 = arguments;\n\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments$1[_i];\n }\n if (fn === null) {\n throw new Error('Callback was already called.');\n }\n var callFn = fn;\n fn = null;\n callFn.apply(this, args);\n };\n}\n/**\n * @private\n * @memberof PIXI\n */\nvar AsyncQueueItem = /** @class */ (function () {\n /**\n * @param data\n * @param callback\n * @private\n */\n function AsyncQueueItem(data, callback) {\n this.data = data;\n this.callback = callback;\n }\n return AsyncQueueItem;\n}());\n/**\n * @private\n * @memberof PIXI\n */\nvar AsyncQueue = /** @class */ (function () {\n /**\n * @param worker\n * @param concurrency\n * @private\n */\n function AsyncQueue(worker, concurrency) {\n var _this = this;\n if (concurrency === void 0) { concurrency = 1; }\n this.workers = 0;\n this.saturated = _noop;\n this.unsaturated = _noop;\n this.empty = _noop;\n this.drain = _noop;\n this.error = _noop;\n this.started = false;\n this.paused = false;\n this._tasks = [];\n this._insert = function (data, insertAtFront, callback) {\n if (callback && typeof callback !== 'function') {\n throw new Error('task callback must be a function');\n }\n _this.started = true;\n // eslint-disable-next-line no-eq-null,eqeqeq\n if (data == null && _this.idle()) {\n // call drain immediately if there are no tasks\n setTimeout(function () { return _this.drain(); }, 1);\n return;\n }\n var item = new AsyncQueueItem(data, typeof callback === 'function' ? callback : _noop);\n if (insertAtFront) {\n _this._tasks.unshift(item);\n }\n else {\n _this._tasks.push(item);\n }\n setTimeout(_this.process, 1);\n };\n this.process = function () {\n while (!_this.paused && _this.workers < _this.concurrency && _this._tasks.length) {\n var task = _this._tasks.shift();\n if (_this._tasks.length === 0) {\n _this.empty();\n }\n _this.workers += 1;\n if (_this.workers === _this.concurrency) {\n _this.saturated();\n }\n _this._worker(task.data, onlyOnce(_this._next(task)));\n }\n };\n this._worker = worker;\n if (concurrency === 0) {\n throw new Error('Concurrency must not be zero');\n }\n this.concurrency = concurrency;\n this.buffer = concurrency / 4.0;\n }\n /**\n * @param task\n * @private\n */\n AsyncQueue.prototype._next = function (task) {\n var _this = this;\n return function () {\n var arguments$1 = arguments;\n\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments$1[_i];\n }\n _this.workers -= 1;\n task.callback.apply(task, args);\n // eslint-disable-next-line no-eq-null,eqeqeq\n if (args[0] != null) {\n _this.error(args[0], task.data);\n }\n if (_this.workers <= (_this.concurrency - _this.buffer)) {\n _this.unsaturated();\n }\n if (_this.idle()) {\n _this.drain();\n }\n _this.process();\n };\n };\n // That was in object\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n AsyncQueue.prototype.push = function (data, callback) {\n this._insert(data, false, callback);\n };\n AsyncQueue.prototype.kill = function () {\n this.workers = 0;\n this.drain = _noop;\n this.started = false;\n this._tasks = [];\n };\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n AsyncQueue.prototype.unshift = function (data, callback) {\n this._insert(data, true, callback);\n };\n AsyncQueue.prototype.length = function () {\n return this._tasks.length;\n };\n AsyncQueue.prototype.running = function () {\n return this.workers;\n };\n AsyncQueue.prototype.idle = function () {\n return this._tasks.length + this.workers === 0;\n };\n AsyncQueue.prototype.pause = function () {\n if (this.paused === true) {\n return;\n }\n this.paused = true;\n };\n AsyncQueue.prototype.resume = function () {\n if (this.paused === false) {\n return;\n }\n this.paused = false;\n // Need to call this.process once per concurrent\n // worker to preserve full concurrency after pause\n for (var w = 1; w <= this.concurrency; w++) {\n this.process();\n }\n };\n /**\n * Iterates an array in series.\n * @param {Array.<*>} array - Array to iterate.\n * @param {Function} iterator - Function to call for each element.\n * @param {Function} callback - Function to call when done, or on error.\n * @param {boolean} [deferNext=false] - Break synchronous each loop by calling next with a setTimeout of 1.\n */\n AsyncQueue.eachSeries = function (array, iterator, callback, deferNext) {\n var i = 0;\n var len = array.length;\n function next(err) {\n if (err || i === len) {\n if (callback) {\n callback(err);\n }\n return;\n }\n if (deferNext) {\n setTimeout(function () {\n iterator(array[i++], next);\n }, 1);\n }\n else {\n iterator(array[i++], next);\n }\n }\n next();\n };\n /**\n * Async queue implementation,\n * @param {Function} worker - The worker function to call for each task.\n * @param {number} concurrency - How many workers to run in parrallel.\n * @returns {*} The async queue object.\n */\n AsyncQueue.queue = function (worker, concurrency) {\n return new AsyncQueue(worker, concurrency);\n };\n return AsyncQueue;\n}());\n\n// some constants\nvar MAX_PROGRESS = 100;\nvar rgxExtractUrlHash = /(#[\\w-]+)?$/;\n/**\n * The new loader, forked from Resource Loader by Chad Engler: https://github.com/englercj/resource-loader\n *\n * ```js\n * const loader = PIXI.Loader.shared; // PixiJS exposes a premade instance for you to use.\n * // or\n * const loader = new PIXI.Loader(); // You can also create your own if you want\n *\n * const sprites = {};\n *\n * // Chainable `add` to enqueue a resource\n * loader.add('bunny', 'data/bunny.png')\n * .add('spaceship', 'assets/spritesheet.json');\n * loader.add('scoreFont', 'assets/score.fnt');\n *\n * // Chainable `pre` to add a middleware that runs for each resource, *before* loading that resource.\n * // This is useful to implement custom caching modules (using filesystem, indexeddb, memory, etc).\n * loader.pre(cachingMiddleware);\n *\n * // Chainable `use` to add a middleware that runs for each resource, *after* loading that resource.\n * // This is useful to implement custom parsing modules (like spritesheet parsers, spine parser, etc).\n * loader.use(parsingMiddleware);\n *\n * // The `load` method loads the queue of resources, and calls the passed in callback called once all\n * // resources have loaded.\n * loader.load((loader, resources) => {\n * // resources is an object where the key is the name of the resource loaded and the value is the resource object.\n * // They have a couple default properties:\n * // - `url`: The URL that the resource was loaded from\n * // - `error`: The error that happened when trying to load (if any)\n * // - `data`: The raw data that was loaded\n * // also may contain other properties based on the middleware that runs.\n * sprites.bunny = new PIXI.TilingSprite(resources.bunny.texture);\n * sprites.spaceship = new PIXI.TilingSprite(resources.spaceship.texture);\n * sprites.scoreFont = new PIXI.TilingSprite(resources.scoreFont.texture);\n * });\n *\n * // throughout the process multiple signals can be dispatched.\n * loader.onProgress.add(() => {}); // called once per loaded/errored file\n * loader.onError.add(() => {}); // called once per errored file\n * loader.onLoad.add(() => {}); // called once per loaded file\n * loader.onComplete.add(() => {}); // called once when the queued resources all load.\n * ```\n * @memberof PIXI\n */\nvar Loader = /** @class */ (function () {\n /**\n * @param baseUrl - The base url for all resources loaded by this loader.\n * @param concurrency - The number of resources to load concurrently.\n */\n function Loader(baseUrl, concurrency) {\n var _this = this;\n if (baseUrl === void 0) { baseUrl = ''; }\n if (concurrency === void 0) { concurrency = 10; }\n /** The progress percent of the loader going through the queue. */\n this.progress = 0;\n /** Loading state of the loader, true if it is currently loading resources. */\n this.loading = false;\n /**\n * A querystring to append to every URL added to the loader.\n *\n * This should be a valid query string *without* the question-mark (`?`). The loader will\n * also *not* escape values for you. Make sure to escape your parameters with\n * [`encodeURIComponent`](https://mdn.io/encodeURIComponent) before assigning this property.\n * @example\n * const loader = new Loader();\n *\n * loader.defaultQueryString = 'user=me&password=secret';\n *\n * // This will request 'image.png?user=me&password=secret'\n * loader.add('image.png').load();\n *\n * loader.reset();\n *\n * // This will request 'image.png?v=1&user=me&password=secret'\n * loader.add('iamge.png?v=1').load();\n */\n this.defaultQueryString = '';\n /** The middleware to run before loading each resource. */\n this._beforeMiddleware = [];\n /** The middleware to run after loading each resource. */\n this._afterMiddleware = [];\n /** The tracks the resources we are currently completing parsing for. */\n this._resourcesParsing = [];\n /**\n * The `_loadResource` function bound with this object context.\n * @param r - The resource to load\n * @param d - The dequeue function\n */\n this._boundLoadResource = function (r, d) { return _this._loadResource(r, d); };\n /** All the resources for this loader keyed by name. */\n this.resources = {};\n this.baseUrl = baseUrl;\n this._beforeMiddleware = [];\n this._afterMiddleware = [];\n this._resourcesParsing = [];\n this._boundLoadResource = function (r, d) { return _this._loadResource(r, d); };\n this._queue = AsyncQueue.queue(this._boundLoadResource, concurrency);\n this._queue.pause();\n this.resources = {};\n this.onProgress = new Signal();\n this.onError = new Signal();\n this.onLoad = new Signal();\n this.onStart = new Signal();\n this.onComplete = new Signal();\n for (var i = 0; i < Loader._plugins.length; ++i) {\n var plugin = Loader._plugins[i];\n var pre = plugin.pre, use = plugin.use;\n if (pre) {\n this.pre(pre);\n }\n if (use) {\n this.use(use);\n }\n }\n this._protected = false;\n }\n /**\n * Same as add, params have strict order\n * @private\n * @param name - The name of the resource to load.\n * @param url - The url for this resource, relative to the baseUrl of this loader.\n * @param options - The options for the load.\n * @param callback - Function to call when this specific resource completes loading.\n * @returns The loader itself.\n */\n Loader.prototype._add = function (name, url, options, callback) {\n // if loading already you can only add resources that have a parent.\n if (this.loading && (!options || !options.parentResource)) {\n throw new Error('Cannot add resources while the loader is running.');\n }\n // check if resource already exists.\n if (this.resources[name]) {\n throw new Error(\"Resource named \\\"\" + name + \"\\\" already exists.\");\n }\n // add base url if this isn't an absolute url\n url = this._prepareUrl(url);\n // create the store the resource\n this.resources[name] = new LoaderResource(name, url, options);\n if (typeof callback === 'function') {\n this.resources[name].onAfterMiddleware.once(callback);\n }\n // if actively loading, make sure to adjust progress chunks for that parent and its children\n if (this.loading) {\n var parent = options.parentResource;\n var incompleteChildren = [];\n for (var i = 0; i < parent.children.length; ++i) {\n if (!parent.children[i].isComplete) {\n incompleteChildren.push(parent.children[i]);\n }\n }\n var fullChunk = parent.progressChunk * (incompleteChildren.length + 1); // +1 for parent\n var eachChunk = fullChunk / (incompleteChildren.length + 2); // +2 for parent & new child\n parent.children.push(this.resources[name]);\n parent.progressChunk = eachChunk;\n for (var i = 0; i < incompleteChildren.length; ++i) {\n incompleteChildren[i].progressChunk = eachChunk;\n }\n this.resources[name].progressChunk = eachChunk;\n }\n // add the resource to the queue\n this._queue.push(this.resources[name]);\n return this;\n };\n /* eslint-enable require-jsdoc,valid-jsdoc */\n /**\n * Sets up a middleware function that will run *before* the\n * resource is loaded.\n * @param fn - The middleware function to register.\n * @returns The loader itself.\n */\n Loader.prototype.pre = function (fn) {\n this._beforeMiddleware.push(fn);\n return this;\n };\n /**\n * Sets up a middleware function that will run *after* the\n * resource is loaded.\n * @param fn - The middleware function to register.\n * @returns The loader itself.\n */\n Loader.prototype.use = function (fn) {\n this._afterMiddleware.push(fn);\n return this;\n };\n /**\n * Resets the queue of the loader to prepare for a new load.\n * @returns The loader itself.\n */\n Loader.prototype.reset = function () {\n this.progress = 0;\n this.loading = false;\n this._queue.kill();\n this._queue.pause();\n // abort all resource loads\n for (var k in this.resources) {\n var res = this.resources[k];\n if (res._onLoadBinding) {\n res._onLoadBinding.detach();\n }\n if (res.isLoading) {\n res.abort('loader reset');\n }\n }\n this.resources = {};\n return this;\n };\n /**\n * Starts loading the queued resources.\n * @param cb - Optional callback that will be bound to the `complete` event.\n * @returns The loader itself.\n */\n Loader.prototype.load = function (cb) {\n deprecation('6.5.0', '@pixi/loaders is being replaced with @pixi/assets in the next major release.');\n // register complete callback if they pass one\n if (typeof cb === 'function') {\n this.onComplete.once(cb);\n }\n // if the queue has already started we are done here\n if (this.loading) {\n return this;\n }\n if (this._queue.idle()) {\n this._onStart();\n this._onComplete();\n }\n else {\n // distribute progress chunks\n var numTasks = this._queue._tasks.length;\n var chunk = MAX_PROGRESS / numTasks;\n for (var i = 0; i < this._queue._tasks.length; ++i) {\n this._queue._tasks[i].data.progressChunk = chunk;\n }\n // notify we are starting\n this._onStart();\n // start loading\n this._queue.resume();\n }\n return this;\n };\n Object.defineProperty(Loader.prototype, \"concurrency\", {\n /**\n * The number of resources to load concurrently.\n * @default 10\n */\n get: function () {\n return this._queue.concurrency;\n },\n set: function (concurrency) {\n this._queue.concurrency = concurrency;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Prepares a url for usage based on the configuration of this object\n * @param url - The url to prepare.\n * @returns The prepared url.\n */\n Loader.prototype._prepareUrl = function (url) {\n var parsedUrl = parseUri(url, { strictMode: true });\n var result;\n // absolute url, just use it as is.\n if (parsedUrl.protocol || !parsedUrl.path || url.indexOf('//') === 0) {\n result = url;\n }\n // if baseUrl doesn't end in slash and url doesn't start with slash, then add a slash inbetween\n else if (this.baseUrl.length\n && this.baseUrl.lastIndexOf('/') !== this.baseUrl.length - 1\n && url.charAt(0) !== '/') {\n result = this.baseUrl + \"/\" + url;\n }\n else {\n result = this.baseUrl + url;\n }\n // if we need to add a default querystring, there is a bit more work\n if (this.defaultQueryString) {\n var hash = rgxExtractUrlHash.exec(result)[0];\n result = result.slice(0, result.length - hash.length);\n if (result.indexOf('?') !== -1) {\n result += \"&\" + this.defaultQueryString;\n }\n else {\n result += \"?\" + this.defaultQueryString;\n }\n result += hash;\n }\n return result;\n };\n /**\n * Loads a single resource.\n * @param resource - The resource to load.\n * @param dequeue - The function to call when we need to dequeue this item.\n */\n Loader.prototype._loadResource = function (resource, dequeue) {\n var _this = this;\n resource._dequeue = dequeue;\n // run before middleware\n AsyncQueue.eachSeries(this._beforeMiddleware, function (fn, next) {\n fn.call(_this, resource, function () {\n // if the before middleware marks the resource as complete,\n // break and don't process any more before middleware\n next(resource.isComplete ? {} : null);\n });\n }, function () {\n if (resource.isComplete) {\n _this._onLoad(resource);\n }\n else {\n resource._onLoadBinding = resource.onComplete.once(_this._onLoad, _this);\n resource.load();\n }\n }, true);\n };\n /** Called once loading has started. */\n Loader.prototype._onStart = function () {\n this.progress = 0;\n this.loading = true;\n this.onStart.dispatch(this);\n };\n /** Called once each resource has loaded. */\n Loader.prototype._onComplete = function () {\n this.progress = MAX_PROGRESS;\n this.loading = false;\n this.onComplete.dispatch(this, this.resources);\n };\n /**\n * Called each time a resources is loaded.\n * @param resource - The resource that was loaded\n */\n Loader.prototype._onLoad = function (resource) {\n var _this = this;\n resource._onLoadBinding = null;\n // remove this resource from the async queue, and add it to our list of resources that are being parsed\n this._resourcesParsing.push(resource);\n resource._dequeue();\n // run all the after middleware for this resource\n AsyncQueue.eachSeries(this._afterMiddleware, function (fn, next) {\n fn.call(_this, resource, next);\n }, function () {\n resource.onAfterMiddleware.dispatch(resource);\n _this.progress = Math.min(MAX_PROGRESS, _this.progress + resource.progressChunk);\n _this.onProgress.dispatch(_this, resource);\n if (resource.error) {\n _this.onError.dispatch(resource.error, _this, resource);\n }\n else {\n _this.onLoad.dispatch(_this, resource);\n }\n _this._resourcesParsing.splice(_this._resourcesParsing.indexOf(resource), 1);\n // do completion check\n if (_this._queue.idle() && _this._resourcesParsing.length === 0) {\n _this._onComplete();\n }\n }, true);\n };\n /** Destroy the loader, removes references. */\n Loader.prototype.destroy = function () {\n if (!this._protected) {\n this.reset();\n }\n };\n Object.defineProperty(Loader, \"shared\", {\n /** A premade instance of the loader that can be used to load resources. */\n get: function () {\n var shared = Loader._shared;\n if (!shared) {\n shared = new Loader();\n shared._protected = true;\n Loader._shared = shared;\n }\n return shared;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Use the {@link PIXI.extensions.add} API to register plugins.\n * @deprecated since 6.5.0\n * @param plugin - The plugin to add\n * @returns Reference to PIXI.Loader for chaining\n */\n Loader.registerPlugin = function (plugin) {\n deprecation('6.5.0', 'Loader.registerPlugin() is deprecated, use extensions.add() instead.');\n extensions.add({\n type: ExtensionType.Loader,\n ref: plugin,\n });\n return Loader;\n };\n Loader._plugins = [];\n return Loader;\n}());\nextensions.handleByList(ExtensionType.Loader, Loader._plugins);\nLoader.prototype.add = function add(name, url, options, callback) {\n // special case of an array of objects or urls\n if (Array.isArray(name)) {\n for (var i = 0; i < name.length; ++i) {\n this.add(name[i]);\n }\n return this;\n }\n // if an object is passed instead of params\n if (typeof name === 'object') {\n options = name;\n callback = url || options.callback || options.onComplete;\n url = options.url;\n name = options.name || options.key || options.url;\n }\n // case where no name is passed shift all args over by one.\n if (typeof url !== 'string') {\n callback = options;\n options = url;\n url = name;\n }\n // now that we shifted make sure we have a proper url.\n if (typeof url !== 'string') {\n throw new Error('No url passed to add resource to loader.');\n }\n // options are optional so people might pass a function and no options\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n return this._add(name, url, options, callback);\n};\n\n/**\n * Application plugin for supporting loader option. Installing the LoaderPlugin\n * is not necessary if using **pixi.js** or **pixi.js-legacy**.\n * @example\n * import {AppLoaderPlugin} from '@pixi/loaders';\n * import {extensions} from '@pixi/core';\n * extensions.add(AppLoaderPlugin);\n * @memberof PIXI\n */\nvar AppLoaderPlugin = /** @class */ (function () {\n function AppLoaderPlugin() {\n }\n /**\n * Called on application constructor\n * @param options\n * @private\n */\n AppLoaderPlugin.init = function (options) {\n options = Object.assign({\n sharedLoader: false,\n }, options);\n this.loader = options.sharedLoader ? Loader.shared : new Loader();\n };\n /**\n * Called when application destroyed\n * @private\n */\n AppLoaderPlugin.destroy = function () {\n if (this.loader) {\n this.loader.destroy();\n this.loader = null;\n }\n };\n /** @ignore */\n AppLoaderPlugin.extension = ExtensionType.Application;\n return AppLoaderPlugin;\n}());\n\n/**\n * Loader plugin for handling Texture resources.\n * @memberof PIXI\n */\nvar TextureLoader = /** @class */ (function () {\n function TextureLoader() {\n }\n /** Handle SVG elements a text, render with SVGResource. */\n TextureLoader.add = function () {\n LoaderResource.setExtensionLoadType('svg', LoaderResource.LOAD_TYPE.XHR);\n LoaderResource.setExtensionXhrType('svg', LoaderResource.XHR_RESPONSE_TYPE.TEXT);\n };\n /**\n * Called after a resource is loaded.\n * @see PIXI.Loader.loaderMiddleware\n * @param resource\n * @param {Function} next\n */\n TextureLoader.use = function (resource, next) {\n // create a new texture if the data is an Image object\n if (resource.data && (resource.type === LoaderResource.TYPE.IMAGE || resource.extension === 'svg')) {\n var data = resource.data, url = resource.url, name = resource.name, metadata = resource.metadata;\n Texture.fromLoader(data, url, name, metadata).then(function (texture) {\n resource.texture = texture;\n next();\n })\n // TODO: handle errors in Texture.fromLoader\n // so we can pass them to the Loader\n .catch(next);\n }\n else {\n next();\n }\n };\n /** @ignore */\n TextureLoader.extension = ExtensionType.Loader;\n return TextureLoader;\n}());\n\nvar _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n/**\n * Encodes binary into base64.\n * @function encodeBinary\n * @param {string} input - The input data to encode.\n * @returns {string} The encoded base64 string\n */\nfunction encodeBinary(input) {\n var output = '';\n var inx = 0;\n while (inx < input.length) {\n // Fill byte buffer array\n var bytebuffer = [0, 0, 0];\n var encodedCharIndexes = [0, 0, 0, 0];\n for (var jnx = 0; jnx < bytebuffer.length; ++jnx) {\n if (inx < input.length) {\n // throw away high-order byte, as documented at:\n // https://developer.mozilla.org/En/Using_XMLHttpRequest#Handling_binary_data\n bytebuffer[jnx] = input.charCodeAt(inx++) & 0xff;\n }\n else {\n bytebuffer[jnx] = 0;\n }\n }\n // Get each encoded character, 6 bits at a time\n // index 1: first 6 bits\n encodedCharIndexes[0] = bytebuffer[0] >> 2;\n // index 2: second 6 bits (2 least significant bits from input byte 1 + 4 most significant bits from byte 2)\n encodedCharIndexes[1] = ((bytebuffer[0] & 0x3) << 4) | (bytebuffer[1] >> 4);\n // index 3: third 6 bits (4 least significant bits from input byte 2 + 2 most significant bits from byte 3)\n encodedCharIndexes[2] = ((bytebuffer[1] & 0x0f) << 2) | (bytebuffer[2] >> 6);\n // index 3: forth 6 bits (6 least significant bits from input byte 3)\n encodedCharIndexes[3] = bytebuffer[2] & 0x3f;\n // Determine whether padding happened, and adjust accordingly\n var paddingBytes = inx - (input.length - 1);\n switch (paddingBytes) {\n case 2:\n // Set last 2 characters to padding char\n encodedCharIndexes[3] = 64;\n encodedCharIndexes[2] = 64;\n break;\n case 1:\n // Set last character to padding char\n encodedCharIndexes[3] = 64;\n break;\n }\n // Now we will grab each appropriate character out of our keystring\n // based on our index array and append it to the output string\n for (var jnx = 0; jnx < encodedCharIndexes.length; ++jnx) {\n output += _keyStr.charAt(encodedCharIndexes[jnx]);\n }\n }\n return output;\n}\n\n/**\n * A middleware for transforming XHR loaded Blobs into more useful objects\n * @ignore\n * @function parsing\n * @example\n * import { Loader, middleware } from 'resource-loader';\n * const loader = new Loader();\n * loader.use(middleware.parsing);\n * @param resource - Current Resource\n * @param next - Callback when complete\n */\nfunction parsing(resource, next) {\n if (!resource.data) {\n next();\n return;\n }\n // if this was an XHR load of a blob\n if (resource.xhr && resource.xhrType === LoaderResource.XHR_RESPONSE_TYPE.BLOB) {\n // if there is no blob support we probably got a binary string back\n if (!self.Blob || typeof resource.data === 'string') {\n var type = resource.xhr.getResponseHeader('content-type');\n // this is an image, convert the binary string into a data url\n if (type && type.indexOf('image') === 0) {\n resource.data = new Image();\n resource.data.src = \"data:\" + type + \";base64,\" + encodeBinary(resource.xhr.responseText);\n resource.type = LoaderResource.TYPE.IMAGE;\n // wait until the image loads and then callback\n resource.data.onload = function () {\n resource.data.onload = null;\n next();\n };\n // next will be called on load\n return;\n }\n }\n // if content type says this is an image, then we should transform the blob into an Image object\n else if (resource.data.type.indexOf('image') === 0) {\n var Url_1 = globalThis.URL || globalThis.webkitURL;\n var src_1 = Url_1.createObjectURL(resource.data);\n resource.blob = resource.data;\n resource.data = new Image();\n resource.data.src = src_1;\n resource.type = LoaderResource.TYPE.IMAGE;\n // cleanup the no longer used blob after the image loads\n // TODO: Is this correct? Will the image be invalid after revoking?\n resource.data.onload = function () {\n Url_1.revokeObjectURL(src_1);\n resource.data.onload = null;\n next();\n };\n // next will be called on load.\n return;\n }\n }\n next();\n}\n\n/**\n * Parse any blob into more usable objects (e.g. Image).\n * @memberof PIXI\n */\nvar ParsingLoader = /** @class */ (function () {\n function ParsingLoader() {\n }\n /** @ignore */\n ParsingLoader.extension = ExtensionType.Loader;\n ParsingLoader.use = parsing;\n return ParsingLoader;\n}());\n\nextensions.add(TextureLoader, ParsingLoader);\n\nexport { AppLoaderPlugin, Loader, LoaderResource, TextureLoader };\n//# sourceMappingURL=loaders.mjs.map\n","/*!\n * @pixi/compressed-textures - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/compressed-textures is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { ViewableBuffer, BufferResource, ExtensionType, Texture, BaseTexture } from '@pixi/core';\nimport { LoaderResource } from '@pixi/loaders';\nimport { url } from '@pixi/utils';\nimport { settings } from '@pixi/settings';\nimport { MIPMAP_MODES, ALPHA_MODES, TYPES, FORMATS } from '@pixi/constants';\n\nvar _a$2;\n/**\n * WebGL internal formats, including compressed texture formats provided by extensions\n * @memberof PIXI\n * @static\n * @name INTERNAL_FORMATS\n * @enum {number}\n * @property {number} [COMPRESSED_RGB_S3TC_DXT1_EXT=0x83F0] -\n * @property {number} [COMPRESSED_RGBA_S3TC_DXT1_EXT=0x83F1] -\n * @property {number} [COMPRESSED_RGBA_S3TC_DXT3_EXT=0x83F2] -\n * @property {number} [COMPRESSED_RGBA_S3TC_DXT5_EXT=0x83F3] -\n * @property {number} [COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917] -\n * @property {number} [COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918] -\n * @property {number} [COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919] -\n * @property {number} [COMPRESSED_SRGB_S3TC_DXT1_EXT=35916] -\n * @property {number} [COMPRESSED_R11_EAC=0x9270] -\n * @property {number} [COMPRESSED_SIGNED_R11_EAC=0x9271] -\n * @property {number} [COMPRESSED_RG11_EAC=0x9272] -\n * @property {number} [COMPRESSED_SIGNED_RG11_EAC=0x9273] -\n * @property {number} [COMPRESSED_RGB8_ETC2=0x9274] -\n * @property {number} [COMPRESSED_RGBA8_ETC2_EAC=0x9278] -\n * @property {number} [COMPRESSED_SRGB8_ETC2=0x9275] -\n * @property {number} [COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=0x9279] -\n * @property {number} [COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=0x9276] -\n * @property {number} [COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=0x9277] -\n * @property {number} [COMPRESSED_RGB_PVRTC_4BPPV1_IMG=0x8C00] -\n * @property {number} [COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=0x8C02] -\n * @property {number} [COMPRESSED_RGB_PVRTC_2BPPV1_IMG=0x8C01] -\n * @property {number} [COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=0x8C03] -\n * @property {number} [COMPRESSED_RGB_ETC1_WEBGL=0x8D64] -\n * @property {number} [COMPRESSED_RGB_ATC_WEBGL=0x8C92] -\n * @property {number} [COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=0x8C92] -\n * @property {number} [COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=0x87EE] -\n * @property {number} [COMPRESSED_RGBA_ASTC_4x4_KHR=0x93B0] -\n */\nvar INTERNAL_FORMATS;\n(function (INTERNAL_FORMATS) {\n // WEBGL_compressed_texture_s3tc\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGB_S3TC_DXT1_EXT\"] = 33776] = \"COMPRESSED_RGB_S3TC_DXT1_EXT\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGBA_S3TC_DXT1_EXT\"] = 33777] = \"COMPRESSED_RGBA_S3TC_DXT1_EXT\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGBA_S3TC_DXT3_EXT\"] = 33778] = \"COMPRESSED_RGBA_S3TC_DXT3_EXT\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGBA_S3TC_DXT5_EXT\"] = 33779] = \"COMPRESSED_RGBA_S3TC_DXT5_EXT\";\n // WEBGL_compressed_texture_s3tc_srgb\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT\"] = 35917] = \"COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT\"] = 35918] = \"COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT\"] = 35919] = \"COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_SRGB_S3TC_DXT1_EXT\"] = 35916] = \"COMPRESSED_SRGB_S3TC_DXT1_EXT\";\n // WEBGL_compressed_texture_etc\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_R11_EAC\"] = 37488] = \"COMPRESSED_R11_EAC\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_SIGNED_R11_EAC\"] = 37489] = \"COMPRESSED_SIGNED_R11_EAC\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RG11_EAC\"] = 37490] = \"COMPRESSED_RG11_EAC\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_SIGNED_RG11_EAC\"] = 37491] = \"COMPRESSED_SIGNED_RG11_EAC\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGB8_ETC2\"] = 37492] = \"COMPRESSED_RGB8_ETC2\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGBA8_ETC2_EAC\"] = 37496] = \"COMPRESSED_RGBA8_ETC2_EAC\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_SRGB8_ETC2\"] = 37493] = \"COMPRESSED_SRGB8_ETC2\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_SRGB8_ALPHA8_ETC2_EAC\"] = 37497] = \"COMPRESSED_SRGB8_ALPHA8_ETC2_EAC\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2\"] = 37494] = \"COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2\"] = 37495] = \"COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2\";\n // WEBGL_compressed_texture_pvrtc\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGB_PVRTC_4BPPV1_IMG\"] = 35840] = \"COMPRESSED_RGB_PVRTC_4BPPV1_IMG\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGBA_PVRTC_4BPPV1_IMG\"] = 35842] = \"COMPRESSED_RGBA_PVRTC_4BPPV1_IMG\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGB_PVRTC_2BPPV1_IMG\"] = 35841] = \"COMPRESSED_RGB_PVRTC_2BPPV1_IMG\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGBA_PVRTC_2BPPV1_IMG\"] = 35843] = \"COMPRESSED_RGBA_PVRTC_2BPPV1_IMG\";\n // WEBGL_compressed_texture_etc1\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGB_ETC1_WEBGL\"] = 36196] = \"COMPRESSED_RGB_ETC1_WEBGL\";\n // WEBGL_compressed_texture_atc\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGB_ATC_WEBGL\"] = 35986] = \"COMPRESSED_RGB_ATC_WEBGL\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL\"] = 35986] = \"COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL\";\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL\"] = 34798] = \"COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL\";\n // WEBGL_compressed_texture_astc\n /* eslint-disable-next-line camelcase */\n INTERNAL_FORMATS[INTERNAL_FORMATS[\"COMPRESSED_RGBA_ASTC_4x4_KHR\"] = 37808] = \"COMPRESSED_RGBA_ASTC_4x4_KHR\";\n})(INTERNAL_FORMATS || (INTERNAL_FORMATS = {}));\n/**\n * Maps the compressed texture formats in {@link PIXI.INTERNAL_FORMATS} to the number of bytes taken by\n * each texel.\n * @memberof PIXI\n * @static\n * @ignore\n */\nvar INTERNAL_FORMAT_TO_BYTES_PER_PIXEL = (_a$2 = {},\n // WEBGL_compressed_texture_s3tc\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGB_S3TC_DXT1_EXT] = 0.5,\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT1_EXT] = 0.5,\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT3_EXT] = 1,\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT] = 1,\n // WEBGL_compressed_texture_s3tc\n _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB_S3TC_DXT1_EXT] = 0.5,\n _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = 0.5,\n _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = 1,\n _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = 1,\n // WEBGL_compressed_texture_etc\n _a$2[INTERNAL_FORMATS.COMPRESSED_R11_EAC] = 0.5,\n _a$2[INTERNAL_FORMATS.COMPRESSED_SIGNED_R11_EAC] = 0.5,\n _a$2[INTERNAL_FORMATS.COMPRESSED_RG11_EAC] = 1,\n _a$2[INTERNAL_FORMATS.COMPRESSED_SIGNED_RG11_EAC] = 1,\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGB8_ETC2] = 0.5,\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA8_ETC2_EAC] = 1,\n _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB8_ETC2] = 0.5,\n _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = 1,\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = 0.5,\n _a$2[INTERNAL_FORMATS.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = 0.5,\n // WEBGL_compressed_texture_pvrtc\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = 0.5,\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = 0.5,\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = 0.25,\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = 0.25,\n // WEBGL_compressed_texture_etc1\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGB_ETC1_WEBGL] = 0.5,\n // @see https://www.khronos.org/registry/OpenGL/extensions/AMD/AMD_compressed_ATC_texture.txt\n // WEBGL_compressed_texture_atc\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGB_ATC_WEBGL] = 0.5,\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = 1,\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = 1,\n // @see https://registry.khronos.org/OpenGL/extensions/KHR/KHR_texture_compression_astc_hdr.txt\n // WEBGL_compressed_texture_astc\n /* eslint-disable-next-line camelcase */\n _a$2[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_4x4_KHR] = 1,\n _a$2);\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nfunction __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nfunction __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) { throw t[1]; } return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) { throw new TypeError(\"Generator is already executing.\"); }\r\n while (_) { try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) { return t; }\r\n if (y = 0, t) { op = [op[0] & 2, t.value]; }\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) { _.ops.pop(); }\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } }\r\n if (op[0] & 5) { throw op[1]; } return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\n\n/**\n * Resource that fetches texture data over the network and stores it in a buffer.\n * @class\n * @extends PIXI.Resource\n * @memberof PIXI\n */\nvar BlobResource = /** @class */ (function (_super) {\n __extends(BlobResource, _super);\n /**\n * @param {string} source - the URL of the texture file\n * @param {PIXI.IBlobOptions} options\n * @param {boolean}[options.autoLoad] - whether to fetch the data immediately;\n * you can fetch it later via {@link BlobResource#load}\n * @param {boolean}[options.width] - the width in pixels.\n * @param {boolean}[options.height] - the height in pixels.\n */\n function BlobResource(source, options) {\n if (options === void 0) { options = { width: 1, height: 1, autoLoad: true }; }\n var _this = this;\n var origin;\n var data;\n if (typeof source === 'string') {\n origin = source;\n data = new Uint8Array();\n }\n else {\n origin = null;\n data = source;\n }\n _this = _super.call(this, data, options) || this;\n /**\n * The URL of the texture file\n * @member {string}\n */\n _this.origin = origin;\n /**\n * The viewable buffer on the data\n * @member {ViewableBuffer}\n */\n // HINT: BlobResource allows \"null\" sources, assuming the child class provides an alternative\n _this.buffer = data ? new ViewableBuffer(data) : null;\n // Allow autoLoad = \"undefined\" still load the resource by default\n if (_this.origin && options.autoLoad !== false) {\n _this.load();\n }\n if (data && data.length) {\n _this.loaded = true;\n _this.onBlobLoaded(_this.buffer.rawBinaryData);\n }\n return _this;\n }\n BlobResource.prototype.onBlobLoaded = function (_data) {\n // TODO: Override this method\n };\n /** Loads the blob */\n BlobResource.prototype.load = function () {\n return __awaiter(this, void 0, Promise, function () {\n var response, blob, arrayBuffer;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, fetch(this.origin)];\n case 1:\n response = _a.sent();\n return [4 /*yield*/, response.blob()];\n case 2:\n blob = _a.sent();\n return [4 /*yield*/, blob.arrayBuffer()];\n case 3:\n arrayBuffer = _a.sent();\n this.data = new Uint32Array(arrayBuffer);\n this.buffer = new ViewableBuffer(arrayBuffer);\n this.loaded = true;\n this.onBlobLoaded(arrayBuffer);\n this.update();\n return [2 /*return*/, this];\n }\n });\n });\n };\n return BlobResource;\n}(BufferResource));\n\n/**\n * Resource for compressed texture formats, as follows: S3TC/DXTn (& their sRGB formats), ATC, ASTC, ETC 1/2, PVRTC.\n *\n * Compressed textures improve performance when rendering is texture-bound. The texture data stays compressed in\n * graphics memory, increasing memory locality and speeding up texture fetches. These formats can also be used to store\n * more detail in the same amount of memory.\n *\n * For most developers, container file formats are a better abstraction instead of directly handling raw texture\n * data. PixiJS provides native support for the following texture file formats (via {@link PIXI.Loader}):\n *\n * **.dds** - the DirectDraw Surface file format stores DXTn (DXT-1,3,5) data. See {@link PIXI.DDSLoader}\n * **.ktx** - the Khronos Texture Container file format supports storing all the supported WebGL compression formats.\n * See {@link PIXI.KTXLoader}.\n * **.basis** - the BASIS supercompressed file format stores texture data in an internal format that is transcoded\n * to the compression format supported on the device at _runtime_. It also supports transcoding into a uncompressed\n * format as a fallback; you must install the `@pixi/basis-loader`, `@pixi/basis-transcoder` packages separately to\n * use these files. See {@link PIXI.BasisLoader}.\n *\n * The loaders for the aforementioned formats use `CompressedTextureResource` internally. It is strongly suggested that\n * they be used instead.\n *\n * ## Working directly with CompressedTextureResource\n *\n * Since `CompressedTextureResource` inherits `BlobResource`, you can provide it a URL pointing to a file containing\n * the raw texture data (with no file headers!):\n *\n * ```js\n * // The resource backing the texture data for your textures.\n * // NOTE: You can also provide a ArrayBufferView instead of a URL. This is used when loading data from a container file\n * // format such as KTX, DDS, or BASIS.\n * const compressedResource = new PIXI.CompressedTextureResource(\"bunny.dxt5\", {\n * format: PIXI.INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT,\n * width: 256,\n * height: 256\n * });\n *\n * // You can create a base-texture to the cache, so that future `Texture`s can be created using the `Texture.from` API.\n * const baseTexture = new PIXI.BaseTexture(compressedResource, { pmaMode: PIXI.ALPHA_MODES.NPM });\n *\n * // Create a Texture to add to the TextureCache\n * const texture = new PIXI.Texture(baseTexture);\n *\n * // Add baseTexture & texture to the global texture cache\n * PIXI.BaseTexture.addToCache(baseTexture, \"bunny.dxt5\");\n * PIXI.Texture.addToCache(texture, \"bunny.dxt5\");\n * ```\n * @memberof PIXI\n */\nvar CompressedTextureResource = /** @class */ (function (_super) {\n __extends(CompressedTextureResource, _super);\n /**\n * @param source - the buffer/URL holding the compressed texture data\n * @param options\n * @param {PIXI.INTERNAL_FORMATS} options.format - the compression format\n * @param {number} options.width - the image width in pixels.\n * @param {number} options.height - the image height in pixels.\n * @param {number} [options.level=1] - the mipmap levels stored in the compressed texture, including level 0.\n * @param {number} [options.levelBuffers] - the buffers for each mipmap level. `CompressedTextureResource` can allows you\n * to pass `null` for `source`, for cases where each level is stored in non-contiguous memory.\n */\n function CompressedTextureResource(source, options) {\n var _this = _super.call(this, source, options) || this;\n _this.format = options.format;\n _this.levels = options.levels || 1;\n _this._width = options.width;\n _this._height = options.height;\n _this._extension = CompressedTextureResource._formatToExtension(_this.format);\n if (options.levelBuffers || _this.buffer) {\n // ViewableBuffer doesn't support byteOffset :-( so allow source to be Uint8Array\n _this._levelBuffers = options.levelBuffers\n || CompressedTextureResource._createLevelBuffers(source instanceof Uint8Array ? source : _this.buffer.uint8View, _this.format, _this.levels, 4, 4, // PVRTC has 8x4 blocks in 2bpp mode\n _this.width, _this.height);\n }\n return _this;\n }\n /**\n * @override\n * @param renderer - A reference to the current renderer\n * @param _texture - the texture\n * @param _glTexture - texture instance for this webgl context\n */\n CompressedTextureResource.prototype.upload = function (renderer, _texture, _glTexture) {\n var gl = renderer.gl;\n var extension = renderer.context.extensions[this._extension];\n if (!extension) {\n throw new Error(this._extension + \" textures are not supported on the current machine\");\n }\n if (!this._levelBuffers) {\n // Do not try to upload data before BlobResource loads, unless the levelBuffers were provided directly!\n return false;\n }\n for (var i = 0, j = this.levels; i < j; i++) {\n var _a = this._levelBuffers[i], levelID = _a.levelID, levelWidth = _a.levelWidth, levelHeight = _a.levelHeight, levelBuffer = _a.levelBuffer;\n gl.compressedTexImage2D(gl.TEXTURE_2D, levelID, this.format, levelWidth, levelHeight, 0, levelBuffer);\n }\n return true;\n };\n /** @protected */\n CompressedTextureResource.prototype.onBlobLoaded = function () {\n this._levelBuffers = CompressedTextureResource._createLevelBuffers(this.buffer.uint8View, this.format, this.levels, 4, 4, // PVRTC has 8x4 blocks in 2bpp mode\n this.width, this.height);\n };\n /**\n * Returns the key (to ContextSystem#extensions) for the WebGL extension supporting the compression format\n * @private\n * @param format - the compression format to get the extension for.\n */\n CompressedTextureResource._formatToExtension = function (format) {\n if (format >= 0x83F0 && format <= 0x83F3) {\n return 's3tc';\n }\n else if (format >= 0x9270 && format <= 0x9279) {\n return 'etc';\n }\n else if (format >= 0x8C00 && format <= 0x8C03) {\n return 'pvrtc';\n }\n else if (format >= 0x8D64) {\n return 'etc1';\n }\n else if (format >= 0x8C92 && format <= 0x87EE) {\n return 'atc';\n }\n throw new Error('Invalid (compressed) texture format given!');\n };\n /**\n * Pre-creates buffer views for each mipmap level\n * @private\n * @param buffer -\n * @param format - compression formats\n * @param levels - mipmap levels\n * @param blockWidth -\n * @param blockHeight -\n * @param imageWidth - width of the image in pixels\n * @param imageHeight - height of the image in pixels\n */\n CompressedTextureResource._createLevelBuffers = function (buffer, format, levels, blockWidth, blockHeight, imageWidth, imageHeight) {\n // The byte-size of the first level buffer\n var buffers = new Array(levels);\n var offset = buffer.byteOffset;\n var levelWidth = imageWidth;\n var levelHeight = imageHeight;\n var alignedLevelWidth = (levelWidth + blockWidth - 1) & ~(blockWidth - 1);\n var alignedLevelHeight = (levelHeight + blockHeight - 1) & ~(blockHeight - 1);\n var levelSize = alignedLevelWidth * alignedLevelHeight * INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[format];\n for (var i = 0; i < levels; i++) {\n buffers[i] = {\n levelID: i,\n levelWidth: levels > 1 ? levelWidth : alignedLevelWidth,\n levelHeight: levels > 1 ? levelHeight : alignedLevelHeight,\n levelBuffer: new Uint8Array(buffer.buffer, offset, levelSize)\n };\n offset += levelSize;\n // Calculate levelBuffer dimensions for next iteration\n levelWidth = (levelWidth >> 1) || 1;\n levelHeight = (levelHeight >> 1) || 1;\n alignedLevelWidth = (levelWidth + blockWidth - 1) & ~(blockWidth - 1);\n alignedLevelHeight = (levelHeight + blockHeight - 1) & ~(blockHeight - 1);\n levelSize = alignedLevelWidth * alignedLevelHeight * INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[format];\n }\n return buffers;\n };\n return CompressedTextureResource;\n}(BlobResource));\n\n/* eslint-enable camelcase */\n/**\n * Loader plugin for handling compressed textures for all platforms.\n * @class\n * @memberof PIXI\n * @implements {PIXI.ILoaderPlugin}\n */\nvar CompressedTextureLoader = /** @class */ (function () {\n function CompressedTextureLoader() {\n }\n /**\n * Called after a compressed-textures manifest is loaded.\n *\n * This will then load the correct compression format for the device. Your manifest should adhere\n * to the following schema:\n *\n * ```js\n * import { INTERNAL_FORMATS } from '@pixi/constants';\n *\n * type CompressedTextureManifest = {\n * textures: Array<{ src: string, format?: keyof INTERNAL_FORMATS}>,\n * cacheID: string;\n * };\n * ```\n *\n * This is an example of a .json manifest file\n *\n * ```json\n * {\n * \"cacheID\":\"asset\",\n * \"textures\":[\n * { \"src\":\"asset.fallback.png\" },\n * { \"format\":\"COMPRESSED_RGBA_S3TC_DXT5_EXT\", \"src\":\"asset.s3tc.ktx\" },\n * { \"format\":\"COMPRESSED_RGBA8_ETC2_EAC\", \"src\":\"asset.etc.ktx\" },\n * { \"format\":\"RGBA_PVRTC_4BPPV1_IMG\", \"src\":\"asset.pvrtc.ktx\" }\n * ]\n * }\n * ```\n */\n CompressedTextureLoader.use = function (resource, next) {\n var data = resource.data;\n var loader = this;\n if (resource.type === LoaderResource.TYPE.JSON\n && data\n && data.cacheID\n && data.textures) {\n var textures = data.textures;\n var textureURL = void 0;\n var fallbackURL = void 0;\n // Search for an extension that holds one the formats\n for (var i = 0, j = textures.length; i < j; i++) {\n var texture = textures[i];\n var url_1 = texture.src;\n var format = texture.format;\n if (!format) {\n fallbackURL = url_1;\n }\n if (CompressedTextureLoader.textureFormats[format]) {\n textureURL = url_1;\n break;\n }\n }\n textureURL = textureURL || fallbackURL;\n // Make sure we have a URL\n if (!textureURL) {\n next(new Error(\"Cannot load compressed-textures in \" + resource.url + \", make sure you provide a fallback\"));\n return;\n }\n if (textureURL === resource.url) {\n // Prevent infinite loops\n next(new Error('URL of compressed texture cannot be the same as the manifest\\'s URL'));\n return;\n }\n var loadOptions = {\n crossOrigin: resource.crossOrigin,\n metadata: resource.metadata.imageMetadata,\n parentResource: resource\n };\n var resourcePath = url.resolve(resource.url.replace(loader.baseUrl, ''), textureURL);\n var resourceName = data.cacheID;\n // The appropriate loader should register the texture\n loader.add(resourceName, resourcePath, loadOptions, function (res) {\n if (res.error) {\n next(res.error);\n return;\n }\n var _a = res.texture, texture = _a === void 0 ? null : _a, _b = res.textures, textures = _b === void 0 ? {} : _b;\n // Make sure texture/textures is assigned to parent resource\n Object.assign(resource, { texture: texture, textures: textures });\n // Pass along any error\n next();\n });\n }\n else {\n next();\n }\n };\n Object.defineProperty(CompressedTextureLoader, \"textureExtensions\", {\n /** Map of available texture extensions. */\n get: function () {\n if (!CompressedTextureLoader._textureExtensions) {\n // Auto-detect WebGL compressed-texture extensions\n var canvas = settings.ADAPTER.createCanvas();\n var gl = canvas.getContext('webgl');\n if (!gl) {\n console.warn('WebGL not available for compressed textures. Silently failing.');\n return {};\n }\n var extensions = {\n s3tc: gl.getExtension('WEBGL_compressed_texture_s3tc'),\n s3tc_sRGB: gl.getExtension('WEBGL_compressed_texture_s3tc_srgb'),\n etc: gl.getExtension('WEBGL_compressed_texture_etc'),\n etc1: gl.getExtension('WEBGL_compressed_texture_etc1'),\n pvrtc: gl.getExtension('WEBGL_compressed_texture_pvrtc')\n || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'),\n atc: gl.getExtension('WEBGL_compressed_texture_atc'),\n astc: gl.getExtension('WEBGL_compressed_texture_astc')\n };\n CompressedTextureLoader._textureExtensions = extensions;\n }\n return CompressedTextureLoader._textureExtensions;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(CompressedTextureLoader, \"textureFormats\", {\n /** Map of available texture formats. */\n get: function () {\n if (!CompressedTextureLoader._textureFormats) {\n var extensions = CompressedTextureLoader.textureExtensions;\n CompressedTextureLoader._textureFormats = {};\n // Assign all available compressed-texture formats\n for (var extensionName in extensions) {\n var extension = extensions[extensionName];\n if (!extension) {\n continue;\n }\n Object.assign(CompressedTextureLoader._textureFormats, Object.getPrototypeOf(extension));\n }\n }\n return CompressedTextureLoader._textureFormats;\n },\n enumerable: false,\n configurable: true\n });\n /** @ignore */\n CompressedTextureLoader.extension = ExtensionType.Loader;\n return CompressedTextureLoader;\n}());\n\n/**\n * Creates base-textures and textures for each compressed-texture resource and adds them into the global\n * texture cache. The first texture has two IDs - `${url}`, `${url}-1`; while the rest have an ID of the\n * form `${url}-i`.\n * @param url - the original address of the resources\n * @param resources - the resources backing texture data\n * @ignore\n */\nfunction registerCompressedTextures(url, resources, metadata) {\n var result = {\n textures: {},\n texture: null,\n };\n if (!resources) {\n return result;\n }\n var textures = resources.map(function (resource) {\n return (new Texture(new BaseTexture(resource, Object.assign({\n mipmap: MIPMAP_MODES.OFF,\n alphaMode: ALPHA_MODES.NO_PREMULTIPLIED_ALPHA\n }, metadata))));\n });\n textures.forEach(function (texture, i) {\n var baseTexture = texture.baseTexture;\n var cacheID = url + \"-\" + (i + 1);\n BaseTexture.addToCache(baseTexture, cacheID);\n Texture.addToCache(texture, cacheID);\n if (i === 0) {\n BaseTexture.addToCache(baseTexture, url);\n Texture.addToCache(texture, url);\n result.texture = texture;\n }\n result.textures[cacheID] = texture;\n });\n return result;\n}\n\nvar _a$1, _b$1;\nvar DDS_MAGIC_SIZE = 4;\nvar DDS_HEADER_SIZE = 124;\nvar DDS_HEADER_PF_SIZE = 32;\nvar DDS_HEADER_DX10_SIZE = 20;\n// DDS file format magic word\nvar DDS_MAGIC = 0x20534444;\n/**\n * DWORD offsets of the DDS file header fields (relative to file start).\n * @ignore\n */\nvar DDS_FIELDS = {\n SIZE: 1,\n FLAGS: 2,\n HEIGHT: 3,\n WIDTH: 4,\n MIPMAP_COUNT: 7,\n PIXEL_FORMAT: 19,\n};\n/**\n * DWORD offsets of the DDS PIXEL_FORMAT fields.\n * @ignore\n */\nvar DDS_PF_FIELDS = {\n SIZE: 0,\n FLAGS: 1,\n FOURCC: 2,\n RGB_BITCOUNT: 3,\n R_BIT_MASK: 4,\n G_BIT_MASK: 5,\n B_BIT_MASK: 6,\n A_BIT_MASK: 7\n};\n/**\n * DWORD offsets of the DDS_HEADER_DX10 fields.\n * @ignore\n */\nvar DDS_DX10_FIELDS = {\n DXGI_FORMAT: 0,\n RESOURCE_DIMENSION: 1,\n MISC_FLAG: 2,\n ARRAY_SIZE: 3,\n MISC_FLAGS2: 4\n};\n/**\n * @see https://docs.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format\n * @ignore\n */\n// This is way over-blown for us! Lend us a hand, and remove the ones that aren't used (but set the remaining\n// ones to their correct value)\nvar DXGI_FORMAT;\n(function (DXGI_FORMAT) {\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_UNKNOWN\"] = 0] = \"DXGI_FORMAT_UNKNOWN\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32G32B32A32_TYPELESS\"] = 1] = \"DXGI_FORMAT_R32G32B32A32_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32G32B32A32_FLOAT\"] = 2] = \"DXGI_FORMAT_R32G32B32A32_FLOAT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32G32B32A32_UINT\"] = 3] = \"DXGI_FORMAT_R32G32B32A32_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32G32B32A32_SINT\"] = 4] = \"DXGI_FORMAT_R32G32B32A32_SINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32G32B32_TYPELESS\"] = 5] = \"DXGI_FORMAT_R32G32B32_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32G32B32_FLOAT\"] = 6] = \"DXGI_FORMAT_R32G32B32_FLOAT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32G32B32_UINT\"] = 7] = \"DXGI_FORMAT_R32G32B32_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32G32B32_SINT\"] = 8] = \"DXGI_FORMAT_R32G32B32_SINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16G16B16A16_TYPELESS\"] = 9] = \"DXGI_FORMAT_R16G16B16A16_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16G16B16A16_FLOAT\"] = 10] = \"DXGI_FORMAT_R16G16B16A16_FLOAT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16G16B16A16_UNORM\"] = 11] = \"DXGI_FORMAT_R16G16B16A16_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16G16B16A16_UINT\"] = 12] = \"DXGI_FORMAT_R16G16B16A16_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16G16B16A16_SNORM\"] = 13] = \"DXGI_FORMAT_R16G16B16A16_SNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16G16B16A16_SINT\"] = 14] = \"DXGI_FORMAT_R16G16B16A16_SINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32G32_TYPELESS\"] = 15] = \"DXGI_FORMAT_R32G32_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32G32_FLOAT\"] = 16] = \"DXGI_FORMAT_R32G32_FLOAT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32G32_UINT\"] = 17] = \"DXGI_FORMAT_R32G32_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32G32_SINT\"] = 18] = \"DXGI_FORMAT_R32G32_SINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32G8X24_TYPELESS\"] = 19] = \"DXGI_FORMAT_R32G8X24_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_D32_FLOAT_S8X24_UINT\"] = 20] = \"DXGI_FORMAT_D32_FLOAT_S8X24_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS\"] = 21] = \"DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_X32_TYPELESS_G8X24_UINT\"] = 22] = \"DXGI_FORMAT_X32_TYPELESS_G8X24_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R10G10B10A2_TYPELESS\"] = 23] = \"DXGI_FORMAT_R10G10B10A2_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R10G10B10A2_UNORM\"] = 24] = \"DXGI_FORMAT_R10G10B10A2_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R10G10B10A2_UINT\"] = 25] = \"DXGI_FORMAT_R10G10B10A2_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R11G11B10_FLOAT\"] = 26] = \"DXGI_FORMAT_R11G11B10_FLOAT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8G8B8A8_TYPELESS\"] = 27] = \"DXGI_FORMAT_R8G8B8A8_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8G8B8A8_UNORM\"] = 28] = \"DXGI_FORMAT_R8G8B8A8_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8G8B8A8_UNORM_SRGB\"] = 29] = \"DXGI_FORMAT_R8G8B8A8_UNORM_SRGB\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8G8B8A8_UINT\"] = 30] = \"DXGI_FORMAT_R8G8B8A8_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8G8B8A8_SNORM\"] = 31] = \"DXGI_FORMAT_R8G8B8A8_SNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8G8B8A8_SINT\"] = 32] = \"DXGI_FORMAT_R8G8B8A8_SINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16G16_TYPELESS\"] = 33] = \"DXGI_FORMAT_R16G16_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16G16_FLOAT\"] = 34] = \"DXGI_FORMAT_R16G16_FLOAT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16G16_UNORM\"] = 35] = \"DXGI_FORMAT_R16G16_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16G16_UINT\"] = 36] = \"DXGI_FORMAT_R16G16_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16G16_SNORM\"] = 37] = \"DXGI_FORMAT_R16G16_SNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16G16_SINT\"] = 38] = \"DXGI_FORMAT_R16G16_SINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32_TYPELESS\"] = 39] = \"DXGI_FORMAT_R32_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_D32_FLOAT\"] = 40] = \"DXGI_FORMAT_D32_FLOAT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32_FLOAT\"] = 41] = \"DXGI_FORMAT_R32_FLOAT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32_UINT\"] = 42] = \"DXGI_FORMAT_R32_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R32_SINT\"] = 43] = \"DXGI_FORMAT_R32_SINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R24G8_TYPELESS\"] = 44] = \"DXGI_FORMAT_R24G8_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_D24_UNORM_S8_UINT\"] = 45] = \"DXGI_FORMAT_D24_UNORM_S8_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R24_UNORM_X8_TYPELESS\"] = 46] = \"DXGI_FORMAT_R24_UNORM_X8_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_X24_TYPELESS_G8_UINT\"] = 47] = \"DXGI_FORMAT_X24_TYPELESS_G8_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8G8_TYPELESS\"] = 48] = \"DXGI_FORMAT_R8G8_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8G8_UNORM\"] = 49] = \"DXGI_FORMAT_R8G8_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8G8_UINT\"] = 50] = \"DXGI_FORMAT_R8G8_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8G8_SNORM\"] = 51] = \"DXGI_FORMAT_R8G8_SNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8G8_SINT\"] = 52] = \"DXGI_FORMAT_R8G8_SINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16_TYPELESS\"] = 53] = \"DXGI_FORMAT_R16_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16_FLOAT\"] = 54] = \"DXGI_FORMAT_R16_FLOAT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_D16_UNORM\"] = 55] = \"DXGI_FORMAT_D16_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16_UNORM\"] = 56] = \"DXGI_FORMAT_R16_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16_UINT\"] = 57] = \"DXGI_FORMAT_R16_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16_SNORM\"] = 58] = \"DXGI_FORMAT_R16_SNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R16_SINT\"] = 59] = \"DXGI_FORMAT_R16_SINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8_TYPELESS\"] = 60] = \"DXGI_FORMAT_R8_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8_UNORM\"] = 61] = \"DXGI_FORMAT_R8_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8_UINT\"] = 62] = \"DXGI_FORMAT_R8_UINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8_SNORM\"] = 63] = \"DXGI_FORMAT_R8_SNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8_SINT\"] = 64] = \"DXGI_FORMAT_R8_SINT\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_A8_UNORM\"] = 65] = \"DXGI_FORMAT_A8_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R1_UNORM\"] = 66] = \"DXGI_FORMAT_R1_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R9G9B9E5_SHAREDEXP\"] = 67] = \"DXGI_FORMAT_R9G9B9E5_SHAREDEXP\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R8G8_B8G8_UNORM\"] = 68] = \"DXGI_FORMAT_R8G8_B8G8_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_G8R8_G8B8_UNORM\"] = 69] = \"DXGI_FORMAT_G8R8_G8B8_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC1_TYPELESS\"] = 70] = \"DXGI_FORMAT_BC1_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC1_UNORM\"] = 71] = \"DXGI_FORMAT_BC1_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC1_UNORM_SRGB\"] = 72] = \"DXGI_FORMAT_BC1_UNORM_SRGB\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC2_TYPELESS\"] = 73] = \"DXGI_FORMAT_BC2_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC2_UNORM\"] = 74] = \"DXGI_FORMAT_BC2_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC2_UNORM_SRGB\"] = 75] = \"DXGI_FORMAT_BC2_UNORM_SRGB\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC3_TYPELESS\"] = 76] = \"DXGI_FORMAT_BC3_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC3_UNORM\"] = 77] = \"DXGI_FORMAT_BC3_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC3_UNORM_SRGB\"] = 78] = \"DXGI_FORMAT_BC3_UNORM_SRGB\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC4_TYPELESS\"] = 79] = \"DXGI_FORMAT_BC4_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC4_UNORM\"] = 80] = \"DXGI_FORMAT_BC4_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC4_SNORM\"] = 81] = \"DXGI_FORMAT_BC4_SNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC5_TYPELESS\"] = 82] = \"DXGI_FORMAT_BC5_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC5_UNORM\"] = 83] = \"DXGI_FORMAT_BC5_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC5_SNORM\"] = 84] = \"DXGI_FORMAT_BC5_SNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_B5G6R5_UNORM\"] = 85] = \"DXGI_FORMAT_B5G6R5_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_B5G5R5A1_UNORM\"] = 86] = \"DXGI_FORMAT_B5G5R5A1_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_B8G8R8A8_UNORM\"] = 87] = \"DXGI_FORMAT_B8G8R8A8_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_B8G8R8X8_UNORM\"] = 88] = \"DXGI_FORMAT_B8G8R8X8_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM\"] = 89] = \"DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_B8G8R8A8_TYPELESS\"] = 90] = \"DXGI_FORMAT_B8G8R8A8_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_B8G8R8A8_UNORM_SRGB\"] = 91] = \"DXGI_FORMAT_B8G8R8A8_UNORM_SRGB\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_B8G8R8X8_TYPELESS\"] = 92] = \"DXGI_FORMAT_B8G8R8X8_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_B8G8R8X8_UNORM_SRGB\"] = 93] = \"DXGI_FORMAT_B8G8R8X8_UNORM_SRGB\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC6H_TYPELESS\"] = 94] = \"DXGI_FORMAT_BC6H_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC6H_UF16\"] = 95] = \"DXGI_FORMAT_BC6H_UF16\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC6H_SF16\"] = 96] = \"DXGI_FORMAT_BC6H_SF16\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC7_TYPELESS\"] = 97] = \"DXGI_FORMAT_BC7_TYPELESS\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC7_UNORM\"] = 98] = \"DXGI_FORMAT_BC7_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_BC7_UNORM_SRGB\"] = 99] = \"DXGI_FORMAT_BC7_UNORM_SRGB\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_AYUV\"] = 100] = \"DXGI_FORMAT_AYUV\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_Y410\"] = 101] = \"DXGI_FORMAT_Y410\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_Y416\"] = 102] = \"DXGI_FORMAT_Y416\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_NV12\"] = 103] = \"DXGI_FORMAT_NV12\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_P010\"] = 104] = \"DXGI_FORMAT_P010\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_P016\"] = 105] = \"DXGI_FORMAT_P016\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_420_OPAQUE\"] = 106] = \"DXGI_FORMAT_420_OPAQUE\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_YUY2\"] = 107] = \"DXGI_FORMAT_YUY2\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_Y210\"] = 108] = \"DXGI_FORMAT_Y210\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_Y216\"] = 109] = \"DXGI_FORMAT_Y216\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_NV11\"] = 110] = \"DXGI_FORMAT_NV11\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_AI44\"] = 111] = \"DXGI_FORMAT_AI44\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_IA44\"] = 112] = \"DXGI_FORMAT_IA44\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_P8\"] = 113] = \"DXGI_FORMAT_P8\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_A8P8\"] = 114] = \"DXGI_FORMAT_A8P8\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_B4G4R4A4_UNORM\"] = 115] = \"DXGI_FORMAT_B4G4R4A4_UNORM\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_P208\"] = 116] = \"DXGI_FORMAT_P208\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_V208\"] = 117] = \"DXGI_FORMAT_V208\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_V408\"] = 118] = \"DXGI_FORMAT_V408\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE\"] = 119] = \"DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE\"] = 120] = \"DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE\";\n DXGI_FORMAT[DXGI_FORMAT[\"DXGI_FORMAT_FORCE_UINT\"] = 121] = \"DXGI_FORMAT_FORCE_UINT\";\n})(DXGI_FORMAT || (DXGI_FORMAT = {}));\n/**\n * Possible values of the field {@link DDS_DX10_FIELDS.RESOURCE_DIMENSION}\n * @ignore\n */\nvar D3D10_RESOURCE_DIMENSION;\n(function (D3D10_RESOURCE_DIMENSION) {\n D3D10_RESOURCE_DIMENSION[D3D10_RESOURCE_DIMENSION[\"DDS_DIMENSION_TEXTURE1D\"] = 2] = \"DDS_DIMENSION_TEXTURE1D\";\n D3D10_RESOURCE_DIMENSION[D3D10_RESOURCE_DIMENSION[\"DDS_DIMENSION_TEXTURE2D\"] = 3] = \"DDS_DIMENSION_TEXTURE2D\";\n D3D10_RESOURCE_DIMENSION[D3D10_RESOURCE_DIMENSION[\"DDS_DIMENSION_TEXTURE3D\"] = 6] = \"DDS_DIMENSION_TEXTURE3D\";\n})(D3D10_RESOURCE_DIMENSION || (D3D10_RESOURCE_DIMENSION = {}));\nvar PF_FLAGS = 1;\n// PIXEL_FORMAT flags\nvar DDPF_ALPHA = 0x2;\nvar DDPF_FOURCC = 0x4;\nvar DDPF_RGB = 0x40;\nvar DDPF_YUV = 0x200;\nvar DDPF_LUMINANCE = 0x20000;\n// Four character codes for DXTn formats\nvar FOURCC_DXT1 = 0x31545844;\nvar FOURCC_DXT3 = 0x33545844;\nvar FOURCC_DXT5 = 0x35545844;\nvar FOURCC_DX10 = 0x30315844;\n// Cubemap texture flag (for DDS_DX10_FIELDS.MISC_FLAG)\nvar DDS_RESOURCE_MISC_TEXTURECUBE = 0x4;\n/**\n * Maps `FOURCC_*` formats to internal formats (see {@link PIXI.INTERNAL_FORMATS}).\n * @ignore\n */\nvar FOURCC_TO_FORMAT = (_a$1 = {},\n _a$1[FOURCC_DXT1] = INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT1_EXT,\n _a$1[FOURCC_DXT3] = INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT3_EXT,\n _a$1[FOURCC_DXT5] = INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT,\n _a$1);\n/**\n * Maps {@link DXGI_FORMAT} to types/internal-formats (see {@link PIXI.TYPES}, {@link PIXI.INTERNAL_FORMATS})\n * @ignore\n */\nvar DXGI_TO_FORMAT = (_b$1 = {},\n // WEBGL_compressed_texture_s3tc\n _b$1[DXGI_FORMAT.DXGI_FORMAT_BC1_TYPELESS] = INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT1_EXT,\n _b$1[DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM] = INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT1_EXT,\n _b$1[DXGI_FORMAT.DXGI_FORMAT_BC2_TYPELESS] = INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT3_EXT,\n _b$1[DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM] = INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT3_EXT,\n _b$1[DXGI_FORMAT.DXGI_FORMAT_BC3_TYPELESS] = INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT,\n _b$1[DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM] = INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT,\n // WEBGL_compressed_texture_s3tc_srgb\n _b$1[DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM_SRGB] = INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,\n _b$1[DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM_SRGB] = INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,\n _b$1[DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM_SRGB] = INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,\n _b$1);\n/**\n * @class\n * @memberof PIXI\n * @implements {PIXI.ILoaderPlugin}\n * @see https://docs.microsoft.com/en-us/windows/win32/direct3ddds/dx-graphics-dds-pguide\n */\n/**\n * Parses the DDS file header, generates base-textures, and puts them into the texture cache.\n * @param arrayBuffer\n */\nfunction parseDDS(arrayBuffer) {\n var data = new Uint32Array(arrayBuffer);\n var magicWord = data[0];\n if (magicWord !== DDS_MAGIC) {\n throw new Error('Invalid DDS file magic word');\n }\n var header = new Uint32Array(arrayBuffer, 0, DDS_HEADER_SIZE / Uint32Array.BYTES_PER_ELEMENT);\n // DDS header fields\n var height = header[DDS_FIELDS.HEIGHT];\n var width = header[DDS_FIELDS.WIDTH];\n var mipmapCount = header[DDS_FIELDS.MIPMAP_COUNT];\n // PIXEL_FORMAT fields\n var pixelFormat = new Uint32Array(arrayBuffer, DDS_FIELDS.PIXEL_FORMAT * Uint32Array.BYTES_PER_ELEMENT, DDS_HEADER_PF_SIZE / Uint32Array.BYTES_PER_ELEMENT);\n var formatFlags = pixelFormat[PF_FLAGS];\n // File contains compressed texture(s)\n if (formatFlags & DDPF_FOURCC) {\n var fourCC = pixelFormat[DDS_PF_FIELDS.FOURCC];\n // File contains one DXTn compressed texture\n if (fourCC !== FOURCC_DX10) {\n var internalFormat_1 = FOURCC_TO_FORMAT[fourCC];\n var dataOffset_1 = DDS_MAGIC_SIZE + DDS_HEADER_SIZE;\n var texData = new Uint8Array(arrayBuffer, dataOffset_1);\n var resource = new CompressedTextureResource(texData, {\n format: internalFormat_1,\n width: width,\n height: height,\n levels: mipmapCount // CompressedTextureResource will separate the levelBuffers for us!\n });\n return [resource];\n }\n // FOURCC_DX10 indicates there is a 20-byte DDS_HEADER_DX10 after DDS_HEADER\n var dx10Offset = DDS_MAGIC_SIZE + DDS_HEADER_SIZE;\n var dx10Header = new Uint32Array(data.buffer, dx10Offset, DDS_HEADER_DX10_SIZE / Uint32Array.BYTES_PER_ELEMENT);\n var dxgiFormat = dx10Header[DDS_DX10_FIELDS.DXGI_FORMAT];\n var resourceDimension = dx10Header[DDS_DX10_FIELDS.RESOURCE_DIMENSION];\n var miscFlag = dx10Header[DDS_DX10_FIELDS.MISC_FLAG];\n var arraySize = dx10Header[DDS_DX10_FIELDS.ARRAY_SIZE];\n // Map dxgiFormat to PIXI.INTERNAL_FORMATS\n var internalFormat_2 = DXGI_TO_FORMAT[dxgiFormat];\n if (internalFormat_2 === undefined) {\n throw new Error(\"DDSParser cannot parse texture data with DXGI format \" + dxgiFormat);\n }\n if (miscFlag === DDS_RESOURCE_MISC_TEXTURECUBE) {\n // FIXME: Anybody excited about cubemap compressed textures?\n throw new Error('DDSParser does not support cubemap textures');\n }\n if (resourceDimension === D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D) {\n // FIXME: Anybody excited about 3D compressed textures?\n throw new Error('DDSParser does not supported 3D texture data');\n }\n // Uint8Array buffers of image data, including all mipmap levels in each image\n var imageBuffers = new Array();\n var dataOffset = DDS_MAGIC_SIZE\n + DDS_HEADER_SIZE\n + DDS_HEADER_DX10_SIZE;\n if (arraySize === 1) {\n // No need bothering with the imageSize calculation!\n imageBuffers.push(new Uint8Array(arrayBuffer, dataOffset));\n }\n else {\n // Calculate imageSize for each texture, and then locate each image's texture data\n var pixelSize = INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[internalFormat_2];\n var imageSize = 0;\n var levelWidth = width;\n var levelHeight = height;\n for (var i = 0; i < mipmapCount; i++) {\n var alignedLevelWidth = Math.max(1, (levelWidth + 3) & ~3);\n var alignedLevelHeight = Math.max(1, (levelHeight + 3) & ~3);\n var levelSize = alignedLevelWidth * alignedLevelHeight * pixelSize;\n imageSize += levelSize;\n levelWidth = levelWidth >>> 1;\n levelHeight = levelHeight >>> 1;\n }\n var imageOffset = dataOffset;\n // NOTE: Cubemaps have 6-images per texture (but they aren't supported so ^_^)\n for (var i = 0; i < arraySize; i++) {\n imageBuffers.push(new Uint8Array(arrayBuffer, imageOffset, imageSize));\n imageOffset += imageSize;\n }\n }\n // Uint8Array -> CompressedTextureResource, and we're done!\n return imageBuffers.map(function (buffer) { return new CompressedTextureResource(buffer, {\n format: internalFormat_2,\n width: width,\n height: height,\n levels: mipmapCount\n }); });\n }\n if (formatFlags & DDPF_RGB) {\n // FIXME: We might want to allow uncompressed *.dds files?\n throw new Error('DDSParser does not support uncompressed texture data.');\n }\n if (formatFlags & DDPF_YUV) {\n // FIXME: Does anybody need this feature?\n throw new Error('DDSParser does not supported YUV uncompressed texture data.');\n }\n if (formatFlags & DDPF_LUMINANCE) {\n // FIXME: Microsoft says older DDS filers use this feature! Probably not worth the effort!\n throw new Error('DDSParser does not support single-channel (lumninance) texture data!');\n }\n if (formatFlags & DDPF_ALPHA) {\n // FIXME: I'm tired! See above =)\n throw new Error('DDSParser does not support single-channel (alpha) texture data!');\n }\n throw new Error('DDSParser failed to load a texture file due to an unknown reason!');\n}\n\nvar _a, _b, _c;\n/**\n * The 12-byte KTX file identifier\n * @see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/#2.1\n * @ignore\n */\nvar FILE_IDENTIFIER = [0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A];\n/**\n * The value stored in the \"endianness\" field.\n * @see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/#2.2\n * @ignore\n */\nvar ENDIANNESS = 0x04030201;\n/**\n * Byte offsets of the KTX file header fields\n * @ignore\n */\nvar KTX_FIELDS = {\n FILE_IDENTIFIER: 0,\n ENDIANNESS: 12,\n GL_TYPE: 16,\n GL_TYPE_SIZE: 20,\n GL_FORMAT: 24,\n GL_INTERNAL_FORMAT: 28,\n GL_BASE_INTERNAL_FORMAT: 32,\n PIXEL_WIDTH: 36,\n PIXEL_HEIGHT: 40,\n PIXEL_DEPTH: 44,\n NUMBER_OF_ARRAY_ELEMENTS: 48,\n NUMBER_OF_FACES: 52,\n NUMBER_OF_MIPMAP_LEVELS: 56,\n BYTES_OF_KEY_VALUE_DATA: 60\n};\n/**\n * Byte size of the file header fields in {@code KTX_FIELDS}\n * @ignore\n */\nvar FILE_HEADER_SIZE = 64;\n/**\n * Maps {@link PIXI.TYPES} to the bytes taken per component, excluding those ones that are bit-fields.\n * @ignore\n */\nvar TYPES_TO_BYTES_PER_COMPONENT = (_a = {},\n _a[TYPES.UNSIGNED_BYTE] = 1,\n _a[TYPES.UNSIGNED_SHORT] = 2,\n _a[TYPES.INT] = 4,\n _a[TYPES.UNSIGNED_INT] = 4,\n _a[TYPES.FLOAT] = 4,\n _a[TYPES.HALF_FLOAT] = 8,\n _a);\n/**\n * Number of components in each {@link PIXI.FORMATS}\n * @ignore\n */\nvar FORMATS_TO_COMPONENTS = (_b = {},\n _b[FORMATS.RGBA] = 4,\n _b[FORMATS.RGB] = 3,\n _b[FORMATS.RG] = 2,\n _b[FORMATS.RED] = 1,\n _b[FORMATS.LUMINANCE] = 1,\n _b[FORMATS.LUMINANCE_ALPHA] = 2,\n _b[FORMATS.ALPHA] = 1,\n _b);\n/**\n * Number of bytes per pixel in bit-field types in {@link PIXI.TYPES}\n * @ignore\n */\nvar TYPES_TO_BYTES_PER_PIXEL = (_c = {},\n _c[TYPES.UNSIGNED_SHORT_4_4_4_4] = 2,\n _c[TYPES.UNSIGNED_SHORT_5_5_5_1] = 2,\n _c[TYPES.UNSIGNED_SHORT_5_6_5] = 2,\n _c);\nfunction parseKTX(url, arrayBuffer, loadKeyValueData) {\n if (loadKeyValueData === void 0) { loadKeyValueData = false; }\n var dataView = new DataView(arrayBuffer);\n if (!validate(url, dataView)) {\n return null;\n }\n var littleEndian = dataView.getUint32(KTX_FIELDS.ENDIANNESS, true) === ENDIANNESS;\n var glType = dataView.getUint32(KTX_FIELDS.GL_TYPE, littleEndian);\n // const glTypeSize = dataView.getUint32(KTX_FIELDS.GL_TYPE_SIZE, littleEndian);\n var glFormat = dataView.getUint32(KTX_FIELDS.GL_FORMAT, littleEndian);\n var glInternalFormat = dataView.getUint32(KTX_FIELDS.GL_INTERNAL_FORMAT, littleEndian);\n var pixelWidth = dataView.getUint32(KTX_FIELDS.PIXEL_WIDTH, littleEndian);\n var pixelHeight = dataView.getUint32(KTX_FIELDS.PIXEL_HEIGHT, littleEndian) || 1; // \"pixelHeight = 0\" -> \"1\"\n var pixelDepth = dataView.getUint32(KTX_FIELDS.PIXEL_DEPTH, littleEndian) || 1; // ^^\n var numberOfArrayElements = dataView.getUint32(KTX_FIELDS.NUMBER_OF_ARRAY_ELEMENTS, littleEndian) || 1; // ^^\n var numberOfFaces = dataView.getUint32(KTX_FIELDS.NUMBER_OF_FACES, littleEndian);\n var numberOfMipmapLevels = dataView.getUint32(KTX_FIELDS.NUMBER_OF_MIPMAP_LEVELS, littleEndian);\n var bytesOfKeyValueData = dataView.getUint32(KTX_FIELDS.BYTES_OF_KEY_VALUE_DATA, littleEndian);\n // Whether the platform architecture is little endian. If littleEndian !== platformLittleEndian, then the\n // file contents must be endian-converted!\n // TODO: Endianness conversion\n // const platformLittleEndian = new Uint8Array((new Uint32Array([ENDIANNESS])).buffer)[0] === 0x01;\n if (pixelHeight === 0 || pixelDepth !== 1) {\n throw new Error('Only 2D textures are supported');\n }\n if (numberOfFaces !== 1) {\n throw new Error('CubeTextures are not supported by KTXLoader yet!');\n }\n if (numberOfArrayElements !== 1) {\n // TODO: Support splitting array-textures into multiple BaseTextures\n throw new Error('WebGL does not support array textures');\n }\n // TODO: 8x4 blocks for 2bpp pvrtc\n var blockWidth = 4;\n var blockHeight = 4;\n var alignedWidth = (pixelWidth + 3) & ~3;\n var alignedHeight = (pixelHeight + 3) & ~3;\n var imageBuffers = new Array(numberOfArrayElements);\n var imagePixels = pixelWidth * pixelHeight;\n if (glType === 0) {\n // Align to 16 pixels (4x4 blocks)\n imagePixels = alignedWidth * alignedHeight;\n }\n var imagePixelByteSize;\n if (glType !== 0) {\n // Uncompressed texture format\n if (TYPES_TO_BYTES_PER_COMPONENT[glType]) {\n imagePixelByteSize = TYPES_TO_BYTES_PER_COMPONENT[glType] * FORMATS_TO_COMPONENTS[glFormat];\n }\n else {\n imagePixelByteSize = TYPES_TO_BYTES_PER_PIXEL[glType];\n }\n }\n else {\n imagePixelByteSize = INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[glInternalFormat];\n }\n if (imagePixelByteSize === undefined) {\n throw new Error('Unable to resolve the pixel format stored in the *.ktx file!');\n }\n var kvData = loadKeyValueData\n ? parseKvData(dataView, bytesOfKeyValueData, littleEndian)\n : null;\n var imageByteSize = imagePixels * imagePixelByteSize;\n var mipByteSize = imageByteSize;\n var mipWidth = pixelWidth;\n var mipHeight = pixelHeight;\n var alignedMipWidth = alignedWidth;\n var alignedMipHeight = alignedHeight;\n var imageOffset = FILE_HEADER_SIZE + bytesOfKeyValueData;\n for (var mipmapLevel = 0; mipmapLevel < numberOfMipmapLevels; mipmapLevel++) {\n var imageSize = dataView.getUint32(imageOffset, littleEndian);\n var elementOffset = imageOffset + 4;\n for (var arrayElement = 0; arrayElement < numberOfArrayElements; arrayElement++) {\n // TODO: Maybe support 3D textures? :-)\n // for (let zSlice = 0; zSlice < pixelDepth; zSlice)\n var mips = imageBuffers[arrayElement];\n if (!mips) {\n mips = imageBuffers[arrayElement] = new Array(numberOfMipmapLevels);\n }\n mips[mipmapLevel] = {\n levelID: mipmapLevel,\n // don't align mipWidth when texture not compressed! (glType not zero)\n levelWidth: numberOfMipmapLevels > 1 || glType !== 0 ? mipWidth : alignedMipWidth,\n levelHeight: numberOfMipmapLevels > 1 || glType !== 0 ? mipHeight : alignedMipHeight,\n levelBuffer: new Uint8Array(arrayBuffer, elementOffset, mipByteSize)\n };\n elementOffset += mipByteSize;\n }\n // HINT: Aligns to 4-byte boundary after jumping imageSize (in lieu of mipPadding)\n imageOffset += imageSize + 4; // (+4 to jump the imageSize field itself)\n imageOffset = imageOffset % 4 !== 0 ? imageOffset + 4 - (imageOffset % 4) : imageOffset;\n // Calculate mipWidth, mipHeight for _next_ iteration\n mipWidth = (mipWidth >> 1) || 1;\n mipHeight = (mipHeight >> 1) || 1;\n alignedMipWidth = (mipWidth + blockWidth - 1) & ~(blockWidth - 1);\n alignedMipHeight = (mipHeight + blockHeight - 1) & ~(blockHeight - 1);\n // Each mipmap level is 4-times smaller?\n mipByteSize = alignedMipWidth * alignedMipHeight * imagePixelByteSize;\n }\n // We use the levelBuffers feature of CompressedTextureResource b/c texture data is image-major, not level-major.\n if (glType !== 0) {\n return {\n uncompressed: imageBuffers.map(function (levelBuffers) {\n var buffer = levelBuffers[0].levelBuffer;\n var convertToInt = false;\n if (glType === TYPES.FLOAT) {\n buffer = new Float32Array(levelBuffers[0].levelBuffer.buffer, levelBuffers[0].levelBuffer.byteOffset, levelBuffers[0].levelBuffer.byteLength / 4);\n }\n else if (glType === TYPES.UNSIGNED_INT) {\n convertToInt = true;\n buffer = new Uint32Array(levelBuffers[0].levelBuffer.buffer, levelBuffers[0].levelBuffer.byteOffset, levelBuffers[0].levelBuffer.byteLength / 4);\n }\n else if (glType === TYPES.INT) {\n convertToInt = true;\n buffer = new Int32Array(levelBuffers[0].levelBuffer.buffer, levelBuffers[0].levelBuffer.byteOffset, levelBuffers[0].levelBuffer.byteLength / 4);\n }\n return {\n resource: new BufferResource(buffer, {\n width: levelBuffers[0].levelWidth,\n height: levelBuffers[0].levelHeight,\n }),\n type: glType,\n format: convertToInt ? convertFormatToInteger(glFormat) : glFormat,\n };\n }),\n kvData: kvData\n };\n }\n return {\n compressed: imageBuffers.map(function (levelBuffers) { return new CompressedTextureResource(null, {\n format: glInternalFormat,\n width: pixelWidth,\n height: pixelHeight,\n levels: numberOfMipmapLevels,\n levelBuffers: levelBuffers,\n }); }),\n kvData: kvData\n };\n}\n/**\n * Checks whether the arrayBuffer contains a valid *.ktx file.\n * @param url\n * @param dataView\n */\nfunction validate(url, dataView) {\n // NOTE: Do not optimize this into 3 32-bit integer comparison because the endianness\n // of the data is not specified.\n for (var i = 0; i < FILE_IDENTIFIER.length; i++) {\n if (dataView.getUint8(i) !== FILE_IDENTIFIER[i]) {\n console.error(url + \" is not a valid *.ktx file!\");\n return false;\n }\n }\n return true;\n}\nfunction convertFormatToInteger(format) {\n switch (format) {\n case FORMATS.RGBA: return FORMATS.RGBA_INTEGER;\n case FORMATS.RGB: return FORMATS.RGB_INTEGER;\n case FORMATS.RG: return FORMATS.RG_INTEGER;\n case FORMATS.RED: return FORMATS.RED_INTEGER;\n default: return format;\n }\n}\nfunction parseKvData(dataView, bytesOfKeyValueData, littleEndian) {\n var kvData = new Map();\n var bytesIntoKeyValueData = 0;\n while (bytesIntoKeyValueData < bytesOfKeyValueData) {\n var keyAndValueByteSize = dataView.getUint32(FILE_HEADER_SIZE + bytesIntoKeyValueData, littleEndian);\n var keyAndValueByteOffset = FILE_HEADER_SIZE + bytesIntoKeyValueData + 4;\n var valuePadding = 3 - ((keyAndValueByteSize + 3) % 4);\n // Bounds check\n if (keyAndValueByteSize === 0 || keyAndValueByteSize > bytesOfKeyValueData - bytesIntoKeyValueData) {\n console.error('KTXLoader: keyAndValueByteSize out of bounds');\n break;\n }\n // Note: keyNulByte can't be 0 otherwise the key is an empty string.\n var keyNulByte = 0;\n for (; keyNulByte < keyAndValueByteSize; keyNulByte++) {\n if (dataView.getUint8(keyAndValueByteOffset + keyNulByte) === 0x00) {\n break;\n }\n }\n if (keyNulByte === -1) {\n console.error('KTXLoader: Failed to find null byte terminating kvData key');\n break;\n }\n var key = new TextDecoder().decode(new Uint8Array(dataView.buffer, keyAndValueByteOffset, keyNulByte));\n var value = new DataView(dataView.buffer, keyAndValueByteOffset + keyNulByte + 1, keyAndValueByteSize - keyNulByte - 1);\n kvData.set(key, value);\n // 4 = the keyAndValueByteSize field itself\n // keyAndValueByteSize = the bytes taken by the key and value\n // valuePadding = extra padding to align with 4 bytes\n bytesIntoKeyValueData += 4 + keyAndValueByteSize + valuePadding;\n }\n return kvData;\n}\n\n// Set DDS files to be loaded as an ArrayBuffer\nLoaderResource.setExtensionXhrType('dds', LoaderResource.XHR_RESPONSE_TYPE.BUFFER);\n/**\n * @class\n * @memberof PIXI\n * @implements {PIXI.ILoaderPlugin}\n * @see https://docs.microsoft.com/en-us/windows/win32/direct3ddds/dx-graphics-dds-pguide\n */\nvar DDSLoader = /** @class */ (function () {\n function DDSLoader() {\n }\n /**\n * Registers a DDS compressed texture\n * @see PIXI.Loader.loaderMiddleware\n * @param resource - loader resource that is checked to see if it is a DDS file\n * @param next - callback Function to call when done\n */\n DDSLoader.use = function (resource, next) {\n if (resource.extension === 'dds' && resource.data) {\n try {\n Object.assign(resource, registerCompressedTextures(resource.name || resource.url, parseDDS(resource.data), resource.metadata));\n }\n catch (err) {\n next(err);\n return;\n }\n }\n next();\n };\n /** @ignore */\n DDSLoader.extension = ExtensionType.Loader;\n return DDSLoader;\n}());\n\n// Set KTX files to be loaded as an ArrayBuffer\nLoaderResource.setExtensionXhrType('ktx', LoaderResource.XHR_RESPONSE_TYPE.BUFFER);\n/**\n * Loader plugin for handling KTX texture container files.\n *\n * This KTX loader does not currently support the following features:\n * * cube textures\n * * 3D textures\n * * endianness conversion for big-endian machines\n * * embedded *.basis files\n *\n * It does supports the following features:\n * * multiple textures per file\n * * mipmapping (only for compressed formats)\n * * vendor-specific key/value data parsing (enable {@link PIXI.KTXLoader.loadKeyValueData})\n * @class\n * @memberof PIXI\n * @implements {PIXI.ILoaderPlugin}\n */\nvar KTXLoader = /** @class */ (function () {\n function KTXLoader() {\n }\n /**\n * Called after a KTX file is loaded.\n *\n * This will parse the KTX file header and add a {@code BaseTexture} to the texture\n * cache.\n * @see PIXI.Loader.loaderMiddleware\n * @param resource - loader resource that is checked to see if it is a KTX file\n * @param next - callback Function to call when done\n */\n KTXLoader.use = function (resource, next) {\n if (resource.extension === 'ktx' && resource.data) {\n try {\n var url_1 = resource.name || resource.url;\n var _a = parseKTX(url_1, resource.data, this.loadKeyValueData), compressed = _a.compressed, uncompressed = _a.uncompressed, kvData_1 = _a.kvData;\n if (compressed) {\n var result = registerCompressedTextures(url_1, compressed, resource.metadata);\n if (kvData_1 && result.textures) {\n for (var textureId in result.textures) {\n result.textures[textureId].baseTexture.ktxKeyValueData = kvData_1;\n }\n }\n Object.assign(resource, result);\n }\n else if (uncompressed) {\n var textures_1 = {};\n uncompressed.forEach(function (image, i) {\n var texture = new Texture(new BaseTexture(image.resource, {\n mipmap: MIPMAP_MODES.OFF,\n alphaMode: ALPHA_MODES.NO_PREMULTIPLIED_ALPHA,\n type: image.type,\n format: image.format,\n }));\n var cacheID = url_1 + \"-\" + (i + 1);\n if (kvData_1)\n { texture.baseTexture.ktxKeyValueData = kvData_1; }\n BaseTexture.addToCache(texture.baseTexture, cacheID);\n Texture.addToCache(texture, cacheID);\n if (i === 0) {\n textures_1[url_1] = texture;\n BaseTexture.addToCache(texture.baseTexture, url_1);\n Texture.addToCache(texture, url_1);\n }\n textures_1[cacheID] = texture;\n });\n Object.assign(resource, { textures: textures_1 });\n }\n }\n catch (err) {\n next(err);\n return;\n }\n }\n next();\n };\n /** @ignore */\n KTXLoader.extension = ExtensionType.Loader;\n /**\n * If set to `true`, {@link PIXI.KTXLoader} will parse key-value data in KTX textures. This feature relies\n * on the [Encoding Standard]{@link https://encoding.spec.whatwg.org}.\n *\n * The key-value data will be available on the base-textures as {@code PIXI.BaseTexture.ktxKeyValueData}. They\n * will hold a reference to the texture data buffer, so make sure to delete key-value data once you are done\n * using it.\n */\n KTXLoader.loadKeyValueData = false;\n return KTXLoader;\n}());\n\nexport { BlobResource, CompressedTextureLoader, CompressedTextureResource, DDSLoader, FORMATS_TO_COMPONENTS, INTERNAL_FORMATS, INTERNAL_FORMAT_TO_BYTES_PER_PIXEL, KTXLoader, TYPES_TO_BYTES_PER_COMPONENT, TYPES_TO_BYTES_PER_PIXEL, parseDDS, parseKTX };\n//# sourceMappingURL=compressed-textures.mjs.map\n","/*!\n * @pixi/particle-container - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/particle-container is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { BLEND_MODES, TYPES } from '@pixi/constants';\nimport { Container } from '@pixi/display';\nimport { hex2rgb, createIndicesForQuads, correctBlendMode, premultiplyRgba, premultiplyTint } from '@pixi/utils';\nimport { Geometry, Buffer, ExtensionType, ObjectRenderer, Shader, State } from '@pixi/core';\nimport { Matrix } from '@pixi/math';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\n/**\n * The ParticleContainer class is a really fast version of the Container built solely for speed,\n * so use when you need a lot of sprites or particles.\n *\n * The tradeoff of the ParticleContainer is that most advanced functionality will not work.\n * ParticleContainer implements the basic object transform (position, scale, rotation)\n * and some advanced functionality like tint (as of v4.5.6).\n *\n * Other more advanced functionality like masking, children, filters, etc will not work on sprites in this batch.\n *\n * It's extremely easy to use:\n * ```js\n * let container = new ParticleContainer();\n *\n * for (let i = 0; i < 100; ++i)\n * {\n * let sprite = PIXI.Sprite.from(\"myImage.png\");\n * container.addChild(sprite);\n * }\n * ```\n *\n * And here you have a hundred sprites that will be rendered at the speed of light.\n * @memberof PIXI\n */\nvar ParticleContainer = /** @class */ (function (_super) {\n __extends(ParticleContainer, _super);\n /**\n * @param maxSize - The maximum number of particles that can be rendered by the container.\n * Affects size of allocated buffers.\n * @param properties - The properties of children that should be uploaded to the gpu and applied.\n * @param {boolean} [properties.vertices=false] - When true, vertices be uploaded and applied.\n * if sprite's ` scale/anchor/trim/frame/orig` is dynamic, please set `true`.\n * @param {boolean} [properties.position=true] - When true, position be uploaded and applied.\n * @param {boolean} [properties.rotation=false] - When true, rotation be uploaded and applied.\n * @param {boolean} [properties.uvs=false] - When true, uvs be uploaded and applied.\n * @param {boolean} [properties.tint=false] - When true, alpha and tint be uploaded and applied.\n * @param {number} [batchSize=16384] - Number of particles per batch. If less than maxSize, it uses maxSize instead.\n * @param {boolean} [autoResize=false] - If true, container allocates more batches in case\n * there are more than `maxSize` particles.\n */\n function ParticleContainer(maxSize, properties, batchSize, autoResize) {\n if (maxSize === void 0) { maxSize = 1500; }\n if (batchSize === void 0) { batchSize = 16384; }\n if (autoResize === void 0) { autoResize = false; }\n var _this = _super.call(this) || this;\n // Making sure the batch size is valid\n // 65535 is max vertex index in the index buffer (see ParticleRenderer)\n // so max number of particles is 65536 / 4 = 16384\n var maxBatchSize = 16384;\n if (batchSize > maxBatchSize) {\n batchSize = maxBatchSize;\n }\n _this._properties = [false, true, false, false, false];\n _this._maxSize = maxSize;\n _this._batchSize = batchSize;\n _this._buffers = null;\n _this._bufferUpdateIDs = [];\n _this._updateID = 0;\n _this.interactiveChildren = false;\n _this.blendMode = BLEND_MODES.NORMAL;\n _this.autoResize = autoResize;\n _this.roundPixels = true;\n _this.baseTexture = null;\n _this.setProperties(properties);\n _this._tint = 0;\n _this.tintRgb = new Float32Array(4);\n _this.tint = 0xFFFFFF;\n return _this;\n }\n /**\n * Sets the private properties array to dynamic / static based on the passed properties object\n * @param properties - The properties to be uploaded\n */\n ParticleContainer.prototype.setProperties = function (properties) {\n if (properties) {\n this._properties[0] = 'vertices' in properties || 'scale' in properties\n ? !!properties.vertices || !!properties.scale : this._properties[0];\n this._properties[1] = 'position' in properties ? !!properties.position : this._properties[1];\n this._properties[2] = 'rotation' in properties ? !!properties.rotation : this._properties[2];\n this._properties[3] = 'uvs' in properties ? !!properties.uvs : this._properties[3];\n this._properties[4] = 'tint' in properties || 'alpha' in properties\n ? !!properties.tint || !!properties.alpha : this._properties[4];\n }\n };\n ParticleContainer.prototype.updateTransform = function () {\n // TODO don't need to!\n this.displayObjectUpdateTransform();\n };\n Object.defineProperty(ParticleContainer.prototype, \"tint\", {\n /**\n * The tint applied to the container. This is a hex value.\n * A value of 0xFFFFFF will remove any tint effect.\n * IMPORTANT: This is a WebGL only feature and will be ignored by the canvas renderer.\n * @default 0xFFFFFF\n */\n get: function () {\n return this._tint;\n },\n set: function (value) {\n this._tint = value;\n hex2rgb(value, this.tintRgb);\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Renders the container using the WebGL renderer.\n * @param renderer - The WebGL renderer.\n */\n ParticleContainer.prototype.render = function (renderer) {\n var _this = this;\n if (!this.visible || this.worldAlpha <= 0 || !this.children.length || !this.renderable) {\n return;\n }\n if (!this.baseTexture) {\n this.baseTexture = this.children[0]._texture.baseTexture;\n if (!this.baseTexture.valid) {\n this.baseTexture.once('update', function () { return _this.onChildrenChange(0); });\n }\n }\n renderer.batch.setObjectRenderer(renderer.plugins.particle);\n renderer.plugins.particle.render(this);\n };\n /**\n * Set the flag that static data should be updated to true\n * @param smallestChildIndex - The smallest child index.\n */\n ParticleContainer.prototype.onChildrenChange = function (smallestChildIndex) {\n var bufferIndex = Math.floor(smallestChildIndex / this._batchSize);\n while (this._bufferUpdateIDs.length < bufferIndex) {\n this._bufferUpdateIDs.push(0);\n }\n this._bufferUpdateIDs[bufferIndex] = ++this._updateID;\n };\n ParticleContainer.prototype.dispose = function () {\n if (this._buffers) {\n for (var i = 0; i < this._buffers.length; ++i) {\n this._buffers[i].destroy();\n }\n this._buffers = null;\n }\n };\n /**\n * Destroys the container\n * @param options - Options parameter. A boolean will act as if all options\n * have been set to that value\n * @param {boolean} [options.children=false] - if set to true, all the children will have their\n * destroy method called as well. 'options' will be passed on to those calls.\n * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true\n * Should it destroy the texture of the child sprite\n * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true\n * Should it destroy the base texture of the child sprite\n */\n ParticleContainer.prototype.destroy = function (options) {\n _super.prototype.destroy.call(this, options);\n this.dispose();\n this._properties = null;\n this._buffers = null;\n this._bufferUpdateIDs = null;\n };\n return ParticleContainer;\n}(Container));\n\n/*\n * @author Mat Groves\n *\n * Big thanks to the very clever Matt DesLauriers https://github.com/mattdesl/\n * for creating the original PixiJS version!\n * Also a thanks to https://github.com/bchevalier for tweaking the tint and alpha so that\n * they now share 4 bytes on the vertex buffer\n *\n * Heavily inspired by LibGDX's ParticleBuffer:\n * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/ParticleBuffer.java\n */\n/**\n * The particle buffer manages the static and dynamic buffers for a particle container.\n * @private\n * @memberof PIXI\n */\nvar ParticleBuffer = /** @class */ (function () {\n /**\n * @param {object} properties - The properties to upload.\n * @param {boolean[]} dynamicPropertyFlags - Flags for which properties are dynamic.\n * @param {number} size - The size of the batch.\n */\n function ParticleBuffer(properties, dynamicPropertyFlags, size) {\n this.geometry = new Geometry();\n this.indexBuffer = null;\n this.size = size;\n this.dynamicProperties = [];\n this.staticProperties = [];\n for (var i = 0; i < properties.length; ++i) {\n var property = properties[i];\n // Make copy of properties object so that when we edit the offset it doesn't\n // change all other instances of the object literal\n property = {\n attributeName: property.attributeName,\n size: property.size,\n uploadFunction: property.uploadFunction,\n type: property.type || TYPES.FLOAT,\n offset: property.offset,\n };\n if (dynamicPropertyFlags[i]) {\n this.dynamicProperties.push(property);\n }\n else {\n this.staticProperties.push(property);\n }\n }\n this.staticStride = 0;\n this.staticBuffer = null;\n this.staticData = null;\n this.staticDataUint32 = null;\n this.dynamicStride = 0;\n this.dynamicBuffer = null;\n this.dynamicData = null;\n this.dynamicDataUint32 = null;\n this._updateID = 0;\n this.initBuffers();\n }\n /** Sets up the renderer context and necessary buffers. */\n ParticleBuffer.prototype.initBuffers = function () {\n var geometry = this.geometry;\n var dynamicOffset = 0;\n this.indexBuffer = new Buffer(createIndicesForQuads(this.size), true, true);\n geometry.addIndex(this.indexBuffer);\n this.dynamicStride = 0;\n for (var i = 0; i < this.dynamicProperties.length; ++i) {\n var property = this.dynamicProperties[i];\n property.offset = dynamicOffset;\n dynamicOffset += property.size;\n this.dynamicStride += property.size;\n }\n var dynBuffer = new ArrayBuffer(this.size * this.dynamicStride * 4 * 4);\n this.dynamicData = new Float32Array(dynBuffer);\n this.dynamicDataUint32 = new Uint32Array(dynBuffer);\n this.dynamicBuffer = new Buffer(this.dynamicData, false, false);\n // static //\n var staticOffset = 0;\n this.staticStride = 0;\n for (var i = 0; i < this.staticProperties.length; ++i) {\n var property = this.staticProperties[i];\n property.offset = staticOffset;\n staticOffset += property.size;\n this.staticStride += property.size;\n }\n var statBuffer = new ArrayBuffer(this.size * this.staticStride * 4 * 4);\n this.staticData = new Float32Array(statBuffer);\n this.staticDataUint32 = new Uint32Array(statBuffer);\n this.staticBuffer = new Buffer(this.staticData, true, false);\n for (var i = 0; i < this.dynamicProperties.length; ++i) {\n var property = this.dynamicProperties[i];\n geometry.addAttribute(property.attributeName, this.dynamicBuffer, 0, property.type === TYPES.UNSIGNED_BYTE, property.type, this.dynamicStride * 4, property.offset * 4);\n }\n for (var i = 0; i < this.staticProperties.length; ++i) {\n var property = this.staticProperties[i];\n geometry.addAttribute(property.attributeName, this.staticBuffer, 0, property.type === TYPES.UNSIGNED_BYTE, property.type, this.staticStride * 4, property.offset * 4);\n }\n };\n /**\n * Uploads the dynamic properties.\n * @param children - The children to upload.\n * @param startIndex - The index to start at.\n * @param amount - The number to upload.\n */\n ParticleBuffer.prototype.uploadDynamic = function (children, startIndex, amount) {\n for (var i = 0; i < this.dynamicProperties.length; i++) {\n var property = this.dynamicProperties[i];\n property.uploadFunction(children, startIndex, amount, property.type === TYPES.UNSIGNED_BYTE ? this.dynamicDataUint32 : this.dynamicData, this.dynamicStride, property.offset);\n }\n this.dynamicBuffer._updateID++;\n };\n /**\n * Uploads the static properties.\n * @param children - The children to upload.\n * @param startIndex - The index to start at.\n * @param amount - The number to upload.\n */\n ParticleBuffer.prototype.uploadStatic = function (children, startIndex, amount) {\n for (var i = 0; i < this.staticProperties.length; i++) {\n var property = this.staticProperties[i];\n property.uploadFunction(children, startIndex, amount, property.type === TYPES.UNSIGNED_BYTE ? this.staticDataUint32 : this.staticData, this.staticStride, property.offset);\n }\n this.staticBuffer._updateID++;\n };\n /** Destroys the ParticleBuffer. */\n ParticleBuffer.prototype.destroy = function () {\n this.indexBuffer = null;\n this.dynamicProperties = null;\n this.dynamicBuffer = null;\n this.dynamicData = null;\n this.dynamicDataUint32 = null;\n this.staticProperties = null;\n this.staticBuffer = null;\n this.staticData = null;\n this.staticDataUint32 = null;\n // all buffers are destroyed inside geometry\n this.geometry.destroy();\n };\n return ParticleBuffer;\n}());\n\nvar fragment = \"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}\";\n\nvar vertex = \"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\";\n\n/*\n * @author Mat Groves\n *\n * Big thanks to the very clever Matt DesLauriers https://github.com/mattdesl/\n * for creating the original PixiJS version!\n * Also a thanks to https://github.com/bchevalier for tweaking the tint and alpha so that they now\n * share 4 bytes on the vertex buffer\n *\n * Heavily inspired by LibGDX's ParticleRenderer:\n * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/ParticleRenderer.java\n */\n/**\n * Renderer for Particles that is designer for speed over feature set.\n * @memberof PIXI\n */\nvar ParticleRenderer = /** @class */ (function (_super) {\n __extends(ParticleRenderer, _super);\n /**\n * @param renderer - The renderer this sprite batch works for.\n */\n function ParticleRenderer(renderer) {\n var _this = _super.call(this, renderer) || this;\n // 65535 is max vertex index in the index buffer (see ParticleRenderer)\n // so max number of particles is 65536 / 4 = 16384\n // and max number of element in the index buffer is 16384 * 6 = 98304\n // Creating a full index buffer, overhead is 98304 * 2 = 196Ko\n // let numIndices = 98304;\n _this.shader = null;\n _this.properties = null;\n _this.tempMatrix = new Matrix();\n _this.properties = [\n // verticesData\n {\n attributeName: 'aVertexPosition',\n size: 2,\n uploadFunction: _this.uploadVertices,\n offset: 0,\n },\n // positionData\n {\n attributeName: 'aPositionCoord',\n size: 2,\n uploadFunction: _this.uploadPosition,\n offset: 0,\n },\n // rotationData\n {\n attributeName: 'aRotation',\n size: 1,\n uploadFunction: _this.uploadRotation,\n offset: 0,\n },\n // uvsData\n {\n attributeName: 'aTextureCoord',\n size: 2,\n uploadFunction: _this.uploadUvs,\n offset: 0,\n },\n // tintData\n {\n attributeName: 'aColor',\n size: 1,\n type: TYPES.UNSIGNED_BYTE,\n uploadFunction: _this.uploadTint,\n offset: 0,\n } ];\n _this.shader = Shader.from(vertex, fragment, {});\n _this.state = State.for2d();\n return _this;\n }\n /**\n * Renders the particle container object.\n * @param container - The container to render using this ParticleRenderer.\n */\n ParticleRenderer.prototype.render = function (container) {\n var children = container.children;\n var maxSize = container._maxSize;\n var batchSize = container._batchSize;\n var renderer = this.renderer;\n var totalChildren = children.length;\n if (totalChildren === 0) {\n return;\n }\n else if (totalChildren > maxSize && !container.autoResize) {\n totalChildren = maxSize;\n }\n var buffers = container._buffers;\n if (!buffers) {\n buffers = container._buffers = this.generateBuffers(container);\n }\n var baseTexture = children[0]._texture.baseTexture;\n var premultiplied = baseTexture.alphaMode > 0;\n // if the uvs have not updated then no point rendering just yet!\n this.state.blendMode = correctBlendMode(container.blendMode, premultiplied);\n renderer.state.set(this.state);\n var gl = renderer.gl;\n var m = container.worldTransform.copyTo(this.tempMatrix);\n m.prepend(renderer.globalUniforms.uniforms.projectionMatrix);\n this.shader.uniforms.translationMatrix = m.toArray(true);\n this.shader.uniforms.uColor = premultiplyRgba(container.tintRgb, container.worldAlpha, this.shader.uniforms.uColor, premultiplied);\n this.shader.uniforms.uSampler = baseTexture;\n this.renderer.shader.bind(this.shader);\n var updateStatic = false;\n // now lets upload and render the buffers..\n for (var i = 0, j = 0; i < totalChildren; i += batchSize, j += 1) {\n var amount = (totalChildren - i);\n if (amount > batchSize) {\n amount = batchSize;\n }\n if (j >= buffers.length) {\n buffers.push(this._generateOneMoreBuffer(container));\n }\n var buffer = buffers[j];\n // we always upload the dynamic\n buffer.uploadDynamic(children, i, amount);\n var bid = container._bufferUpdateIDs[j] || 0;\n updateStatic = updateStatic || (buffer._updateID < bid);\n // we only upload the static content when we have to!\n if (updateStatic) {\n buffer._updateID = container._updateID;\n buffer.uploadStatic(children, i, amount);\n }\n // bind the buffer\n renderer.geometry.bind(buffer.geometry);\n gl.drawElements(gl.TRIANGLES, amount * 6, gl.UNSIGNED_SHORT, 0);\n }\n };\n /**\n * Creates one particle buffer for each child in the container we want to render and updates internal properties.\n * @param container - The container to render using this ParticleRenderer\n * @returns - The buffers\n */\n ParticleRenderer.prototype.generateBuffers = function (container) {\n var buffers = [];\n var size = container._maxSize;\n var batchSize = container._batchSize;\n var dynamicPropertyFlags = container._properties;\n for (var i = 0; i < size; i += batchSize) {\n buffers.push(new ParticleBuffer(this.properties, dynamicPropertyFlags, batchSize));\n }\n return buffers;\n };\n /**\n * Creates one more particle buffer, because container has autoResize feature.\n * @param container - The container to render using this ParticleRenderer\n * @returns - The generated buffer\n */\n ParticleRenderer.prototype._generateOneMoreBuffer = function (container) {\n var batchSize = container._batchSize;\n var dynamicPropertyFlags = container._properties;\n return new ParticleBuffer(this.properties, dynamicPropertyFlags, batchSize);\n };\n /**\n * Uploads the vertices.\n * @param children - the array of sprites to render\n * @param startIndex - the index to start from in the children array\n * @param amount - the amount of children that will have their vertices uploaded\n * @param array - The vertices to upload.\n * @param stride - Stride to use for iteration.\n * @param offset - Offset to start at.\n */\n ParticleRenderer.prototype.uploadVertices = function (children, startIndex, amount, array, stride, offset) {\n var w0 = 0;\n var w1 = 0;\n var h0 = 0;\n var h1 = 0;\n for (var i = 0; i < amount; ++i) {\n var sprite = children[startIndex + i];\n var texture = sprite._texture;\n var sx = sprite.scale.x;\n var sy = sprite.scale.y;\n var trim = texture.trim;\n var orig = texture.orig;\n if (trim) {\n // if the sprite is trimmed and is not a tilingsprite then we need to add the\n // extra space before transforming the sprite coords..\n w1 = trim.x - (sprite.anchor.x * orig.width);\n w0 = w1 + trim.width;\n h1 = trim.y - (sprite.anchor.y * orig.height);\n h0 = h1 + trim.height;\n }\n else {\n w0 = (orig.width) * (1 - sprite.anchor.x);\n w1 = (orig.width) * -sprite.anchor.x;\n h0 = orig.height * (1 - sprite.anchor.y);\n h1 = orig.height * -sprite.anchor.y;\n }\n array[offset] = w1 * sx;\n array[offset + 1] = h1 * sy;\n array[offset + stride] = w0 * sx;\n array[offset + stride + 1] = h1 * sy;\n array[offset + (stride * 2)] = w0 * sx;\n array[offset + (stride * 2) + 1] = h0 * sy;\n array[offset + (stride * 3)] = w1 * sx;\n array[offset + (stride * 3) + 1] = h0 * sy;\n offset += stride * 4;\n }\n };\n /**\n * Uploads the position.\n * @param children - the array of sprites to render\n * @param startIndex - the index to start from in the children array\n * @param amount - the amount of children that will have their positions uploaded\n * @param array - The vertices to upload.\n * @param stride - Stride to use for iteration.\n * @param offset - Offset to start at.\n */\n ParticleRenderer.prototype.uploadPosition = function (children, startIndex, amount, array, stride, offset) {\n for (var i = 0; i < amount; i++) {\n var spritePosition = children[startIndex + i].position;\n array[offset] = spritePosition.x;\n array[offset + 1] = spritePosition.y;\n array[offset + stride] = spritePosition.x;\n array[offset + stride + 1] = spritePosition.y;\n array[offset + (stride * 2)] = spritePosition.x;\n array[offset + (stride * 2) + 1] = spritePosition.y;\n array[offset + (stride * 3)] = spritePosition.x;\n array[offset + (stride * 3) + 1] = spritePosition.y;\n offset += stride * 4;\n }\n };\n /**\n * Uploads the rotation.\n * @param children - the array of sprites to render\n * @param startIndex - the index to start from in the children array\n * @param amount - the amount of children that will have their rotation uploaded\n * @param array - The vertices to upload.\n * @param stride - Stride to use for iteration.\n * @param offset - Offset to start at.\n */\n ParticleRenderer.prototype.uploadRotation = function (children, startIndex, amount, array, stride, offset) {\n for (var i = 0; i < amount; i++) {\n var spriteRotation = children[startIndex + i].rotation;\n array[offset] = spriteRotation;\n array[offset + stride] = spriteRotation;\n array[offset + (stride * 2)] = spriteRotation;\n array[offset + (stride * 3)] = spriteRotation;\n offset += stride * 4;\n }\n };\n /**\n * Uploads the UVs.\n * @param children - the array of sprites to render\n * @param startIndex - the index to start from in the children array\n * @param amount - the amount of children that will have their rotation uploaded\n * @param array - The vertices to upload.\n * @param stride - Stride to use for iteration.\n * @param offset - Offset to start at.\n */\n ParticleRenderer.prototype.uploadUvs = function (children, startIndex, amount, array, stride, offset) {\n for (var i = 0; i < amount; ++i) {\n var textureUvs = children[startIndex + i]._texture._uvs;\n if (textureUvs) {\n array[offset] = textureUvs.x0;\n array[offset + 1] = textureUvs.y0;\n array[offset + stride] = textureUvs.x1;\n array[offset + stride + 1] = textureUvs.y1;\n array[offset + (stride * 2)] = textureUvs.x2;\n array[offset + (stride * 2) + 1] = textureUvs.y2;\n array[offset + (stride * 3)] = textureUvs.x3;\n array[offset + (stride * 3) + 1] = textureUvs.y3;\n offset += stride * 4;\n }\n else {\n // TODO you know this can be easier!\n array[offset] = 0;\n array[offset + 1] = 0;\n array[offset + stride] = 0;\n array[offset + stride + 1] = 0;\n array[offset + (stride * 2)] = 0;\n array[offset + (stride * 2) + 1] = 0;\n array[offset + (stride * 3)] = 0;\n array[offset + (stride * 3) + 1] = 0;\n offset += stride * 4;\n }\n }\n };\n /**\n * Uploads the tint.\n * @param children - the array of sprites to render\n * @param startIndex - the index to start from in the children array\n * @param amount - the amount of children that will have their rotation uploaded\n * @param array - The vertices to upload.\n * @param stride - Stride to use for iteration.\n * @param offset - Offset to start at.\n */\n ParticleRenderer.prototype.uploadTint = function (children, startIndex, amount, array, stride, offset) {\n for (var i = 0; i < amount; ++i) {\n var sprite = children[startIndex + i];\n var premultiplied = sprite._texture.baseTexture.alphaMode > 0;\n var alpha = sprite.alpha;\n // we dont call extra function if alpha is 1.0, that's faster\n var argb = alpha < 1.0 && premultiplied\n ? premultiplyTint(sprite._tintRGB, alpha) : sprite._tintRGB + (alpha * 255 << 24);\n array[offset] = argb;\n array[offset + stride] = argb;\n array[offset + (stride * 2)] = argb;\n array[offset + (stride * 3)] = argb;\n offset += stride * 4;\n }\n };\n /** Destroys the ParticleRenderer. */\n ParticleRenderer.prototype.destroy = function () {\n _super.prototype.destroy.call(this);\n if (this.shader) {\n this.shader.destroy();\n this.shader = null;\n }\n this.tempMatrix = null;\n };\n /** @ignore */\n ParticleRenderer.extension = {\n name: 'particle',\n type: ExtensionType.RendererPlugin,\n };\n return ParticleRenderer;\n}(ObjectRenderer));\n\nexport { ParticleContainer, ParticleRenderer };\n//# sourceMappingURL=particle-container.mjs.map\n","/*!\n * @pixi/graphics - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/graphics is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { Texture, BaseTexture, BatchDrawCall, BatchTextureArray, BatchGeometry, UniformGroup, Shader, State } from '@pixi/core';\nimport { SHAPES, Point, PI_2, Polygon, Rectangle, RoundedRectangle, Circle, Ellipse, Matrix } from '@pixi/math';\nimport { earcut, premultiplyTint, hex2rgb } from '@pixi/utils';\nimport { WRAP_MODES, DRAW_MODES, BLEND_MODES } from '@pixi/constants';\nimport { Bounds, Container } from '@pixi/display';\n\n/**\n * Supported line joints in `PIXI.LineStyle` for graphics.\n * @see PIXI.Graphics#lineStyle\n * @see https://graphicdesign.stackexchange.com/questions/59018/what-is-a-bevel-join-of-two-lines-exactly-illustrator\n * @name LINE_JOIN\n * @memberof PIXI\n * @static\n * @enum {string}\n * @property {string} MITER - 'miter': make a sharp corner where outer part of lines meet\n * @property {string} BEVEL - 'bevel': add a square butt at each end of line segment and fill the triangle at turn\n * @property {string} ROUND - 'round': add an arc at the joint\n */\nvar LINE_JOIN;\n(function (LINE_JOIN) {\n LINE_JOIN[\"MITER\"] = \"miter\";\n LINE_JOIN[\"BEVEL\"] = \"bevel\";\n LINE_JOIN[\"ROUND\"] = \"round\";\n})(LINE_JOIN || (LINE_JOIN = {}));\n/**\n * Support line caps in `PIXI.LineStyle` for graphics.\n * @see PIXI.Graphics#lineStyle\n * @name LINE_CAP\n * @memberof PIXI\n * @static\n * @enum {string}\n * @property {string} BUTT - 'butt': don't add any cap at line ends (leaves orthogonal edges)\n * @property {string} ROUND - 'round': add semicircle at ends\n * @property {string} SQUARE - 'square': add square at end (like `BUTT` except more length at end)\n */\nvar LINE_CAP;\n(function (LINE_CAP) {\n LINE_CAP[\"BUTT\"] = \"butt\";\n LINE_CAP[\"ROUND\"] = \"round\";\n LINE_CAP[\"SQUARE\"] = \"square\";\n})(LINE_CAP || (LINE_CAP = {}));\n/**\n * Graphics curves resolution settings. If `adaptive` flag is set to `true`,\n * the resolution is calculated based on the curve's length to ensure better visual quality.\n * Adaptive draw works with `bezierCurveTo` and `quadraticCurveTo`.\n * @static\n * @constant\n * @memberof PIXI\n * @name GRAPHICS_CURVES\n * @type {object}\n * @property {boolean} [adaptive=true] - flag indicating if the resolution should be adaptive\n * @property {number} [maxLength=10] - maximal length of a single segment of the curve (if adaptive = false, ignored)\n * @property {number} [minSegments=8] - minimal number of segments in the curve (if adaptive = false, ignored)\n * @property {number} [maxSegments=2048] - maximal number of segments in the curve (if adaptive = false, ignored)\n */\nvar GRAPHICS_CURVES = {\n adaptive: true,\n maxLength: 10,\n minSegments: 8,\n maxSegments: 2048,\n epsilon: 0.0001,\n _segmentsCount: function (length, defaultSegments) {\n if (defaultSegments === void 0) { defaultSegments = 20; }\n if (!this.adaptive || !length || isNaN(length)) {\n return defaultSegments;\n }\n var result = Math.ceil(length / this.maxLength);\n if (result < this.minSegments) {\n result = this.minSegments;\n }\n else if (result > this.maxSegments) {\n result = this.maxSegments;\n }\n return result;\n },\n};\n\n/**\n * Fill style object for Graphics.\n * @memberof PIXI\n */\nvar FillStyle = /** @class */ (function () {\n function FillStyle() {\n /**\n * The hex color value used when coloring the Graphics object.\n * @default 0xFFFFFF\n */\n this.color = 0xFFFFFF;\n /** The alpha value used when filling the Graphics object. */\n this.alpha = 1.0;\n /**\n * The texture to be used for the fill.\n * @default 0\n */\n this.texture = Texture.WHITE;\n /**\n * The transform applied to the texture.\n * @default null\n */\n this.matrix = null;\n /** If the current fill is visible. */\n this.visible = false;\n this.reset();\n }\n /** Clones the object */\n FillStyle.prototype.clone = function () {\n var obj = new FillStyle();\n obj.color = this.color;\n obj.alpha = this.alpha;\n obj.texture = this.texture;\n obj.matrix = this.matrix;\n obj.visible = this.visible;\n return obj;\n };\n /** Reset */\n FillStyle.prototype.reset = function () {\n this.color = 0xFFFFFF;\n this.alpha = 1;\n this.texture = Texture.WHITE;\n this.matrix = null;\n this.visible = false;\n };\n /** Destroy and don't use after this. */\n FillStyle.prototype.destroy = function () {\n this.texture = null;\n this.matrix = null;\n };\n return FillStyle;\n}());\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\nfunction fixOrientation(points, hole) {\n var _a, _b;\n if (hole === void 0) { hole = false; }\n var m = points.length;\n if (m < 6) {\n return;\n }\n var area = 0;\n for (var i = 0, x1 = points[m - 2], y1 = points[m - 1]; i < m; i += 2) {\n var x2 = points[i];\n var y2 = points[i + 1];\n area += (x2 - x1) * (y2 + y1);\n x1 = x2;\n y1 = y2;\n }\n if ((!hole && area > 0) || (hole && area <= 0)) {\n var n = m / 2;\n for (var i = n + (n % 2); i < m; i += 2) {\n var i1 = m - i - 2;\n var i2 = m - i - 1;\n var i3 = i;\n var i4 = i + 1;\n _a = [points[i3], points[i1]], points[i1] = _a[0], points[i3] = _a[1];\n _b = [points[i4], points[i2]], points[i2] = _b[0], points[i4] = _b[1];\n }\n }\n}\n/**\n * Builds a polygon to draw\n *\n * Ignored from docs since it is not directly exposed.\n * @ignore\n * @private\n * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties\n * @param {object} webGLData - an object containing all the WebGL-specific information to create this shape\n * @param {object} webGLDataNativeLines - an object containing all the WebGL-specific information to create nativeLines\n */\nvar buildPoly = {\n build: function (graphicsData) {\n graphicsData.points = graphicsData.shape.points.slice();\n },\n triangulate: function (graphicsData, graphicsGeometry) {\n var points = graphicsData.points;\n var holes = graphicsData.holes;\n var verts = graphicsGeometry.points;\n var indices = graphicsGeometry.indices;\n if (points.length >= 6) {\n fixOrientation(points, false);\n var holeArray = [];\n // Process holes..\n for (var i = 0; i < holes.length; i++) {\n var hole = holes[i];\n fixOrientation(hole.points, true);\n holeArray.push(points.length / 2);\n points = points.concat(hole.points);\n }\n // sort color\n var triangles = earcut(points, holeArray, 2);\n if (!triangles) {\n return;\n }\n var vertPos = verts.length / 2;\n for (var i = 0; i < triangles.length; i += 3) {\n indices.push(triangles[i] + vertPos);\n indices.push(triangles[i + 1] + vertPos);\n indices.push(triangles[i + 2] + vertPos);\n }\n for (var i = 0; i < points.length; i++) {\n verts.push(points[i]);\n }\n }\n },\n};\n\n// for type only\n/**\n * Builds a circle to draw\n *\n * Ignored from docs since it is not directly exposed.\n * @ignore\n * @private\n * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object to draw\n * @param {object} webGLData - an object containing all the WebGL-specific information to create this shape\n * @param {object} webGLDataNativeLines - an object containing all the WebGL-specific information to create nativeLines\n */\nvar buildCircle = {\n build: function (graphicsData) {\n // need to convert points to a nice regular data\n var points = graphicsData.points;\n var x;\n var y;\n var dx;\n var dy;\n var rx;\n var ry;\n if (graphicsData.type === SHAPES.CIRC) {\n var circle = graphicsData.shape;\n x = circle.x;\n y = circle.y;\n rx = ry = circle.radius;\n dx = dy = 0;\n }\n else if (graphicsData.type === SHAPES.ELIP) {\n var ellipse = graphicsData.shape;\n x = ellipse.x;\n y = ellipse.y;\n rx = ellipse.width;\n ry = ellipse.height;\n dx = dy = 0;\n }\n else {\n var roundedRect = graphicsData.shape;\n var halfWidth = roundedRect.width / 2;\n var halfHeight = roundedRect.height / 2;\n x = roundedRect.x + halfWidth;\n y = roundedRect.y + halfHeight;\n rx = ry = Math.max(0, Math.min(roundedRect.radius, Math.min(halfWidth, halfHeight)));\n dx = halfWidth - rx;\n dy = halfHeight - ry;\n }\n if (!(rx >= 0 && ry >= 0 && dx >= 0 && dy >= 0)) {\n points.length = 0;\n return;\n }\n // Choose a number of segments such that the maximum absolute deviation from the circle is approximately 0.029\n var n = Math.ceil(2.3 * Math.sqrt(rx + ry));\n var m = (n * 8) + (dx ? 4 : 0) + (dy ? 4 : 0);\n points.length = m;\n if (m === 0) {\n return;\n }\n if (n === 0) {\n points.length = 8;\n points[0] = points[6] = x + dx;\n points[1] = points[3] = y + dy;\n points[2] = points[4] = x - dx;\n points[5] = points[7] = y - dy;\n return;\n }\n var j1 = 0;\n var j2 = (n * 4) + (dx ? 2 : 0) + 2;\n var j3 = j2;\n var j4 = m;\n {\n var x0 = dx + rx;\n var y0 = dy;\n var x1 = x + x0;\n var x2 = x - x0;\n var y1 = y + y0;\n points[j1++] = x1;\n points[j1++] = y1;\n points[--j2] = y1;\n points[--j2] = x2;\n if (dy) {\n var y2 = y - y0;\n points[j3++] = x2;\n points[j3++] = y2;\n points[--j4] = y2;\n points[--j4] = x1;\n }\n }\n for (var i = 1; i < n; i++) {\n var a = Math.PI / 2 * (i / n);\n var x0 = dx + (Math.cos(a) * rx);\n var y0 = dy + (Math.sin(a) * ry);\n var x1 = x + x0;\n var x2 = x - x0;\n var y1 = y + y0;\n var y2 = y - y0;\n points[j1++] = x1;\n points[j1++] = y1;\n points[--j2] = y1;\n points[--j2] = x2;\n points[j3++] = x2;\n points[j3++] = y2;\n points[--j4] = y2;\n points[--j4] = x1;\n }\n {\n var x0 = dx;\n var y0 = dy + ry;\n var x1 = x + x0;\n var x2 = x - x0;\n var y1 = y + y0;\n var y2 = y - y0;\n points[j1++] = x1;\n points[j1++] = y1;\n points[--j4] = y2;\n points[--j4] = x1;\n if (dx) {\n points[j1++] = x2;\n points[j1++] = y1;\n points[--j4] = y2;\n points[--j4] = x2;\n }\n }\n },\n triangulate: function (graphicsData, graphicsGeometry) {\n var points = graphicsData.points;\n var verts = graphicsGeometry.points;\n var indices = graphicsGeometry.indices;\n if (points.length === 0) {\n return;\n }\n var vertPos = verts.length / 2;\n var center = vertPos;\n var x;\n var y;\n if (graphicsData.type !== SHAPES.RREC) {\n var circle = graphicsData.shape;\n x = circle.x;\n y = circle.y;\n }\n else {\n var roundedRect = graphicsData.shape;\n x = roundedRect.x + (roundedRect.width / 2);\n y = roundedRect.y + (roundedRect.height / 2);\n }\n var matrix = graphicsData.matrix;\n // Push center (special point)\n verts.push(graphicsData.matrix ? (matrix.a * x) + (matrix.c * y) + matrix.tx : x, graphicsData.matrix ? (matrix.b * x) + (matrix.d * y) + matrix.ty : y);\n vertPos++;\n verts.push(points[0], points[1]);\n for (var i = 2; i < points.length; i += 2) {\n verts.push(points[i], points[i + 1]);\n // add some uvs\n indices.push(vertPos++, center, vertPos);\n }\n indices.push(center + 1, center, vertPos);\n },\n};\n\n/**\n * Builds a rectangle to draw\n *\n * Ignored from docs since it is not directly exposed.\n * @ignore\n * @private\n * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties\n * @param {object} webGLData - an object containing all the WebGL-specific information to create this shape\n * @param {object} webGLDataNativeLines - an object containing all the WebGL-specific information to create nativeLines\n */\nvar buildRectangle = {\n build: function (graphicsData) {\n // --- //\n // need to convert points to a nice regular data\n //\n var rectData = graphicsData.shape;\n var x = rectData.x;\n var y = rectData.y;\n var width = rectData.width;\n var height = rectData.height;\n var points = graphicsData.points;\n points.length = 0;\n points.push(x, y, x + width, y, x + width, y + height, x, y + height);\n },\n triangulate: function (graphicsData, graphicsGeometry) {\n var points = graphicsData.points;\n var verts = graphicsGeometry.points;\n var vertPos = verts.length / 2;\n verts.push(points[0], points[1], points[2], points[3], points[6], points[7], points[4], points[5]);\n graphicsGeometry.indices.push(vertPos, vertPos + 1, vertPos + 2, vertPos + 1, vertPos + 2, vertPos + 3);\n },\n};\n\n/**\n * Calculate a single point for a quadratic bezier curve.\n * Utility function used by quadraticBezierCurve.\n * Ignored from docs since it is not directly exposed.\n * @ignore\n * @private\n * @param {number} n1 - first number\n * @param {number} n2 - second number\n * @param {number} perc - percentage\n * @returns {number} the result\n */\nfunction getPt(n1, n2, perc) {\n var diff = n2 - n1;\n return n1 + (diff * perc);\n}\n/**\n * Calculate the points for a quadratic bezier curve. (helper function..)\n * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c\n *\n * Ignored from docs since it is not directly exposed.\n * @ignore\n * @private\n * @param {number} fromX - Origin point x\n * @param {number} fromY - Origin point x\n * @param {number} cpX - Control point x\n * @param {number} cpY - Control point y\n * @param {number} toX - Destination point x\n * @param {number} toY - Destination point y\n * @param {number[]} [out=[]] - The output array to add points into. If not passed, a new array is created.\n * @returns {number[]} an array of points\n */\nfunction quadraticBezierCurve(fromX, fromY, cpX, cpY, toX, toY, out) {\n if (out === void 0) { out = []; }\n var n = 20;\n var points = out;\n var xa = 0;\n var ya = 0;\n var xb = 0;\n var yb = 0;\n var x = 0;\n var y = 0;\n for (var i = 0, j = 0; i <= n; ++i) {\n j = i / n;\n // The Green Line\n xa = getPt(fromX, cpX, j);\n ya = getPt(fromY, cpY, j);\n xb = getPt(cpX, toX, j);\n yb = getPt(cpY, toY, j);\n // The Black Dot\n x = getPt(xa, xb, j);\n y = getPt(ya, yb, j);\n // Handle case when first curve points overlaps and earcut fails to triangulate\n if (i === 0 && points[points.length - 2] === x && points[points.length - 1] === y) {\n continue;\n }\n points.push(x, y);\n }\n return points;\n}\n/**\n * Builds a rounded rectangle to draw\n *\n * Ignored from docs since it is not directly exposed.\n * @ignore\n * @private\n * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties\n * @param {object} webGLData - an object containing all the WebGL-specific information to create this shape\n * @param {object} webGLDataNativeLines - an object containing all the WebGL-specific information to create nativeLines\n */\nvar buildRoundedRectangle = {\n build: function (graphicsData) {\n if (Graphics.nextRoundedRectBehavior) {\n buildCircle.build(graphicsData);\n return;\n }\n var rrectData = graphicsData.shape;\n var points = graphicsData.points;\n var x = rrectData.x;\n var y = rrectData.y;\n var width = rrectData.width;\n var height = rrectData.height;\n // Don't allow negative radius or greater than half the smallest width\n var radius = Math.max(0, Math.min(rrectData.radius, Math.min(width, height) / 2));\n points.length = 0;\n // No radius, do a simple rectangle\n if (!radius) {\n points.push(x, y, x + width, y, x + width, y + height, x, y + height);\n }\n else {\n quadraticBezierCurve(x, y + radius, x, y, x + radius, y, points);\n quadraticBezierCurve(x + width - radius, y, x + width, y, x + width, y + radius, points);\n quadraticBezierCurve(x + width, y + height - radius, x + width, y + height, x + width - radius, y + height, points);\n quadraticBezierCurve(x + radius, y + height, x, y + height, x, y + height - radius, points);\n }\n },\n triangulate: function (graphicsData, graphicsGeometry) {\n if (Graphics.nextRoundedRectBehavior) {\n buildCircle.triangulate(graphicsData, graphicsGeometry);\n return;\n }\n var points = graphicsData.points;\n var verts = graphicsGeometry.points;\n var indices = graphicsGeometry.indices;\n var vecPos = verts.length / 2;\n var triangles = earcut(points, null, 2);\n for (var i = 0, j = triangles.length; i < j; i += 3) {\n indices.push(triangles[i] + vecPos);\n // indices.push(triangles[i] + vecPos);\n indices.push(triangles[i + 1] + vecPos);\n // indices.push(triangles[i + 2] + vecPos);\n indices.push(triangles[i + 2] + vecPos);\n }\n for (var i = 0, j = points.length; i < j; i++) {\n verts.push(points[i], points[++i]);\n }\n },\n};\n\n/**\n * Buffers vertices to draw a square cap.\n *\n * Ignored from docs since it is not directly exposed.\n * @ignore\n * @private\n * @param {number} x - X-coord of end point\n * @param {number} y - Y-coord of end point\n * @param {number} nx - X-coord of line normal pointing inside\n * @param {number} ny - Y-coord of line normal pointing inside\n * @param {number} innerWeight - Weight of inner points\n * @param {number} outerWeight - Weight of outer points\n * @param {boolean} clockwise - Whether the cap is drawn clockwise\n * @param {Array} verts - vertex buffer\n * @returns {number} - no. of vertices pushed\n */\nfunction square(x, y, nx, ny, innerWeight, outerWeight, clockwise, /* rotation for square (true at left end, false at right end) */ verts) {\n var ix = x - (nx * innerWeight);\n var iy = y - (ny * innerWeight);\n var ox = x + (nx * outerWeight);\n var oy = y + (ny * outerWeight);\n /* Rotate nx,ny for extension vector */\n var exx;\n var eyy;\n if (clockwise) {\n exx = ny;\n eyy = -nx;\n }\n else {\n exx = -ny;\n eyy = nx;\n }\n /* [i|0]x,y extended at cap */\n var eix = ix + exx;\n var eiy = iy + eyy;\n var eox = ox + exx;\n var eoy = oy + eyy;\n /* Square itself must be inserted clockwise*/\n verts.push(eix, eiy);\n verts.push(eox, eoy);\n return 2;\n}\n/**\n * Buffers vertices to draw an arc at the line joint or cap.\n *\n * Ignored from docs since it is not directly exposed.\n * @ignore\n * @private\n * @param {number} cx - X-coord of center\n * @param {number} cy - Y-coord of center\n * @param {number} sx - X-coord of arc start\n * @param {number} sy - Y-coord of arc start\n * @param {number} ex - X-coord of arc end\n * @param {number} ey - Y-coord of arc end\n * @param {Array} verts - buffer of vertices\n * @param {boolean} clockwise - orientation of vertices\n * @returns {number} - no. of vertices pushed\n */\nfunction round(cx, cy, sx, sy, ex, ey, verts, clockwise) {\n var cx2p0x = sx - cx;\n var cy2p0y = sy - cy;\n var angle0 = Math.atan2(cx2p0x, cy2p0y);\n var angle1 = Math.atan2(ex - cx, ey - cy);\n if (clockwise && angle0 < angle1) {\n angle0 += Math.PI * 2;\n }\n else if (!clockwise && angle0 > angle1) {\n angle1 += Math.PI * 2;\n }\n var startAngle = angle0;\n var angleDiff = angle1 - angle0;\n var absAngleDiff = Math.abs(angleDiff);\n /* if (absAngleDiff >= PI_LBOUND && absAngleDiff <= PI_UBOUND)\n {\n const r1x = cx - nxtPx;\n const r1y = cy - nxtPy;\n\n if (r1x === 0)\n {\n if (r1y > 0)\n {\n angleDiff = -angleDiff;\n }\n }\n else if (r1x >= -GRAPHICS_CURVES.epsilon)\n {\n angleDiff = -angleDiff;\n }\n }*/\n var radius = Math.sqrt((cx2p0x * cx2p0x) + (cy2p0y * cy2p0y));\n var segCount = ((15 * absAngleDiff * Math.sqrt(radius) / Math.PI) >> 0) + 1;\n var angleInc = angleDiff / segCount;\n startAngle += angleInc;\n if (clockwise) {\n verts.push(cx, cy);\n verts.push(sx, sy);\n for (var i = 1, angle = startAngle; i < segCount; i++, angle += angleInc) {\n verts.push(cx, cy);\n verts.push(cx + ((Math.sin(angle) * radius)), cy + ((Math.cos(angle) * radius)));\n }\n verts.push(cx, cy);\n verts.push(ex, ey);\n }\n else {\n verts.push(sx, sy);\n verts.push(cx, cy);\n for (var i = 1, angle = startAngle; i < segCount; i++, angle += angleInc) {\n verts.push(cx + ((Math.sin(angle) * radius)), cy + ((Math.cos(angle) * radius)));\n verts.push(cx, cy);\n }\n verts.push(ex, ey);\n verts.push(cx, cy);\n }\n return segCount * 2;\n}\n/**\n * Builds a line to draw using the polygon method.\n *\n * Ignored from docs since it is not directly exposed.\n * @ignore\n * @private\n * @param {PIXI.GraphicsData} graphicsData - The graphics object containing all the necessary properties\n * @param {PIXI.GraphicsGeometry} graphicsGeometry - Geometry where to append output\n */\nfunction buildNonNativeLine(graphicsData, graphicsGeometry) {\n var shape = graphicsData.shape;\n var points = graphicsData.points || shape.points.slice();\n var eps = graphicsGeometry.closePointEps;\n if (points.length === 0) {\n return;\n }\n // if the line width is an odd number add 0.5 to align to a whole pixel\n // commenting this out fixes #711 and #1620\n // if (graphicsData.lineWidth%2)\n // {\n // for (i = 0; i < points.length; i++)\n // {\n // points[i] += 0.5;\n // }\n // }\n var style = graphicsData.lineStyle;\n // get first and last point.. figure out the middle!\n var firstPoint = new Point(points[0], points[1]);\n var lastPoint = new Point(points[points.length - 2], points[points.length - 1]);\n var closedShape = shape.type !== SHAPES.POLY || shape.closeStroke;\n var closedPath = Math.abs(firstPoint.x - lastPoint.x) < eps\n && Math.abs(firstPoint.y - lastPoint.y) < eps;\n // if the first point is the last point - gonna have issues :)\n if (closedShape) {\n // need to clone as we are going to slightly modify the shape..\n points = points.slice();\n if (closedPath) {\n points.pop();\n points.pop();\n lastPoint.set(points[points.length - 2], points[points.length - 1]);\n }\n var midPointX = (firstPoint.x + lastPoint.x) * 0.5;\n var midPointY = (lastPoint.y + firstPoint.y) * 0.5;\n points.unshift(midPointX, midPointY);\n points.push(midPointX, midPointY);\n }\n var verts = graphicsGeometry.points;\n var length = points.length / 2;\n var indexCount = points.length;\n var indexStart = verts.length / 2;\n // Max. inner and outer width\n var width = style.width / 2;\n var widthSquared = width * width;\n var miterLimitSquared = style.miterLimit * style.miterLimit;\n /* Line segments of interest where (x1,y1) forms the corner. */\n var x0 = points[0];\n var y0 = points[1];\n var x1 = points[2];\n var y1 = points[3];\n var x2 = 0;\n var y2 = 0;\n /* perp[?](x|y) = the line normal with magnitude lineWidth. */\n var perpx = -(y0 - y1);\n var perpy = x0 - x1;\n var perp1x = 0;\n var perp1y = 0;\n var dist = Math.sqrt((perpx * perpx) + (perpy * perpy));\n perpx /= dist;\n perpy /= dist;\n perpx *= width;\n perpy *= width;\n var ratio = style.alignment; // 0.5;\n var innerWeight = (1 - ratio) * 2;\n var outerWeight = ratio * 2;\n if (!closedShape) {\n if (style.cap === LINE_CAP.ROUND) {\n indexCount += round(x0 - (perpx * (innerWeight - outerWeight) * 0.5), y0 - (perpy * (innerWeight - outerWeight) * 0.5), x0 - (perpx * innerWeight), y0 - (perpy * innerWeight), x0 + (perpx * outerWeight), y0 + (perpy * outerWeight), verts, true) + 2;\n }\n else if (style.cap === LINE_CAP.SQUARE) {\n indexCount += square(x0, y0, perpx, perpy, innerWeight, outerWeight, true, verts);\n }\n }\n // Push first point (below & above vertices)\n verts.push(x0 - (perpx * innerWeight), y0 - (perpy * innerWeight));\n verts.push(x0 + (perpx * outerWeight), y0 + (perpy * outerWeight));\n for (var i = 1; i < length - 1; ++i) {\n x0 = points[(i - 1) * 2];\n y0 = points[((i - 1) * 2) + 1];\n x1 = points[i * 2];\n y1 = points[(i * 2) + 1];\n x2 = points[(i + 1) * 2];\n y2 = points[((i + 1) * 2) + 1];\n perpx = -(y0 - y1);\n perpy = x0 - x1;\n dist = Math.sqrt((perpx * perpx) + (perpy * perpy));\n perpx /= dist;\n perpy /= dist;\n perpx *= width;\n perpy *= width;\n perp1x = -(y1 - y2);\n perp1y = x1 - x2;\n dist = Math.sqrt((perp1x * perp1x) + (perp1y * perp1y));\n perp1x /= dist;\n perp1y /= dist;\n perp1x *= width;\n perp1y *= width;\n /* d[x|y](0|1) = the component displacement between points p(0,1|1,2) */\n var dx0 = x1 - x0;\n var dy0 = y0 - y1;\n var dx1 = x1 - x2;\n var dy1 = y2 - y1;\n /* +ve if internal angle < 90 degree, -ve if internal angle > 90 degree. */\n var dot = (dx0 * dx1) + (dy0 * dy1);\n /* +ve if internal angle counterclockwise, -ve if internal angle clockwise. */\n var cross = (dy0 * dx1) - (dy1 * dx0);\n var clockwise = (cross < 0);\n /* Going nearly parallel? */\n /* atan(0.001) ~= 0.001 rad ~= 0.057 degree */\n if (Math.abs(cross) < 0.001 * Math.abs(dot)) {\n verts.push(x1 - (perpx * innerWeight), y1 - (perpy * innerWeight));\n verts.push(x1 + (perpx * outerWeight), y1 + (perpy * outerWeight));\n /* 180 degree corner? */\n if (dot >= 0) {\n if (style.join === LINE_JOIN.ROUND) {\n indexCount += round(x1, y1, x1 - (perpx * innerWeight), y1 - (perpy * innerWeight), x1 - (perp1x * innerWeight), y1 - (perp1y * innerWeight), verts, false) + 4;\n }\n else {\n indexCount += 2;\n }\n verts.push(x1 - (perp1x * outerWeight), y1 - (perp1y * outerWeight));\n verts.push(x1 + (perp1x * innerWeight), y1 + (perp1y * innerWeight));\n }\n continue;\n }\n /* p[x|y] is the miter point. pdist is the distance between miter point and p1. */\n var c1 = ((-perpx + x0) * (-perpy + y1)) - ((-perpx + x1) * (-perpy + y0));\n var c2 = ((-perp1x + x2) * (-perp1y + y1)) - ((-perp1x + x1) * (-perp1y + y2));\n var px = ((dx0 * c2) - (dx1 * c1)) / cross;\n var py = ((dy1 * c1) - (dy0 * c2)) / cross;\n var pdist = ((px - x1) * (px - x1)) + ((py - y1) * (py - y1));\n /* Inner miter point */\n var imx = x1 + ((px - x1) * innerWeight);\n var imy = y1 + ((py - y1) * innerWeight);\n /* Outer miter point */\n var omx = x1 - ((px - x1) * outerWeight);\n var omy = y1 - ((py - y1) * outerWeight);\n /* Is the inside miter point too far away, creating a spike? */\n var smallerInsideSegmentSq = Math.min((dx0 * dx0) + (dy0 * dy0), (dx1 * dx1) + (dy1 * dy1));\n var insideWeight = clockwise ? innerWeight : outerWeight;\n var smallerInsideDiagonalSq = smallerInsideSegmentSq + (insideWeight * insideWeight * widthSquared);\n var insideMiterOk = pdist <= smallerInsideDiagonalSq;\n if (insideMiterOk) {\n if (style.join === LINE_JOIN.BEVEL || pdist / widthSquared > miterLimitSquared) {\n if (clockwise) /* rotating at inner angle */ {\n verts.push(imx, imy); // inner miter point\n verts.push(x1 + (perpx * outerWeight), y1 + (perpy * outerWeight)); // first segment's outer vertex\n verts.push(imx, imy); // inner miter point\n verts.push(x1 + (perp1x * outerWeight), y1 + (perp1y * outerWeight)); // second segment's outer vertex\n }\n else /* rotating at outer angle */ {\n verts.push(x1 - (perpx * innerWeight), y1 - (perpy * innerWeight)); // first segment's inner vertex\n verts.push(omx, omy); // outer miter point\n verts.push(x1 - (perp1x * innerWeight), y1 - (perp1y * innerWeight)); // second segment's outer vertex\n verts.push(omx, omy); // outer miter point\n }\n indexCount += 2;\n }\n else if (style.join === LINE_JOIN.ROUND) {\n if (clockwise) /* arc is outside */ {\n verts.push(imx, imy);\n verts.push(x1 + (perpx * outerWeight), y1 + (perpy * outerWeight));\n indexCount += round(x1, y1, x1 + (perpx * outerWeight), y1 + (perpy * outerWeight), x1 + (perp1x * outerWeight), y1 + (perp1y * outerWeight), verts, true) + 4;\n verts.push(imx, imy);\n verts.push(x1 + (perp1x * outerWeight), y1 + (perp1y * outerWeight));\n }\n else /* arc is inside */ {\n verts.push(x1 - (perpx * innerWeight), y1 - (perpy * innerWeight));\n verts.push(omx, omy);\n indexCount += round(x1, y1, x1 - (perpx * innerWeight), y1 - (perpy * innerWeight), x1 - (perp1x * innerWeight), y1 - (perp1y * innerWeight), verts, false) + 4;\n verts.push(x1 - (perp1x * innerWeight), y1 - (perp1y * innerWeight));\n verts.push(omx, omy);\n }\n }\n else {\n verts.push(imx, imy);\n verts.push(omx, omy);\n }\n }\n else // inside miter is NOT ok\n {\n verts.push(x1 - (perpx * innerWeight), y1 - (perpy * innerWeight)); // first segment's inner vertex\n verts.push(x1 + (perpx * outerWeight), y1 + (perpy * outerWeight)); // first segment's outer vertex\n if (style.join === LINE_JOIN.ROUND) {\n if (clockwise) /* arc is outside */ {\n indexCount += round(x1, y1, x1 + (perpx * outerWeight), y1 + (perpy * outerWeight), x1 + (perp1x * outerWeight), y1 + (perp1y * outerWeight), verts, true) + 2;\n }\n else /* arc is inside */ {\n indexCount += round(x1, y1, x1 - (perpx * innerWeight), y1 - (perpy * innerWeight), x1 - (perp1x * innerWeight), y1 - (perp1y * innerWeight), verts, false) + 2;\n }\n }\n else if (style.join === LINE_JOIN.MITER && pdist / widthSquared <= miterLimitSquared) {\n if (clockwise) {\n verts.push(omx, omy); // inner miter point\n verts.push(omx, omy); // inner miter point\n }\n else {\n verts.push(imx, imy); // outer miter point\n verts.push(imx, imy); // outer miter point\n }\n indexCount += 2;\n }\n verts.push(x1 - (perp1x * innerWeight), y1 - (perp1y * innerWeight)); // second segment's inner vertex\n verts.push(x1 + (perp1x * outerWeight), y1 + (perp1y * outerWeight)); // second segment's outer vertex\n indexCount += 2;\n }\n }\n x0 = points[(length - 2) * 2];\n y0 = points[((length - 2) * 2) + 1];\n x1 = points[(length - 1) * 2];\n y1 = points[((length - 1) * 2) + 1];\n perpx = -(y0 - y1);\n perpy = x0 - x1;\n dist = Math.sqrt((perpx * perpx) + (perpy * perpy));\n perpx /= dist;\n perpy /= dist;\n perpx *= width;\n perpy *= width;\n verts.push(x1 - (perpx * innerWeight), y1 - (perpy * innerWeight));\n verts.push(x1 + (perpx * outerWeight), y1 + (perpy * outerWeight));\n if (!closedShape) {\n if (style.cap === LINE_CAP.ROUND) {\n indexCount += round(x1 - (perpx * (innerWeight - outerWeight) * 0.5), y1 - (perpy * (innerWeight - outerWeight) * 0.5), x1 - (perpx * innerWeight), y1 - (perpy * innerWeight), x1 + (perpx * outerWeight), y1 + (perpy * outerWeight), verts, false) + 2;\n }\n else if (style.cap === LINE_CAP.SQUARE) {\n indexCount += square(x1, y1, perpx, perpy, innerWeight, outerWeight, false, verts);\n }\n }\n var indices = graphicsGeometry.indices;\n var eps2 = GRAPHICS_CURVES.epsilon * GRAPHICS_CURVES.epsilon;\n // indices.push(indexStart);\n for (var i = indexStart; i < indexCount + indexStart - 2; ++i) {\n x0 = verts[(i * 2)];\n y0 = verts[(i * 2) + 1];\n x1 = verts[(i + 1) * 2];\n y1 = verts[((i + 1) * 2) + 1];\n x2 = verts[(i + 2) * 2];\n y2 = verts[((i + 2) * 2) + 1];\n /* Skip zero area triangles */\n if (Math.abs((x0 * (y1 - y2)) + (x1 * (y2 - y0)) + (x2 * (y0 - y1))) < eps2) {\n continue;\n }\n indices.push(i, i + 1, i + 2);\n }\n}\n/**\n * Builds a line to draw using the gl.drawArrays(gl.LINES) method\n *\n * Ignored from docs since it is not directly exposed.\n * @ignore\n * @private\n * @param {PIXI.GraphicsData} graphicsData - The graphics object containing all the necessary properties\n * @param {PIXI.GraphicsGeometry} graphicsGeometry - Geometry where to append output\n */\nfunction buildNativeLine(graphicsData, graphicsGeometry) {\n var i = 0;\n var shape = graphicsData.shape;\n var points = graphicsData.points || shape.points;\n var closedShape = shape.type !== SHAPES.POLY || shape.closeStroke;\n if (points.length === 0)\n { return; }\n var verts = graphicsGeometry.points;\n var indices = graphicsGeometry.indices;\n var length = points.length / 2;\n var startIndex = verts.length / 2;\n var currentIndex = startIndex;\n verts.push(points[0], points[1]);\n for (i = 1; i < length; i++) {\n verts.push(points[i * 2], points[(i * 2) + 1]);\n indices.push(currentIndex, currentIndex + 1);\n currentIndex++;\n }\n if (closedShape) {\n indices.push(currentIndex, startIndex);\n }\n}\n/**\n * Builds a line to draw\n *\n * Ignored from docs since it is not directly exposed.\n * @ignore\n * @private\n * @param {PIXI.GraphicsData} graphicsData - The graphics object containing all the necessary properties\n * @param {PIXI.GraphicsGeometry} graphicsGeometry - Geometry where to append output\n */\nfunction buildLine(graphicsData, graphicsGeometry) {\n if (graphicsData.lineStyle.native) {\n buildNativeLine(graphicsData, graphicsGeometry);\n }\n else {\n buildNonNativeLine(graphicsData, graphicsGeometry);\n }\n}\n\n/**\n * Utilities for arc curves.\n * @private\n */\nvar ArcUtils = /** @class */ (function () {\n function ArcUtils() {\n }\n /**\n * The arcTo() method creates an arc/curve between two tangents on the canvas.\n *\n * \"borrowed\" from https://code.google.com/p/fxcanvas/ - thanks google!\n * @private\n * @param x1 - The x-coordinate of the beginning of the arc\n * @param y1 - The y-coordinate of the beginning of the arc\n * @param x2 - The x-coordinate of the end of the arc\n * @param y2 - The y-coordinate of the end of the arc\n * @param radius - The radius of the arc\n * @param points -\n * @returns - If the arc length is valid, return center of circle, radius and other info otherwise `null`.\n */\n ArcUtils.curveTo = function (x1, y1, x2, y2, radius, points) {\n var fromX = points[points.length - 2];\n var fromY = points[points.length - 1];\n var a1 = fromY - y1;\n var b1 = fromX - x1;\n var a2 = y2 - y1;\n var b2 = x2 - x1;\n var mm = Math.abs((a1 * b2) - (b1 * a2));\n if (mm < 1.0e-8 || radius === 0) {\n if (points[points.length - 2] !== x1 || points[points.length - 1] !== y1) {\n points.push(x1, y1);\n }\n return null;\n }\n var dd = (a1 * a1) + (b1 * b1);\n var cc = (a2 * a2) + (b2 * b2);\n var tt = (a1 * a2) + (b1 * b2);\n var k1 = radius * Math.sqrt(dd) / mm;\n var k2 = radius * Math.sqrt(cc) / mm;\n var j1 = k1 * tt / dd;\n var j2 = k2 * tt / cc;\n var cx = (k1 * b2) + (k2 * b1);\n var cy = (k1 * a2) + (k2 * a1);\n var px = b1 * (k2 + j1);\n var py = a1 * (k2 + j1);\n var qx = b2 * (k1 + j2);\n var qy = a2 * (k1 + j2);\n var startAngle = Math.atan2(py - cy, px - cx);\n var endAngle = Math.atan2(qy - cy, qx - cx);\n return {\n cx: (cx + x1),\n cy: (cy + y1),\n radius: radius,\n startAngle: startAngle,\n endAngle: endAngle,\n anticlockwise: (b1 * a2 > b2 * a1),\n };\n };\n /* eslint-disable max-len */\n /**\n * The arc method creates an arc/curve (used to create circles, or parts of circles).\n * @private\n * @param _startX - Start x location of arc\n * @param _startY - Start y location of arc\n * @param cx - The x-coordinate of the center of the circle\n * @param cy - The y-coordinate of the center of the circle\n * @param radius - The radius of the circle\n * @param startAngle - The starting angle, in radians (0 is at the 3 o'clock position\n * of the arc's circle)\n * @param endAngle - The ending angle, in radians\n * @param _anticlockwise - Specifies whether the drawing should be\n * counter-clockwise or clockwise. False is default, and indicates clockwise, while true\n * indicates counter-clockwise.\n * @param points - Collection of points to add to\n */\n ArcUtils.arc = function (_startX, _startY, cx, cy, radius, startAngle, endAngle, _anticlockwise, points) {\n var sweep = endAngle - startAngle;\n var n = GRAPHICS_CURVES._segmentsCount(Math.abs(sweep) * radius, Math.ceil(Math.abs(sweep) / PI_2) * 40);\n var theta = (sweep) / (n * 2);\n var theta2 = theta * 2;\n var cTheta = Math.cos(theta);\n var sTheta = Math.sin(theta);\n var segMinus = n - 1;\n var remainder = (segMinus % 1) / segMinus;\n for (var i = 0; i <= segMinus; ++i) {\n var real = i + (remainder * i);\n var angle = ((theta) + startAngle + (theta2 * real));\n var c = Math.cos(angle);\n var s = -Math.sin(angle);\n points.push((((cTheta * c) + (sTheta * s)) * radius) + cx, (((cTheta * -s) + (sTheta * c)) * radius) + cy);\n }\n };\n return ArcUtils;\n}());\n\n/**\n * Utilities for bezier curves\n * @private\n */\nvar BezierUtils = /** @class */ (function () {\n function BezierUtils() {\n }\n /**\n * Calculate length of bezier curve.\n * Analytical solution is impossible, since it involves an integral that does not integrate in general.\n * Therefore numerical solution is used.\n * @private\n * @param fromX - Starting point x\n * @param fromY - Starting point y\n * @param cpX - Control point x\n * @param cpY - Control point y\n * @param cpX2 - Second Control point x\n * @param cpY2 - Second Control point y\n * @param toX - Destination point x\n * @param toY - Destination point y\n * @returns - Length of bezier curve\n */\n BezierUtils.curveLength = function (fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY) {\n var n = 10;\n var result = 0.0;\n var t = 0.0;\n var t2 = 0.0;\n var t3 = 0.0;\n var nt = 0.0;\n var nt2 = 0.0;\n var nt3 = 0.0;\n var x = 0.0;\n var y = 0.0;\n var dx = 0.0;\n var dy = 0.0;\n var prevX = fromX;\n var prevY = fromY;\n for (var i = 1; i <= n; ++i) {\n t = i / n;\n t2 = t * t;\n t3 = t2 * t;\n nt = (1.0 - t);\n nt2 = nt * nt;\n nt3 = nt2 * nt;\n x = (nt3 * fromX) + (3.0 * nt2 * t * cpX) + (3.0 * nt * t2 * cpX2) + (t3 * toX);\n y = (nt3 * fromY) + (3.0 * nt2 * t * cpY) + (3 * nt * t2 * cpY2) + (t3 * toY);\n dx = prevX - x;\n dy = prevY - y;\n prevX = x;\n prevY = y;\n result += Math.sqrt((dx * dx) + (dy * dy));\n }\n return result;\n };\n /**\n * Calculate the points for a bezier curve and then draws it.\n *\n * Ignored from docs since it is not directly exposed.\n * @ignore\n * @param cpX - Control point x\n * @param cpY - Control point y\n * @param cpX2 - Second Control point x\n * @param cpY2 - Second Control point y\n * @param toX - Destination point x\n * @param toY - Destination point y\n * @param points - Path array to push points into\n */\n BezierUtils.curveTo = function (cpX, cpY, cpX2, cpY2, toX, toY, points) {\n var fromX = points[points.length - 2];\n var fromY = points[points.length - 1];\n points.length -= 2;\n var n = GRAPHICS_CURVES._segmentsCount(BezierUtils.curveLength(fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY));\n var dt = 0;\n var dt2 = 0;\n var dt3 = 0;\n var t2 = 0;\n var t3 = 0;\n points.push(fromX, fromY);\n for (var i = 1, j = 0; i <= n; ++i) {\n j = i / n;\n dt = (1 - j);\n dt2 = dt * dt;\n dt3 = dt2 * dt;\n t2 = j * j;\n t3 = t2 * j;\n 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));\n }\n };\n return BezierUtils;\n}());\n\n/**\n * Utilities for quadratic curves.\n * @private\n */\nvar QuadraticUtils = /** @class */ (function () {\n function QuadraticUtils() {\n }\n /**\n * Calculate length of quadratic curve\n * @see {@link http://www.malczak.linuxpl.com/blog/quadratic-bezier-curve-length/}\n * for the detailed explanation of math behind this.\n * @private\n * @param fromX - x-coordinate of curve start point\n * @param fromY - y-coordinate of curve start point\n * @param cpX - x-coordinate of curve control point\n * @param cpY - y-coordinate of curve control point\n * @param toX - x-coordinate of curve end point\n * @param toY - y-coordinate of curve end point\n * @returns - Length of quadratic curve\n */\n QuadraticUtils.curveLength = function (fromX, fromY, cpX, cpY, toX, toY) {\n var ax = fromX - (2.0 * cpX) + toX;\n var ay = fromY - (2.0 * cpY) + toY;\n var bx = (2.0 * cpX) - (2.0 * fromX);\n var by = (2.0 * cpY) - (2.0 * fromY);\n var a = 4.0 * ((ax * ax) + (ay * ay));\n var b = 4.0 * ((ax * bx) + (ay * by));\n var c = (bx * bx) + (by * by);\n var s = 2.0 * Math.sqrt(a + b + c);\n var a2 = Math.sqrt(a);\n var a32 = 2.0 * a * a2;\n var c2 = 2.0 * Math.sqrt(c);\n var ba = b / a2;\n return ((a32 * s)\n + (a2 * b * (s - c2))\n + (((4.0 * c * a) - (b * b))\n * Math.log(((2.0 * a2) + ba + s) / (ba + c2)))) / (4.0 * a32);\n };\n /**\n * Calculate the points for a quadratic bezier curve and then draws it.\n * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c\n * @private\n * @param cpX - Control point x\n * @param cpY - Control point y\n * @param toX - Destination point x\n * @param toY - Destination point y\n * @param points - Points to add segments to.\n */\n QuadraticUtils.curveTo = function (cpX, cpY, toX, toY, points) {\n var fromX = points[points.length - 2];\n var fromY = points[points.length - 1];\n var n = GRAPHICS_CURVES._segmentsCount(QuadraticUtils.curveLength(fromX, fromY, cpX, cpY, toX, toY));\n var xa = 0;\n var ya = 0;\n for (var i = 1; i <= n; ++i) {\n var j = i / n;\n xa = fromX + ((cpX - fromX) * j);\n ya = fromY + ((cpY - fromY) * j);\n points.push(xa + (((cpX + ((toX - cpX) * j)) - xa) * j), ya + (((cpY + ((toY - cpY) * j)) - ya) * j));\n }\n };\n return QuadraticUtils;\n}());\n\n/**\n * A structure to hold interim batch objects for Graphics.\n * @memberof PIXI.graphicsUtils\n */\nvar BatchPart = /** @class */ (function () {\n function BatchPart() {\n this.reset();\n }\n /**\n * Begin batch part.\n * @param style\n * @param startIndex\n * @param attribStart\n */\n BatchPart.prototype.begin = function (style, startIndex, attribStart) {\n this.reset();\n this.style = style;\n this.start = startIndex;\n this.attribStart = attribStart;\n };\n /**\n * End batch part.\n * @param endIndex\n * @param endAttrib\n */\n BatchPart.prototype.end = function (endIndex, endAttrib) {\n this.attribSize = endAttrib - this.attribStart;\n this.size = endIndex - this.start;\n };\n BatchPart.prototype.reset = function () {\n this.style = null;\n this.size = 0;\n this.start = 0;\n this.attribStart = 0;\n this.attribSize = 0;\n };\n return BatchPart;\n}());\n\n/**\n * Generalized convenience utilities for Graphics.\n * @namespace graphicsUtils\n * @memberof PIXI\n */\nvar _a;\n/**\n * Map of fill commands for each shape type.\n * @memberof PIXI.graphicsUtils\n * @member {object} FILL_COMMANDS\n */\nvar FILL_COMMANDS = (_a = {},\n _a[SHAPES.POLY] = buildPoly,\n _a[SHAPES.CIRC] = buildCircle,\n _a[SHAPES.ELIP] = buildCircle,\n _a[SHAPES.RECT] = buildRectangle,\n _a[SHAPES.RREC] = buildRoundedRectangle,\n _a);\n/**\n * Batch pool, stores unused batches for preventing allocations.\n * @memberof PIXI.graphicsUtils\n * @member {Array} BATCH_POOL\n */\nvar BATCH_POOL = [];\n/**\n * Draw call pool, stores unused draw calls for preventing allocations.\n * @memberof PIXI.graphicsUtils\n * @member {Array} DRAW_CALL_POOL\n */\nvar DRAW_CALL_POOL = [];\n\n/**\n * A class to contain data useful for Graphics objects\n * @memberof PIXI\n */\nvar GraphicsData = /** @class */ (function () {\n /**\n * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - The shape object to draw.\n * @param fillStyle - the width of the line to draw\n * @param lineStyle - the color of the line to draw\n * @param matrix - Transform matrix\n */\n function GraphicsData(shape, fillStyle, lineStyle, matrix) {\n if (fillStyle === void 0) { fillStyle = null; }\n if (lineStyle === void 0) { lineStyle = null; }\n if (matrix === void 0) { matrix = null; }\n /** The collection of points. */\n this.points = [];\n /** The collection of holes. */\n this.holes = [];\n this.shape = shape;\n this.lineStyle = lineStyle;\n this.fillStyle = fillStyle;\n this.matrix = matrix;\n this.type = shape.type;\n }\n /**\n * Creates a new GraphicsData object with the same values as this one.\n * @returns - Cloned GraphicsData object\n */\n GraphicsData.prototype.clone = function () {\n return new GraphicsData(this.shape, this.fillStyle, this.lineStyle, this.matrix);\n };\n /** Destroys the Graphics data. */\n GraphicsData.prototype.destroy = function () {\n this.shape = null;\n this.holes.length = 0;\n this.holes = null;\n this.points.length = 0;\n this.points = null;\n this.lineStyle = null;\n this.fillStyle = null;\n };\n return GraphicsData;\n}());\n\nvar tmpPoint = new Point();\n/**\n * The Graphics class contains methods used to draw primitive shapes such as lines, circles and\n * rectangles to the display, and to color and fill them.\n *\n * GraphicsGeometry is designed to not be continually updating the geometry since it's expensive\n * to re-tesselate using **earcut**. Consider using {@link PIXI.Mesh} for this use-case, it's much faster.\n * @memberof PIXI\n */\nvar GraphicsGeometry = /** @class */ (function (_super) {\n __extends(GraphicsGeometry, _super);\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n function GraphicsGeometry() {\n var _this = _super.call(this) || this;\n /** Minimal distance between points that are considered different. Affects line tesselation. */\n _this.closePointEps = 1e-4;\n /** Padding to add to the bounds. */\n _this.boundsPadding = 0;\n _this.uvsFloat32 = null;\n _this.indicesUint16 = null;\n _this.batchable = false;\n /** An array of points to draw, 2 numbers per point */\n _this.points = [];\n /** The collection of colors */\n _this.colors = [];\n /** The UVs collection */\n _this.uvs = [];\n /** The indices of the vertices */\n _this.indices = [];\n /** Reference to the texture IDs. */\n _this.textureIds = [];\n /**\n * The collection of drawn shapes.\n * @member {PIXI.GraphicsData[]}\n */\n _this.graphicsData = [];\n /**\n * List of current draw calls drived from the batches.\n * @member {PIXI.BatchDrawCall[]}\n */\n _this.drawCalls = [];\n /** Batches need to regenerated if the geometry is updated. */\n _this.batchDirty = -1;\n /**\n * Intermediate abstract format sent to batch system.\n * Can be converted to drawCalls or to batchable objects.\n * @member {PIXI.graphicsUtils.BatchPart[]}\n */\n _this.batches = [];\n /** Used to detect if the graphics object has changed. */\n _this.dirty = 0;\n /** Used to check if the cache is dirty. */\n _this.cacheDirty = -1;\n /** Used to detect if we cleared the graphicsData. */\n _this.clearDirty = 0;\n /** Index of the last batched shape in the stack of calls. */\n _this.shapeIndex = 0;\n /** Cached bounds. */\n _this._bounds = new Bounds();\n /** The bounds dirty flag. */\n _this.boundsDirty = -1;\n return _this;\n }\n Object.defineProperty(GraphicsGeometry.prototype, \"bounds\", {\n /**\n * Get the current bounds of the graphic geometry.\n * @readonly\n */\n get: function () {\n this.updateBatches();\n if (this.boundsDirty !== this.dirty) {\n this.boundsDirty = this.dirty;\n this.calculateBounds();\n }\n return this._bounds;\n },\n enumerable: false,\n configurable: true\n });\n /** Call if you changed graphicsData manually. Empties all batch buffers. */\n GraphicsGeometry.prototype.invalidate = function () {\n this.boundsDirty = -1;\n this.dirty++;\n this.batchDirty++;\n this.shapeIndex = 0;\n this.points.length = 0;\n this.colors.length = 0;\n this.uvs.length = 0;\n this.indices.length = 0;\n this.textureIds.length = 0;\n for (var i = 0; i < this.drawCalls.length; i++) {\n this.drawCalls[i].texArray.clear();\n DRAW_CALL_POOL.push(this.drawCalls[i]);\n }\n this.drawCalls.length = 0;\n for (var i = 0; i < this.batches.length; i++) {\n var batchPart = this.batches[i];\n batchPart.reset();\n BATCH_POOL.push(batchPart);\n }\n this.batches.length = 0;\n };\n /**\n * Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings.\n * @returns - This GraphicsGeometry object. Good for chaining method calls\n */\n GraphicsGeometry.prototype.clear = function () {\n if (this.graphicsData.length > 0) {\n this.invalidate();\n this.clearDirty++;\n this.graphicsData.length = 0;\n }\n return this;\n };\n /**\n * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon.\n * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - The shape object to draw.\n * @param fillStyle - Defines style of the fill.\n * @param lineStyle - Defines style of the lines.\n * @param matrix - Transform applied to the points of the shape.\n * @returns - Returns geometry for chaining.\n */\n GraphicsGeometry.prototype.drawShape = function (shape, fillStyle, lineStyle, matrix) {\n if (fillStyle === void 0) { fillStyle = null; }\n if (lineStyle === void 0) { lineStyle = null; }\n if (matrix === void 0) { matrix = null; }\n var data = new GraphicsData(shape, fillStyle, lineStyle, matrix);\n this.graphicsData.push(data);\n this.dirty++;\n return this;\n };\n /**\n * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon.\n * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - The shape object to draw.\n * @param matrix - Transform applied to the points of the shape.\n * @returns - Returns geometry for chaining.\n */\n GraphicsGeometry.prototype.drawHole = function (shape, matrix) {\n if (matrix === void 0) { matrix = null; }\n if (!this.graphicsData.length) {\n return null;\n }\n var data = new GraphicsData(shape, null, null, matrix);\n var lastShape = this.graphicsData[this.graphicsData.length - 1];\n data.lineStyle = lastShape.lineStyle;\n lastShape.holes.push(data);\n this.dirty++;\n return this;\n };\n /** Destroys the GraphicsGeometry object. */\n GraphicsGeometry.prototype.destroy = function () {\n _super.prototype.destroy.call(this);\n // destroy each of the GraphicsData objects\n for (var i = 0; i < this.graphicsData.length; ++i) {\n this.graphicsData[i].destroy();\n }\n this.points.length = 0;\n this.points = null;\n this.colors.length = 0;\n this.colors = null;\n this.uvs.length = 0;\n this.uvs = null;\n this.indices.length = 0;\n this.indices = null;\n this.indexBuffer.destroy();\n this.indexBuffer = null;\n this.graphicsData.length = 0;\n this.graphicsData = null;\n this.drawCalls.length = 0;\n this.drawCalls = null;\n this.batches.length = 0;\n this.batches = null;\n this._bounds = null;\n };\n /**\n * Check to see if a point is contained within this geometry.\n * @param point - Point to check if it's contained.\n * @returns {boolean} `true` if the point is contained within geometry.\n */\n GraphicsGeometry.prototype.containsPoint = function (point) {\n var graphicsData = this.graphicsData;\n for (var i = 0; i < graphicsData.length; ++i) {\n var data = graphicsData[i];\n if (!data.fillStyle.visible) {\n continue;\n }\n // only deal with fills..\n if (data.shape) {\n if (data.matrix) {\n data.matrix.applyInverse(point, tmpPoint);\n }\n else {\n tmpPoint.copyFrom(point);\n }\n if (data.shape.contains(tmpPoint.x, tmpPoint.y)) {\n var hitHole = false;\n if (data.holes) {\n for (var i_1 = 0; i_1 < data.holes.length; i_1++) {\n var hole = data.holes[i_1];\n if (hole.shape.contains(tmpPoint.x, tmpPoint.y)) {\n hitHole = true;\n break;\n }\n }\n }\n if (!hitHole) {\n return true;\n }\n }\n }\n }\n return false;\n };\n /**\n * Generates intermediate batch data. Either gets converted to drawCalls\n * or used to convert to batch objects directly by the Graphics object.\n */\n GraphicsGeometry.prototype.updateBatches = function () {\n if (!this.graphicsData.length) {\n this.batchable = true;\n return;\n }\n if (!this.validateBatching()) {\n return;\n }\n this.cacheDirty = this.dirty;\n var uvs = this.uvs;\n var graphicsData = this.graphicsData;\n var batchPart = null;\n var currentStyle = null;\n if (this.batches.length > 0) {\n batchPart = this.batches[this.batches.length - 1];\n currentStyle = batchPart.style;\n }\n for (var i = this.shapeIndex; i < graphicsData.length; i++) {\n this.shapeIndex++;\n var data = graphicsData[i];\n var fillStyle = data.fillStyle;\n var lineStyle = data.lineStyle;\n var command = FILL_COMMANDS[data.type];\n // build out the shapes points..\n command.build(data);\n if (data.matrix) {\n this.transformPoints(data.points, data.matrix);\n }\n if (fillStyle.visible || lineStyle.visible) {\n this.processHoles(data.holes);\n }\n for (var j = 0; j < 2; j++) {\n var style = (j === 0) ? fillStyle : lineStyle;\n if (!style.visible)\n { continue; }\n var nextTexture = style.texture.baseTexture;\n var index_1 = this.indices.length;\n var attribIndex = this.points.length / 2;\n nextTexture.wrapMode = WRAP_MODES.REPEAT;\n if (j === 0) {\n this.processFill(data);\n }\n else {\n this.processLine(data);\n }\n var size = (this.points.length / 2) - attribIndex;\n if (size === 0)\n { continue; }\n // close batch if style is different\n if (batchPart && !this._compareStyles(currentStyle, style)) {\n batchPart.end(index_1, attribIndex);\n batchPart = null;\n }\n // spawn new batch if its first batch or previous was closed\n if (!batchPart) {\n batchPart = BATCH_POOL.pop() || new BatchPart();\n batchPart.begin(style, index_1, attribIndex);\n this.batches.push(batchPart);\n currentStyle = style;\n }\n this.addUvs(this.points, uvs, style.texture, attribIndex, size, style.matrix);\n }\n }\n var index = this.indices.length;\n var attrib = this.points.length / 2;\n if (batchPart) {\n batchPart.end(index, attrib);\n }\n if (this.batches.length === 0) {\n // there are no visible styles in GraphicsData\n // its possible that someone wants Graphics just for the bounds\n this.batchable = true;\n return;\n }\n var need32 = attrib > 0xffff;\n // prevent allocation when length is same as buffer\n if (this.indicesUint16 && this.indices.length === this.indicesUint16.length\n && need32 === (this.indicesUint16.BYTES_PER_ELEMENT > 2)) {\n this.indicesUint16.set(this.indices);\n }\n else {\n this.indicesUint16 = need32 ? new Uint32Array(this.indices) : new Uint16Array(this.indices);\n }\n // TODO make this a const..\n this.batchable = this.isBatchable();\n if (this.batchable) {\n this.packBatches();\n }\n else {\n this.buildDrawCalls();\n }\n };\n /**\n * Affinity check\n * @param styleA\n * @param styleB\n */\n GraphicsGeometry.prototype._compareStyles = function (styleA, styleB) {\n if (!styleA || !styleB) {\n return false;\n }\n if (styleA.texture.baseTexture !== styleB.texture.baseTexture) {\n return false;\n }\n if (styleA.color + styleA.alpha !== styleB.color + styleB.alpha) {\n return false;\n }\n if (!!styleA.native !== !!styleB.native) {\n return false;\n }\n return true;\n };\n /** Test geometry for batching process. */\n GraphicsGeometry.prototype.validateBatching = function () {\n if (this.dirty === this.cacheDirty || !this.graphicsData.length) {\n return false;\n }\n for (var i = 0, l = this.graphicsData.length; i < l; i++) {\n var data = this.graphicsData[i];\n var fill = data.fillStyle;\n var line = data.lineStyle;\n if (fill && !fill.texture.baseTexture.valid)\n { return false; }\n if (line && !line.texture.baseTexture.valid)\n { return false; }\n }\n return true;\n };\n /** Offset the indices so that it works with the batcher. */\n GraphicsGeometry.prototype.packBatches = function () {\n this.batchDirty++;\n this.uvsFloat32 = new Float32Array(this.uvs);\n var batches = this.batches;\n for (var i = 0, l = batches.length; i < l; i++) {\n var batch = batches[i];\n for (var j = 0; j < batch.size; j++) {\n var index = batch.start + j;\n this.indicesUint16[index] = this.indicesUint16[index] - batch.attribStart;\n }\n }\n };\n /**\n * Checks to see if this graphics geometry can be batched.\n * Currently it needs to be small enough and not contain any native lines.\n */\n GraphicsGeometry.prototype.isBatchable = function () {\n // prevent heavy mesh batching\n if (this.points.length > 0xffff * 2) {\n return false;\n }\n var batches = this.batches;\n for (var i = 0; i < batches.length; i++) {\n if (batches[i].style.native) {\n return false;\n }\n }\n return (this.points.length < GraphicsGeometry.BATCHABLE_SIZE * 2);\n };\n /** Converts intermediate batches data to drawCalls. */\n GraphicsGeometry.prototype.buildDrawCalls = function () {\n var TICK = ++BaseTexture._globalBatch;\n for (var i = 0; i < this.drawCalls.length; i++) {\n this.drawCalls[i].texArray.clear();\n DRAW_CALL_POOL.push(this.drawCalls[i]);\n }\n this.drawCalls.length = 0;\n var colors = this.colors;\n var textureIds = this.textureIds;\n var currentGroup = DRAW_CALL_POOL.pop();\n if (!currentGroup) {\n currentGroup = new BatchDrawCall();\n currentGroup.texArray = new BatchTextureArray();\n }\n currentGroup.texArray.count = 0;\n currentGroup.start = 0;\n currentGroup.size = 0;\n currentGroup.type = DRAW_MODES.TRIANGLES;\n var textureCount = 0;\n var currentTexture = null;\n var textureId = 0;\n var native = false;\n var drawMode = DRAW_MODES.TRIANGLES;\n var index = 0;\n this.drawCalls.push(currentGroup);\n // TODO - this can be simplified\n for (var i = 0; i < this.batches.length; i++) {\n var data = this.batches[i];\n // TODO add some full on MAX_TEXTURE CODE..\n var MAX_TEXTURES = 8;\n // Forced cast for checking `native` without errors\n var style = data.style;\n var nextTexture = style.texture.baseTexture;\n if (native !== !!style.native) {\n native = !!style.native;\n drawMode = native ? DRAW_MODES.LINES : DRAW_MODES.TRIANGLES;\n // force the batch to break!\n currentTexture = null;\n textureCount = MAX_TEXTURES;\n TICK++;\n }\n if (currentTexture !== nextTexture) {\n currentTexture = nextTexture;\n if (nextTexture._batchEnabled !== TICK) {\n if (textureCount === MAX_TEXTURES) {\n TICK++;\n textureCount = 0;\n if (currentGroup.size > 0) {\n currentGroup = DRAW_CALL_POOL.pop();\n if (!currentGroup) {\n currentGroup = new BatchDrawCall();\n currentGroup.texArray = new BatchTextureArray();\n }\n this.drawCalls.push(currentGroup);\n }\n currentGroup.start = index;\n currentGroup.size = 0;\n currentGroup.texArray.count = 0;\n currentGroup.type = drawMode;\n }\n // TODO add this to the render part..\n // Hack! Because texture has protected `touched`\n nextTexture.touched = 1; // touch;\n nextTexture._batchEnabled = TICK;\n nextTexture._batchLocation = textureCount;\n nextTexture.wrapMode = WRAP_MODES.REPEAT;\n currentGroup.texArray.elements[currentGroup.texArray.count++] = nextTexture;\n textureCount++;\n }\n }\n currentGroup.size += data.size;\n index += data.size;\n textureId = nextTexture._batchLocation;\n this.addColors(colors, style.color, style.alpha, data.attribSize, data.attribStart);\n this.addTextureIds(textureIds, textureId, data.attribSize, data.attribStart);\n }\n BaseTexture._globalBatch = TICK;\n // upload..\n // merge for now!\n this.packAttributes();\n };\n /** Packs attributes to single buffer. */\n GraphicsGeometry.prototype.packAttributes = function () {\n var verts = this.points;\n var uvs = this.uvs;\n var colors = this.colors;\n var textureIds = this.textureIds;\n // verts are 2 positions.. so we * by 3 as there are 6 properties.. then 4 cos its bytes\n var glPoints = new ArrayBuffer(verts.length * 3 * 4);\n var f32 = new Float32Array(glPoints);\n var u32 = new Uint32Array(glPoints);\n var p = 0;\n for (var i = 0; i < verts.length / 2; i++) {\n f32[p++] = verts[i * 2];\n f32[p++] = verts[(i * 2) + 1];\n f32[p++] = uvs[i * 2];\n f32[p++] = uvs[(i * 2) + 1];\n u32[p++] = colors[i];\n f32[p++] = textureIds[i];\n }\n this._buffer.update(glPoints);\n this._indexBuffer.update(this.indicesUint16);\n };\n /**\n * Process fill part of Graphics.\n * @param data\n */\n GraphicsGeometry.prototype.processFill = function (data) {\n if (data.holes.length) {\n buildPoly.triangulate(data, this);\n }\n else {\n var command = FILL_COMMANDS[data.type];\n command.triangulate(data, this);\n }\n };\n /**\n * Process line part of Graphics.\n * @param data\n */\n GraphicsGeometry.prototype.processLine = function (data) {\n buildLine(data, this);\n for (var i = 0; i < data.holes.length; i++) {\n buildLine(data.holes[i], this);\n }\n };\n /**\n * Process the holes data.\n * @param holes\n */\n GraphicsGeometry.prototype.processHoles = function (holes) {\n for (var i = 0; i < holes.length; i++) {\n var hole = holes[i];\n var command = FILL_COMMANDS[hole.type];\n command.build(hole);\n if (hole.matrix) {\n this.transformPoints(hole.points, hole.matrix);\n }\n }\n };\n /** Update the local bounds of the object. Expensive to use performance-wise. */\n GraphicsGeometry.prototype.calculateBounds = function () {\n var bounds = this._bounds;\n bounds.clear();\n bounds.addVertexData(this.points, 0, this.points.length);\n bounds.pad(this.boundsPadding, this.boundsPadding);\n };\n /**\n * Transform points using matrix.\n * @param points - Points to transform\n * @param matrix - Transform matrix\n */\n GraphicsGeometry.prototype.transformPoints = function (points, matrix) {\n for (var i = 0; i < points.length / 2; i++) {\n var x = points[(i * 2)];\n var y = points[(i * 2) + 1];\n points[(i * 2)] = (matrix.a * x) + (matrix.c * y) + matrix.tx;\n points[(i * 2) + 1] = (matrix.b * x) + (matrix.d * y) + matrix.ty;\n }\n };\n /**\n * Add colors.\n * @param colors - List of colors to add to\n * @param color - Color to add\n * @param alpha - Alpha to use\n * @param size - Number of colors to add\n * @param offset\n */\n GraphicsGeometry.prototype.addColors = function (colors, color, alpha, size, offset) {\n if (offset === void 0) { offset = 0; }\n // TODO use the premultiply bits Ivan added\n var rgb = (color >> 16) + (color & 0xff00) + ((color & 0xff) << 16);\n var rgba = premultiplyTint(rgb, alpha);\n colors.length = Math.max(colors.length, offset + size);\n for (var i = 0; i < size; i++) {\n colors[offset + i] = rgba;\n }\n };\n /**\n * Add texture id that the shader/fragment wants to use.\n * @param textureIds\n * @param id\n * @param size\n * @param offset\n */\n GraphicsGeometry.prototype.addTextureIds = function (textureIds, id, size, offset) {\n if (offset === void 0) { offset = 0; }\n textureIds.length = Math.max(textureIds.length, offset + size);\n for (var i = 0; i < size; i++) {\n textureIds[offset + i] = id;\n }\n };\n /**\n * Generates the UVs for a shape.\n * @param verts - Vertices\n * @param uvs - UVs\n * @param texture - Reference to Texture\n * @param start - Index buffer start index.\n * @param size - The size/length for index buffer.\n * @param matrix - Optional transform for all points.\n */\n GraphicsGeometry.prototype.addUvs = function (verts, uvs, texture, start, size, matrix) {\n if (matrix === void 0) { matrix = null; }\n var index = 0;\n var uvsStart = uvs.length;\n var frame = texture.frame;\n while (index < size) {\n var x = verts[(start + index) * 2];\n var y = verts[((start + index) * 2) + 1];\n if (matrix) {\n var nx = (matrix.a * x) + (matrix.c * y) + matrix.tx;\n y = (matrix.b * x) + (matrix.d * y) + matrix.ty;\n x = nx;\n }\n index++;\n uvs.push(x / frame.width, y / frame.height);\n }\n var baseTexture = texture.baseTexture;\n if (frame.width < baseTexture.width\n || frame.height < baseTexture.height) {\n this.adjustUvs(uvs, texture, uvsStart, size);\n }\n };\n /**\n * Modify uvs array according to position of texture region\n * Does not work with rotated or trimmed textures\n * @param uvs - array\n * @param texture - region\n * @param start - starting index for uvs\n * @param size - how many points to adjust\n */\n GraphicsGeometry.prototype.adjustUvs = function (uvs, texture, start, size) {\n var baseTexture = texture.baseTexture;\n var eps = 1e-6;\n var finish = start + (size * 2);\n var frame = texture.frame;\n var scaleX = frame.width / baseTexture.width;\n var scaleY = frame.height / baseTexture.height;\n var offsetX = frame.x / frame.width;\n var offsetY = frame.y / frame.height;\n var minX = Math.floor(uvs[start] + eps);\n var minY = Math.floor(uvs[start + 1] + eps);\n for (var i = start + 2; i < finish; i += 2) {\n minX = Math.min(minX, Math.floor(uvs[i] + eps));\n minY = Math.min(minY, Math.floor(uvs[i + 1] + eps));\n }\n offsetX -= minX;\n offsetY -= minY;\n for (var i = start; i < finish; i += 2) {\n uvs[i] = (uvs[i] + offsetX) * scaleX;\n uvs[i + 1] = (uvs[i + 1] + offsetY) * scaleY;\n }\n };\n /**\n * The maximum number of points to consider an object \"batchable\",\n * able to be batched by the renderer's batch system.\n\\\n */\n GraphicsGeometry.BATCHABLE_SIZE = 100;\n return GraphicsGeometry;\n}(BatchGeometry));\n\n/**\n * Represents the line style for Graphics.\n * @memberof PIXI\n */\nvar LineStyle = /** @class */ (function (_super) {\n __extends(LineStyle, _super);\n function LineStyle() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n /** The width (thickness) of any lines drawn. */\n _this.width = 0;\n /** The alignment of any lines drawn (0.5 = middle, 1 = outer, 0 = inner). WebGL only. */\n _this.alignment = 0.5;\n /** If true the lines will be draw using LINES instead of TRIANGLE_STRIP. */\n _this.native = false;\n /**\n * Line cap style.\n * @member {PIXI.LINE_CAP}\n * @default PIXI.LINE_CAP.BUTT\n */\n _this.cap = LINE_CAP.BUTT;\n /**\n * Line join style.\n * @member {PIXI.LINE_JOIN}\n * @default PIXI.LINE_JOIN.MITER\n */\n _this.join = LINE_JOIN.MITER;\n /** Miter limit. */\n _this.miterLimit = 10;\n return _this;\n }\n /** Clones the object. */\n LineStyle.prototype.clone = function () {\n var obj = new LineStyle();\n obj.color = this.color;\n obj.alpha = this.alpha;\n obj.texture = this.texture;\n obj.matrix = this.matrix;\n obj.visible = this.visible;\n obj.width = this.width;\n obj.alignment = this.alignment;\n obj.native = this.native;\n obj.cap = this.cap;\n obj.join = this.join;\n obj.miterLimit = this.miterLimit;\n return obj;\n };\n /** Reset the line style to default. */\n LineStyle.prototype.reset = function () {\n _super.prototype.reset.call(this);\n // Override default line style color\n this.color = 0x0;\n this.alignment = 0.5;\n this.width = 0;\n this.native = false;\n };\n return LineStyle;\n}(FillStyle));\n\nvar temp = new Float32Array(3);\n// a default shaders map used by graphics..\nvar DEFAULT_SHADERS = {};\n/**\n * The Graphics class is primarily used to render primitive shapes such as lines, circles and\n * rectangles to the display, and to color and fill them. However, you can also use a Graphics\n * object to build a list of primitives to use as a mask, or as a complex hitArea.\n *\n * Please note that due to legacy naming conventions, the behavior of some functions in this class\n * can be confusing. Each call to `drawRect()`, `drawPolygon()`, etc. actually stores that primitive\n * in the Geometry class's GraphicsGeometry object for later use in rendering or hit testing - the\n * functions do not directly draw anything to the screen. Similarly, the `clear()` function doesn't\n * change the screen, it simply resets the list of primitives, which can be useful if you want to\n * rebuild the contents of an existing Graphics object.\n *\n * Once a GraphicsGeometry list is built, you can re-use it in other Geometry objects as\n * an optimization, by passing it into a new Geometry object's constructor. Because of this\n * ability, it's important to call `destroy()` on Geometry objects once you are done with them, to\n * properly dereference each GraphicsGeometry and prevent memory leaks.\n * @memberof PIXI\n */\nvar Graphics = /** @class */ (function (_super) {\n __extends(Graphics, _super);\n /**\n * @param geometry - Geometry to use, if omitted will create a new GraphicsGeometry instance.\n */\n function Graphics(geometry) {\n if (geometry === void 0) { geometry = null; }\n var _this = _super.call(this) || this;\n /**\n * Represents the vertex and fragment shaders that processes the geometry and runs on the GPU.\n * Can be shared between multiple Graphics objects.\n */\n _this.shader = null;\n /** Renderer plugin for batching */\n _this.pluginName = 'batch';\n /**\n * Current path\n * @readonly\n */\n _this.currentPath = null;\n /** A collections of batches! These can be drawn by the renderer batch system. */\n _this.batches = [];\n /** Update dirty for limiting calculating tints for batches. */\n _this.batchTint = -1;\n /** Update dirty for limiting calculating batches.*/\n _this.batchDirty = -1;\n /** Copy of the object vertex data. */\n _this.vertexData = null;\n /** Current fill style. */\n _this._fillStyle = new FillStyle();\n /** Current line style. */\n _this._lineStyle = new LineStyle();\n /** Current shape transform matrix. */\n _this._matrix = null;\n /** Current hole mode is enabled. */\n _this._holeMode = false;\n /**\n * Represents the WebGL state the Graphics required to render, excludes shader and geometry. E.g.,\n * blend mode, culling, depth testing, direction of rendering triangles, backface, etc.\n */\n _this.state = State.for2d();\n _this._geometry = geometry || new GraphicsGeometry();\n _this._geometry.refCount++;\n /**\n * When cacheAsBitmap is set to true the graphics object will be rendered as if it was a sprite.\n * This is useful if your graphics element does not change often, as it will speed up the rendering\n * of the object in exchange for taking up texture memory. It is also useful if you need the graphics\n * object to be anti-aliased, because it will be rendered using canvas. This is not recommended if\n * you are constantly redrawing the graphics element.\n * @name cacheAsBitmap\n * @member {boolean}\n * @memberof PIXI.Graphics#\n * @default false\n */\n _this._transformID = -1;\n // Set default\n _this.tint = 0xFFFFFF;\n _this.blendMode = BLEND_MODES.NORMAL;\n return _this;\n }\n Object.defineProperty(Graphics.prototype, \"geometry\", {\n /**\n * Includes vertex positions, face indices, normals, colors, UVs, and\n * custom attributes within buffers, reducing the cost of passing all\n * this data to the GPU. Can be shared between multiple Mesh or Graphics objects.\n * @readonly\n */\n get: function () {\n return this._geometry;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Creates a new Graphics object with the same values as this one.\n * Note that only the geometry of the object is cloned, not its transform (position,scale,etc)\n * @returns - A clone of the graphics object\n */\n Graphics.prototype.clone = function () {\n this.finishPoly();\n return new Graphics(this._geometry);\n };\n Object.defineProperty(Graphics.prototype, \"blendMode\", {\n get: function () {\n return this.state.blendMode;\n },\n /**\n * The blend mode to be applied to the graphic shape. Apply a value of\n * `PIXI.BLEND_MODES.NORMAL` to reset the blend mode. Note that, since each\n * primitive in the GraphicsGeometry list is rendered sequentially, modes\n * such as `PIXI.BLEND_MODES.ADD` and `PIXI.BLEND_MODES.MULTIPLY` will\n * be applied per-primitive.\n * @default PIXI.BLEND_MODES.NORMAL\n */\n set: function (value) {\n this.state.blendMode = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Graphics.prototype, \"tint\", {\n /**\n * The tint applied to each graphic shape. This is a hex value. A value of\n * 0xFFFFFF will remove any tint effect.\n * @default 0xFFFFFF\n */\n get: function () {\n return this._tint;\n },\n set: function (value) {\n this._tint = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Graphics.prototype, \"fill\", {\n /**\n * The current fill style.\n * @readonly\n */\n get: function () {\n return this._fillStyle;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Graphics.prototype, \"line\", {\n /**\n * The current line style.\n * @readonly\n */\n get: function () {\n return this._lineStyle;\n },\n enumerable: false,\n configurable: true\n });\n Graphics.prototype.lineStyle = function (options, color, alpha, alignment, native) {\n if (options === void 0) { options = null; }\n if (color === void 0) { color = 0x0; }\n if (alpha === void 0) { alpha = 1; }\n if (alignment === void 0) { alignment = 0.5; }\n if (native === void 0) { native = false; }\n // Support non-object params: (width, color, alpha, alignment, native)\n if (typeof options === 'number') {\n options = { width: options, color: color, alpha: alpha, alignment: alignment, native: native };\n }\n return this.lineTextureStyle(options);\n };\n /**\n * Like line style but support texture for line fill.\n * @param [options] - Collection of options for setting line style.\n * @param {number} [options.width=0] - width of the line to draw, will update the objects stored style\n * @param {PIXI.Texture} [options.texture=PIXI.Texture.WHITE] - Texture to use\n * @param {number} [options.color=0x0] - color of the line to draw, will update the objects stored style.\n * Default 0xFFFFFF if texture present.\n * @param {number} [options.alpha=1] - alpha of the line to draw, will update the objects stored style\n * @param {PIXI.Matrix} [options.matrix=null] - Texture matrix to transform texture\n * @param {number} [options.alignment=0.5] - alignment of the line to draw, (0 = inner, 0.5 = middle, 1 = outer).\n * WebGL only.\n * @param {boolean} [options.native=false] - If true the lines will be draw using LINES instead of TRIANGLE_STRIP\n * @param {PIXI.LINE_CAP}[options.cap=PIXI.LINE_CAP.BUTT] - line cap style\n * @param {PIXI.LINE_JOIN}[options.join=PIXI.LINE_JOIN.MITER] - line join style\n * @param {number}[options.miterLimit=10] - miter limit ratio\n * @returns {PIXI.Graphics} This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.lineTextureStyle = function (options) {\n // Apply defaults\n options = Object.assign({\n width: 0,\n texture: Texture.WHITE,\n color: (options && options.texture) ? 0xFFFFFF : 0x0,\n alpha: 1,\n matrix: null,\n alignment: 0.5,\n native: false,\n cap: LINE_CAP.BUTT,\n join: LINE_JOIN.MITER,\n miterLimit: 10,\n }, options);\n if (this.currentPath) {\n this.startPoly();\n }\n var visible = options.width > 0 && options.alpha > 0;\n if (!visible) {\n this._lineStyle.reset();\n }\n else {\n if (options.matrix) {\n options.matrix = options.matrix.clone();\n options.matrix.invert();\n }\n Object.assign(this._lineStyle, { visible: visible }, options);\n }\n return this;\n };\n /**\n * Start a polygon object internally.\n * @protected\n */\n Graphics.prototype.startPoly = function () {\n if (this.currentPath) {\n var points = this.currentPath.points;\n var len = this.currentPath.points.length;\n if (len > 2) {\n this.drawShape(this.currentPath);\n this.currentPath = new Polygon();\n this.currentPath.closeStroke = false;\n this.currentPath.points.push(points[len - 2], points[len - 1]);\n }\n }\n else {\n this.currentPath = new Polygon();\n this.currentPath.closeStroke = false;\n }\n };\n /**\n * Finish the polygon object.\n * @protected\n */\n Graphics.prototype.finishPoly = function () {\n if (this.currentPath) {\n if (this.currentPath.points.length > 2) {\n this.drawShape(this.currentPath);\n this.currentPath = null;\n }\n else {\n this.currentPath.points.length = 0;\n }\n }\n };\n /**\n * Moves the current drawing position to x, y.\n * @param x - the X coordinate to move to\n * @param y - the Y coordinate to move to\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.moveTo = function (x, y) {\n this.startPoly();\n this.currentPath.points[0] = x;\n this.currentPath.points[1] = y;\n return this;\n };\n /**\n * Draws a line using the current line style from the current drawing position to (x, y);\n * The current drawing position is then set to (x, y).\n * @param x - the X coordinate to draw to\n * @param y - the Y coordinate to draw to\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.lineTo = function (x, y) {\n if (!this.currentPath) {\n this.moveTo(0, 0);\n }\n // remove duplicates..\n var points = this.currentPath.points;\n var fromX = points[points.length - 2];\n var fromY = points[points.length - 1];\n if (fromX !== x || fromY !== y) {\n points.push(x, y);\n }\n return this;\n };\n /**\n * Initialize the curve\n * @param x\n * @param y\n */\n Graphics.prototype._initCurve = function (x, y) {\n if (x === void 0) { x = 0; }\n if (y === void 0) { y = 0; }\n if (this.currentPath) {\n if (this.currentPath.points.length === 0) {\n this.currentPath.points = [x, y];\n }\n }\n else {\n this.moveTo(x, y);\n }\n };\n /**\n * Calculate the points for a quadratic bezier curve and then draws it.\n * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c\n * @param cpX - Control point x\n * @param cpY - Control point y\n * @param toX - Destination point x\n * @param toY - Destination point y\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.quadraticCurveTo = function (cpX, cpY, toX, toY) {\n this._initCurve();\n var points = this.currentPath.points;\n if (points.length === 0) {\n this.moveTo(0, 0);\n }\n QuadraticUtils.curveTo(cpX, cpY, toX, toY, points);\n return this;\n };\n /**\n * Calculate the points for a bezier curve and then draws it.\n * @param cpX - Control point x\n * @param cpY - Control point y\n * @param cpX2 - Second Control point x\n * @param cpY2 - Second Control point y\n * @param toX - Destination point x\n * @param toY - Destination point y\n * @returns This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.bezierCurveTo = function (cpX, cpY, cpX2, cpY2, toX, toY) {\n this._initCurve();\n BezierUtils.curveTo(cpX, cpY, cpX2, cpY2, toX, toY, this.currentPath.points);\n return this;\n };\n /**\n * The arcTo() method creates an arc/curve between two tangents on the canvas.\n *\n * \"borrowed\" from https://code.google.com/p/fxcanvas/ - thanks google!\n * @param x1 - The x-coordinate of the first tangent point of the arc\n * @param y1 - The y-coordinate of the first tangent point of the arc\n * @param x2 - The x-coordinate of the end of the arc\n * @param y2 - The y-coordinate of the end of the arc\n * @param radius - The radius of the arc\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.arcTo = function (x1, y1, x2, y2, radius) {\n this._initCurve(x1, y1);\n var points = this.currentPath.points;\n var result = ArcUtils.curveTo(x1, y1, x2, y2, radius, points);\n if (result) {\n var cx = result.cx, cy = result.cy, radius_1 = result.radius, startAngle = result.startAngle, endAngle = result.endAngle, anticlockwise = result.anticlockwise;\n this.arc(cx, cy, radius_1, startAngle, endAngle, anticlockwise);\n }\n return this;\n };\n /**\n * The arc method creates an arc/curve (used to create circles, or parts of circles).\n * @param cx - The x-coordinate of the center of the circle\n * @param cy - The y-coordinate of the center of the circle\n * @param radius - The radius of the circle\n * @param startAngle - The starting angle, in radians (0 is at the 3 o'clock position\n * of the arc's circle)\n * @param endAngle - The ending angle, in radians\n * @param anticlockwise - Specifies whether the drawing should be\n * counter-clockwise or clockwise. False is default, and indicates clockwise, while true\n * indicates counter-clockwise.\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.arc = function (cx, cy, radius, startAngle, endAngle, anticlockwise) {\n if (anticlockwise === void 0) { anticlockwise = false; }\n if (startAngle === endAngle) {\n return this;\n }\n if (!anticlockwise && endAngle <= startAngle) {\n endAngle += PI_2;\n }\n else if (anticlockwise && startAngle <= endAngle) {\n startAngle += PI_2;\n }\n var sweep = endAngle - startAngle;\n if (sweep === 0) {\n return this;\n }\n var startX = cx + (Math.cos(startAngle) * radius);\n var startY = cy + (Math.sin(startAngle) * radius);\n var eps = this._geometry.closePointEps;\n // If the currentPath exists, take its points. Otherwise call `moveTo` to start a path.\n var points = this.currentPath ? this.currentPath.points : null;\n if (points) {\n // TODO: make a better fix.\n // We check how far our start is from the last existing point\n var xDiff = Math.abs(points[points.length - 2] - startX);\n var yDiff = Math.abs(points[points.length - 1] - startY);\n if (xDiff < eps && yDiff < eps) ;\n else {\n points.push(startX, startY);\n }\n }\n else {\n this.moveTo(startX, startY);\n points = this.currentPath.points;\n }\n ArcUtils.arc(startX, startY, cx, cy, radius, startAngle, endAngle, anticlockwise, points);\n return this;\n };\n /**\n * Specifies a simple one-color fill that subsequent calls to other Graphics methods\n * (such as lineTo() or drawCircle()) use when drawing.\n * @param color - the color of the fill\n * @param alpha - the alpha of the fill\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.beginFill = function (color, alpha) {\n if (color === void 0) { color = 0; }\n if (alpha === void 0) { alpha = 1; }\n return this.beginTextureFill({ texture: Texture.WHITE, color: color, alpha: alpha });\n };\n /**\n * Begin the texture fill\n * @param options - Object object.\n * @param {PIXI.Texture} [options.texture=PIXI.Texture.WHITE] - Texture to fill\n * @param {number} [options.color=0xffffff] - Background to fill behind texture\n * @param {number} [options.alpha=1] - Alpha of fill\n * @param {PIXI.Matrix} [options.matrix=null] - Transform matrix\n * @returns {PIXI.Graphics} This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.beginTextureFill = function (options) {\n // Apply defaults\n options = Object.assign({\n texture: Texture.WHITE,\n color: 0xFFFFFF,\n alpha: 1,\n matrix: null,\n }, options);\n if (this.currentPath) {\n this.startPoly();\n }\n var visible = options.alpha > 0;\n if (!visible) {\n this._fillStyle.reset();\n }\n else {\n if (options.matrix) {\n options.matrix = options.matrix.clone();\n options.matrix.invert();\n }\n Object.assign(this._fillStyle, { visible: visible }, options);\n }\n return this;\n };\n /**\n * Applies a fill to the lines and shapes that were added since the last call to the beginFill() method.\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.endFill = function () {\n this.finishPoly();\n this._fillStyle.reset();\n return this;\n };\n /**\n * Draws a rectangle shape.\n * @param x - The X coord of the top-left of the rectangle\n * @param y - The Y coord of the top-left of the rectangle\n * @param width - The width of the rectangle\n * @param height - The height of the rectangle\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.drawRect = function (x, y, width, height) {\n return this.drawShape(new Rectangle(x, y, width, height));\n };\n /**\n * Draw a rectangle shape with rounded/beveled corners.\n * @param x - The X coord of the top-left of the rectangle\n * @param y - The Y coord of the top-left of the rectangle\n * @param width - The width of the rectangle\n * @param height - The height of the rectangle\n * @param radius - Radius of the rectangle corners\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.drawRoundedRect = function (x, y, width, height, radius) {\n return this.drawShape(new RoundedRectangle(x, y, width, height, radius));\n };\n /**\n * Draws a circle.\n * @param x - The X coordinate of the center of the circle\n * @param y - The Y coordinate of the center of the circle\n * @param radius - The radius of the circle\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.drawCircle = function (x, y, radius) {\n return this.drawShape(new Circle(x, y, radius));\n };\n /**\n * Draws an ellipse.\n * @param x - The X coordinate of the center of the ellipse\n * @param y - The Y coordinate of the center of the ellipse\n * @param width - The half width of the ellipse\n * @param height - The half height of the ellipse\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.drawEllipse = function (x, y, width, height) {\n return this.drawShape(new Ellipse(x, y, width, height));\n };\n /**\n * Draws a polygon using the given path.\n * @param {number[]|PIXI.IPointData[]|PIXI.Polygon} path - The path data used to construct the polygon.\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.drawPolygon = function () {\n var arguments$1 = arguments;\n\n var path = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n path[_i] = arguments$1[_i];\n }\n var points;\n var closeStroke = true; // !!this._fillStyle;\n var poly = path[0];\n // check if data has points..\n if (poly.points) {\n closeStroke = poly.closeStroke;\n points = poly.points;\n }\n else if (Array.isArray(path[0])) {\n points = path[0];\n }\n else {\n points = path;\n }\n var shape = new Polygon(points);\n shape.closeStroke = closeStroke;\n this.drawShape(shape);\n return this;\n };\n /**\n * Draw any shape.\n * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - Shape to draw\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.drawShape = function (shape) {\n if (!this._holeMode) {\n this._geometry.drawShape(shape, this._fillStyle.clone(), this._lineStyle.clone(), this._matrix);\n }\n else {\n this._geometry.drawHole(shape, this._matrix);\n }\n return this;\n };\n /**\n * Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings.\n * @returns - This Graphics object. Good for chaining method calls\n */\n Graphics.prototype.clear = function () {\n this._geometry.clear();\n this._lineStyle.reset();\n this._fillStyle.reset();\n this._boundsID++;\n this._matrix = null;\n this._holeMode = false;\n this.currentPath = null;\n return this;\n };\n /**\n * True if graphics consists of one rectangle, and thus, can be drawn like a Sprite and\n * masked with gl.scissor.\n * @returns - True if only 1 rect.\n */\n Graphics.prototype.isFastRect = function () {\n var data = this._geometry.graphicsData;\n return data.length === 1\n && data[0].shape.type === SHAPES.RECT\n && !data[0].matrix\n && !data[0].holes.length\n && !(data[0].lineStyle.visible && data[0].lineStyle.width);\n };\n /**\n * Renders the object using the WebGL renderer\n * @param renderer - The renderer\n */\n Graphics.prototype._render = function (renderer) {\n this.finishPoly();\n var geometry = this._geometry;\n // batch part..\n // batch it!\n geometry.updateBatches();\n if (geometry.batchable) {\n if (this.batchDirty !== geometry.batchDirty) {\n this._populateBatches();\n }\n this._renderBatched(renderer);\n }\n else {\n // no batching...\n renderer.batch.flush();\n this._renderDirect(renderer);\n }\n };\n /** Populating batches for rendering. */\n Graphics.prototype._populateBatches = function () {\n var geometry = this._geometry;\n var blendMode = this.blendMode;\n var len = geometry.batches.length;\n this.batchTint = -1;\n this._transformID = -1;\n this.batchDirty = geometry.batchDirty;\n this.batches.length = len;\n this.vertexData = new Float32Array(geometry.points);\n for (var i = 0; i < len; i++) {\n var gI = geometry.batches[i];\n var color = gI.style.color;\n var vertexData = new Float32Array(this.vertexData.buffer, gI.attribStart * 4 * 2, gI.attribSize * 2);\n var uvs = new Float32Array(geometry.uvsFloat32.buffer, gI.attribStart * 4 * 2, gI.attribSize * 2);\n var indices = new Uint16Array(geometry.indicesUint16.buffer, gI.start * 2, gI.size);\n var batch = {\n vertexData: vertexData,\n blendMode: blendMode,\n indices: indices,\n uvs: uvs,\n _batchRGB: hex2rgb(color),\n _tintRGB: color,\n _texture: gI.style.texture,\n alpha: gI.style.alpha,\n worldAlpha: 1\n };\n this.batches[i] = batch;\n }\n };\n /**\n * Renders the batches using the BathedRenderer plugin\n * @param renderer - The renderer\n */\n Graphics.prototype._renderBatched = function (renderer) {\n if (!this.batches.length) {\n return;\n }\n renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]);\n this.calculateVertices();\n this.calculateTints();\n for (var i = 0, l = this.batches.length; i < l; i++) {\n var batch = this.batches[i];\n batch.worldAlpha = this.worldAlpha * batch.alpha;\n renderer.plugins[this.pluginName].render(batch);\n }\n };\n /**\n * Renders the graphics direct\n * @param renderer - The renderer\n */\n Graphics.prototype._renderDirect = function (renderer) {\n var shader = this._resolveDirectShader(renderer);\n var geometry = this._geometry;\n var tint = this.tint;\n var worldAlpha = this.worldAlpha;\n var uniforms = shader.uniforms;\n var drawCalls = geometry.drawCalls;\n // lets set the transfomr\n uniforms.translationMatrix = this.transform.worldTransform;\n // and then lets set the tint..\n uniforms.tint[0] = (((tint >> 16) & 0xFF) / 255) * worldAlpha;\n uniforms.tint[1] = (((tint >> 8) & 0xFF) / 255) * worldAlpha;\n uniforms.tint[2] = ((tint & 0xFF) / 255) * worldAlpha;\n uniforms.tint[3] = worldAlpha;\n // the first draw call, we can set the uniforms of the shader directly here.\n // this means that we can tack advantage of the sync function of pixi!\n // bind and sync uniforms..\n // there is a way to optimise this..\n renderer.shader.bind(shader);\n renderer.geometry.bind(geometry, shader);\n // set state..\n renderer.state.set(this.state);\n // then render the rest of them...\n for (var i = 0, l = drawCalls.length; i < l; i++) {\n this._renderDrawCallDirect(renderer, geometry.drawCalls[i]);\n }\n };\n /**\n * Renders specific DrawCall\n * @param renderer\n * @param drawCall\n */\n Graphics.prototype._renderDrawCallDirect = function (renderer, drawCall) {\n var texArray = drawCall.texArray, type = drawCall.type, size = drawCall.size, start = drawCall.start;\n var groupTextureCount = texArray.count;\n for (var j = 0; j < groupTextureCount; j++) {\n renderer.texture.bind(texArray.elements[j], j);\n }\n renderer.geometry.draw(type, size, start);\n };\n /**\n * Resolves shader for direct rendering\n * @param renderer - The renderer\n */\n Graphics.prototype._resolveDirectShader = function (renderer) {\n var shader = this.shader;\n var pluginName = this.pluginName;\n if (!shader) {\n // if there is no shader here, we can use the default shader.\n // and that only gets created if we actually need it..\n // but may be more than one plugins for graphics\n if (!DEFAULT_SHADERS[pluginName]) {\n var MAX_TEXTURES = renderer.plugins[pluginName].MAX_TEXTURES;\n var sampleValues = new Int32Array(MAX_TEXTURES);\n for (var i = 0; i < MAX_TEXTURES; i++) {\n sampleValues[i] = i;\n }\n var uniforms = {\n tint: new Float32Array([1, 1, 1, 1]),\n translationMatrix: new Matrix(),\n default: UniformGroup.from({ uSamplers: sampleValues }, true),\n };\n var program = renderer.plugins[pluginName]._shader.program;\n DEFAULT_SHADERS[pluginName] = new Shader(program, uniforms);\n }\n shader = DEFAULT_SHADERS[pluginName];\n }\n return shader;\n };\n /** Retrieves the bounds of the graphic shape as a rectangle object. */\n Graphics.prototype._calculateBounds = function () {\n this.finishPoly();\n var geometry = this._geometry;\n // skipping when graphics is empty, like a container\n if (!geometry.graphicsData.length) {\n return;\n }\n var _a = geometry.bounds, minX = _a.minX, minY = _a.minY, maxX = _a.maxX, maxY = _a.maxY;\n this._bounds.addFrame(this.transform, minX, minY, maxX, maxY);\n };\n /**\n * Tests if a point is inside this graphics object\n * @param point - the point to test\n * @returns - the result of the test\n */\n Graphics.prototype.containsPoint = function (point) {\n this.worldTransform.applyInverse(point, Graphics._TEMP_POINT);\n return this._geometry.containsPoint(Graphics._TEMP_POINT);\n };\n /** Recalculate the tint by applying tint to batches using Graphics tint. */\n Graphics.prototype.calculateTints = function () {\n if (this.batchTint !== this.tint) {\n this.batchTint = this.tint;\n var tintRGB = hex2rgb(this.tint, temp);\n for (var i = 0; i < this.batches.length; i++) {\n var batch = this.batches[i];\n var batchTint = batch._batchRGB;\n var r = (tintRGB[0] * batchTint[0]) * 255;\n var g = (tintRGB[1] * batchTint[1]) * 255;\n var b = (tintRGB[2] * batchTint[2]) * 255;\n // TODO Ivan, can this be done in one go?\n var color = (r << 16) + (g << 8) + (b | 0);\n batch._tintRGB = (color >> 16)\n + (color & 0xff00)\n + ((color & 0xff) << 16);\n }\n }\n };\n /** If there's a transform update or a change to the shape of the geometry, recalculate the vertices. */\n Graphics.prototype.calculateVertices = function () {\n var wtID = this.transform._worldID;\n if (this._transformID === wtID) {\n return;\n }\n this._transformID = wtID;\n var wt = this.transform.worldTransform;\n var a = wt.a;\n var b = wt.b;\n var c = wt.c;\n var d = wt.d;\n var tx = wt.tx;\n var ty = wt.ty;\n var data = this._geometry.points; // batch.vertexDataOriginal;\n var vertexData = this.vertexData;\n var count = 0;\n for (var i = 0; i < data.length; i += 2) {\n var x = data[i];\n var y = data[i + 1];\n vertexData[count++] = (a * x) + (c * y) + tx;\n vertexData[count++] = (d * y) + (b * x) + ty;\n }\n };\n /**\n * Closes the current path.\n * @returns - Returns itself.\n */\n Graphics.prototype.closePath = function () {\n var currentPath = this.currentPath;\n if (currentPath) {\n // we don't need to add extra point in the end because buildLine will take care of that\n currentPath.closeStroke = true;\n // ensure that the polygon is completed, and is available for hit detection\n // (even if the graphics is not rendered yet)\n this.finishPoly();\n }\n return this;\n };\n /**\n * Apply a matrix to the positional data.\n * @param matrix - Matrix to use for transform current shape.\n * @returns - Returns itself.\n */\n Graphics.prototype.setMatrix = function (matrix) {\n this._matrix = matrix;\n return this;\n };\n /**\n * Begin adding holes to the last draw shape\n * IMPORTANT: holes must be fully inside a shape to work\n * Also weirdness ensues if holes overlap!\n * Ellipses, Circles, Rectangles and Rounded Rectangles cannot be holes or host for holes in CanvasRenderer,\n * please use `moveTo` `lineTo`, `quadraticCurveTo` if you rely on pixi-legacy bundle.\n * @returns - Returns itself.\n */\n Graphics.prototype.beginHole = function () {\n this.finishPoly();\n this._holeMode = true;\n return this;\n };\n /**\n * End adding holes to the last draw shape.\n * @returns - Returns itself.\n */\n Graphics.prototype.endHole = function () {\n this.finishPoly();\n this._holeMode = false;\n return this;\n };\n /**\n * Destroys the Graphics object.\n * @param options - Options parameter. A boolean will act as if all\n * options have been set to that value\n * @param {boolean} [options.children=false] - if set to true, all the children will have\n * their destroy method called as well. 'options' will be passed on to those calls.\n * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true\n * Should it destroy the texture of the child sprite\n * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true\n * Should it destroy the base texture of the child sprite\n */\n Graphics.prototype.destroy = function (options) {\n this._geometry.refCount--;\n if (this._geometry.refCount === 0) {\n this._geometry.dispose();\n }\n this._matrix = null;\n this.currentPath = null;\n this._lineStyle.destroy();\n this._lineStyle = null;\n this._fillStyle.destroy();\n this._fillStyle = null;\n this._geometry = null;\n this.shader = null;\n this.vertexData = null;\n this.batches.length = 0;\n this.batches = null;\n _super.prototype.destroy.call(this, options);\n };\n /**\n * New rendering behavior for rounded rectangles: circular arcs instead of quadratic bezier curves.\n * In the next major release, we'll enable this by default.\n */\n Graphics.nextRoundedRectBehavior = false;\n /**\n * Temporary point to use for containsPoint.\n * @private\n */\n Graphics._TEMP_POINT = new Point();\n return Graphics;\n}(Container));\n\nvar graphicsUtils = {\n buildPoly: buildPoly,\n buildCircle: buildCircle,\n buildRectangle: buildRectangle,\n buildRoundedRectangle: buildRoundedRectangle,\n buildLine: buildLine,\n ArcUtils: ArcUtils,\n BezierUtils: BezierUtils,\n QuadraticUtils: QuadraticUtils,\n BatchPart: BatchPart,\n FILL_COMMANDS: FILL_COMMANDS,\n BATCH_POOL: BATCH_POOL,\n DRAW_CALL_POOL: DRAW_CALL_POOL\n};\n\nexport { FillStyle, GRAPHICS_CURVES, Graphics, GraphicsData, GraphicsGeometry, LINE_CAP, LINE_JOIN, LineStyle, graphicsUtils };\n//# sourceMappingURL=graphics.mjs.map\n","/*!\n * @pixi/sprite - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/sprite is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { BLEND_MODES } from '@pixi/constants';\nimport { Texture } from '@pixi/core';\nimport { Bounds, Container } from '@pixi/display';\nimport { Point, Rectangle, ObservablePoint } from '@pixi/math';\nimport { settings } from '@pixi/settings';\nimport { sign } from '@pixi/utils';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\nvar tempPoint = new Point();\nvar indices = new Uint16Array([0, 1, 2, 0, 2, 3]);\n/**\n * The Sprite object is the base for all textured objects that are rendered to the screen\n *\n * A sprite can be created directly from an image like this:\n *\n * ```js\n * let sprite = PIXI.Sprite.from('assets/image.png');\n * ```\n *\n * The more efficient way to create sprites is using a {@link PIXI.Spritesheet},\n * as swapping base textures when rendering to the screen is inefficient.\n *\n * ```js\n * PIXI.Loader.shared.add(\"assets/spritesheet.json\").load(setup);\n *\n * function setup() {\n * let sheet = PIXI.Loader.shared.resources[\"assets/spritesheet.json\"].spritesheet;\n * let sprite = new PIXI.Sprite(sheet.textures[\"image.png\"]);\n * ...\n * }\n * ```\n * @memberof PIXI\n */\nvar Sprite = /** @class */ (function (_super) {\n __extends(Sprite, _super);\n /** @param texture - The texture for this sprite. */\n function Sprite(texture) {\n var _this = _super.call(this) || this;\n _this._anchor = new ObservablePoint(_this._onAnchorUpdate, _this, (texture ? texture.defaultAnchor.x : 0), (texture ? texture.defaultAnchor.y : 0));\n _this._texture = null;\n _this._width = 0;\n _this._height = 0;\n _this._tint = null;\n _this._tintRGB = null;\n _this.tint = 0xFFFFFF;\n _this.blendMode = BLEND_MODES.NORMAL;\n _this._cachedTint = 0xFFFFFF;\n _this.uvs = null;\n // call texture setter\n _this.texture = texture || Texture.EMPTY;\n _this.vertexData = new Float32Array(8);\n _this.vertexTrimmedData = null;\n _this._transformID = -1;\n _this._textureID = -1;\n _this._transformTrimmedID = -1;\n _this._textureTrimmedID = -1;\n // Batchable stuff..\n // TODO could make this a mixin?\n _this.indices = indices;\n _this.pluginName = 'batch';\n /**\n * Used to fast check if a sprite is.. a sprite!\n * @member {boolean}\n */\n _this.isSprite = true;\n _this._roundPixels = settings.ROUND_PIXELS;\n return _this;\n }\n /** When the texture is updated, this event will fire to update the scale and frame. */\n Sprite.prototype._onTextureUpdate = function () {\n this._textureID = -1;\n this._textureTrimmedID = -1;\n this._cachedTint = 0xFFFFFF;\n // so if _width is 0 then width was not set..\n if (this._width) {\n this.scale.x = sign(this.scale.x) * this._width / this._texture.orig.width;\n }\n if (this._height) {\n this.scale.y = sign(this.scale.y) * this._height / this._texture.orig.height;\n }\n };\n /** Called when the anchor position updates. */\n Sprite.prototype._onAnchorUpdate = function () {\n this._transformID = -1;\n this._transformTrimmedID = -1;\n };\n /** Calculates worldTransform * vertices, store it in vertexData. */\n Sprite.prototype.calculateVertices = function () {\n var texture = this._texture;\n if (this._transformID === this.transform._worldID && this._textureID === texture._updateID) {\n return;\n }\n // update texture UV here, because base texture can be changed without calling `_onTextureUpdate`\n if (this._textureID !== texture._updateID) {\n this.uvs = this._texture._uvs.uvsFloat32;\n }\n this._transformID = this.transform._worldID;\n this._textureID = texture._updateID;\n // set the vertex data\n var wt = this.transform.worldTransform;\n var a = wt.a;\n var b = wt.b;\n var c = wt.c;\n var d = wt.d;\n var tx = wt.tx;\n var ty = wt.ty;\n var vertexData = this.vertexData;\n var trim = texture.trim;\n var orig = texture.orig;\n var anchor = this._anchor;\n var w0 = 0;\n var w1 = 0;\n var h0 = 0;\n var h1 = 0;\n if (trim) {\n // if the sprite is trimmed and is not a tilingsprite then we need to add the extra\n // space before transforming the sprite coords.\n w1 = trim.x - (anchor._x * orig.width);\n w0 = w1 + trim.width;\n h1 = trim.y - (anchor._y * orig.height);\n h0 = h1 + trim.height;\n }\n else {\n w1 = -anchor._x * orig.width;\n w0 = w1 + orig.width;\n h1 = -anchor._y * orig.height;\n h0 = h1 + orig.height;\n }\n // xy\n vertexData[0] = (a * w1) + (c * h1) + tx;\n vertexData[1] = (d * h1) + (b * w1) + ty;\n // xy\n vertexData[2] = (a * w0) + (c * h1) + tx;\n vertexData[3] = (d * h1) + (b * w0) + ty;\n // xy\n vertexData[4] = (a * w0) + (c * h0) + tx;\n vertexData[5] = (d * h0) + (b * w0) + ty;\n // xy\n vertexData[6] = (a * w1) + (c * h0) + tx;\n vertexData[7] = (d * h0) + (b * w1) + ty;\n if (this._roundPixels) {\n var resolution = settings.RESOLUTION;\n for (var i = 0; i < vertexData.length; ++i) {\n vertexData[i] = Math.round((vertexData[i] * resolution | 0) / resolution);\n }\n }\n };\n /**\n * Calculates worldTransform * vertices for a non texture with a trim. store it in vertexTrimmedData.\n *\n * This is used to ensure that the true width and height of a trimmed texture is respected.\n */\n Sprite.prototype.calculateTrimmedVertices = function () {\n if (!this.vertexTrimmedData) {\n this.vertexTrimmedData = new Float32Array(8);\n }\n else if (this._transformTrimmedID === this.transform._worldID && this._textureTrimmedID === this._texture._updateID) {\n return;\n }\n this._transformTrimmedID = this.transform._worldID;\n this._textureTrimmedID = this._texture._updateID;\n // lets do some special trim code!\n var texture = this._texture;\n var vertexData = this.vertexTrimmedData;\n var orig = texture.orig;\n var anchor = this._anchor;\n // lets calculate the new untrimmed bounds..\n var wt = this.transform.worldTransform;\n var a = wt.a;\n var b = wt.b;\n var c = wt.c;\n var d = wt.d;\n var tx = wt.tx;\n var ty = wt.ty;\n var w1 = -anchor._x * orig.width;\n var w0 = w1 + orig.width;\n var h1 = -anchor._y * orig.height;\n var h0 = h1 + orig.height;\n // xy\n vertexData[0] = (a * w1) + (c * h1) + tx;\n vertexData[1] = (d * h1) + (b * w1) + ty;\n // xy\n vertexData[2] = (a * w0) + (c * h1) + tx;\n vertexData[3] = (d * h1) + (b * w0) + ty;\n // xy\n vertexData[4] = (a * w0) + (c * h0) + tx;\n vertexData[5] = (d * h0) + (b * w0) + ty;\n // xy\n vertexData[6] = (a * w1) + (c * h0) + tx;\n vertexData[7] = (d * h0) + (b * w1) + ty;\n };\n /**\n *\n * Renders the object using the WebGL renderer\n * @param renderer - The webgl renderer to use.\n */\n Sprite.prototype._render = function (renderer) {\n this.calculateVertices();\n renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]);\n renderer.plugins[this.pluginName].render(this);\n };\n /** Updates the bounds of the sprite. */\n Sprite.prototype._calculateBounds = function () {\n var trim = this._texture.trim;\n var orig = this._texture.orig;\n // First lets check to see if the current texture has a trim..\n if (!trim || (trim.width === orig.width && trim.height === orig.height)) {\n // no trim! lets use the usual calculations..\n this.calculateVertices();\n this._bounds.addQuad(this.vertexData);\n }\n else {\n // lets calculate a special trimmed bounds...\n this.calculateTrimmedVertices();\n this._bounds.addQuad(this.vertexTrimmedData);\n }\n };\n /**\n * Gets the local bounds of the sprite object.\n * @param rect - Optional output rectangle.\n * @returns The bounds.\n */\n Sprite.prototype.getLocalBounds = function (rect) {\n // we can do a fast local bounds if the sprite has no children!\n if (this.children.length === 0) {\n if (!this._localBounds) {\n this._localBounds = new Bounds();\n }\n this._localBounds.minX = this._texture.orig.width * -this._anchor._x;\n this._localBounds.minY = this._texture.orig.height * -this._anchor._y;\n this._localBounds.maxX = this._texture.orig.width * (1 - this._anchor._x);\n this._localBounds.maxY = this._texture.orig.height * (1 - this._anchor._y);\n if (!rect) {\n if (!this._localBoundsRect) {\n this._localBoundsRect = new Rectangle();\n }\n rect = this._localBoundsRect;\n }\n return this._localBounds.getRectangle(rect);\n }\n return _super.prototype.getLocalBounds.call(this, rect);\n };\n /**\n * Tests if a point is inside this sprite\n * @param point - the point to test\n * @returns The result of the test\n */\n Sprite.prototype.containsPoint = function (point) {\n this.worldTransform.applyInverse(point, tempPoint);\n var width = this._texture.orig.width;\n var height = this._texture.orig.height;\n var x1 = -width * this.anchor.x;\n var y1 = 0;\n if (tempPoint.x >= x1 && tempPoint.x < x1 + width) {\n y1 = -height * this.anchor.y;\n if (tempPoint.y >= y1 && tempPoint.y < y1 + height) {\n return true;\n }\n }\n return false;\n };\n /**\n * Destroys this sprite and optionally its texture and children.\n * @param options - Options parameter. A boolean will act as if all options\n * have been set to that value\n * @param [options.children=false] - if set to true, all the children will have their destroy\n * method called as well. 'options' will be passed on to those calls.\n * @param [options.texture=false] - Should it destroy the current texture of the sprite as well\n * @param [options.baseTexture=false] - Should it destroy the base texture of the sprite as well\n */\n Sprite.prototype.destroy = function (options) {\n _super.prototype.destroy.call(this, options);\n this._texture.off('update', this._onTextureUpdate, this);\n this._anchor = null;\n var destroyTexture = typeof options === 'boolean' ? options : options && options.texture;\n if (destroyTexture) {\n var destroyBaseTexture = typeof options === 'boolean' ? options : options && options.baseTexture;\n this._texture.destroy(!!destroyBaseTexture);\n }\n this._texture = null;\n };\n // some helper functions..\n /**\n * Helper function that creates a new sprite based on the source you provide.\n * The source can be - frame id, image url, video url, canvas element, video element, base texture\n * @param {string|PIXI.Texture|HTMLCanvasElement|HTMLVideoElement} source - Source to create texture from\n * @param {object} [options] - See {@link PIXI.BaseTexture}'s constructor for options.\n * @returns The newly created sprite\n */\n Sprite.from = function (source, options) {\n var texture = (source instanceof Texture)\n ? source\n : Texture.from(source, options);\n return new Sprite(texture);\n };\n Object.defineProperty(Sprite.prototype, \"roundPixels\", {\n get: function () {\n return this._roundPixels;\n },\n /**\n * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation.\n *\n * Advantages can include sharper image quality (like text) and faster rendering on canvas.\n * The main disadvantage is movement of objects may appear less smooth.\n *\n * To set the global default, change {@link PIXI.settings.ROUND_PIXELS}.\n * @default false\n */\n set: function (value) {\n if (this._roundPixels !== value) {\n this._transformID = -1;\n }\n this._roundPixels = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Sprite.prototype, \"width\", {\n /** The width of the sprite, setting this will actually modify the scale to achieve the value set. */\n get: function () {\n return Math.abs(this.scale.x) * this._texture.orig.width;\n },\n set: function (value) {\n var s = sign(this.scale.x) || 1;\n this.scale.x = s * value / this._texture.orig.width;\n this._width = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Sprite.prototype, \"height\", {\n /** The height of the sprite, setting this will actually modify the scale to achieve the value set. */\n get: function () {\n return Math.abs(this.scale.y) * this._texture.orig.height;\n },\n set: function (value) {\n var s = sign(this.scale.y) || 1;\n this.scale.y = s * value / this._texture.orig.height;\n this._height = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Sprite.prototype, \"anchor\", {\n /**\n * The anchor sets the origin point of the sprite. The default value is taken from the {@link PIXI.Texture|Texture}\n * and passed to the constructor.\n *\n * The default is `(0,0)`, this means the sprite's origin is the top left.\n *\n * Setting the anchor to `(0.5,0.5)` means the sprite's origin is centered.\n *\n * Setting the anchor to `(1,1)` would mean the sprite's origin point will be the bottom right corner.\n *\n * If you pass only single parameter, it will set both x and y to the same value as shown in the example below.\n * @example\n * const sprite = new PIXI.Sprite(texture);\n * sprite.anchor.set(0.5); // This will set the origin to center. (0.5) is same as (0.5, 0.5).\n */\n get: function () {\n return this._anchor;\n },\n set: function (value) {\n this._anchor.copyFrom(value);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Sprite.prototype, \"tint\", {\n /**\n * The tint applied to the sprite. This is a hex value.\n *\n * A value of 0xFFFFFF will remove any tint effect.\n * @default 0xFFFFFF\n */\n get: function () {\n return this._tint;\n },\n set: function (value) {\n this._tint = value;\n this._tintRGB = (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Sprite.prototype, \"texture\", {\n /** The texture that the sprite is using. */\n get: function () {\n return this._texture;\n },\n set: function (value) {\n if (this._texture === value) {\n return;\n }\n if (this._texture) {\n this._texture.off('update', this._onTextureUpdate, this);\n }\n this._texture = value || Texture.EMPTY;\n this._cachedTint = 0xFFFFFF;\n this._textureID = -1;\n this._textureTrimmedID = -1;\n if (value) {\n // wait for the texture to load\n if (value.baseTexture.valid) {\n this._onTextureUpdate();\n }\n else {\n value.once('update', this._onTextureUpdate, this);\n }\n }\n },\n enumerable: false,\n configurable: true\n });\n return Sprite;\n}(Container));\n\nexport { Sprite };\n//# sourceMappingURL=sprite.mjs.map\n","/*!\n * @pixi/text - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/text is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { Sprite } from '@pixi/sprite';\nimport { Texture } from '@pixi/core';\nimport { settings } from '@pixi/settings';\nimport { Rectangle } from '@pixi/math';\nimport { hex2string, hex2rgb, string2hex, trimCanvas, sign } from '@pixi/utils';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\n/**\n * Constants that define the type of gradient on text.\n * @static\n * @constant\n * @name TEXT_GRADIENT\n * @memberof PIXI\n * @type {object}\n * @property {number} LINEAR_VERTICAL Vertical gradient\n * @property {number} LINEAR_HORIZONTAL Linear gradient\n */\nvar TEXT_GRADIENT;\n(function (TEXT_GRADIENT) {\n TEXT_GRADIENT[TEXT_GRADIENT[\"LINEAR_VERTICAL\"] = 0] = \"LINEAR_VERTICAL\";\n TEXT_GRADIENT[TEXT_GRADIENT[\"LINEAR_HORIZONTAL\"] = 1] = \"LINEAR_HORIZONTAL\";\n})(TEXT_GRADIENT || (TEXT_GRADIENT = {}));\n\n// disabling eslint for now, going to rewrite this in v5\nvar defaultStyle = {\n align: 'left',\n breakWords: false,\n dropShadow: false,\n dropShadowAlpha: 1,\n dropShadowAngle: Math.PI / 6,\n dropShadowBlur: 0,\n dropShadowColor: 'black',\n dropShadowDistance: 5,\n fill: 'black',\n fillGradientType: TEXT_GRADIENT.LINEAR_VERTICAL,\n fillGradientStops: [],\n fontFamily: 'Arial',\n fontSize: 26,\n fontStyle: 'normal',\n fontVariant: 'normal',\n fontWeight: 'normal',\n letterSpacing: 0,\n lineHeight: 0,\n lineJoin: 'miter',\n miterLimit: 10,\n padding: 0,\n stroke: 'black',\n strokeThickness: 0,\n textBaseline: 'alphabetic',\n trim: false,\n whiteSpace: 'pre',\n wordWrap: false,\n wordWrapWidth: 100,\n leading: 0,\n};\nvar genericFontFamilies = [\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n 'system-ui' ];\n/**\n * A TextStyle Object contains information to decorate a Text objects.\n *\n * An instance can be shared between multiple Text objects; then changing the style will update all text objects using it.\n *\n * A tool can be used to generate a text style [here](https://pixijs.io/pixi-text-style).\n *\n * @memberof PIXI\n */\nvar TextStyle = /** @class */ (function () {\n /**\n * @param {object} [style] - The style parameters\n * @param {string} [style.align='left'] - Alignment for multiline text ('left', 'center' or 'right'),\n * does not affect single line text\n * @param {boolean} [style.breakWords=false] - Indicates if lines can be wrapped within words, it\n * needs wordWrap to be set to true\n * @param {boolean} [style.dropShadow=false] - Set a drop shadow for the text\n * @param {number} [style.dropShadowAlpha=1] - Set alpha for the drop shadow\n * @param {number} [style.dropShadowAngle=Math.PI/6] - Set a angle of the drop shadow\n * @param {number} [style.dropShadowBlur=0] - Set a shadow blur radius\n * @param {string|number} [style.dropShadowColor='black'] - A fill style to be used on the dropshadow e.g 'red', '#00FF00'\n * @param {number} [style.dropShadowDistance=5] - Set a distance of the drop shadow\n * @param {string|string[]|number|number[]|CanvasGradient|CanvasPattern} [style.fill='black'] - A canvas\n * fillstyle that will be used on the text e.g 'red', '#00FF00'. Can be an array to create a gradient\n * eg ['#000000','#FFFFFF']\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle|MDN}\n * @param {number} [style.fillGradientType=PIXI.TEXT_GRADIENT.LINEAR_VERTICAL] - If fill is an array of colours\n * to create a gradient, this can change the type/direction of the gradient. See {@link PIXI.TEXT_GRADIENT}\n * @param {number[]} [style.fillGradientStops] - If fill is an array of colours to create a gradient, this array can set\n * the stop points (numbers between 0 and 1) for the color, overriding the default behaviour of evenly spacing them.\n * @param {string|string[]} [style.fontFamily='Arial'] - The font family\n * @param {number|string} [style.fontSize=26] - The font size (as a number it converts to px, but as a string,\n * equivalents are '26px','20pt','160%' or '1.6em')\n * @param {string} [style.fontStyle='normal'] - The font style ('normal', 'italic' or 'oblique')\n * @param {string} [style.fontVariant='normal'] - The font variant ('normal' or 'small-caps')\n * @param {string} [style.fontWeight='normal'] - The font weight ('normal', 'bold', 'bolder', 'lighter' and '100',\n * '200', '300', '400', '500', '600', '700', '800' or '900')\n * @param {number} [style.leading=0] - The space between lines\n * @param {number} [style.letterSpacing=0] - The amount of spacing between letters, default is 0\n * @param {number} [style.lineHeight] - The line height, a number that represents the vertical space that a letter uses\n * @param {string} [style.lineJoin='miter'] - The lineJoin property sets the type of corner created, it can resolve\n * spiked text issues. Possible values \"miter\" (creates a sharp corner), \"round\" (creates a round corner) or \"bevel\"\n * (creates a squared corner).\n * @param {number} [style.miterLimit=10] - The miter limit to use when using the 'miter' lineJoin mode. This can reduce\n * or increase the spikiness of rendered text.\n * @param {number} [style.padding=0] - Occasionally some fonts are cropped. Adding some padding will prevent this from\n * happening by adding padding to all sides of the text.\n * @param {string|number} [style.stroke='black'] - A canvas fillstyle that will be used on the text stroke\n * e.g 'blue', '#FCFF00'\n * @param {number} [style.strokeThickness=0] - A number that represents the thickness of the stroke.\n * Default is 0 (no stroke)\n * @param {boolean} [style.trim=false] - Trim transparent borders\n * @param {string} [style.textBaseline='alphabetic'] - The baseline of the text that is rendered.\n * @param {string} [style.whiteSpace='pre'] - Determines whether newlines & spaces are collapsed or preserved \"normal\"\n * (collapse, collapse), \"pre\" (preserve, preserve) | \"pre-line\" (preserve, collapse). It needs wordWrap to be set to true\n * @param {boolean} [style.wordWrap=false] - Indicates if word wrap should be used\n * @param {number} [style.wordWrapWidth=100] - The width at which text will wrap, it needs wordWrap to be set to true\n */\n function TextStyle(style) {\n this.styleID = 0;\n this.reset();\n deepCopyProperties(this, style, style);\n }\n /**\n * Creates a new TextStyle object with the same values as this one.\n * Note that the only the properties of the object are cloned.\n *\n * @return New cloned TextStyle object\n */\n TextStyle.prototype.clone = function () {\n var clonedProperties = {};\n deepCopyProperties(clonedProperties, this, defaultStyle);\n return new TextStyle(clonedProperties);\n };\n /** Resets all properties to the defaults specified in TextStyle.prototype._default */\n TextStyle.prototype.reset = function () {\n deepCopyProperties(this, defaultStyle, defaultStyle);\n };\n Object.defineProperty(TextStyle.prototype, \"align\", {\n /**\n * Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text\n *\n * @member {string}\n */\n get: function () {\n return this._align;\n },\n set: function (align) {\n if (this._align !== align) {\n this._align = align;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"breakWords\", {\n /** Indicates if lines can be wrapped within words, it needs wordWrap to be set to true. */\n get: function () {\n return this._breakWords;\n },\n set: function (breakWords) {\n if (this._breakWords !== breakWords) {\n this._breakWords = breakWords;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"dropShadow\", {\n /** Set a drop shadow for the text. */\n get: function () {\n return this._dropShadow;\n },\n set: function (dropShadow) {\n if (this._dropShadow !== dropShadow) {\n this._dropShadow = dropShadow;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"dropShadowAlpha\", {\n /** Set alpha for the drop shadow. */\n get: function () {\n return this._dropShadowAlpha;\n },\n set: function (dropShadowAlpha) {\n if (this._dropShadowAlpha !== dropShadowAlpha) {\n this._dropShadowAlpha = dropShadowAlpha;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"dropShadowAngle\", {\n /** Set a angle of the drop shadow. */\n get: function () {\n return this._dropShadowAngle;\n },\n set: function (dropShadowAngle) {\n if (this._dropShadowAngle !== dropShadowAngle) {\n this._dropShadowAngle = dropShadowAngle;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"dropShadowBlur\", {\n /** Set a shadow blur radius. */\n get: function () {\n return this._dropShadowBlur;\n },\n set: function (dropShadowBlur) {\n if (this._dropShadowBlur !== dropShadowBlur) {\n this._dropShadowBlur = dropShadowBlur;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"dropShadowColor\", {\n /** A fill style to be used on the dropshadow e.g 'red', '#00FF00'. */\n get: function () {\n return this._dropShadowColor;\n },\n set: function (dropShadowColor) {\n var outputColor = getColor(dropShadowColor);\n if (this._dropShadowColor !== outputColor) {\n this._dropShadowColor = outputColor;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"dropShadowDistance\", {\n /** Set a distance of the drop shadow. */\n get: function () {\n return this._dropShadowDistance;\n },\n set: function (dropShadowDistance) {\n if (this._dropShadowDistance !== dropShadowDistance) {\n this._dropShadowDistance = dropShadowDistance;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"fill\", {\n /**\n * A canvas fillstyle that will be used on the text e.g 'red', '#00FF00'.\n *\n * Can be an array to create a gradient eg ['#000000','#FFFFFF']\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle|MDN}\n *\n * @member {string|string[]|number|number[]|CanvasGradient|CanvasPattern}\n */\n get: function () {\n return this._fill;\n },\n set: function (fill) {\n // TODO: Can't have different types for getter and setter. The getter shouldn't have the number type as\n // the setter converts to string. See this thread for more details:\n // https://github.com/microsoft/TypeScript/issues/2521\n // TODO: Not sure if getColor works properly with CanvasGradient and/or CanvasPattern, can't pass in\n // without casting here.\n var outputColor = getColor(fill);\n if (this._fill !== outputColor) {\n this._fill = outputColor;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"fillGradientType\", {\n /**\n * If fill is an array of colours to create a gradient, this can change the type/direction of the gradient.\n *\n * @see PIXI.TEXT_GRADIENT\n */\n get: function () {\n return this._fillGradientType;\n },\n set: function (fillGradientType) {\n if (this._fillGradientType !== fillGradientType) {\n this._fillGradientType = fillGradientType;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"fillGradientStops\", {\n /**\n * If fill is an array of colours to create a gradient, this array can set the stop points\n * (numbers between 0 and 1) for the color, overriding the default behaviour of evenly spacing them.\n */\n get: function () {\n return this._fillGradientStops;\n },\n set: function (fillGradientStops) {\n if (!areArraysEqual(this._fillGradientStops, fillGradientStops)) {\n this._fillGradientStops = fillGradientStops;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"fontFamily\", {\n /** The font family. */\n get: function () {\n return this._fontFamily;\n },\n set: function (fontFamily) {\n if (this.fontFamily !== fontFamily) {\n this._fontFamily = fontFamily;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"fontSize\", {\n /**\n * The font size\n * (as a number it converts to px, but as a string, equivalents are '26px','20pt','160%' or '1.6em')\n */\n get: function () {\n return this._fontSize;\n },\n set: function (fontSize) {\n if (this._fontSize !== fontSize) {\n this._fontSize = fontSize;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"fontStyle\", {\n /**\n * The font style\n * ('normal', 'italic' or 'oblique')\n *\n * @member {string}\n */\n get: function () {\n return this._fontStyle;\n },\n set: function (fontStyle) {\n if (this._fontStyle !== fontStyle) {\n this._fontStyle = fontStyle;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"fontVariant\", {\n /**\n * The font variant\n * ('normal' or 'small-caps')\n *\n * @member {string}\n */\n get: function () {\n return this._fontVariant;\n },\n set: function (fontVariant) {\n if (this._fontVariant !== fontVariant) {\n this._fontVariant = fontVariant;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"fontWeight\", {\n /**\n * The font weight\n * ('normal', 'bold', 'bolder', 'lighter' and '100', '200', '300', '400', '500', '600', '700', 800' or '900')\n *\n * @member {string}\n */\n get: function () {\n return this._fontWeight;\n },\n set: function (fontWeight) {\n if (this._fontWeight !== fontWeight) {\n this._fontWeight = fontWeight;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"letterSpacing\", {\n /** The amount of spacing between letters, default is 0. */\n get: function () {\n return this._letterSpacing;\n },\n set: function (letterSpacing) {\n if (this._letterSpacing !== letterSpacing) {\n this._letterSpacing = letterSpacing;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"lineHeight\", {\n /** The line height, a number that represents the vertical space that a letter uses. */\n get: function () {\n return this._lineHeight;\n },\n set: function (lineHeight) {\n if (this._lineHeight !== lineHeight) {\n this._lineHeight = lineHeight;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"leading\", {\n /** The space between lines. */\n get: function () {\n return this._leading;\n },\n set: function (leading) {\n if (this._leading !== leading) {\n this._leading = leading;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"lineJoin\", {\n /**\n * The lineJoin property sets the type of corner created, it can resolve spiked text issues.\n * Default is 'miter' (creates a sharp corner).\n *\n * @member {string}\n */\n get: function () {\n return this._lineJoin;\n },\n set: function (lineJoin) {\n if (this._lineJoin !== lineJoin) {\n this._lineJoin = lineJoin;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"miterLimit\", {\n /**\n * The miter limit to use when using the 'miter' lineJoin mode.\n *\n * This can reduce or increase the spikiness of rendered text.\n */\n get: function () {\n return this._miterLimit;\n },\n set: function (miterLimit) {\n if (this._miterLimit !== miterLimit) {\n this._miterLimit = miterLimit;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"padding\", {\n /**\n * Occasionally some fonts are cropped. Adding some padding will prevent this from happening\n * by adding padding to all sides of the text.\n */\n get: function () {\n return this._padding;\n },\n set: function (padding) {\n if (this._padding !== padding) {\n this._padding = padding;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"stroke\", {\n /**\n * A canvas fillstyle that will be used on the text stroke\n * e.g 'blue', '#FCFF00'\n */\n get: function () {\n return this._stroke;\n },\n set: function (stroke) {\n // TODO: Can't have different types for getter and setter. The getter shouldn't have the number type as\n // the setter converts to string. See this thread for more details:\n // https://github.com/microsoft/TypeScript/issues/2521\n var outputColor = getColor(stroke);\n if (this._stroke !== outputColor) {\n this._stroke = outputColor;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"strokeThickness\", {\n /**\n * A number that represents the thickness of the stroke.\n *\n * @default 0\n */\n get: function () {\n return this._strokeThickness;\n },\n set: function (strokeThickness) {\n if (this._strokeThickness !== strokeThickness) {\n this._strokeThickness = strokeThickness;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"textBaseline\", {\n /**\n * The baseline of the text that is rendered.\n *\n * @member {string}\n */\n get: function () {\n return this._textBaseline;\n },\n set: function (textBaseline) {\n if (this._textBaseline !== textBaseline) {\n this._textBaseline = textBaseline;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"trim\", {\n /** Trim transparent borders. */\n get: function () {\n return this._trim;\n },\n set: function (trim) {\n if (this._trim !== trim) {\n this._trim = trim;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"whiteSpace\", {\n /**\n * How newlines and spaces should be handled.\n * Default is 'pre' (preserve, preserve).\n *\n * value | New lines | Spaces\n * --- | --- | ---\n * 'normal' | Collapse | Collapse\n * 'pre' | Preserve | Preserve\n * 'pre-line' | Preserve | Collapse\n *\n * @member {string}\n */\n get: function () {\n return this._whiteSpace;\n },\n set: function (whiteSpace) {\n if (this._whiteSpace !== whiteSpace) {\n this._whiteSpace = whiteSpace;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"wordWrap\", {\n /** Indicates if word wrap should be used. */\n get: function () {\n return this._wordWrap;\n },\n set: function (wordWrap) {\n if (this._wordWrap !== wordWrap) {\n this._wordWrap = wordWrap;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextStyle.prototype, \"wordWrapWidth\", {\n /** The width at which text will wrap, it needs wordWrap to be set to true. */\n get: function () {\n return this._wordWrapWidth;\n },\n set: function (wordWrapWidth) {\n if (this._wordWrapWidth !== wordWrapWidth) {\n this._wordWrapWidth = wordWrapWidth;\n this.styleID++;\n }\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Generates a font style string to use for `TextMetrics.measureFont()`.\n *\n * @return Font style string, for passing to `TextMetrics.measureFont()`\n */\n TextStyle.prototype.toFontString = function () {\n // build canvas api font setting from individual components. Convert a numeric this.fontSize to px\n var fontSizeString = (typeof this.fontSize === 'number') ? this.fontSize + \"px\" : this.fontSize;\n // Clean-up fontFamily property by quoting each font name\n // this will support font names with spaces\n var fontFamilies = this.fontFamily;\n if (!Array.isArray(this.fontFamily)) {\n fontFamilies = this.fontFamily.split(',');\n }\n for (var i = fontFamilies.length - 1; i >= 0; i--) {\n // Trim any extra white-space\n var fontFamily = fontFamilies[i].trim();\n // Check if font already contains strings\n if (!(/([\\\"\\'])[^\\'\\\"]+\\1/).test(fontFamily) && genericFontFamilies.indexOf(fontFamily) < 0) {\n fontFamily = \"\\\"\" + fontFamily + \"\\\"\";\n }\n fontFamilies[i] = fontFamily;\n }\n return this.fontStyle + \" \" + this.fontVariant + \" \" + this.fontWeight + \" \" + fontSizeString + \" \" + fontFamilies.join(',');\n };\n return TextStyle;\n}());\n/**\n * Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string.\n * @private\n * @param color\n * @return The color as a string.\n */\nfunction getSingleColor(color) {\n if (typeof color === 'number') {\n return hex2string(color);\n }\n else if (typeof color === 'string') {\n if (color.indexOf('0x') === 0) {\n color = color.replace('0x', '#');\n }\n }\n return color;\n}\nfunction getColor(color) {\n if (!Array.isArray(color)) {\n return getSingleColor(color);\n }\n else {\n for (var i = 0; i < color.length; ++i) {\n color[i] = getSingleColor(color[i]);\n }\n return color;\n }\n}\n/**\n * Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string.\n * This version can also convert array of colors\n * @private\n * @param array1 - First array to compare\n * @param array2 - Second array to compare\n * @return Do the arrays contain the same values in the same order\n */\nfunction areArraysEqual(array1, array2) {\n if (!Array.isArray(array1) || !Array.isArray(array2)) {\n return false;\n }\n if (array1.length !== array2.length) {\n return false;\n }\n for (var i = 0; i < array1.length; ++i) {\n if (array1[i] !== array2[i]) {\n return false;\n }\n }\n return true;\n}\n/**\n * Utility function to ensure that object properties are copied by value, and not by reference\n * @private\n * @param target - Target object to copy properties into\n * @param source - Source object for the properties to copy\n * @param propertyObj - Object containing properties names we want to loop over\n */\nfunction deepCopyProperties(target, source, propertyObj) {\n for (var prop in propertyObj) {\n if (Array.isArray(source[prop])) {\n target[prop] = source[prop].slice();\n }\n else {\n target[prop] = source[prop];\n }\n }\n}\n\n// Default settings used for all getContext calls\nvar contextSettings = {\n // TextMetrics requires getImageData readback for measuring fonts.\n willReadFrequently: true,\n};\n/**\n * The TextMetrics object represents the measurement of a block of text with a specified style.\n *\n * ```js\n * let style = new PIXI.TextStyle({fontFamily : 'Arial', fontSize: 24, fill : 0xff1010, align : 'center'})\n * let textMetrics = PIXI.TextMetrics.measureText('Your text', style)\n * ```\n * @memberof PIXI\n */\nvar TextMetrics = /** @class */ (function () {\n /**\n * @param text - the text that was measured\n * @param style - the style that was measured\n * @param width - the measured width of the text\n * @param height - the measured height of the text\n * @param lines - an array of the lines of text broken by new lines and wrapping if specified in style\n * @param lineWidths - an array of the line widths for each line matched to `lines`\n * @param lineHeight - the measured line height for this style\n * @param maxLineWidth - the maximum line width for all measured lines\n * @param {PIXI.IFontMetrics} fontProperties - the font properties object from TextMetrics.measureFont\n */\n function TextMetrics(text, style, width, height, lines, lineWidths, lineHeight, maxLineWidth, fontProperties) {\n this.text = text;\n this.style = style;\n this.width = width;\n this.height = height;\n this.lines = lines;\n this.lineWidths = lineWidths;\n this.lineHeight = lineHeight;\n this.maxLineWidth = maxLineWidth;\n this.fontProperties = fontProperties;\n }\n /**\n * Measures the supplied string of text and returns a Rectangle.\n * @param text - The text to measure.\n * @param style - The text style to use for measuring\n * @param wordWrap - Override for if word-wrap should be applied to the text.\n * @param canvas - optional specification of the canvas to use for measuring.\n * @returns Measured width and height of the text.\n */\n TextMetrics.measureText = function (text, style, wordWrap, canvas) {\n if (canvas === void 0) { canvas = TextMetrics._canvas; }\n wordWrap = (wordWrap === undefined || wordWrap === null) ? style.wordWrap : wordWrap;\n var font = style.toFontString();\n var fontProperties = TextMetrics.measureFont(font);\n // fallback in case UA disallow canvas data extraction\n // (toDataURI, getImageData functions)\n if (fontProperties.fontSize === 0) {\n fontProperties.fontSize = style.fontSize;\n fontProperties.ascent = style.fontSize;\n }\n var context = canvas.getContext('2d', contextSettings);\n context.font = font;\n var outputText = wordWrap ? TextMetrics.wordWrap(text, style, canvas) : text;\n var lines = outputText.split(/(?:\\r\\n|\\r|\\n)/);\n var lineWidths = new Array(lines.length);\n var maxLineWidth = 0;\n for (var i = 0; i < lines.length; i++) {\n var lineWidth = context.measureText(lines[i]).width + ((lines[i].length - 1) * style.letterSpacing);\n lineWidths[i] = lineWidth;\n maxLineWidth = Math.max(maxLineWidth, lineWidth);\n }\n var width = maxLineWidth + style.strokeThickness;\n if (style.dropShadow) {\n width += style.dropShadowDistance;\n }\n var lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness;\n var height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness)\n + ((lines.length - 1) * (lineHeight + style.leading));\n if (style.dropShadow) {\n height += style.dropShadowDistance;\n }\n return new TextMetrics(text, style, width, height, lines, lineWidths, lineHeight + style.leading, maxLineWidth, fontProperties);\n };\n /**\n * Applies newlines to a string to have it optimally fit into the horizontal\n * bounds set by the Text object's wordWrapWidth property.\n * @param text - String to apply word wrapping to\n * @param style - the style to use when wrapping\n * @param canvas - optional specification of the canvas to use for measuring.\n * @returns New string with new lines applied where required\n */\n TextMetrics.wordWrap = function (text, style, canvas) {\n if (canvas === void 0) { canvas = TextMetrics._canvas; }\n var context = canvas.getContext('2d', contextSettings);\n var width = 0;\n var line = '';\n var lines = '';\n var cache = Object.create(null);\n var letterSpacing = style.letterSpacing, whiteSpace = style.whiteSpace;\n // How to handle whitespaces\n var collapseSpaces = TextMetrics.collapseSpaces(whiteSpace);\n var collapseNewlines = TextMetrics.collapseNewlines(whiteSpace);\n // whether or not spaces may be added to the beginning of lines\n var canPrependSpaces = !collapseSpaces;\n // There is letterSpacing after every char except the last one\n // t_h_i_s_' '_i_s_' '_a_n_' '_e_x_a_m_p_l_e_' '_!\n // so for convenience the above needs to be compared to width + 1 extra letterSpace\n // t_h_i_s_' '_i_s_' '_a_n_' '_e_x_a_m_p_l_e_' '_!_\n // ________________________________________________\n // And then the final space is simply no appended to each line\n var wordWrapWidth = style.wordWrapWidth + letterSpacing;\n // break text into words, spaces and newline chars\n var tokens = TextMetrics.tokenize(text);\n for (var i = 0; i < tokens.length; i++) {\n // get the word, space or newlineChar\n var token = tokens[i];\n // if word is a new line\n if (TextMetrics.isNewline(token)) {\n // keep the new line\n if (!collapseNewlines) {\n lines += TextMetrics.addLine(line);\n canPrependSpaces = !collapseSpaces;\n line = '';\n width = 0;\n continue;\n }\n // if we should collapse new lines\n // we simply convert it into a space\n token = ' ';\n }\n // if we should collapse repeated whitespaces\n if (collapseSpaces) {\n // check both this and the last tokens for spaces\n var currIsBreakingSpace = TextMetrics.isBreakingSpace(token);\n var lastIsBreakingSpace = TextMetrics.isBreakingSpace(line[line.length - 1]);\n if (currIsBreakingSpace && lastIsBreakingSpace) {\n continue;\n }\n }\n // get word width from cache if possible\n var tokenWidth = TextMetrics.getFromCache(token, letterSpacing, cache, context);\n // word is longer than desired bounds\n if (tokenWidth > wordWrapWidth) {\n // if we are not already at the beginning of a line\n if (line !== '') {\n // start newlines for overflow words\n lines += TextMetrics.addLine(line);\n line = '';\n width = 0;\n }\n // break large word over multiple lines\n if (TextMetrics.canBreakWords(token, style.breakWords)) {\n // break word into characters\n var characters = TextMetrics.wordWrapSplit(token);\n // loop the characters\n for (var j = 0; j < characters.length; j++) {\n var char = characters[j];\n var k = 1;\n // we are not at the end of the token\n while (characters[j + k]) {\n var nextChar = characters[j + k];\n var lastChar = char[char.length - 1];\n // should not split chars\n if (!TextMetrics.canBreakChars(lastChar, nextChar, token, j, style.breakWords)) {\n // combine chars & move forward one\n char += nextChar;\n }\n else {\n break;\n }\n k++;\n }\n j += char.length - 1;\n var characterWidth = TextMetrics.getFromCache(char, letterSpacing, cache, context);\n if (characterWidth + width > wordWrapWidth) {\n lines += TextMetrics.addLine(line);\n canPrependSpaces = false;\n line = '';\n width = 0;\n }\n line += char;\n width += characterWidth;\n }\n }\n // run word out of the bounds\n else {\n // if there are words in this line already\n // finish that line and start a new one\n if (line.length > 0) {\n lines += TextMetrics.addLine(line);\n line = '';\n width = 0;\n }\n var isLastToken = i === tokens.length - 1;\n // give it its own line if it's not the end\n lines += TextMetrics.addLine(token, !isLastToken);\n canPrependSpaces = false;\n line = '';\n width = 0;\n }\n }\n // word could fit\n else {\n // word won't fit because of existing words\n // start a new line\n if (tokenWidth + width > wordWrapWidth) {\n // if its a space we don't want it\n canPrependSpaces = false;\n // add a new line\n lines += TextMetrics.addLine(line);\n // start a new line\n line = '';\n width = 0;\n }\n // don't add spaces to the beginning of lines\n if (line.length > 0 || !TextMetrics.isBreakingSpace(token) || canPrependSpaces) {\n // add the word to the current line\n line += token;\n // update width counter\n width += tokenWidth;\n }\n }\n }\n lines += TextMetrics.addLine(line, false);\n return lines;\n };\n /**\n * Convienience function for logging each line added during the wordWrap method.\n * @param line - The line of text to add\n * @param newLine - Add new line character to end\n * @returns A formatted line\n */\n TextMetrics.addLine = function (line, newLine) {\n if (newLine === void 0) { newLine = true; }\n line = TextMetrics.trimRight(line);\n line = (newLine) ? line + \"\\n\" : line;\n return line;\n };\n /**\n * Gets & sets the widths of calculated characters in a cache object\n * @param key - The key\n * @param letterSpacing - The letter spacing\n * @param cache - The cache\n * @param context - The canvas context\n * @returns The from cache.\n */\n TextMetrics.getFromCache = function (key, letterSpacing, cache, context) {\n var width = cache[key];\n if (typeof width !== 'number') {\n var spacing = ((key.length) * letterSpacing);\n width = context.measureText(key).width + spacing;\n cache[key] = width;\n }\n return width;\n };\n /**\n * Determines whether we should collapse breaking spaces.\n * @param whiteSpace - The TextStyle property whiteSpace\n * @returns Should collapse\n */\n TextMetrics.collapseSpaces = function (whiteSpace) {\n return (whiteSpace === 'normal' || whiteSpace === 'pre-line');\n };\n /**\n * Determines whether we should collapse newLine chars.\n * @param whiteSpace - The white space\n * @returns should collapse\n */\n TextMetrics.collapseNewlines = function (whiteSpace) {\n return (whiteSpace === 'normal');\n };\n /**\n * Trims breaking whitespaces from string.\n * @param text - The text\n * @returns Trimmed string\n */\n TextMetrics.trimRight = function (text) {\n if (typeof text !== 'string') {\n return '';\n }\n for (var i = text.length - 1; i >= 0; i--) {\n var char = text[i];\n if (!TextMetrics.isBreakingSpace(char)) {\n break;\n }\n text = text.slice(0, -1);\n }\n return text;\n };\n /**\n * Determines if char is a newline.\n * @param char - The character\n * @returns True if newline, False otherwise.\n */\n TextMetrics.isNewline = function (char) {\n if (typeof char !== 'string') {\n return false;\n }\n return (TextMetrics._newlines.indexOf(char.charCodeAt(0)) >= 0);\n };\n /**\n * Determines if char is a breaking whitespace.\n *\n * It allows one to determine whether char should be a breaking whitespace\n * For example certain characters in CJK langs or numbers.\n * It must return a boolean.\n * @param char - The character\n * @param [_nextChar] - The next character\n * @returns True if whitespace, False otherwise.\n */\n TextMetrics.isBreakingSpace = function (char, _nextChar) {\n if (typeof char !== 'string') {\n return false;\n }\n return (TextMetrics._breakingSpaces.indexOf(char.charCodeAt(0)) >= 0);\n };\n /**\n * Splits a string into words, breaking-spaces and newLine characters\n * @param text - The text\n * @returns A tokenized array\n */\n TextMetrics.tokenize = function (text) {\n var tokens = [];\n var token = '';\n if (typeof text !== 'string') {\n return tokens;\n }\n for (var i = 0; i < text.length; i++) {\n var char = text[i];\n var nextChar = text[i + 1];\n if (TextMetrics.isBreakingSpace(char, nextChar) || TextMetrics.isNewline(char)) {\n if (token !== '') {\n tokens.push(token);\n token = '';\n }\n tokens.push(char);\n continue;\n }\n token += char;\n }\n if (token !== '') {\n tokens.push(token);\n }\n return tokens;\n };\n /**\n * Overridable helper method used internally by TextMetrics, exposed to allow customizing the class's behavior.\n *\n * It allows one to customise which words should break\n * Examples are if the token is CJK or numbers.\n * It must return a boolean.\n * @param _token - The token\n * @param breakWords - The style attr break words\n * @returns Whether to break word or not\n */\n TextMetrics.canBreakWords = function (_token, breakWords) {\n return breakWords;\n };\n /**\n * Overridable helper method used internally by TextMetrics, exposed to allow customizing the class's behavior.\n *\n * It allows one to determine whether a pair of characters\n * should be broken by newlines\n * For example certain characters in CJK langs or numbers.\n * It must return a boolean.\n * @param _char - The character\n * @param _nextChar - The next character\n * @param _token - The token/word the characters are from\n * @param _index - The index in the token of the char\n * @param _breakWords - The style attr break words\n * @returns whether to break word or not\n */\n TextMetrics.canBreakChars = function (_char, _nextChar, _token, _index, _breakWords) {\n return true;\n };\n /**\n * Overridable helper method used internally by TextMetrics, exposed to allow customizing the class's behavior.\n *\n * It is called when a token (usually a word) has to be split into separate pieces\n * in order to determine the point to break a word.\n * It must return an array of characters.\n * @example\n * // Correctly splits emojis, eg \"🤪🤪\" will result in two element array, each with one emoji.\n * TextMetrics.wordWrapSplit = (token) => [...token];\n * @param token - The token to split\n * @returns The characters of the token\n */\n TextMetrics.wordWrapSplit = function (token) {\n return token.split('');\n };\n /**\n * Calculates the ascent, descent and fontSize of a given font-style\n * @param font - String representing the style of the font\n * @returns Font properties object\n */\n TextMetrics.measureFont = function (font) {\n // as this method is used for preparing assets, don't recalculate things if we don't need to\n if (TextMetrics._fonts[font]) {\n return TextMetrics._fonts[font];\n }\n var properties = {\n ascent: 0,\n descent: 0,\n fontSize: 0,\n };\n var canvas = TextMetrics._canvas;\n var context = TextMetrics._context;\n context.font = font;\n var metricsString = TextMetrics.METRICS_STRING + TextMetrics.BASELINE_SYMBOL;\n var width = Math.ceil(context.measureText(metricsString).width);\n var baseline = Math.ceil(context.measureText(TextMetrics.BASELINE_SYMBOL).width);\n var height = Math.ceil(TextMetrics.HEIGHT_MULTIPLIER * baseline);\n baseline = baseline * TextMetrics.BASELINE_MULTIPLIER | 0;\n canvas.width = width;\n canvas.height = height;\n context.fillStyle = '#f00';\n context.fillRect(0, 0, width, height);\n context.font = font;\n context.textBaseline = 'alphabetic';\n context.fillStyle = '#000';\n context.fillText(metricsString, 0, baseline);\n var imagedata = context.getImageData(0, 0, width, height).data;\n var pixels = imagedata.length;\n var line = width * 4;\n var i = 0;\n var idx = 0;\n var stop = false;\n // ascent. scan from top to bottom until we find a non red pixel\n for (i = 0; i < baseline; ++i) {\n for (var j = 0; j < line; j += 4) {\n if (imagedata[idx + j] !== 255) {\n stop = true;\n break;\n }\n }\n if (!stop) {\n idx += line;\n }\n else {\n break;\n }\n }\n properties.ascent = baseline - i;\n idx = pixels - line;\n stop = false;\n // descent. scan from bottom to top until we find a non red pixel\n for (i = height; i > baseline; --i) {\n for (var j = 0; j < line; j += 4) {\n if (imagedata[idx + j] !== 255) {\n stop = true;\n break;\n }\n }\n if (!stop) {\n idx -= line;\n }\n else {\n break;\n }\n }\n properties.descent = i - baseline;\n properties.fontSize = properties.ascent + properties.descent;\n TextMetrics._fonts[font] = properties;\n return properties;\n };\n /**\n * Clear font metrics in metrics cache.\n * @param {string} [font] - font name. If font name not set then clear cache for all fonts.\n */\n TextMetrics.clearMetrics = function (font) {\n if (font === void 0) { font = ''; }\n if (font) {\n delete TextMetrics._fonts[font];\n }\n else {\n TextMetrics._fonts = {};\n }\n };\n Object.defineProperty(TextMetrics, \"_canvas\", {\n /**\n * Cached canvas element for measuring text\n * TODO: this should be private, but isn't because of backward compat, will fix later.\n * @ignore\n */\n get: function () {\n if (!TextMetrics.__canvas) {\n var canvas = void 0;\n try {\n // OffscreenCanvas2D measureText can be up to 40% faster.\n var c = new OffscreenCanvas(0, 0);\n var context = c.getContext('2d', contextSettings);\n if (context && context.measureText) {\n TextMetrics.__canvas = c;\n return c;\n }\n canvas = settings.ADAPTER.createCanvas();\n }\n catch (ex) {\n canvas = settings.ADAPTER.createCanvas();\n }\n canvas.width = canvas.height = 10;\n TextMetrics.__canvas = canvas;\n }\n return TextMetrics.__canvas;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TextMetrics, \"_context\", {\n /**\n * TODO: this should be private, but isn't because of backward compat, will fix later.\n * @ignore\n */\n get: function () {\n if (!TextMetrics.__context) {\n TextMetrics.__context = TextMetrics._canvas.getContext('2d', contextSettings);\n }\n return TextMetrics.__context;\n },\n enumerable: false,\n configurable: true\n });\n return TextMetrics;\n}());\n/**\n * Internal return object for {@link PIXI.TextMetrics.measureFont `TextMetrics.measureFont`}.\n * @typedef {object} FontMetrics\n * @property {number} ascent - The ascent distance\n * @property {number} descent - The descent distance\n * @property {number} fontSize - Font size from ascent to descent\n * @memberof PIXI.TextMetrics\n * @private\n */\n/**\n * Cache of {@see PIXI.TextMetrics.FontMetrics} objects.\n * @memberof PIXI.TextMetrics\n * @type {object}\n * @private\n */\nTextMetrics._fonts = {};\n/**\n * String used for calculate font metrics.\n * These characters are all tall to help calculate the height required for text.\n * @static\n * @memberof PIXI.TextMetrics\n * @name METRICS_STRING\n * @type {string}\n * @default |ÉqÅ\n */\nTextMetrics.METRICS_STRING = '|ÉqÅ';\n/**\n * Baseline symbol for calculate font metrics.\n * @static\n * @memberof PIXI.TextMetrics\n * @name BASELINE_SYMBOL\n * @type {string}\n * @default M\n */\nTextMetrics.BASELINE_SYMBOL = 'M';\n/**\n * Baseline multiplier for calculate font metrics.\n * @static\n * @memberof PIXI.TextMetrics\n * @name BASELINE_MULTIPLIER\n * @type {number}\n * @default 1.4\n */\nTextMetrics.BASELINE_MULTIPLIER = 1.4;\n/**\n * Height multiplier for setting height of canvas to calculate font metrics.\n * @static\n * @memberof PIXI.TextMetrics\n * @name HEIGHT_MULTIPLIER\n * @type {number}\n * @default 2.00\n */\nTextMetrics.HEIGHT_MULTIPLIER = 2.0;\n/**\n * Cache of new line chars.\n * @memberof PIXI.TextMetrics\n * @type {number[]}\n * @private\n */\nTextMetrics._newlines = [\n 0x000A,\n 0x000D ];\n/**\n * Cache of breaking spaces.\n * @memberof PIXI.TextMetrics\n * @type {number[]}\n * @private\n */\nTextMetrics._breakingSpaces = [\n 0x0009,\n 0x0020,\n 0x2000,\n 0x2001,\n 0x2002,\n 0x2003,\n 0x2004,\n 0x2005,\n 0x2006,\n 0x2008,\n 0x2009,\n 0x200A,\n 0x205F,\n 0x3000 ];\n/**\n * A number, or a string containing a number.\n * @memberof PIXI\n * @typedef {object} IFontMetrics\n * @property {number} ascent - Font ascent\n * @property {number} descent - Font descent\n * @property {number} fontSize - Font size\n */\n\nvar defaultDestroyOptions = {\n texture: true,\n children: false,\n baseTexture: true,\n};\n/**\n * A Text Object will create a line or multiple lines of text.\n *\n * The text is created using the [Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API).\n *\n * The primary advantage of this class over BitmapText is that you have great control over the style of the text,\n * which you can change at runtime.\n *\n * The primary disadvantages is that each piece of text has it's own texture, which can use more memory.\n * When text changes, this texture has to be re-generated and re-uploaded to the GPU, taking up time.\n *\n * To split a line you can use '\\n' in your text string, or, on the `style` object,\n * change its `wordWrap` property to true and and give the `wordWrapWidth` property a value.\n *\n * A Text can be created directly from a string and a style object,\n * which can be generated [here](https://pixijs.io/pixi-text-style).\n *\n * ```js\n * let text = new PIXI.Text('This is a PixiJS text',{fontFamily : 'Arial', fontSize: 24, fill : 0xff1010, align : 'center'});\n * ```\n * @memberof PIXI\n */\nvar Text = /** @class */ (function (_super) {\n __extends(Text, _super);\n /**\n * @param text - The string that you would like the text to display\n * @param {object|PIXI.TextStyle} [style] - The style parameters\n * @param canvas - The canvas element for drawing text\n */\n function Text(text, style, canvas) {\n var _this = this;\n var ownCanvas = false;\n if (!canvas) {\n canvas = settings.ADAPTER.createCanvas();\n ownCanvas = true;\n }\n canvas.width = 3;\n canvas.height = 3;\n var texture = Texture.from(canvas);\n texture.orig = new Rectangle();\n texture.trim = new Rectangle();\n _this = _super.call(this, texture) || this;\n _this._ownCanvas = ownCanvas;\n _this.canvas = canvas;\n _this.context = canvas.getContext('2d', {\n // required for trimming to work without warnings\n willReadFrequently: true,\n });\n _this._resolution = settings.RESOLUTION;\n _this._autoResolution = true;\n _this._text = null;\n _this._style = null;\n _this._styleListener = null;\n _this._font = '';\n _this.text = text;\n _this.style = style;\n _this.localStyleID = -1;\n return _this;\n }\n /**\n * Renders text to its canvas, and updates its texture.\n *\n * By default this is used internally to ensure the texture is correct before rendering,\n * but it can be used called externally, for example from this class to 'pre-generate' the texture from a piece of text,\n * and then shared across multiple Sprites.\n * @param respectDirty - Whether to abort updating the text if the Text isn't dirty and the function is called.\n */\n Text.prototype.updateText = function (respectDirty) {\n var style = this._style;\n // check if style has changed..\n if (this.localStyleID !== style.styleID) {\n this.dirty = true;\n this.localStyleID = style.styleID;\n }\n if (!this.dirty && respectDirty) {\n return;\n }\n this._font = this._style.toFontString();\n var context = this.context;\n var measured = TextMetrics.measureText(this._text || ' ', this._style, this._style.wordWrap, this.canvas);\n var width = measured.width;\n var height = measured.height;\n var lines = measured.lines;\n var lineHeight = measured.lineHeight;\n var lineWidths = measured.lineWidths;\n var maxLineWidth = measured.maxLineWidth;\n var fontProperties = measured.fontProperties;\n this.canvas.width = Math.ceil(Math.ceil((Math.max(1, width) + (style.padding * 2))) * this._resolution);\n this.canvas.height = Math.ceil(Math.ceil((Math.max(1, height) + (style.padding * 2))) * this._resolution);\n context.scale(this._resolution, this._resolution);\n context.clearRect(0, 0, this.canvas.width, this.canvas.height);\n context.font = this._font;\n context.lineWidth = style.strokeThickness;\n context.textBaseline = style.textBaseline;\n context.lineJoin = style.lineJoin;\n context.miterLimit = style.miterLimit;\n var linePositionX;\n var linePositionY;\n // require 2 passes if a shadow; the first to draw the drop shadow, the second to draw the text\n var passesCount = style.dropShadow ? 2 : 1;\n // For v4, we drew text at the colours of the drop shadow underneath the normal text. This gave the correct zIndex,\n // but features such as alpha and shadowblur did not look right at all, since we were using actual text as a shadow.\n //\n // For v5.0.0, we moved over to just use the canvas API for drop shadows, which made them look much nicer and more\n // visually please, but now because the stroke is drawn and then the fill, drop shadows would appear on both the fill\n // and the stroke; and fill drop shadows would appear over the top of the stroke.\n //\n // For v5.1.1, the new route is to revert to v4 style of drawing text first to get the drop shadows underneath normal\n // text, but instead drawing text in the correct location, we'll draw it off screen (-paddingY), and then adjust the\n // drop shadow so only that appears on screen (+paddingY). Now we'll have the correct draw order of the shadow\n // beneath the text, whilst also having the proper text shadow styling.\n for (var i = 0; i < passesCount; ++i) {\n var isShadowPass = style.dropShadow && i === 0;\n // we only want the drop shadow, so put text way off-screen\n var dsOffsetText = isShadowPass ? Math.ceil(Math.max(1, height) + (style.padding * 2)) : 0;\n var dsOffsetShadow = dsOffsetText * this._resolution;\n if (isShadowPass) {\n // On Safari, text with gradient and drop shadows together do not position correctly\n // if the scale of the canvas is not 1: https://bugs.webkit.org/show_bug.cgi?id=197689\n // Therefore we'll set the styles to be a plain black whilst generating this drop shadow\n context.fillStyle = 'black';\n context.strokeStyle = 'black';\n var dropShadowColor = style.dropShadowColor;\n var rgb = hex2rgb(typeof dropShadowColor === 'number' ? dropShadowColor : string2hex(dropShadowColor));\n var dropShadowBlur = style.dropShadowBlur * this._resolution;\n var dropShadowDistance = style.dropShadowDistance * this._resolution;\n context.shadowColor = \"rgba(\" + rgb[0] * 255 + \",\" + rgb[1] * 255 + \",\" + rgb[2] * 255 + \",\" + style.dropShadowAlpha + \")\";\n context.shadowBlur = dropShadowBlur;\n context.shadowOffsetX = Math.cos(style.dropShadowAngle) * dropShadowDistance;\n context.shadowOffsetY = (Math.sin(style.dropShadowAngle) * dropShadowDistance) + dsOffsetShadow;\n }\n else {\n // set canvas text styles\n context.fillStyle = this._generateFillStyle(style, lines, measured);\n // TODO: Can't have different types for getter and setter. The getter shouldn't have the number type as\n // the setter converts to string. See this thread for more details:\n // https://github.com/microsoft/TypeScript/issues/2521\n context.strokeStyle = style.stroke;\n context.shadowColor = 'black';\n context.shadowBlur = 0;\n context.shadowOffsetX = 0;\n context.shadowOffsetY = 0;\n }\n var linePositionYShift = (lineHeight - fontProperties.fontSize) / 2;\n if (!Text.nextLineHeightBehavior || lineHeight - fontProperties.fontSize < 0) {\n linePositionYShift = 0;\n }\n // draw lines line by line\n for (var i_1 = 0; i_1 < lines.length; i_1++) {\n linePositionX = style.strokeThickness / 2;\n linePositionY = ((style.strokeThickness / 2) + (i_1 * lineHeight)) + fontProperties.ascent\n + linePositionYShift;\n if (style.align === 'right') {\n linePositionX += maxLineWidth - lineWidths[i_1];\n }\n else if (style.align === 'center') {\n linePositionX += (maxLineWidth - lineWidths[i_1]) / 2;\n }\n if (style.stroke && style.strokeThickness) {\n this.drawLetterSpacing(lines[i_1], linePositionX + style.padding, linePositionY + style.padding - dsOffsetText, true);\n }\n if (style.fill) {\n this.drawLetterSpacing(lines[i_1], linePositionX + style.padding, linePositionY + style.padding - dsOffsetText);\n }\n }\n }\n this.updateTexture();\n };\n /**\n * Render the text with letter-spacing.\n * @param text - The text to draw\n * @param x - Horizontal position to draw the text\n * @param y - Vertical position to draw the text\n * @param isStroke - Is this drawing for the outside stroke of the\n * text? If not, it's for the inside fill\n */\n Text.prototype.drawLetterSpacing = function (text, x, y, isStroke) {\n if (isStroke === void 0) { isStroke = false; }\n var style = this._style;\n // letterSpacing of 0 means normal\n var letterSpacing = style.letterSpacing;\n // Checking that we can use moddern canvas2D api\n // https://developer.chrome.com/origintrials/#/view_trial/3585991203293757441\n // note: this is unstable API, Chrome less 94 use a `textLetterSpacing`, newest use a letterSpacing\n // eslint-disable-next-line max-len\n var supportLetterSpacing = Text.experimentalLetterSpacing\n && ('letterSpacing' in CanvasRenderingContext2D.prototype\n || 'textLetterSpacing' in CanvasRenderingContext2D.prototype);\n if (letterSpacing === 0 || supportLetterSpacing) {\n if (supportLetterSpacing) {\n this.context.letterSpacing = letterSpacing;\n this.context.textLetterSpacing = letterSpacing;\n }\n if (isStroke) {\n this.context.strokeText(text, x, y);\n }\n else {\n this.context.fillText(text, x, y);\n }\n return;\n }\n var currentPosition = x;\n // Using Array.from correctly splits characters whilst keeping emoji together.\n // This is not supported on IE as it requires ES6, so regular text splitting occurs.\n // This also doesn't account for emoji that are multiple emoji put together to make something else.\n // Handling all of this would require a big library itself.\n // https://medium.com/@giltayar/iterating-over-emoji-characters-the-es6-way-f06e4589516\n // https://github.com/orling/grapheme-splitter\n var stringArray = Array.from ? Array.from(text) : text.split('');\n var previousWidth = this.context.measureText(text).width;\n var currentWidth = 0;\n for (var i = 0; i < stringArray.length; ++i) {\n var currentChar = stringArray[i];\n if (isStroke) {\n this.context.strokeText(currentChar, currentPosition, y);\n }\n else {\n this.context.fillText(currentChar, currentPosition, y);\n }\n var textStr = '';\n for (var j = i + 1; j < stringArray.length; ++j) {\n textStr += stringArray[j];\n }\n currentWidth = this.context.measureText(textStr).width;\n currentPosition += previousWidth - currentWidth + letterSpacing;\n previousWidth = currentWidth;\n }\n };\n /** Updates texture size based on canvas size. */\n Text.prototype.updateTexture = function () {\n var canvas = this.canvas;\n if (this._style.trim) {\n var trimmed = trimCanvas(canvas);\n if (trimmed.data) {\n canvas.width = trimmed.width;\n canvas.height = trimmed.height;\n this.context.putImageData(trimmed.data, 0, 0);\n }\n }\n var texture = this._texture;\n var style = this._style;\n var padding = style.trim ? 0 : style.padding;\n var baseTexture = texture.baseTexture;\n texture.trim.width = texture._frame.width = canvas.width / this._resolution;\n texture.trim.height = texture._frame.height = canvas.height / this._resolution;\n texture.trim.x = -padding;\n texture.trim.y = -padding;\n texture.orig.width = texture._frame.width - (padding * 2);\n texture.orig.height = texture._frame.height - (padding * 2);\n // call sprite onTextureUpdate to update scale if _width or _height were set\n this._onTextureUpdate();\n baseTexture.setRealSize(canvas.width, canvas.height, this._resolution);\n texture.updateUvs();\n this.dirty = false;\n };\n /**\n * Renders the object using the WebGL renderer\n * @param renderer - The renderer\n */\n Text.prototype._render = function (renderer) {\n if (this._autoResolution && this._resolution !== renderer.resolution) {\n this._resolution = renderer.resolution;\n this.dirty = true;\n }\n this.updateText(true);\n _super.prototype._render.call(this, renderer);\n };\n /** Updates the transform on all children of this container for rendering. */\n Text.prototype.updateTransform = function () {\n this.updateText(true);\n _super.prototype.updateTransform.call(this);\n };\n Text.prototype.getBounds = function (skipUpdate, rect) {\n this.updateText(true);\n if (this._textureID === -1) {\n // texture was updated: recalculate transforms\n skipUpdate = false;\n }\n return _super.prototype.getBounds.call(this, skipUpdate, rect);\n };\n /**\n * Gets the local bounds of the text object.\n * @param rect - The output rectangle.\n * @returns The bounds.\n */\n Text.prototype.getLocalBounds = function (rect) {\n this.updateText(true);\n return _super.prototype.getLocalBounds.call(this, rect);\n };\n /** Calculates the bounds of the Text as a rectangle. The bounds calculation takes the worldTransform into account. */\n Text.prototype._calculateBounds = function () {\n this.calculateVertices();\n // if we have already done this on THIS frame.\n this._bounds.addQuad(this.vertexData);\n };\n /**\n * Generates the fill style. Can automatically generate a gradient based on the fill style being an array\n * @param style - The style.\n * @param lines - The lines of text.\n * @param metrics\n * @returns The fill style\n */\n Text.prototype._generateFillStyle = function (style, lines, metrics) {\n // TODO: Can't have different types for getter and setter. The getter shouldn't have the number type as\n // the setter converts to string. See this thread for more details:\n // https://github.com/microsoft/TypeScript/issues/2521\n var fillStyle = style.fill;\n if (!Array.isArray(fillStyle)) {\n return fillStyle;\n }\n else if (fillStyle.length === 1) {\n return fillStyle[0];\n }\n // the gradient will be evenly spaced out according to how large the array is.\n // ['#FF0000', '#00FF00', '#0000FF'] would created stops at 0.25, 0.5 and 0.75\n var gradient;\n // a dropshadow will enlarge the canvas and result in the gradient being\n // generated with the incorrect dimensions\n var dropShadowCorrection = (style.dropShadow) ? style.dropShadowDistance : 0;\n // should also take padding into account, padding can offset the gradient\n var padding = style.padding || 0;\n var width = (this.canvas.width / this._resolution) - dropShadowCorrection - (padding * 2);\n var height = (this.canvas.height / this._resolution) - dropShadowCorrection - (padding * 2);\n // make a copy of the style settings, so we can manipulate them later\n var fill = fillStyle.slice();\n var fillGradientStops = style.fillGradientStops.slice();\n // wanting to evenly distribute the fills. So an array of 4 colours should give fills of 0.25, 0.5 and 0.75\n if (!fillGradientStops.length) {\n var lengthPlus1 = fill.length + 1;\n for (var i = 1; i < lengthPlus1; ++i) {\n fillGradientStops.push(i / lengthPlus1);\n }\n }\n // stop the bleeding of the last gradient on the line above to the top gradient of the this line\n // by hard defining the first gradient colour at point 0, and last gradient colour at point 1\n fill.unshift(fillStyle[0]);\n fillGradientStops.unshift(0);\n fill.push(fillStyle[fillStyle.length - 1]);\n fillGradientStops.push(1);\n if (style.fillGradientType === TEXT_GRADIENT.LINEAR_VERTICAL) {\n // start the gradient at the top center of the canvas, and end at the bottom middle of the canvas\n gradient = this.context.createLinearGradient(width / 2, padding, width / 2, height + padding);\n // we need to repeat the gradient so that each individual line of text has the same vertical gradient effect\n // ['#FF0000', '#00FF00', '#0000FF'] over 2 lines would create stops at 0.125, 0.25, 0.375, 0.625, 0.75, 0.875\n // Actual height of the text itself, not counting spacing for lineHeight/leading/dropShadow etc\n var textHeight = metrics.fontProperties.fontSize + style.strokeThickness;\n for (var i = 0; i < lines.length; i++) {\n var lastLineBottom = (metrics.lineHeight * (i - 1)) + textHeight;\n var thisLineTop = metrics.lineHeight * i;\n var thisLineGradientStart = thisLineTop;\n // Handle case where last & this line overlap\n if (i > 0 && lastLineBottom > thisLineTop) {\n thisLineGradientStart = (thisLineTop + lastLineBottom) / 2;\n }\n var thisLineBottom = thisLineTop + textHeight;\n var nextLineTop = metrics.lineHeight * (i + 1);\n var thisLineGradientEnd = thisLineBottom;\n // Handle case where this & next line overlap\n if (i + 1 < lines.length && nextLineTop < thisLineBottom) {\n thisLineGradientEnd = (thisLineBottom + nextLineTop) / 2;\n }\n // textHeight, but as a 0-1 size in global gradient stop space\n var gradStopLineHeight = (thisLineGradientEnd - thisLineGradientStart) / height;\n for (var j = 0; j < fill.length; j++) {\n // 0-1 stop point for the current line, multiplied to global space afterwards\n var lineStop = 0;\n if (typeof fillGradientStops[j] === 'number') {\n lineStop = fillGradientStops[j];\n }\n else {\n lineStop = j / fill.length;\n }\n var globalStop = Math.min(1, Math.max(0, (thisLineGradientStart / height) + (lineStop * gradStopLineHeight)));\n // There's potential for floating point precision issues at the seams between gradient repeats.\n globalStop = Number(globalStop.toFixed(5));\n gradient.addColorStop(globalStop, fill[j]);\n }\n }\n }\n else {\n // start the gradient at the center left of the canvas, and end at the center right of the canvas\n gradient = this.context.createLinearGradient(padding, height / 2, width + padding, height / 2);\n // can just evenly space out the gradients in this case, as multiple lines makes no difference\n // to an even left to right gradient\n var totalIterations = fill.length + 1;\n var currentIteration = 1;\n for (var i = 0; i < fill.length; i++) {\n var stop = void 0;\n if (typeof fillGradientStops[i] === 'number') {\n stop = fillGradientStops[i];\n }\n else {\n stop = currentIteration / totalIterations;\n }\n gradient.addColorStop(stop, fill[i]);\n currentIteration++;\n }\n }\n return gradient;\n };\n /**\n * Destroys this text object.\n *\n * Note* Unlike a Sprite, a Text object will automatically destroy its baseTexture and texture as\n * the majority of the time the texture will not be shared with any other Sprites.\n * @param options - Options parameter. A boolean will act as if all options\n * have been set to that value\n * @param {boolean} [options.children=false] - if set to true, all the children will have their\n * destroy method called as well. 'options' will be passed on to those calls.\n * @param {boolean} [options.texture=true] - Should it destroy the current texture of the sprite as well\n * @param {boolean} [options.baseTexture=true] - Should it destroy the base texture of the sprite as well\n */\n Text.prototype.destroy = function (options) {\n if (typeof options === 'boolean') {\n options = { children: options };\n }\n options = Object.assign({}, defaultDestroyOptions, options);\n _super.prototype.destroy.call(this, options);\n // set canvas width and height to 0 to workaround memory leak in Safari < 13\n // https://stackoverflow.com/questions/52532614/total-canvas-memory-use-exceeds-the-maximum-limit-safari-12\n if (this._ownCanvas) {\n this.canvas.height = this.canvas.width = 0;\n }\n // make sure to reset the context and canvas.. dont want this hanging around in memory!\n this.context = null;\n this.canvas = null;\n this._style = null;\n };\n Object.defineProperty(Text.prototype, \"width\", {\n /** The width of the Text, setting this will actually modify the scale to achieve the value set. */\n get: function () {\n this.updateText(true);\n return Math.abs(this.scale.x) * this._texture.orig.width;\n },\n set: function (value) {\n this.updateText(true);\n var s = sign(this.scale.x) || 1;\n this.scale.x = s * value / this._texture.orig.width;\n this._width = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Text.prototype, \"height\", {\n /** The height of the Text, setting this will actually modify the scale to achieve the value set. */\n get: function () {\n this.updateText(true);\n return Math.abs(this.scale.y) * this._texture.orig.height;\n },\n set: function (value) {\n this.updateText(true);\n var s = sign(this.scale.y) || 1;\n this.scale.y = s * value / this._texture.orig.height;\n this._height = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Text.prototype, \"style\", {\n /**\n * Set the style of the text.\n *\n * Set up an event listener to listen for changes on the style object and mark the text as dirty.\n */\n get: function () {\n // TODO: Can't have different types for getter and setter. The getter shouldn't have the ITextStyle\n // since the setter creates the TextStyle. See this thread for more details:\n // https://github.com/microsoft/TypeScript/issues/2521\n return this._style;\n },\n set: function (style) {\n style = style || {};\n if (style instanceof TextStyle) {\n this._style = style;\n }\n else {\n this._style = new TextStyle(style);\n }\n this.localStyleID = -1;\n this.dirty = true;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Text.prototype, \"text\", {\n /** Set the copy for the text object. To split a line you can use '\\n'. */\n get: function () {\n return this._text;\n },\n set: function (text) {\n text = String(text === null || text === undefined ? '' : text);\n if (this._text === text) {\n return;\n }\n this._text = text;\n this.dirty = true;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Text.prototype, \"resolution\", {\n /**\n * The resolution / device pixel ratio of the canvas.\n *\n * This is set to automatically match the renderer resolution by default, but can be overridden by setting manually.\n * @default 1\n */\n get: function () {\n return this._resolution;\n },\n set: function (value) {\n this._autoResolution = false;\n if (this._resolution === value) {\n return;\n }\n this._resolution = value;\n this.dirty = true;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * New behavior for `lineHeight` that's meant to mimic HTML text. A value of `true` will\n * make sure the first baseline is offset by the `lineHeight` value if it is greater than `fontSize`.\n * A value of `false` will use the legacy behavior and not change the baseline of the first line.\n * In the next major release, we'll enable this by default.\n */\n Text.nextLineHeightBehavior = false;\n /**\n * New rendering behavior for letter-spacing which uses Chrome's new native API. This will\n * lead to more accurate letter-spacing results because it does not try to manually draw\n * each character. However, this Chrome API is experimental and may not serve all cases yet.\n */\n Text.experimentalLetterSpacing = false;\n return Text;\n}(Sprite));\n\nexport { TEXT_GRADIENT, Text, TextMetrics, TextStyle };\n//# sourceMappingURL=text.mjs.map\n","/*!\n * @pixi/prepare - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/prepare is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { settings } from '@pixi/settings';\nimport { Texture, BaseTexture, ExtensionType } from '@pixi/core';\nimport { Graphics } from '@pixi/graphics';\nimport { Ticker, UPDATE_PRIORITY } from '@pixi/ticker';\nimport { Container } from '@pixi/display';\nimport { Text, TextStyle, TextMetrics } from '@pixi/text';\nimport { deprecation } from '@pixi/utils';\n\n/**\n * Default number of uploads per frame using prepare plugin.\n * @static\n * @memberof PIXI.settings\n * @name UPLOADS_PER_FRAME\n * @type {number}\n * @default 4\n */\nsettings.UPLOADS_PER_FRAME = 4;\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\n/**\n * CountLimiter limits the number of items handled by a {@link PIXI.BasePrepare} to a specified\n * number of items per frame.\n * @memberof PIXI\n */\nvar CountLimiter = /** @class */ (function () {\n /**\n * @param maxItemsPerFrame - The maximum number of items that can be prepared each frame.\n */\n function CountLimiter(maxItemsPerFrame) {\n this.maxItemsPerFrame = maxItemsPerFrame;\n this.itemsLeft = 0;\n }\n /** Resets any counting properties to start fresh on a new frame. */\n CountLimiter.prototype.beginFrame = function () {\n this.itemsLeft = this.maxItemsPerFrame;\n };\n /**\n * Checks to see if another item can be uploaded. This should only be called once per item.\n * @returns If the item is allowed to be uploaded.\n */\n CountLimiter.prototype.allowedToUpload = function () {\n return this.itemsLeft-- > 0;\n };\n return CountLimiter;\n}());\n\n/**\n * Built-in hook to find multiple textures from objects like AnimatedSprites.\n * @private\n * @param item - Display object to check\n * @param queue - Collection of items to upload\n * @returns If a PIXI.Texture object was found.\n */\nfunction findMultipleBaseTextures(item, queue) {\n var result = false;\n // Objects with multiple textures\n if (item && item._textures && item._textures.length) {\n for (var i = 0; i < item._textures.length; i++) {\n if (item._textures[i] instanceof Texture) {\n var baseTexture = item._textures[i].baseTexture;\n if (queue.indexOf(baseTexture) === -1) {\n queue.push(baseTexture);\n result = true;\n }\n }\n }\n }\n return result;\n}\n/**\n * Built-in hook to find BaseTextures from Texture.\n * @private\n * @param item - Display object to check\n * @param queue - Collection of items to upload\n * @returns If a PIXI.Texture object was found.\n */\nfunction findBaseTexture(item, queue) {\n if (item.baseTexture instanceof BaseTexture) {\n var texture = item.baseTexture;\n if (queue.indexOf(texture) === -1) {\n queue.push(texture);\n }\n return true;\n }\n return false;\n}\n/**\n * Built-in hook to find textures from objects.\n * @private\n * @param item - Display object to check\n * @param queue - Collection of items to upload\n * @returns If a PIXI.Texture object was found.\n */\nfunction findTexture(item, queue) {\n if (item._texture && item._texture instanceof Texture) {\n var texture = item._texture.baseTexture;\n if (queue.indexOf(texture) === -1) {\n queue.push(texture);\n }\n return true;\n }\n return false;\n}\n/**\n * Built-in hook to draw PIXI.Text to its texture.\n * @private\n * @param _helper - Not used by this upload handler\n * @param item - Item to check\n * @returns If item was uploaded.\n */\nfunction drawText(_helper, item) {\n if (item instanceof Text) {\n // updating text will return early if it is not dirty\n item.updateText(true);\n return true;\n }\n return false;\n}\n/**\n * Built-in hook to calculate a text style for a PIXI.Text object.\n * @private\n * @param _helper - Not used by this upload handler\n * @param item - Item to check\n * @returns If item was uploaded.\n */\nfunction calculateTextStyle(_helper, item) {\n if (item instanceof TextStyle) {\n var font = item.toFontString();\n TextMetrics.measureFont(font);\n return true;\n }\n return false;\n}\n/**\n * Built-in hook to find Text objects.\n * @private\n * @param item - Display object to check\n * @param queue - Collection of items to upload\n * @returns if a PIXI.Text object was found.\n */\nfunction findText(item, queue) {\n if (item instanceof Text) {\n // push the text style to prepare it - this can be really expensive\n if (queue.indexOf(item.style) === -1) {\n queue.push(item.style);\n }\n // also push the text object so that we can render it (to canvas/texture) if needed\n if (queue.indexOf(item) === -1) {\n queue.push(item);\n }\n // also push the Text's texture for upload to GPU\n var texture = item._texture.baseTexture;\n if (queue.indexOf(texture) === -1) {\n queue.push(texture);\n }\n return true;\n }\n return false;\n}\n/**\n * Built-in hook to find TextStyle objects.\n * @private\n * @param item - Display object to check\n * @param queue - Collection of items to upload\n * @returns If a PIXI.TextStyle object was found.\n */\nfunction findTextStyle(item, queue) {\n if (item instanceof TextStyle) {\n if (queue.indexOf(item) === -1) {\n queue.push(item);\n }\n return true;\n }\n return false;\n}\n/**\n * The prepare manager provides functionality to upload content to the GPU.\n *\n * BasePrepare handles basic queuing functionality and is extended by\n * {@link PIXI.Prepare} and {@link PIXI.CanvasPrepare}\n * to provide preparation capabilities specific to their respective renderers.\n * @example\n * // Create a sprite\n * const sprite = PIXI.Sprite.from('something.png');\n *\n * // Load object into GPU\n * app.renderer.plugins.prepare.upload(sprite, () => {\n *\n * //Texture(s) has been uploaded to GPU\n * app.stage.addChild(sprite);\n *\n * })\n * @abstract\n * @memberof PIXI\n */\nvar BasePrepare = /** @class */ (function () {\n /**\n * @param {PIXI.AbstractRenderer} renderer - A reference to the current renderer\n */\n function BasePrepare(renderer) {\n var _this = this;\n this.limiter = new CountLimiter(settings.UPLOADS_PER_FRAME);\n this.renderer = renderer;\n this.uploadHookHelper = null;\n this.queue = [];\n this.addHooks = [];\n this.uploadHooks = [];\n this.completes = [];\n this.ticking = false;\n this.delayedTick = function () {\n // unlikely, but in case we were destroyed between tick() and delayedTick()\n if (!_this.queue) {\n return;\n }\n _this.prepareItems();\n };\n // hooks to find the correct texture\n this.registerFindHook(findText);\n this.registerFindHook(findTextStyle);\n this.registerFindHook(findMultipleBaseTextures);\n this.registerFindHook(findBaseTexture);\n this.registerFindHook(findTexture);\n // upload hooks\n this.registerUploadHook(drawText);\n this.registerUploadHook(calculateTextStyle);\n }\n /** @ignore */\n BasePrepare.prototype.upload = function (item, done) {\n var _this = this;\n if (typeof item === 'function') {\n done = item;\n item = null;\n }\n if (done) {\n deprecation('6.5.0', 'BasePrepare.upload callback is deprecated, use the return Promise instead.');\n }\n return new Promise(function (resolve) {\n // If a display object, search for items\n // that we could upload\n if (item) {\n _this.add(item);\n }\n // TODO: remove done callback and just use resolve\n var complete = function () {\n done === null || done === void 0 ? void 0 : done();\n resolve();\n };\n // Get the items for upload from the display\n if (_this.queue.length) {\n _this.completes.push(complete);\n if (!_this.ticking) {\n _this.ticking = true;\n Ticker.system.addOnce(_this.tick, _this, UPDATE_PRIORITY.UTILITY);\n }\n }\n else {\n complete();\n }\n });\n };\n /**\n * Handle tick update\n * @private\n */\n BasePrepare.prototype.tick = function () {\n setTimeout(this.delayedTick, 0);\n };\n /**\n * Actually prepare items. This is handled outside of the tick because it will take a while\n * and we do NOT want to block the current animation frame from rendering.\n * @private\n */\n BasePrepare.prototype.prepareItems = function () {\n this.limiter.beginFrame();\n // Upload the graphics\n while (this.queue.length && this.limiter.allowedToUpload()) {\n var item = this.queue[0];\n var uploaded = false;\n if (item && !item._destroyed) {\n for (var i = 0, len = this.uploadHooks.length; i < len; i++) {\n if (this.uploadHooks[i](this.uploadHookHelper, item)) {\n this.queue.shift();\n uploaded = true;\n break;\n }\n }\n }\n if (!uploaded) {\n this.queue.shift();\n }\n }\n // We're finished\n if (!this.queue.length) {\n this.ticking = false;\n var completes = this.completes.slice(0);\n this.completes.length = 0;\n for (var i = 0, len = completes.length; i < len; i++) {\n completes[i]();\n }\n }\n else {\n // if we are not finished, on the next rAF do this again\n Ticker.system.addOnce(this.tick, this, UPDATE_PRIORITY.UTILITY);\n }\n };\n /**\n * Adds hooks for finding items.\n * @param {Function} addHook - Function call that takes two parameters: `item:*, queue:Array`\n * function must return `true` if it was able to add item to the queue.\n * @returns Instance of plugin for chaining.\n */\n BasePrepare.prototype.registerFindHook = function (addHook) {\n if (addHook) {\n this.addHooks.push(addHook);\n }\n return this;\n };\n /**\n * Adds hooks for uploading items.\n * @param {Function} uploadHook - Function call that takes two parameters: `prepare:CanvasPrepare, item:*` and\n * function must return `true` if it was able to handle upload of item.\n * @returns Instance of plugin for chaining.\n */\n BasePrepare.prototype.registerUploadHook = function (uploadHook) {\n if (uploadHook) {\n this.uploadHooks.push(uploadHook);\n }\n return this;\n };\n /**\n * Manually add an item to the uploading queue.\n * @param {PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text|*} item - Object to\n * add to the queue\n * @returns Instance of plugin for chaining.\n */\n BasePrepare.prototype.add = function (item) {\n // Add additional hooks for finding elements on special\n // types of objects that\n for (var i = 0, len = this.addHooks.length; i < len; i++) {\n if (this.addHooks[i](item, this.queue)) {\n break;\n }\n }\n // Get children recursively\n if (item instanceof Container) {\n for (var i = item.children.length - 1; i >= 0; i--) {\n this.add(item.children[i]);\n }\n }\n return this;\n };\n /** Destroys the plugin, don't use after this. */\n BasePrepare.prototype.destroy = function () {\n if (this.ticking) {\n Ticker.system.remove(this.tick, this);\n }\n this.ticking = false;\n this.addHooks = null;\n this.uploadHooks = null;\n this.renderer = null;\n this.completes = null;\n this.queue = null;\n this.limiter = null;\n this.uploadHookHelper = null;\n };\n return BasePrepare;\n}());\n\n/**\n * Built-in hook to upload PIXI.Texture objects to the GPU.\n * @private\n * @param renderer - instance of the webgl renderer\n * @param item - Item to check\n * @returns If item was uploaded.\n */\nfunction uploadBaseTextures(renderer, item) {\n if (item instanceof BaseTexture) {\n // if the texture already has a GL texture, then the texture has been prepared or rendered\n // before now. If the texture changed, then the changer should be calling texture.update() which\n // reuploads the texture without need for preparing it again\n if (!item._glTextures[renderer.CONTEXT_UID]) {\n renderer.texture.bind(item);\n }\n return true;\n }\n return false;\n}\n/**\n * Built-in hook to upload PIXI.Graphics to the GPU.\n * @private\n * @param renderer - instance of the webgl renderer\n * @param item - Item to check\n * @returns If item was uploaded.\n */\nfunction uploadGraphics(renderer, item) {\n if (!(item instanceof Graphics)) {\n return false;\n }\n var geometry = item.geometry;\n // update dirty graphics to get batches\n item.finishPoly();\n geometry.updateBatches();\n var batches = geometry.batches;\n // upload all textures found in styles\n for (var i = 0; i < batches.length; i++) {\n var texture = batches[i].style.texture;\n if (texture) {\n uploadBaseTextures(renderer, texture.baseTexture);\n }\n }\n // if its not batchable - update vao for particular shader\n if (!geometry.batchable) {\n renderer.geometry.bind(geometry, item._resolveDirectShader(renderer));\n }\n return true;\n}\n/**\n * Built-in hook to find graphics.\n * @private\n * @param item - Display object to check\n * @param queue - Collection of items to upload\n * @returns if a PIXI.Graphics object was found.\n */\nfunction findGraphics(item, queue) {\n if (item instanceof Graphics) {\n queue.push(item);\n return true;\n }\n return false;\n}\n/**\n * The prepare plugin provides renderer-specific plugins for pre-rendering DisplayObjects. These plugins are useful for\n * asynchronously preparing and uploading to the GPU assets, textures, graphics waiting to be displayed.\n *\n * Do not instantiate this plugin directly. It is available from the `renderer.plugins` property.\n * See {@link PIXI.CanvasRenderer#plugins} or {@link PIXI.Renderer#plugins}.\n * @example\n * // Create a new application\n * const app = new PIXI.Application();\n * document.body.appendChild(app.view);\n *\n * // Don't start rendering right away\n * app.stop();\n *\n * // create a display object\n * const rect = new PIXI.Graphics()\n * .beginFill(0x00ff00)\n * .drawRect(40, 40, 200, 200);\n *\n * // Add to the stage\n * app.stage.addChild(rect);\n *\n * // Don't start rendering until the graphic is uploaded to the GPU\n * app.renderer.plugins.prepare.upload(app.stage, () => {\n * app.start();\n * });\n * @memberof PIXI\n */\nvar Prepare = /** @class */ (function (_super) {\n __extends(Prepare, _super);\n /**\n * @param {PIXI.Renderer} renderer - A reference to the current renderer\n */\n function Prepare(renderer) {\n var _this = _super.call(this, renderer) || this;\n _this.uploadHookHelper = _this.renderer;\n // Add textures and graphics to upload\n _this.registerFindHook(findGraphics);\n _this.registerUploadHook(uploadBaseTextures);\n _this.registerUploadHook(uploadGraphics);\n return _this;\n }\n /** @ignore */\n Prepare.extension = {\n name: 'prepare',\n type: ExtensionType.RendererPlugin,\n };\n return Prepare;\n}(BasePrepare));\n\n/**\n * TimeLimiter limits the number of items handled by a {@link PIXI.BasePrepare} to a specified\n * number of milliseconds per frame.\n * @memberof PIXI\n */\nvar TimeLimiter = /** @class */ (function () {\n /** @param maxMilliseconds - The maximum milliseconds that can be spent preparing items each frame. */\n function TimeLimiter(maxMilliseconds) {\n this.maxMilliseconds = maxMilliseconds;\n this.frameStart = 0;\n }\n /** Resets any counting properties to start fresh on a new frame. */\n TimeLimiter.prototype.beginFrame = function () {\n this.frameStart = Date.now();\n };\n /**\n * Checks to see if another item can be uploaded. This should only be called once per item.\n * @returns - If the item is allowed to be uploaded.\n */\n TimeLimiter.prototype.allowedToUpload = function () {\n return Date.now() - this.frameStart < this.maxMilliseconds;\n };\n return TimeLimiter;\n}());\n\nexport { BasePrepare, CountLimiter, Prepare, TimeLimiter };\n//# sourceMappingURL=prepare.mjs.map\n","/*!\n * @pixi/spritesheet - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/spritesheet is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { Rectangle } from '@pixi/math';\nimport { Texture, BaseTexture, ExtensionType } from '@pixi/core';\nimport { getResolutionOfUrl, deprecation, url } from '@pixi/utils';\nimport { LoaderResource } from '@pixi/loaders';\n\n/**\n * Utility class for maintaining reference to a collection\n * of Textures on a single Spritesheet.\n *\n * To access a sprite sheet from your code you may pass its JSON data file to Pixi's loader:\n *\n * ```js\n * PIXI.Loader.shared.add(\"images/spritesheet.json\").load(setup);\n *\n * function setup() {\n * let sheet = PIXI.Loader.shared.resources[\"images/spritesheet.json\"].spritesheet;\n * ...\n * }\n * ```\n *\n * Alternately, you may circumvent the loader by instantiating the Spritesheet directly:\n * ```js\n * const sheet = new PIXI.Spritesheet(texture, spritesheetData);\n * await sheet.parse();\n * console.log('Spritesheet ready to use!');\n * ```\n *\n * With the `sheet.textures` you can create Sprite objects,`sheet.animations` can be used to create an AnimatedSprite.\n *\n * Sprite sheets can be packed using tools like {@link https://codeandweb.com/texturepacker|TexturePacker},\n * {@link https://renderhjs.net/shoebox/|Shoebox} or {@link https://github.com/krzysztof-o/spritesheet.js|Spritesheet.js}.\n * Default anchor points (see {@link PIXI.Texture#defaultAnchor}) and grouping of animation sprites are currently only\n * supported by TexturePacker.\n * @memberof PIXI\n */\nvar Spritesheet = /** @class */ (function () {\n /**\n * @param texture - Reference to the source BaseTexture object.\n * @param {object} data - Spritesheet image data.\n * @param resolutionFilename - The filename to consider when determining\n * the resolution of the spritesheet. If not provided, the imageUrl will\n * be used on the BaseTexture.\n */\n function Spritesheet(texture, data, resolutionFilename) {\n if (resolutionFilename === void 0) { resolutionFilename = null; }\n /** For multi-packed spritesheets, this contains a reference to all the other spritesheets it depends on. */\n this.linkedSheets = [];\n this._texture = texture instanceof Texture ? texture : null;\n this.baseTexture = texture instanceof BaseTexture ? texture : this._texture.baseTexture;\n this.textures = {};\n this.animations = {};\n this.data = data;\n var resource = this.baseTexture.resource;\n this.resolution = this._updateResolution(resolutionFilename || (resource ? resource.url : null));\n this._frames = this.data.frames;\n this._frameKeys = Object.keys(this._frames);\n this._batchIndex = 0;\n this._callback = null;\n }\n /**\n * Generate the resolution from the filename or fallback\n * to the meta.scale field of the JSON data.\n * @param resolutionFilename - The filename to use for resolving\n * the default resolution.\n * @returns Resolution to use for spritesheet.\n */\n Spritesheet.prototype._updateResolution = function (resolutionFilename) {\n if (resolutionFilename === void 0) { resolutionFilename = null; }\n var scale = this.data.meta.scale;\n // Use a defaultValue of `null` to check if a url-based resolution is set\n var resolution = getResolutionOfUrl(resolutionFilename, null);\n // No resolution found via URL\n if (resolution === null) {\n // Use the scale value or default to 1\n resolution = scale !== undefined ? parseFloat(scale) : 1;\n }\n // For non-1 resolutions, update baseTexture\n if (resolution !== 1) {\n this.baseTexture.setResolution(resolution);\n }\n return resolution;\n };\n /** @ignore */\n Spritesheet.prototype.parse = function (callback) {\n var _this = this;\n if (callback) {\n deprecation('6.5.0', 'Spritesheet.parse callback is deprecated, use the return Promise instead.');\n }\n return new Promise(function (resolve) {\n _this._callback = function (textures) {\n callback === null || callback === void 0 ? void 0 : callback(textures);\n resolve(textures);\n };\n _this._batchIndex = 0;\n if (_this._frameKeys.length <= Spritesheet.BATCH_SIZE) {\n _this._processFrames(0);\n _this._processAnimations();\n _this._parseComplete();\n }\n else {\n _this._nextBatch();\n }\n });\n };\n /**\n * Process a batch of frames\n * @param initialFrameIndex - The index of frame to start.\n */\n Spritesheet.prototype._processFrames = function (initialFrameIndex) {\n var frameIndex = initialFrameIndex;\n var maxFrames = Spritesheet.BATCH_SIZE;\n while (frameIndex - initialFrameIndex < maxFrames && frameIndex < this._frameKeys.length) {\n var i = this._frameKeys[frameIndex];\n var data = this._frames[i];\n var rect = data.frame;\n if (rect) {\n var frame = null;\n var trim = null;\n var sourceSize = data.trimmed !== false && data.sourceSize\n ? data.sourceSize : data.frame;\n var orig = new Rectangle(0, 0, Math.floor(sourceSize.w) / this.resolution, Math.floor(sourceSize.h) / this.resolution);\n if (data.rotated) {\n 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);\n }\n else {\n 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);\n }\n // Check to see if the sprite is trimmed\n if (data.trimmed !== false && data.spriteSourceSize) {\n 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);\n }\n this.textures[i] = new Texture(this.baseTexture, frame, orig, trim, data.rotated ? 2 : 0, data.anchor);\n // lets also add the frame to pixi's global cache for 'from' and 'fromLoader' functions\n Texture.addToCache(this.textures[i], i);\n }\n frameIndex++;\n }\n };\n /** Parse animations config. */\n Spritesheet.prototype._processAnimations = function () {\n var animations = this.data.animations || {};\n for (var animName in animations) {\n this.animations[animName] = [];\n for (var i = 0; i < animations[animName].length; i++) {\n var frameName = animations[animName][i];\n this.animations[animName].push(this.textures[frameName]);\n }\n }\n };\n /** The parse has completed. */\n Spritesheet.prototype._parseComplete = function () {\n var callback = this._callback;\n this._callback = null;\n this._batchIndex = 0;\n callback.call(this, this.textures);\n };\n /** Begin the next batch of textures. */\n Spritesheet.prototype._nextBatch = function () {\n var _this = this;\n this._processFrames(this._batchIndex * Spritesheet.BATCH_SIZE);\n this._batchIndex++;\n setTimeout(function () {\n if (_this._batchIndex * Spritesheet.BATCH_SIZE < _this._frameKeys.length) {\n _this._nextBatch();\n }\n else {\n _this._processAnimations();\n _this._parseComplete();\n }\n }, 0);\n };\n /**\n * Destroy Spritesheet and don't use after this.\n * @param {boolean} [destroyBase=false] - Whether to destroy the base texture as well\n */\n Spritesheet.prototype.destroy = function (destroyBase) {\n var _a;\n if (destroyBase === void 0) { destroyBase = false; }\n for (var i in this.textures) {\n this.textures[i].destroy();\n }\n this._frames = null;\n this._frameKeys = null;\n this.data = null;\n this.textures = null;\n if (destroyBase) {\n (_a = this._texture) === null || _a === void 0 ? void 0 : _a.destroy();\n this.baseTexture.destroy();\n }\n this._texture = null;\n this.baseTexture = null;\n this.linkedSheets = [];\n };\n /** The maximum number of Textures to build per process. */\n Spritesheet.BATCH_SIZE = 1000;\n return Spritesheet;\n}());\n/**\n * Reference to Spritesheet object created.\n * @member {PIXI.Spritesheet} spritesheet\n * @memberof PIXI.LoaderResource\n * @instance\n */\n/**\n * Dictionary of textures from Spritesheet.\n * @member {Object} textures\n * @memberof PIXI.LoaderResource\n * @instance\n */\n\n/**\n * {@link PIXI.Loader} middleware for loading texture atlases that have been created with\n * TexturePacker or similar JSON-based spritesheet.\n *\n * This middleware automatically generates Texture resources.\n *\n * If you're using Webpack or other bundlers and plan on bundling the atlas' JSON,\n * use the {@link PIXI.Spritesheet} class to directly parse the JSON.\n *\n * The Loader's image Resource name is automatically appended with `\"_image\"`.\n * If a Resource with this name is already loaded, the Loader will skip parsing the\n * Spritesheet. The code below will generate an internal Loader Resource called `\"myatlas_image\"`.\n * @example\n * loader.add('myatlas', 'path/to/myatlas.json');\n * loader.load(() => {\n * loader.resources.myatlas; // atlas JSON resource\n * loader.resources.myatlas_image; // atlas Image resource\n * });\n * @memberof PIXI\n */\nvar SpritesheetLoader = /** @class */ (function () {\n function SpritesheetLoader() {\n }\n /**\n * Called after a resource is loaded.\n * @see PIXI.Loader.loaderMiddleware\n * @param resource\n * @param next\n */\n SpritesheetLoader.use = function (resource, next) {\n var _a, _b;\n // because this is middleware, it execute in loader context. `this` = loader\n var loader = this;\n var imageResourceName = resource.name + \"_image\";\n // skip if no data, its not json, it isn't spritesheet data, or the image resource already exists\n if (!resource.data\n || resource.type !== LoaderResource.TYPE.JSON\n || !resource.data.frames\n || loader.resources[imageResourceName]) {\n next();\n return;\n }\n // Check and add the multi atlas\n // Heavily influenced and based on https://github.com/rocket-ua/pixi-tps-loader/blob/master/src/ResourceLoader.js\n // eslint-disable-next-line camelcase\n var multiPacks = (_b = (_a = resource.data) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.related_multi_packs;\n if (Array.isArray(multiPacks)) {\n var _loop_1 = function (item) {\n if (typeof item !== 'string') {\n return \"continue\";\n }\n var itemName = item.replace('.json', '');\n var itemUrl = url.resolve(resource.url.replace(loader.baseUrl, ''), item);\n // Check if the file wasn't already added as multipacks are redundant\n if (loader.resources[itemName]\n || Object.values(loader.resources).some(function (r) { return url.format(url.parse(r.url)) === itemUrl; })) {\n return \"continue\";\n }\n var options = {\n crossOrigin: resource.crossOrigin,\n loadType: LoaderResource.LOAD_TYPE.XHR,\n xhrType: LoaderResource.XHR_RESPONSE_TYPE.JSON,\n parentResource: resource,\n metadata: resource.metadata\n };\n loader.add(itemName, itemUrl, options);\n };\n for (var _i = 0, multiPacks_1 = multiPacks; _i < multiPacks_1.length; _i++) {\n var item = multiPacks_1[_i];\n _loop_1(item);\n }\n }\n var loadOptions = {\n crossOrigin: resource.crossOrigin,\n metadata: resource.metadata.imageMetadata,\n parentResource: resource,\n };\n var resourcePath = SpritesheetLoader.getResourcePath(resource, loader.baseUrl);\n // load the image for this sheet\n loader.add(imageResourceName, resourcePath, loadOptions, function onImageLoad(res) {\n if (res.error) {\n next(res.error);\n return;\n }\n var spritesheet = new Spritesheet(res.texture, resource.data, resource.url);\n spritesheet.parse().then(function () {\n resource.spritesheet = spritesheet;\n resource.textures = spritesheet.textures;\n next();\n });\n });\n };\n /**\n * Get the spritesheets root path\n * @param resource - Resource to check path\n * @param baseUrl - Base root url\n */\n SpritesheetLoader.getResourcePath = function (resource, baseUrl) {\n // Prepend url path unless the resource image is a data url\n if (resource.isDataUrl) {\n return resource.data.meta.image;\n }\n return url.resolve(resource.url.replace(baseUrl, ''), resource.data.meta.image);\n };\n /** @ignore */\n SpritesheetLoader.extension = ExtensionType.Loader;\n return SpritesheetLoader;\n}());\n\nexport { Spritesheet, SpritesheetLoader };\n//# sourceMappingURL=spritesheet.mjs.map\n","/*!\n * @pixi/sprite-tiling - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/sprite-tiling is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { Texture, TextureMatrix, Shader, ExtensionType, QuadUv, State, ObjectRenderer } from '@pixi/core';\nimport { Point, Rectangle, Transform, Matrix } from '@pixi/math';\nimport { Sprite } from '@pixi/sprite';\nimport { WRAP_MODES } from '@pixi/constants';\nimport { premultiplyTintToRgba, correctBlendMode } from '@pixi/utils';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\nvar tempPoint = new Point();\n/**\n * A tiling sprite is a fast way of rendering a tiling image.\n * @memberof PIXI\n */\nvar TilingSprite = /** @class */ (function (_super) {\n __extends(TilingSprite, _super);\n /**\n * @param texture - The texture of the tiling sprite.\n * @param width - The width of the tiling sprite.\n * @param height - The height of the tiling sprite.\n */\n function TilingSprite(texture, width, height) {\n if (width === void 0) { width = 100; }\n if (height === void 0) { height = 100; }\n var _this = _super.call(this, texture) || this;\n _this.tileTransform = new Transform();\n // The width of the tiling sprite\n _this._width = width;\n // The height of the tiling sprite\n _this._height = height;\n _this.uvMatrix = _this.texture.uvMatrix || new TextureMatrix(texture);\n /**\n * Plugin that is responsible for rendering this element.\n * Allows to customize the rendering process without overriding '_render' method.\n * @default 'tilingSprite'\n */\n _this.pluginName = 'tilingSprite';\n _this.uvRespectAnchor = false;\n return _this;\n }\n Object.defineProperty(TilingSprite.prototype, \"clampMargin\", {\n /**\n * Changes frame clamping in corresponding textureTransform, shortcut\n * Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas\n * @default 0.5\n * @member {number}\n */\n get: function () {\n return this.uvMatrix.clampMargin;\n },\n set: function (value) {\n this.uvMatrix.clampMargin = value;\n this.uvMatrix.update(true);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TilingSprite.prototype, \"tileScale\", {\n /** The scaling of the image that is being tiled. */\n get: function () {\n return this.tileTransform.scale;\n },\n set: function (value) {\n this.tileTransform.scale.copyFrom(value);\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TilingSprite.prototype, \"tilePosition\", {\n /** The offset of the image that is being tiled. */\n get: function () {\n return this.tileTransform.position;\n },\n set: function (value) {\n this.tileTransform.position.copyFrom(value);\n },\n enumerable: false,\n configurable: true\n });\n /**\n * @protected\n */\n TilingSprite.prototype._onTextureUpdate = function () {\n if (this.uvMatrix) {\n this.uvMatrix.texture = this._texture;\n }\n this._cachedTint = 0xFFFFFF;\n };\n /**\n * Renders the object using the WebGL renderer\n * @param renderer - The renderer\n */\n TilingSprite.prototype._render = function (renderer) {\n // tweak our texture temporarily..\n var texture = this._texture;\n if (!texture || !texture.valid) {\n return;\n }\n this.tileTransform.updateLocalTransform();\n this.uvMatrix.update();\n renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]);\n renderer.plugins[this.pluginName].render(this);\n };\n /** Updates the bounds of the tiling sprite. */\n TilingSprite.prototype._calculateBounds = function () {\n var minX = this._width * -this._anchor._x;\n var minY = this._height * -this._anchor._y;\n var maxX = this._width * (1 - this._anchor._x);\n var maxY = this._height * (1 - this._anchor._y);\n this._bounds.addFrame(this.transform, minX, minY, maxX, maxY);\n };\n /**\n * Gets the local bounds of the sprite object.\n * @param rect - Optional output rectangle.\n * @returns The bounds.\n */\n TilingSprite.prototype.getLocalBounds = function (rect) {\n // we can do a fast local bounds if the sprite has no children!\n if (this.children.length === 0) {\n this._bounds.minX = this._width * -this._anchor._x;\n this._bounds.minY = this._height * -this._anchor._y;\n this._bounds.maxX = this._width * (1 - this._anchor._x);\n this._bounds.maxY = this._height * (1 - this._anchor._y);\n if (!rect) {\n if (!this._localBoundsRect) {\n this._localBoundsRect = new Rectangle();\n }\n rect = this._localBoundsRect;\n }\n return this._bounds.getRectangle(rect);\n }\n return _super.prototype.getLocalBounds.call(this, rect);\n };\n /**\n * Checks if a point is inside this tiling sprite.\n * @param point - The point to check.\n * @returns Whether or not the sprite contains the point.\n */\n TilingSprite.prototype.containsPoint = function (point) {\n this.worldTransform.applyInverse(point, tempPoint);\n var width = this._width;\n var height = this._height;\n var x1 = -width * this.anchor._x;\n if (tempPoint.x >= x1 && tempPoint.x < x1 + width) {\n var y1 = -height * this.anchor._y;\n if (tempPoint.y >= y1 && tempPoint.y < y1 + height) {\n return true;\n }\n }\n return false;\n };\n /**\n * Destroys this sprite and optionally its texture and children\n * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options\n * have been set to that value\n * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy\n * method called as well. 'options' will be passed on to those calls.\n * @param {boolean} [options.texture=false] - Should it destroy the current texture of the sprite as well\n * @param {boolean} [options.baseTexture=false] - Should it destroy the base texture of the sprite as well\n */\n TilingSprite.prototype.destroy = function (options) {\n _super.prototype.destroy.call(this, options);\n this.tileTransform = null;\n this.uvMatrix = null;\n };\n /**\n * Helper function that creates a new tiling sprite based on the source you provide.\n * The source can be - frame id, image url, video url, canvas element, video element, base texture\n * @static\n * @param {string|PIXI.Texture|HTMLCanvasElement|HTMLVideoElement} source - Source to create texture from\n * @param {object} options - See {@link PIXI.BaseTexture}'s constructor for options.\n * @param {number} options.width - required width of the tiling sprite\n * @param {number} options.height - required height of the tiling sprite\n * @returns {PIXI.TilingSprite} The newly created texture\n */\n TilingSprite.from = function (source, options) {\n var texture = (source instanceof Texture)\n ? source\n : Texture.from(source, options);\n return new TilingSprite(texture, options.width, options.height);\n };\n Object.defineProperty(TilingSprite.prototype, \"width\", {\n /** The width of the sprite, setting this will actually modify the scale to achieve the value set. */\n get: function () {\n return this._width;\n },\n set: function (value) {\n this._width = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(TilingSprite.prototype, \"height\", {\n /** The height of the TilingSprite, setting this will actually modify the scale to achieve the value set. */\n get: function () {\n return this._height;\n },\n set: function (value) {\n this._height = value;\n },\n enumerable: false,\n configurable: true\n });\n return TilingSprite;\n}(Sprite));\n\nvar fragmentSimpleSrc = \"#version 100\\n#define SHADER_NAME Tiling-Sprite-Simple-100\\n\\nprecision lowp float;\\n\\nvarying vec2 vTextureCoord;\\n\\nuniform sampler2D uSampler;\\nuniform vec4 uColor;\\n\\nvoid main(void)\\n{\\n vec4 texSample = texture2D(uSampler, vTextureCoord);\\n gl_FragColor = texSample * uColor;\\n}\\n\";\n\nvar gl1VertexSrc = \"#version 100\\n#define SHADER_NAME Tiling-Sprite-100\\n\\nprecision lowp float;\\n\\nattribute 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\";\n\nvar gl1FragmentSrc = \"#version 100\\n#ifdef GL_EXT_shader_texture_lod\\n #extension GL_EXT_shader_texture_lod : enable\\n#endif\\n#define SHADER_NAME Tiling-Sprite-100\\n\\nprecision lowp float;\\n\\nvarying 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 = vTextureCoord + ceil(uClampOffset - vTextureCoord);\\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\\n vec2 unclamped = coord;\\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\\n\\n #ifdef GL_EXT_shader_texture_lod\\n vec4 texSample = unclamped == coord\\n ? texture2D(uSampler, coord) \\n : texture2DLodEXT(uSampler, coord, 0);\\n #else\\n vec4 texSample = texture2D(uSampler, coord);\\n #endif\\n\\n gl_FragColor = texSample * uColor;\\n}\\n\";\n\nvar gl2VertexSrc = \"#version 300 es\\n#define SHADER_NAME Tiling-Sprite-300\\n\\nprecision lowp float;\\n\\nin vec2 aVertexPosition;\\nin vec2 aTextureCoord;\\n\\nuniform mat3 projectionMatrix;\\nuniform mat3 translationMatrix;\\nuniform mat3 uTransform;\\n\\nout 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\";\n\nvar gl2FragmentSrc = \"#version 300 es\\n#define SHADER_NAME Tiling-Sprite-100\\n\\nprecision lowp float;\\n\\nin vec2 vTextureCoord;\\n\\nout vec4 fragmentColor;\\n\\nuniform sampler2D uSampler;\\nuniform vec4 uColor;\\nuniform mat3 uMapCoord;\\nuniform vec4 uClampFrame;\\nuniform vec2 uClampOffset;\\n\\nvoid main(void)\\n{\\n vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);\\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\\n vec2 unclamped = coord;\\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\\n\\n vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0\\n\\n fragmentColor = texSample * uColor;\\n}\\n\";\n\nvar tempMat = new Matrix();\n/**\n * WebGL renderer plugin for tiling sprites\n * @class\n * @memberof PIXI\n * @extends PIXI.ObjectRenderer\n */\nvar TilingSpriteRenderer = /** @class */ (function (_super) {\n __extends(TilingSpriteRenderer, _super);\n /**\n * constructor for renderer\n * @param {PIXI.Renderer} renderer - The renderer this tiling awesomeness works for.\n */\n function TilingSpriteRenderer(renderer) {\n var _this = _super.call(this, renderer) || this;\n // WebGL version is not available during initialization!\n renderer.runners.contextChange.add(_this);\n _this.quad = new QuadUv();\n /**\n * The WebGL state in which this renderer will work.\n * @member {PIXI.State}\n * @readonly\n */\n _this.state = State.for2d();\n return _this;\n }\n /** Creates shaders when context is initialized. */\n TilingSpriteRenderer.prototype.contextChange = function () {\n var renderer = this.renderer;\n var uniforms = { globals: renderer.globalUniforms };\n this.simpleShader = Shader.from(gl1VertexSrc, fragmentSimpleSrc, uniforms);\n this.shader = renderer.context.webGLVersion > 1\n ? Shader.from(gl2VertexSrc, gl2FragmentSrc, uniforms)\n : Shader.from(gl1VertexSrc, gl1FragmentSrc, uniforms);\n };\n /**\n * @param {PIXI.TilingSprite} ts - tilingSprite to be rendered\n */\n TilingSpriteRenderer.prototype.render = function (ts) {\n var renderer = this.renderer;\n var quad = this.quad;\n var vertices = quad.vertices;\n vertices[0] = vertices[6] = (ts._width) * -ts.anchor.x;\n vertices[1] = vertices[3] = ts._height * -ts.anchor.y;\n vertices[2] = vertices[4] = (ts._width) * (1.0 - ts.anchor.x);\n vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y);\n var anchorX = ts.uvRespectAnchor ? ts.anchor.x : 0;\n var anchorY = ts.uvRespectAnchor ? ts.anchor.y : 0;\n vertices = quad.uvs;\n vertices[0] = vertices[6] = -anchorX;\n vertices[1] = vertices[3] = -anchorY;\n vertices[2] = vertices[4] = 1.0 - anchorX;\n vertices[5] = vertices[7] = 1.0 - anchorY;\n quad.invalidate();\n var tex = ts._texture;\n var baseTex = tex.baseTexture;\n var premultiplied = baseTex.alphaMode > 0;\n var lt = ts.tileTransform.localTransform;\n var uv = ts.uvMatrix;\n var isSimple = baseTex.isPowerOfTwo\n && tex.frame.width === baseTex.width && tex.frame.height === baseTex.height;\n // auto, force repeat wrapMode for big tiling textures\n if (isSimple) {\n if (!baseTex._glTextures[renderer.CONTEXT_UID]) {\n if (baseTex.wrapMode === WRAP_MODES.CLAMP) {\n baseTex.wrapMode = WRAP_MODES.REPEAT;\n }\n }\n else {\n isSimple = baseTex.wrapMode !== WRAP_MODES.CLAMP;\n }\n }\n var shader = isSimple ? this.simpleShader : this.shader;\n var w = tex.width;\n var h = tex.height;\n var W = ts._width;\n var H = ts._height;\n tempMat.set(lt.a * w / W, lt.b * w / H, lt.c * h / W, lt.d * h / H, lt.tx / W, lt.ty / H);\n // that part is the same as above:\n // tempMat.identity();\n // tempMat.scale(tex.width, tex.height);\n // tempMat.prepend(lt);\n // tempMat.scale(1.0 / ts._width, 1.0 / ts._height);\n tempMat.invert();\n if (isSimple) {\n tempMat.prepend(uv.mapCoord);\n }\n else {\n shader.uniforms.uMapCoord = uv.mapCoord.toArray(true);\n shader.uniforms.uClampFrame = uv.uClampFrame;\n shader.uniforms.uClampOffset = uv.uClampOffset;\n }\n shader.uniforms.uTransform = tempMat.toArray(true);\n shader.uniforms.uColor = premultiplyTintToRgba(ts.tint, ts.worldAlpha, shader.uniforms.uColor, premultiplied);\n shader.uniforms.translationMatrix = ts.transform.worldTransform.toArray(true);\n shader.uniforms.uSampler = tex;\n renderer.shader.bind(shader);\n renderer.geometry.bind(quad);\n this.state.blendMode = correctBlendMode(ts.blendMode, premultiplied);\n renderer.state.set(this.state);\n renderer.geometry.draw(this.renderer.gl.TRIANGLES, 6, 0);\n };\n /** @ignore */\n TilingSpriteRenderer.extension = {\n name: 'tilingSprite',\n type: ExtensionType.RendererPlugin,\n };\n return TilingSpriteRenderer;\n}(ObjectRenderer));\n\nexport { TilingSprite, TilingSpriteRenderer };\n//# sourceMappingURL=sprite-tiling.mjs.map\n","/*!\n * @pixi/mesh - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/mesh is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { State, Program, TextureMatrix, Shader, Buffer, Geometry } from '@pixi/core';\nimport { Point, Polygon, Matrix } from '@pixi/math';\nimport { DRAW_MODES, TYPES } from '@pixi/constants';\nimport { Container } from '@pixi/display';\nimport { settings } from '@pixi/settings';\nimport { premultiplyTintToRgba } from '@pixi/utils';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\n/**\n * Class controls cache for UV mapping from Texture normal space to BaseTexture normal space.\n * @memberof PIXI\n */\nvar MeshBatchUvs = /** @class */ (function () {\n /**\n * @param uvBuffer - Buffer with normalized uv's\n * @param uvMatrix - Material UV matrix\n */\n function MeshBatchUvs(uvBuffer, uvMatrix) {\n this.uvBuffer = uvBuffer;\n this.uvMatrix = uvMatrix;\n this.data = null;\n this._bufferUpdateId = -1;\n this._textureUpdateId = -1;\n this._updateID = 0;\n }\n /**\n * Updates\n * @param forceUpdate - force the update\n */\n MeshBatchUvs.prototype.update = function (forceUpdate) {\n if (!forceUpdate\n && this._bufferUpdateId === this.uvBuffer._updateID\n && this._textureUpdateId === this.uvMatrix._updateID) {\n return;\n }\n this._bufferUpdateId = this.uvBuffer._updateID;\n this._textureUpdateId = this.uvMatrix._updateID;\n var data = this.uvBuffer.data;\n if (!this.data || this.data.length !== data.length) {\n this.data = new Float32Array(data.length);\n }\n this.uvMatrix.multiplyUvs(data, this.data);\n this._updateID++;\n };\n return MeshBatchUvs;\n}());\n\nvar tempPoint = new Point();\nvar tempPolygon = new Polygon();\n/**\n * Base mesh class.\n *\n * This class empowers you to have maximum flexibility to render any kind of WebGL visuals you can think of.\n * This class assumes a certain level of WebGL knowledge.\n * If you know a bit this should abstract enough away to make your life easier!\n *\n * Pretty much ALL WebGL can be broken down into the following:\n * - Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc..\n * - Shader - This is the shader that PixiJS will render the geometry with (attributes in the shader must match the geometry)\n * - State - This is the state of WebGL required to render the mesh.\n *\n * Through a combination of the above elements you can render anything you want, 2D or 3D!\n * @memberof PIXI\n */\nvar Mesh = /** @class */ (function (_super) {\n __extends(Mesh, _super);\n /**\n * @param geometry - The geometry the mesh will use.\n * @param {PIXI.MeshMaterial} shader - The shader the mesh will use.\n * @param state - The state that the WebGL context is required to be in to render the mesh\n * if no state is provided, uses {@link PIXI.State.for2d} to create a 2D state for PixiJS.\n * @param drawMode - The drawMode, can be any of the {@link PIXI.DRAW_MODES} constants.\n */\n function Mesh(geometry, shader, state, drawMode) {\n if (drawMode === void 0) { drawMode = DRAW_MODES.TRIANGLES; }\n var _this = _super.call(this) || this;\n _this.geometry = geometry;\n _this.shader = shader;\n _this.state = state || State.for2d();\n _this.drawMode = drawMode;\n _this.start = 0;\n _this.size = 0;\n _this.uvs = null;\n _this.indices = null;\n _this.vertexData = new Float32Array(1);\n _this.vertexDirty = -1;\n _this._transformID = -1;\n _this._roundPixels = settings.ROUND_PIXELS;\n _this.batchUvs = null;\n return _this;\n }\n Object.defineProperty(Mesh.prototype, \"geometry\", {\n /**\n * Includes vertex positions, face indices, normals, colors, UVs, and\n * custom attributes within buffers, reducing the cost of passing all\n * this data to the GPU. Can be shared between multiple Mesh objects.\n */\n get: function () {\n return this._geometry;\n },\n set: function (value) {\n if (this._geometry === value) {\n return;\n }\n if (this._geometry) {\n this._geometry.refCount--;\n if (this._geometry.refCount === 0) {\n this._geometry.dispose();\n }\n }\n this._geometry = value;\n if (this._geometry) {\n this._geometry.refCount++;\n }\n this.vertexDirty = -1;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Mesh.prototype, \"uvBuffer\", {\n /**\n * To change mesh uv's, change its uvBuffer data and increment its _updateID.\n * @readonly\n */\n get: function () {\n return this.geometry.buffers[1];\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Mesh.prototype, \"verticesBuffer\", {\n /**\n * To change mesh vertices, change its uvBuffer data and increment its _updateID.\n * Incrementing _updateID is optional because most of Mesh objects do it anyway.\n * @readonly\n */\n get: function () {\n return this.geometry.buffers[0];\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Mesh.prototype, \"material\", {\n get: function () {\n return this.shader;\n },\n /** Alias for {@link PIXI.Mesh#shader}. */\n set: function (value) {\n this.shader = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Mesh.prototype, \"blendMode\", {\n get: function () {\n return this.state.blendMode;\n },\n /**\n * The blend mode to be applied to the Mesh. Apply a value of\n * `PIXI.BLEND_MODES.NORMAL` to reset the blend mode.\n * @default PIXI.BLEND_MODES.NORMAL;\n */\n set: function (value) {\n this.state.blendMode = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Mesh.prototype, \"roundPixels\", {\n get: function () {\n return this._roundPixels;\n },\n /**\n * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation.\n * Advantages can include sharper image quality (like text) and faster rendering on canvas.\n * The main disadvantage is movement of objects may appear less smooth.\n * To set the global default, change {@link PIXI.settings.ROUND_PIXELS}\n * @default false\n */\n set: function (value) {\n if (this._roundPixels !== value) {\n this._transformID = -1;\n }\n this._roundPixels = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Mesh.prototype, \"tint\", {\n /**\n * The multiply tint applied to the Mesh. This is a hex value. A value of\n * `0xFFFFFF` will remove any tint effect.\n *\n * Null for non-MeshMaterial shaders\n * @default 0xFFFFFF\n */\n get: function () {\n return 'tint' in this.shader ? this.shader.tint : null;\n },\n set: function (value) {\n this.shader.tint = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Mesh.prototype, \"texture\", {\n /** The texture that the Mesh uses. Null for non-MeshMaterial shaders */\n get: function () {\n return 'texture' in this.shader ? this.shader.texture : null;\n },\n set: function (value) {\n this.shader.texture = value;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Standard renderer draw.\n * @param renderer - Instance to renderer.\n */\n Mesh.prototype._render = function (renderer) {\n // set properties for batching..\n // TODO could use a different way to grab verts?\n var vertices = this.geometry.buffers[0].data;\n var shader = this.shader;\n // TODO benchmark check for attribute size..\n if (shader.batchable\n && this.drawMode === DRAW_MODES.TRIANGLES\n && vertices.length < Mesh.BATCHABLE_SIZE * 2) {\n this._renderToBatch(renderer);\n }\n else {\n this._renderDefault(renderer);\n }\n };\n /**\n * Standard non-batching way of rendering.\n * @param renderer - Instance to renderer.\n */\n Mesh.prototype._renderDefault = function (renderer) {\n var shader = this.shader;\n shader.alpha = this.worldAlpha;\n if (shader.update) {\n shader.update();\n }\n renderer.batch.flush();\n // bind and sync uniforms..\n shader.uniforms.translationMatrix = this.transform.worldTransform.toArray(true);\n renderer.shader.bind(shader);\n // set state..\n renderer.state.set(this.state);\n // bind the geometry...\n renderer.geometry.bind(this.geometry, shader);\n // then render it\n renderer.geometry.draw(this.drawMode, this.size, this.start, this.geometry.instanceCount);\n };\n /**\n * Rendering by using the Batch system.\n * @param renderer - Instance to renderer.\n */\n Mesh.prototype._renderToBatch = function (renderer) {\n var geometry = this.geometry;\n var shader = this.shader;\n if (shader.uvMatrix) {\n shader.uvMatrix.update();\n this.calculateUvs();\n }\n // set properties for batching..\n this.calculateVertices();\n this.indices = geometry.indexBuffer.data;\n this._tintRGB = shader._tintRGB;\n this._texture = shader.texture;\n var pluginName = this.material.pluginName;\n renderer.batch.setObjectRenderer(renderer.plugins[pluginName]);\n renderer.plugins[pluginName].render(this);\n };\n /** Updates vertexData field based on transform and vertices. */\n Mesh.prototype.calculateVertices = function () {\n var geometry = this.geometry;\n var verticesBuffer = geometry.buffers[0];\n var vertices = verticesBuffer.data;\n var vertexDirtyId = verticesBuffer._updateID;\n if (vertexDirtyId === this.vertexDirty && this._transformID === this.transform._worldID) {\n return;\n }\n this._transformID = this.transform._worldID;\n if (this.vertexData.length !== vertices.length) {\n this.vertexData = new Float32Array(vertices.length);\n }\n var wt = this.transform.worldTransform;\n var a = wt.a;\n var b = wt.b;\n var c = wt.c;\n var d = wt.d;\n var tx = wt.tx;\n var ty = wt.ty;\n var vertexData = this.vertexData;\n for (var i = 0; i < vertexData.length / 2; i++) {\n var x = vertices[(i * 2)];\n var y = vertices[(i * 2) + 1];\n vertexData[(i * 2)] = (a * x) + (c * y) + tx;\n vertexData[(i * 2) + 1] = (b * x) + (d * y) + ty;\n }\n if (this._roundPixels) {\n var resolution = settings.RESOLUTION;\n for (var i = 0; i < vertexData.length; ++i) {\n vertexData[i] = Math.round((vertexData[i] * resolution | 0) / resolution);\n }\n }\n this.vertexDirty = vertexDirtyId;\n };\n /** Updates uv field based on from geometry uv's or batchUvs. */\n Mesh.prototype.calculateUvs = function () {\n var geomUvs = this.geometry.buffers[1];\n var shader = this.shader;\n if (!shader.uvMatrix.isSimple) {\n if (!this.batchUvs) {\n this.batchUvs = new MeshBatchUvs(geomUvs, shader.uvMatrix);\n }\n this.batchUvs.update();\n this.uvs = this.batchUvs.data;\n }\n else {\n this.uvs = geomUvs.data;\n }\n };\n /**\n * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account.\n * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly.\n */\n Mesh.prototype._calculateBounds = function () {\n this.calculateVertices();\n this._bounds.addVertexData(this.vertexData, 0, this.vertexData.length);\n };\n /**\n * Tests if a point is inside this mesh. Works only for PIXI.DRAW_MODES.TRIANGLES.\n * @param point - The point to test.\n * @returns - The result of the test.\n */\n Mesh.prototype.containsPoint = function (point) {\n if (!this.getBounds().contains(point.x, point.y)) {\n return false;\n }\n this.worldTransform.applyInverse(point, tempPoint);\n var vertices = this.geometry.getBuffer('aVertexPosition').data;\n var points = tempPolygon.points;\n var indices = this.geometry.getIndex().data;\n var len = indices.length;\n var step = this.drawMode === 4 ? 3 : 1;\n for (var i = 0; i + 2 < len; i += step) {\n var ind0 = indices[i] * 2;\n var ind1 = indices[i + 1] * 2;\n var ind2 = indices[i + 2] * 2;\n points[0] = vertices[ind0];\n points[1] = vertices[ind0 + 1];\n points[2] = vertices[ind1];\n points[3] = vertices[ind1 + 1];\n points[4] = vertices[ind2];\n points[5] = vertices[ind2 + 1];\n if (tempPolygon.contains(tempPoint.x, tempPoint.y)) {\n return true;\n }\n }\n return false;\n };\n Mesh.prototype.destroy = function (options) {\n _super.prototype.destroy.call(this, options);\n if (this._cachedTexture) {\n this._cachedTexture.destroy();\n this._cachedTexture = null;\n }\n this.geometry = null;\n this.shader = null;\n this.state = null;\n this.uvs = null;\n this.indices = null;\n this.vertexData = null;\n };\n /** The maximum number of vertices to consider batchable. Generally, the complexity of the geometry. */\n Mesh.BATCHABLE_SIZE = 100;\n return Mesh;\n}(Container));\n\nvar fragment = \"varying vec2 vTextureCoord;\\nuniform vec4 uColor;\\n\\nuniform sampler2D uSampler;\\n\\nvoid main(void)\\n{\\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;\\n}\\n\";\n\nvar vertex = \"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\";\n\n/**\n * Slightly opinionated default shader for PixiJS 2D objects.\n * @memberof PIXI\n */\nvar MeshMaterial = /** @class */ (function (_super) {\n __extends(MeshMaterial, _super);\n /**\n * @param uSampler - Texture that material uses to render.\n * @param options - Additional options\n * @param {number} [options.alpha=1] - Default alpha.\n * @param {number} [options.tint=0xFFFFFF] - Default tint.\n * @param {string} [options.pluginName='batch'] - Renderer plugin for batching.\n * @param {PIXI.Program} [options.program=0xFFFFFF] - Custom program.\n * @param {object} [options.uniforms] - Custom uniforms.\n */\n function MeshMaterial(uSampler, options) {\n var _this = this;\n var uniforms = {\n uSampler: uSampler,\n alpha: 1,\n uTextureMatrix: Matrix.IDENTITY,\n uColor: new Float32Array([1, 1, 1, 1]),\n };\n // Set defaults\n options = Object.assign({\n tint: 0xFFFFFF,\n alpha: 1,\n pluginName: 'batch',\n }, options);\n if (options.uniforms) {\n Object.assign(uniforms, options.uniforms);\n }\n _this = _super.call(this, options.program || Program.from(vertex, fragment), uniforms) || this;\n _this._colorDirty = false;\n _this.uvMatrix = new TextureMatrix(uSampler);\n _this.batchable = options.program === undefined;\n _this.pluginName = options.pluginName;\n _this.tint = options.tint;\n _this.alpha = options.alpha;\n return _this;\n }\n Object.defineProperty(MeshMaterial.prototype, \"texture\", {\n /** Reference to the texture being rendered. */\n get: function () {\n return this.uniforms.uSampler;\n },\n set: function (value) {\n if (this.uniforms.uSampler !== value) {\n if (!this.uniforms.uSampler.baseTexture.alphaMode !== !value.baseTexture.alphaMode) {\n this._colorDirty = true;\n }\n this.uniforms.uSampler = value;\n this.uvMatrix.texture = value;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(MeshMaterial.prototype, \"alpha\", {\n get: function () {\n return this._alpha;\n },\n /**\n * This gets automatically set by the object using this.\n * @default 1\n */\n set: function (value) {\n if (value === this._alpha)\n { return; }\n this._alpha = value;\n this._colorDirty = true;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(MeshMaterial.prototype, \"tint\", {\n get: function () {\n return this._tint;\n },\n /**\n * Multiply tint for the material.\n * @default 0xFFFFFF\n */\n set: function (value) {\n if (value === this._tint)\n { return; }\n this._tint = value;\n this._tintRGB = (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16);\n this._colorDirty = true;\n },\n enumerable: false,\n configurable: true\n });\n /** Gets called automatically by the Mesh. Intended to be overridden for custom {@link MeshMaterial} objects. */\n MeshMaterial.prototype.update = function () {\n if (this._colorDirty) {\n this._colorDirty = false;\n var baseTexture = this.texture.baseTexture;\n premultiplyTintToRgba(this._tint, this._alpha, this.uniforms.uColor, baseTexture.alphaMode);\n }\n if (this.uvMatrix.update()) {\n this.uniforms.uTextureMatrix = this.uvMatrix.mapCoord;\n }\n };\n return MeshMaterial;\n}(Shader));\n\n/**\n * Standard 2D geometry used in PixiJS.\n *\n * Geometry can be defined without passing in a style or data if required.\n *\n * ```js\n * const geometry = new PIXI.Geometry();\n *\n * geometry.addAttribute('positions', [0, 0, 100, 0, 100, 100, 0, 100], 2);\n * geometry.addAttribute('uvs', [0,0,1,0,1,1,0,1], 2);\n * geometry.addIndex([0,1,2,1,3,2]);\n *\n * ```\n * @memberof PIXI\n */\nvar MeshGeometry = /** @class */ (function (_super) {\n __extends(MeshGeometry, _super);\n /**\n * @param {Float32Array|number[]} [vertices] - Positional data on geometry.\n * @param {Float32Array|number[]} [uvs] - Texture UVs.\n * @param {Uint16Array|number[]} [index] - IndexBuffer\n */\n function MeshGeometry(vertices, uvs, index) {\n var _this = _super.call(this) || this;\n var verticesBuffer = new Buffer(vertices);\n var uvsBuffer = new Buffer(uvs, true);\n var indexBuffer = new Buffer(index, true, true);\n _this.addAttribute('aVertexPosition', verticesBuffer, 2, false, TYPES.FLOAT)\n .addAttribute('aTextureCoord', uvsBuffer, 2, false, TYPES.FLOAT)\n .addIndex(indexBuffer);\n _this._updateId = -1;\n return _this;\n }\n Object.defineProperty(MeshGeometry.prototype, \"vertexDirtyId\", {\n /**\n * If the vertex position is updated.\n * @readonly\n * @private\n */\n get: function () {\n return this.buffers[0]._updateID;\n },\n enumerable: false,\n configurable: true\n });\n return MeshGeometry;\n}(Geometry));\n\nexport { Mesh, MeshBatchUvs, MeshGeometry, MeshMaterial };\n//# sourceMappingURL=mesh.mjs.map\n","/*!\n * @pixi/text-bitmap - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/text-bitmap is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { Rectangle, Point, ObservablePoint } from '@pixi/math';\nimport { settings } from '@pixi/settings';\nimport { MeshGeometry, MeshMaterial, Mesh } from '@pixi/mesh';\nimport { hex2rgb, string2hex, getResolutionOfUrl, removeItems } from '@pixi/utils';\nimport { BaseTexture, Texture, Program, ExtensionType } from '@pixi/core';\nimport { TEXT_GRADIENT, TextStyle, TextMetrics } from '@pixi/text';\nimport { ALPHA_MODES, MIPMAP_MODES, BLEND_MODES } from '@pixi/constants';\nimport { Container } from '@pixi/display';\nimport { LoaderResource } from '@pixi/loaders';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\n/* eslint-disable max-len */\n/**\n * Normalized parsed data from .fnt files.\n * @memberof PIXI\n */\nvar BitmapFontData = /** @class */ (function () {\n function BitmapFontData() {\n this.info = [];\n this.common = [];\n this.page = [];\n this.char = [];\n this.kerning = [];\n this.distanceField = [];\n }\n return BitmapFontData;\n}());\n\n/**\n * BitmapFont format that's Text-based.\n * @private\n */\nvar TextFormat = /** @class */ (function () {\n function TextFormat() {\n }\n /**\n * Check if resource refers to txt font data.\n * @param data\n * @returns - True if resource could be treated as font data, false otherwise.\n */\n TextFormat.test = function (data) {\n return typeof data === 'string' && data.indexOf('info face=') === 0;\n };\n /**\n * Convert text font data to a javascript object.\n * @param txt - Raw string data to be converted\n * @returns - Parsed font data\n */\n TextFormat.parse = function (txt) {\n // Retrieve data item\n var items = txt.match(/^[a-z]+\\s+.+$/gm);\n var rawData = {\n info: [],\n common: [],\n page: [],\n char: [],\n chars: [],\n kerning: [],\n kernings: [],\n distanceField: [],\n };\n for (var i in items) {\n // Extract item name\n var name = items[i].match(/^[a-z]+/gm)[0];\n // Extract item attribute list as string ex.: \"width=10\"\n var attributeList = items[i].match(/[a-zA-Z]+=([^\\s\"']+|\"([^\"]*)\")/gm);\n // Convert attribute list into an object\n var itemData = {};\n for (var i_1 in attributeList) {\n // Split key-value pairs\n var split = attributeList[i_1].split('=');\n var key = split[0];\n // Remove eventual quotes from value\n var strValue = split[1].replace(/\"/gm, '');\n // Try to convert value into float\n var floatValue = parseFloat(strValue);\n // Use string value case float value is NaN\n var value = isNaN(floatValue) ? strValue : floatValue;\n itemData[key] = value;\n }\n // Push current item to the resulting data\n rawData[name].push(itemData);\n }\n var font = new BitmapFontData();\n rawData.info.forEach(function (info) { return font.info.push({\n face: info.face,\n size: parseInt(info.size, 10),\n }); });\n rawData.common.forEach(function (common) { return font.common.push({\n lineHeight: parseInt(common.lineHeight, 10),\n }); });\n rawData.page.forEach(function (page) { return font.page.push({\n id: parseInt(page.id, 10),\n file: page.file,\n }); });\n rawData.char.forEach(function (char) { return font.char.push({\n id: parseInt(char.id, 10),\n page: parseInt(char.page, 10),\n x: parseInt(char.x, 10),\n y: parseInt(char.y, 10),\n width: parseInt(char.width, 10),\n height: parseInt(char.height, 10),\n xoffset: parseInt(char.xoffset, 10),\n yoffset: parseInt(char.yoffset, 10),\n xadvance: parseInt(char.xadvance, 10),\n }); });\n rawData.kerning.forEach(function (kerning) { return font.kerning.push({\n first: parseInt(kerning.first, 10),\n second: parseInt(kerning.second, 10),\n amount: parseInt(kerning.amount, 10),\n }); });\n rawData.distanceField.forEach(function (df) { return font.distanceField.push({\n distanceRange: parseInt(df.distanceRange, 10),\n fieldType: df.fieldType,\n }); });\n return font;\n };\n return TextFormat;\n}());\n\n/**\n * BitmapFont format that's XML-based.\n * @private\n */\nvar XMLFormat = /** @class */ (function () {\n function XMLFormat() {\n }\n /**\n * Check if resource refers to xml font data.\n * @param data\n * @returns - True if resource could be treated as font data, false otherwise.\n */\n XMLFormat.test = function (data) {\n return data instanceof XMLDocument\n && data.getElementsByTagName('page').length\n && data.getElementsByTagName('info')[0].getAttribute('face') !== null;\n };\n /**\n * Convert the XML into BitmapFontData that we can use.\n * @param xml\n * @returns - Data to use for BitmapFont\n */\n XMLFormat.parse = function (xml) {\n var data = new BitmapFontData();\n var info = xml.getElementsByTagName('info');\n var common = xml.getElementsByTagName('common');\n var page = xml.getElementsByTagName('page');\n var char = xml.getElementsByTagName('char');\n var kerning = xml.getElementsByTagName('kerning');\n var distanceField = xml.getElementsByTagName('distanceField');\n for (var i = 0; i < info.length; i++) {\n data.info.push({\n face: info[i].getAttribute('face'),\n size: parseInt(info[i].getAttribute('size'), 10),\n });\n }\n for (var i = 0; i < common.length; i++) {\n data.common.push({\n lineHeight: parseInt(common[i].getAttribute('lineHeight'), 10),\n });\n }\n for (var i = 0; i < page.length; i++) {\n data.page.push({\n id: parseInt(page[i].getAttribute('id'), 10) || 0,\n file: page[i].getAttribute('file'),\n });\n }\n for (var i = 0; i < char.length; i++) {\n var letter = char[i];\n data.char.push({\n id: parseInt(letter.getAttribute('id'), 10),\n page: parseInt(letter.getAttribute('page'), 10) || 0,\n x: parseInt(letter.getAttribute('x'), 10),\n y: parseInt(letter.getAttribute('y'), 10),\n width: parseInt(letter.getAttribute('width'), 10),\n height: parseInt(letter.getAttribute('height'), 10),\n xoffset: parseInt(letter.getAttribute('xoffset'), 10),\n yoffset: parseInt(letter.getAttribute('yoffset'), 10),\n xadvance: parseInt(letter.getAttribute('xadvance'), 10),\n });\n }\n for (var i = 0; i < kerning.length; i++) {\n data.kerning.push({\n first: parseInt(kerning[i].getAttribute('first'), 10),\n second: parseInt(kerning[i].getAttribute('second'), 10),\n amount: parseInt(kerning[i].getAttribute('amount'), 10),\n });\n }\n for (var i = 0; i < distanceField.length; i++) {\n data.distanceField.push({\n fieldType: distanceField[i].getAttribute('fieldType'),\n distanceRange: parseInt(distanceField[i].getAttribute('distanceRange'), 10),\n });\n }\n return data;\n };\n return XMLFormat;\n}());\n\n/**\n * BitmapFont format that's XML-based.\n * @private\n */\nvar XMLStringFormat = /** @class */ (function () {\n function XMLStringFormat() {\n }\n /**\n * Check if resource refers to text xml font data.\n * @param data\n * @returns - True if resource could be treated as font data, false otherwise.\n */\n XMLStringFormat.test = function (data) {\n if (typeof data === 'string' && data.indexOf('') > -1) {\n var xml = new globalThis.DOMParser().parseFromString(data, 'text/xml');\n return XMLFormat.test(xml);\n }\n return false;\n };\n /**\n * Convert the text XML into BitmapFontData that we can use.\n * @param xmlTxt\n * @returns - Data to use for BitmapFont\n */\n XMLStringFormat.parse = function (xmlTxt) {\n var xml = new globalThis.DOMParser().parseFromString(xmlTxt, 'text/xml');\n return XMLFormat.parse(xml);\n };\n return XMLStringFormat;\n}());\n\n// Registered formats, maybe make this extensible in the future?\nvar formats = [\n TextFormat,\n XMLFormat,\n XMLStringFormat ];\n/**\n * Auto-detect BitmapFont parsing format based on data.\n * @private\n * @param {any} data - Data to detect format\n * @returns {any} Format or null\n */\nfunction autoDetectFormat(data) {\n for (var i = 0; i < formats.length; i++) {\n if (formats[i].test(data)) {\n return formats[i];\n }\n }\n return null;\n}\n\n// TODO: Prevent code duplication b/w generateFillStyle & Text#generateFillStyle\n/**\n * Generates the fill style. Can automatically generate a gradient based on the fill style being an array\n * @private\n * @param canvas\n * @param context\n * @param {object} style - The style.\n * @param resolution\n * @param {string[]} lines - The lines of text.\n * @param metrics\n * @returns {string|number|CanvasGradient} The fill style\n */\nfunction generateFillStyle(canvas, context, style, resolution, lines, metrics) {\n // TODO: Can't have different types for getter and setter. The getter shouldn't have the number type as\n // the setter converts to string. See this thread for more details:\n // https://github.com/microsoft/TypeScript/issues/2521\n var fillStyle = style.fill;\n if (!Array.isArray(fillStyle)) {\n return fillStyle;\n }\n else if (fillStyle.length === 1) {\n return fillStyle[0];\n }\n // the gradient will be evenly spaced out according to how large the array is.\n // ['#FF0000', '#00FF00', '#0000FF'] would created stops at 0.25, 0.5 and 0.75\n var gradient;\n // a dropshadow will enlarge the canvas and result in the gradient being\n // generated with the incorrect dimensions\n var dropShadowCorrection = (style.dropShadow) ? style.dropShadowDistance : 0;\n // should also take padding into account, padding can offset the gradient\n var padding = style.padding || 0;\n var width = (canvas.width / resolution) - dropShadowCorrection - (padding * 2);\n var height = (canvas.height / resolution) - dropShadowCorrection - (padding * 2);\n // make a copy of the style settings, so we can manipulate them later\n var fill = fillStyle.slice();\n var fillGradientStops = style.fillGradientStops.slice();\n // wanting to evenly distribute the fills. So an array of 4 colours should give fills of 0.25, 0.5 and 0.75\n if (!fillGradientStops.length) {\n var lengthPlus1 = fill.length + 1;\n for (var i = 1; i < lengthPlus1; ++i) {\n fillGradientStops.push(i / lengthPlus1);\n }\n }\n // stop the bleeding of the last gradient on the line above to the top gradient of the this line\n // by hard defining the first gradient colour at point 0, and last gradient colour at point 1\n fill.unshift(fillStyle[0]);\n fillGradientStops.unshift(0);\n fill.push(fillStyle[fillStyle.length - 1]);\n fillGradientStops.push(1);\n if (style.fillGradientType === TEXT_GRADIENT.LINEAR_VERTICAL) {\n // start the gradient at the top center of the canvas, and end at the bottom middle of the canvas\n gradient = context.createLinearGradient(width / 2, padding, width / 2, height + padding);\n // we need to repeat the gradient so that each individual line of text has the same vertical gradient effect\n // ['#FF0000', '#00FF00', '#0000FF'] over 2 lines would create stops at 0.125, 0.25, 0.375, 0.625, 0.75, 0.875\n // There's potential for floating point precision issues at the seams between gradient repeats.\n // The loop below generates the stops in order, so track the last generated one to prevent\n // floating point precision from making us go the teeniest bit backwards, resulting in\n // the first and last colors getting swapped.\n var lastIterationStop = 0;\n // Actual height of the text itself, not counting spacing for lineHeight/leading/dropShadow etc\n var textHeight = metrics.fontProperties.fontSize + style.strokeThickness;\n // textHeight, but as a 0-1 size in global gradient stop space\n var gradStopLineHeight = textHeight / height;\n for (var i = 0; i < lines.length; i++) {\n var thisLineTop = metrics.lineHeight * i;\n for (var j = 0; j < fill.length; j++) {\n // 0-1 stop point for the current line, multiplied to global space afterwards\n var lineStop = 0;\n if (typeof fillGradientStops[j] === 'number') {\n lineStop = fillGradientStops[j];\n }\n else {\n lineStop = j / fill.length;\n }\n var globalStop = (thisLineTop / height) + (lineStop * gradStopLineHeight);\n // Prevent color stop generation going backwards from floating point imprecision\n var clampedStop = Math.max(lastIterationStop, globalStop);\n clampedStop = Math.min(clampedStop, 1); // Cap at 1 as well for safety's sake to avoid a possible throw.\n gradient.addColorStop(clampedStop, fill[j]);\n lastIterationStop = clampedStop;\n }\n }\n }\n else {\n // start the gradient at the center left of the canvas, and end at the center right of the canvas\n gradient = context.createLinearGradient(padding, height / 2, width + padding, height / 2);\n // can just evenly space out the gradients in this case, as multiple lines makes no difference\n // to an even left to right gradient\n var totalIterations = fill.length + 1;\n var currentIteration = 1;\n for (var i = 0; i < fill.length; i++) {\n var stop = void 0;\n if (typeof fillGradientStops[i] === 'number') {\n stop = fillGradientStops[i];\n }\n else {\n stop = currentIteration / totalIterations;\n }\n gradient.addColorStop(stop, fill[i]);\n currentIteration++;\n }\n }\n return gradient;\n}\n\n// TODO: Prevent code duplication b/w drawGlyph & Text#updateText\n/**\n * Draws the glyph `metrics.text` on the given canvas.\n *\n * Ignored because not directly exposed.\n * @ignore\n * @param {HTMLCanvasElement} canvas\n * @param {CanvasRenderingContext2D} context\n * @param {TextMetrics} metrics\n * @param {number} x\n * @param {number} y\n * @param {number} resolution\n * @param {TextStyle} style\n */\nfunction drawGlyph(canvas, context, metrics, x, y, resolution, style) {\n var char = metrics.text;\n var fontProperties = metrics.fontProperties;\n context.translate(x, y);\n context.scale(resolution, resolution);\n var tx = style.strokeThickness / 2;\n var ty = -(style.strokeThickness / 2);\n context.font = style.toFontString();\n context.lineWidth = style.strokeThickness;\n context.textBaseline = style.textBaseline;\n context.lineJoin = style.lineJoin;\n context.miterLimit = style.miterLimit;\n // set canvas text styles\n context.fillStyle = generateFillStyle(canvas, context, style, resolution, [char], metrics);\n context.strokeStyle = style.stroke;\n if (style.dropShadow) {\n var dropShadowColor = style.dropShadowColor;\n var rgb = hex2rgb(typeof dropShadowColor === 'number' ? dropShadowColor : string2hex(dropShadowColor));\n var dropShadowBlur = style.dropShadowBlur * resolution;\n var dropShadowDistance = style.dropShadowDistance * resolution;\n context.shadowColor = \"rgba(\" + rgb[0] * 255 + \",\" + rgb[1] * 255 + \",\" + rgb[2] * 255 + \",\" + style.dropShadowAlpha + \")\";\n context.shadowBlur = dropShadowBlur;\n context.shadowOffsetX = Math.cos(style.dropShadowAngle) * dropShadowDistance;\n context.shadowOffsetY = Math.sin(style.dropShadowAngle) * dropShadowDistance;\n }\n else {\n context.shadowColor = 'black';\n context.shadowBlur = 0;\n context.shadowOffsetX = 0;\n context.shadowOffsetY = 0;\n }\n if (style.stroke && style.strokeThickness) {\n context.strokeText(char, tx, ty + metrics.lineHeight - fontProperties.descent);\n }\n if (style.fill) {\n context.fillText(char, tx, ty + metrics.lineHeight - fontProperties.descent);\n }\n context.setTransform(1, 0, 0, 1, 0, 0); // defaults needed for older browsers (e.g. Opera 29)\n context.fillStyle = 'rgba(0, 0, 0, 0)';\n}\n\n/**\n * Ponyfill for IE because it doesn't support `Array.from`\n * @param text\n * @private\n */\nfunction splitTextToCharacters(text) {\n return Array.from ? Array.from(text) : text.split('');\n}\n\n/**\n * Processes the passed character set data and returns a flattened array of all the characters.\n *\n * Ignored because not directly exposed.\n * @ignore\n * @param {string | string[] | string[][] } chars\n * @returns {string[]} the flattened array of characters\n */\nfunction resolveCharacters(chars) {\n // Split the chars string into individual characters\n if (typeof chars === 'string') {\n chars = [chars];\n }\n // Handle an array of characters+ranges\n var result = [];\n for (var i = 0, j = chars.length; i < j; i++) {\n var item = chars[i];\n // Handle range delimited by start/end chars\n if (Array.isArray(item)) {\n if (item.length !== 2) {\n throw new Error(\"[BitmapFont]: Invalid character range length, expecting 2 got \" + item.length + \".\");\n }\n var startCode = item[0].charCodeAt(0);\n var endCode = item[1].charCodeAt(0);\n if (endCode < startCode) {\n throw new Error('[BitmapFont]: Invalid character range.');\n }\n for (var i_1 = startCode, j_1 = endCode; i_1 <= j_1; i_1++) {\n result.push(String.fromCharCode(i_1));\n }\n }\n // Handle a character set string\n else {\n result.push.apply(result, splitTextToCharacters(item));\n }\n }\n if (result.length === 0) {\n throw new Error('[BitmapFont]: Empty set when resolving characters.');\n }\n return result;\n}\n\n/**\n * Ponyfill for IE because it doesn't support `codePointAt`\n * @param str\n * @private\n */\nfunction extractCharCode(str) {\n return str.codePointAt ? str.codePointAt(0) : str.charCodeAt(0);\n}\n\n/**\n * BitmapFont represents a typeface available for use with the BitmapText class. Use the `install`\n * method for adding a font to be used.\n * @memberof PIXI\n */\nvar BitmapFont = /** @class */ (function () {\n /**\n * @param data\n * @param textures\n * @param ownsTextures - Setting to `true` will destroy page textures\n * when the font is uninstalled.\n */\n function BitmapFont(data, textures, ownsTextures) {\n var _a, _b;\n var info = data.info[0];\n var common = data.common[0];\n var page = data.page[0];\n var distanceField = data.distanceField[0];\n var res = getResolutionOfUrl(page.file);\n var pageTextures = {};\n this._ownsTextures = ownsTextures;\n this.font = info.face;\n this.size = info.size;\n this.lineHeight = common.lineHeight / res;\n this.chars = {};\n this.pageTextures = pageTextures;\n // Convert the input Texture, Textures or object\n // into a page Texture lookup by \"id\"\n for (var i = 0; i < data.page.length; i++) {\n var _c = data.page[i], id = _c.id, file = _c.file;\n pageTextures[id] = textures instanceof Array\n ? textures[i] : textures[file];\n // only MSDF and SDF fonts need no-premultiplied-alpha\n if ((distanceField === null || distanceField === void 0 ? void 0 : distanceField.fieldType) && distanceField.fieldType !== 'none') {\n pageTextures[id].baseTexture.alphaMode = ALPHA_MODES.NO_PREMULTIPLIED_ALPHA;\n pageTextures[id].baseTexture.mipmap = MIPMAP_MODES.OFF;\n }\n }\n // parse letters\n for (var i = 0; i < data.char.length; i++) {\n var _d = data.char[i], id = _d.id, page_1 = _d.page;\n var _e = data.char[i], x = _e.x, y = _e.y, width = _e.width, height = _e.height, xoffset = _e.xoffset, yoffset = _e.yoffset, xadvance = _e.xadvance;\n x /= res;\n y /= res;\n width /= res;\n height /= res;\n xoffset /= res;\n yoffset /= res;\n xadvance /= res;\n var rect = new Rectangle(x + (pageTextures[page_1].frame.x / res), y + (pageTextures[page_1].frame.y / res), width, height);\n this.chars[id] = {\n xOffset: xoffset,\n yOffset: yoffset,\n xAdvance: xadvance,\n kerning: {},\n texture: new Texture(pageTextures[page_1].baseTexture, rect),\n page: page_1,\n };\n }\n // parse kernings\n for (var i = 0; i < data.kerning.length; i++) {\n var _f = data.kerning[i], first = _f.first, second = _f.second, amount = _f.amount;\n first /= res;\n second /= res;\n amount /= res;\n if (this.chars[second]) {\n this.chars[second].kerning[first] = amount;\n }\n }\n // Store distance field information\n this.distanceFieldRange = distanceField === null || distanceField === void 0 ? void 0 : distanceField.distanceRange;\n this.distanceFieldType = (_b = (_a = distanceField === null || distanceField === void 0 ? void 0 : distanceField.fieldType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : 'none';\n }\n /** Remove references to created glyph textures. */\n BitmapFont.prototype.destroy = function () {\n for (var id in this.chars) {\n this.chars[id].texture.destroy();\n this.chars[id].texture = null;\n }\n for (var id in this.pageTextures) {\n if (this._ownsTextures) {\n this.pageTextures[id].destroy(true);\n }\n this.pageTextures[id] = null;\n }\n // Set readonly null.\n this.chars = null;\n this.pageTextures = null;\n };\n /**\n * Register a new bitmap font.\n * @param data - The\n * characters map that could be provided as xml or raw string.\n * @param textures - List of textures for each page.\n * @param ownsTextures - Set to `true` to destroy page textures\n * when the font is uninstalled. By default fonts created with\n * `BitmapFont.from` or from the `BitmapFontLoader` are `true`.\n * @returns {PIXI.BitmapFont} Result font object with font, size, lineHeight\n * and char fields.\n */\n BitmapFont.install = function (data, textures, ownsTextures) {\n var fontData;\n if (data instanceof BitmapFontData) {\n fontData = data;\n }\n else {\n var format = autoDetectFormat(data);\n if (!format) {\n throw new Error('Unrecognized data format for font.');\n }\n fontData = format.parse(data);\n }\n // Single texture, convert to list\n if (textures instanceof Texture) {\n textures = [textures];\n }\n var font = new BitmapFont(fontData, textures, ownsTextures);\n BitmapFont.available[font.font] = font;\n return font;\n };\n /**\n * Remove bitmap font by name.\n * @param name - Name of the font to uninstall.\n */\n BitmapFont.uninstall = function (name) {\n var font = BitmapFont.available[name];\n if (!font) {\n throw new Error(\"No font found named '\" + name + \"'\");\n }\n font.destroy();\n delete BitmapFont.available[name];\n };\n /**\n * Generates a bitmap-font for the given style and character set. This does not support\n * kernings yet. With `style` properties, only the following non-layout properties are used:\n *\n * - {@link PIXI.TextStyle#dropShadow|dropShadow}\n * - {@link PIXI.TextStyle#dropShadowDistance|dropShadowDistance}\n * - {@link PIXI.TextStyle#dropShadowColor|dropShadowColor}\n * - {@link PIXI.TextStyle#dropShadowBlur|dropShadowBlur}\n * - {@link PIXI.TextStyle#dropShadowAngle|dropShadowAngle}\n * - {@link PIXI.TextStyle#fill|fill}\n * - {@link PIXI.TextStyle#fillGradientStops|fillGradientStops}\n * - {@link PIXI.TextStyle#fillGradientType|fillGradientType}\n * - {@link PIXI.TextStyle#fontFamily|fontFamily}\n * - {@link PIXI.TextStyle#fontSize|fontSize}\n * - {@link PIXI.TextStyle#fontVariant|fontVariant}\n * - {@link PIXI.TextStyle#fontWeight|fontWeight}\n * - {@link PIXI.TextStyle#lineJoin|lineJoin}\n * - {@link PIXI.TextStyle#miterLimit|miterLimit}\n * - {@link PIXI.TextStyle#stroke|stroke}\n * - {@link PIXI.TextStyle#strokeThickness|strokeThickness}\n * - {@link PIXI.TextStyle#textBaseline|textBaseline}\n * @param name - The name of the custom font to use with BitmapText.\n * @param textStyle - Style options to render with BitmapFont.\n * @param options - Setup options for font or name of the font.\n * @param {string|string[]|string[][]} [options.chars=PIXI.BitmapFont.ALPHANUMERIC] - characters included\n * in the font set. You can also use ranges. For example, `[['a', 'z'], ['A', 'Z'], \"!@#$%^&*()~{}[] \"]`.\n * Don't forget to include spaces ' ' in your character set!\n * @param {number} [options.resolution=1] - Render resolution for glyphs.\n * @param {number} [options.textureWidth=512] - Optional width of atlas, smaller values to reduce memory.\n * @param {number} [options.textureHeight=512] - Optional height of atlas, smaller values to reduce memory.\n * @param {number} [options.padding=4] - Padding between glyphs on texture atlas.\n * @returns Font generated by style options.\n * @example\n * PIXI.BitmapFont.from(\"TitleFont\", {\n * fontFamily: \"Arial\",\n * fontSize: 12,\n * strokeThickness: 2,\n * fill: \"purple\"\n * });\n *\n * const title = new PIXI.BitmapText(\"This is the title\", { fontName: \"TitleFont\" });\n */\n BitmapFont.from = function (name, textStyle, options) {\n if (!name) {\n throw new Error('[BitmapFont] Property `name` is required.');\n }\n var _a = Object.assign({}, BitmapFont.defaultOptions, options), chars = _a.chars, padding = _a.padding, resolution = _a.resolution, textureWidth = _a.textureWidth, textureHeight = _a.textureHeight;\n var charsList = resolveCharacters(chars);\n var style = textStyle instanceof TextStyle ? textStyle : new TextStyle(textStyle);\n var lineWidth = textureWidth;\n var fontData = new BitmapFontData();\n fontData.info[0] = {\n face: style.fontFamily,\n size: style.fontSize,\n };\n fontData.common[0] = {\n lineHeight: style.fontSize,\n };\n var positionX = 0;\n var positionY = 0;\n var canvas;\n var context;\n var baseTexture;\n var maxCharHeight = 0;\n var textures = [];\n for (var i = 0; i < charsList.length; i++) {\n if (!canvas) {\n canvas = settings.ADAPTER.createCanvas();\n canvas.width = textureWidth;\n canvas.height = textureHeight;\n context = canvas.getContext('2d');\n baseTexture = new BaseTexture(canvas, { resolution: resolution });\n textures.push(new Texture(baseTexture));\n fontData.page.push({\n id: textures.length - 1,\n file: '',\n });\n }\n // Measure glyph dimensions\n var character = charsList[i];\n var metrics = TextMetrics.measureText(character, style, false, canvas);\n var width = metrics.width;\n var height = Math.ceil(metrics.height);\n // This is ugly - but italics are given more space so they don't overlap\n var textureGlyphWidth = Math.ceil((style.fontStyle === 'italic' ? 2 : 1) * width);\n // Can't fit char anymore: next canvas please!\n if (positionY >= textureHeight - (height * resolution)) {\n if (positionY === 0) {\n // We don't want user debugging an infinite loop (or do we? :)\n throw new Error(\"[BitmapFont] textureHeight \" + textureHeight + \"px is too small \"\n + (\"(fontFamily: '\" + style.fontFamily + \"', fontSize: \" + style.fontSize + \"px, char: '\" + character + \"')\"));\n }\n --i;\n // Create new atlas once current has filled up\n canvas = null;\n context = null;\n baseTexture = null;\n positionY = 0;\n positionX = 0;\n maxCharHeight = 0;\n continue;\n }\n maxCharHeight = Math.max(height + metrics.fontProperties.descent, maxCharHeight);\n // Wrap line once full row has been rendered\n if ((textureGlyphWidth * resolution) + positionX >= lineWidth) {\n if (positionX === 0) {\n // Avoid infinite loop (There can be some very wide char like '\\uFDFD'!)\n throw new Error(\"[BitmapFont] textureWidth \" + textureWidth + \"px is too small \"\n + (\"(fontFamily: '\" + style.fontFamily + \"', fontSize: \" + style.fontSize + \"px, char: '\" + character + \"')\"));\n }\n --i;\n positionY += maxCharHeight * resolution;\n positionY = Math.ceil(positionY);\n positionX = 0;\n maxCharHeight = 0;\n continue;\n }\n drawGlyph(canvas, context, metrics, positionX, positionY, resolution, style);\n // Unique (numeric) ID mapping to this glyph\n var id = extractCharCode(metrics.text);\n // Create a texture holding just the glyph\n fontData.char.push({\n id: id,\n page: textures.length - 1,\n x: positionX / resolution,\n y: positionY / resolution,\n width: textureGlyphWidth,\n height: height,\n xoffset: 0,\n yoffset: 0,\n xadvance: Math.ceil(width\n - (style.dropShadow ? style.dropShadowDistance : 0)\n - (style.stroke ? style.strokeThickness : 0)),\n });\n positionX += (textureGlyphWidth + (2 * padding)) * resolution;\n positionX = Math.ceil(positionX);\n }\n if (!(options === null || options === void 0 ? void 0 : options.skipKerning)) {\n // Brute-force kerning info, this can be expensive b/c it's an O(n²),\n // but we're using measureText which is native and fast.\n for (var i = 0, len = charsList.length; i < len; i++) {\n var first = charsList[i];\n for (var j = 0; j < len; j++) {\n var second = charsList[j];\n var c1 = context.measureText(first).width;\n var c2 = context.measureText(second).width;\n var total = context.measureText(first + second).width;\n var amount = total - (c1 + c2);\n if (amount) {\n fontData.kerning.push({\n first: extractCharCode(first),\n second: extractCharCode(second),\n amount: amount,\n });\n }\n }\n }\n }\n var font = new BitmapFont(fontData, textures, true);\n // Make it easier to replace a font\n if (BitmapFont.available[name] !== undefined) {\n BitmapFont.uninstall(name);\n }\n BitmapFont.available[name] = font;\n return font;\n };\n /**\n * This character set includes all the letters in the alphabet (both lower- and upper- case).\n * @type {string[][]}\n * @example\n * BitmapFont.from(\"ExampleFont\", style, { chars: BitmapFont.ALPHA })\n */\n BitmapFont.ALPHA = [['a', 'z'], ['A', 'Z'], ' '];\n /**\n * This character set includes all decimal digits (from 0 to 9).\n * @type {string[][]}\n * @example\n * BitmapFont.from(\"ExampleFont\", style, { chars: BitmapFont.NUMERIC })\n */\n BitmapFont.NUMERIC = [['0', '9']];\n /**\n * This character set is the union of `BitmapFont.ALPHA` and `BitmapFont.NUMERIC`.\n * @type {string[][]}\n */\n BitmapFont.ALPHANUMERIC = [['a', 'z'], ['A', 'Z'], ['0', '9'], ' '];\n /**\n * This character set consists of all the ASCII table.\n * @member {string[][]}\n * @see http://www.asciitable.com/\n */\n BitmapFont.ASCII = [[' ', '~']];\n /**\n * Collection of default options when using `BitmapFont.from`.\n * @property {number} [resolution=1] -\n * @property {number} [textureWidth=512] -\n * @property {number} [textureHeight=512] -\n * @property {number} [padding=4] -\n * @property {string|string[]|string[][]} chars = PIXI.BitmapFont.ALPHANUMERIC\n */\n BitmapFont.defaultOptions = {\n resolution: 1,\n textureWidth: 512,\n textureHeight: 512,\n padding: 4,\n chars: BitmapFont.ALPHANUMERIC,\n };\n /** Collection of available/installed fonts. */\n BitmapFont.available = {};\n return BitmapFont;\n}());\n\nvar msdfFrag = \"// Pixi texture info\\r\\nvarying vec2 vTextureCoord;\\r\\nuniform sampler2D uSampler;\\r\\n\\r\\n// Tint\\r\\nuniform vec4 uColor;\\r\\n\\r\\n// on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\\r\\nuniform float uFWidth;\\r\\n\\r\\nvoid main(void) {\\r\\n\\r\\n // To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\\r\\n vec4 texColor = texture2D(uSampler, vTextureCoord);\\r\\n\\r\\n // MSDF\\r\\n float median = texColor.r + texColor.g + texColor.b -\\r\\n min(texColor.r, min(texColor.g, texColor.b)) -\\r\\n max(texColor.r, max(texColor.g, texColor.b));\\r\\n // SDF\\r\\n median = min(median, texColor.a);\\r\\n\\r\\n float screenPxDistance = uFWidth * (median - 0.5);\\r\\n float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\\r\\n if (median < 0.01) {\\r\\n alpha = 0.0;\\r\\n } else if (median > 0.99) {\\r\\n alpha = 1.0;\\r\\n }\\r\\n\\r\\n // NPM Textures, NPM outputs\\r\\n gl_FragColor = vec4(uColor.rgb, uColor.a * alpha);\\r\\n\\r\\n}\\r\\n\";\n\nvar msdfVert = \"// Mesh material default fragment\\r\\nattribute vec2 aVertexPosition;\\r\\nattribute vec2 aTextureCoord;\\r\\n\\r\\nuniform mat3 projectionMatrix;\\r\\nuniform mat3 translationMatrix;\\r\\nuniform mat3 uTextureMatrix;\\r\\n\\r\\nvarying vec2 vTextureCoord;\\r\\n\\r\\nvoid main(void)\\r\\n{\\r\\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\\r\\n\\r\\n vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\\r\\n}\\r\\n\";\n\n// If we ever need more than two pools, please make a Dict or something better.\nvar pageMeshDataDefaultPageMeshData = [];\nvar pageMeshDataMSDFPageMeshData = [];\nvar charRenderDataPool = [];\n/**\n * A BitmapText object will create a line or multiple lines of text using bitmap font.\n *\n * The primary advantage of this class over Text is that all of your textures are pre-generated and loading,\n * meaning that rendering is fast, and changing text has no performance implications.\n *\n * Supporting character sets other than latin, such as CJK languages, may be impractical due to the number of characters.\n *\n * To split a line you can use '\\n', '\\r' or '\\r\\n' in your string.\n *\n * PixiJS can auto-generate fonts on-the-fly using BitmapFont or use fnt files provided by:\n * http://www.angelcode.com/products/bmfont/ for Windows or\n * http://www.bmglyph.com/ for Mac.\n *\n * You can also use SDF, MSDF and MTSDF BitmapFonts for vector-like scaling appearance provided by:\n * https://github.com/soimy/msdf-bmfont-xml for SDF and MSDF fnt files or\n * https://github.com/Chlumsky/msdf-atlas-gen for SDF, MSDF and MTSDF json files\n *\n * A BitmapText can only be created when the font is loaded.\n *\n * ```js\n * // in this case the font is in a file called 'desyrel.fnt'\n * let bitmapText = new PIXI.BitmapText(\"text using a fancy font!\", {\n * fontName: \"Desyrel\",\n * fontSize: 35,\n * align: \"right\"\n * });\n * ```\n * @memberof PIXI\n */\nvar BitmapText = /** @class */ (function (_super) {\n __extends(BitmapText, _super);\n /**\n * @param text - A string that you would like the text to display.\n * @param style - The style parameters.\n * @param {string} style.fontName - The installed BitmapFont name.\n * @param {number} [style.fontSize] - The size of the font in pixels, e.g. 24. If undefined,\n *. this will default to the BitmapFont size.\n * @param {string} [style.align='left'] - Alignment for multiline text ('left', 'center', 'right' or 'justify'),\n * does not affect single line text.\n * @param {number} [style.tint=0xFFFFFF] - The tint color.\n * @param {number} [style.letterSpacing=0] - The amount of spacing between letters.\n * @param {number} [style.maxWidth=0] - The max width of the text before line wrapping.\n */\n function BitmapText(text, style) {\n if (style === void 0) { style = {}; }\n var _this = _super.call(this) || this;\n /**\n * Private tracker for the current tint.\n * @private\n */\n _this._tint = 0xFFFFFF;\n // Apply the defaults\n var _a = Object.assign({}, BitmapText.styleDefaults, style), align = _a.align, tint = _a.tint, maxWidth = _a.maxWidth, letterSpacing = _a.letterSpacing, fontName = _a.fontName, fontSize = _a.fontSize;\n if (!BitmapFont.available[fontName]) {\n throw new Error(\"Missing BitmapFont \\\"\" + fontName + \"\\\"\");\n }\n _this._activePagesMeshData = [];\n _this._textWidth = 0;\n _this._textHeight = 0;\n _this._align = align;\n _this._tint = tint;\n _this._font = undefined;\n _this._fontName = fontName;\n _this._fontSize = fontSize;\n _this.text = text;\n _this._maxWidth = maxWidth;\n _this._maxLineHeight = 0;\n _this._letterSpacing = letterSpacing;\n _this._anchor = new ObservablePoint(function () { _this.dirty = true; }, _this, 0, 0);\n _this._roundPixels = settings.ROUND_PIXELS;\n _this.dirty = true;\n _this._resolution = settings.RESOLUTION;\n _this._autoResolution = true;\n _this._textureCache = {};\n return _this;\n }\n /** Renders text and updates it when needed. This should only be called if the BitmapFont is regenerated. */\n BitmapText.prototype.updateText = function () {\n var _a;\n var data = BitmapFont.available[this._fontName];\n var fontSize = this.fontSize;\n var scale = fontSize / data.size;\n var pos = new Point();\n var chars = [];\n var lineWidths = [];\n var lineSpaces = [];\n var text = this._text.replace(/(?:\\r\\n|\\r)/g, '\\n') || ' ';\n var charsInput = splitTextToCharacters(text);\n var maxWidth = this._maxWidth * data.size / fontSize;\n var pageMeshDataPool = data.distanceFieldType === 'none'\n ? pageMeshDataDefaultPageMeshData : pageMeshDataMSDFPageMeshData;\n var prevCharCode = null;\n var lastLineWidth = 0;\n var maxLineWidth = 0;\n var line = 0;\n var lastBreakPos = -1;\n var lastBreakWidth = 0;\n var spacesRemoved = 0;\n var maxLineHeight = 0;\n var spaceCount = 0;\n for (var i = 0; i < charsInput.length; i++) {\n var char = charsInput[i];\n var charCode = extractCharCode(char);\n if ((/(?:\\s)/).test(char)) {\n lastBreakPos = i;\n lastBreakWidth = lastLineWidth;\n spaceCount++;\n }\n if (char === '\\r' || char === '\\n') {\n lineWidths.push(lastLineWidth);\n lineSpaces.push(-1);\n maxLineWidth = Math.max(maxLineWidth, lastLineWidth);\n ++line;\n ++spacesRemoved;\n pos.x = 0;\n pos.y += data.lineHeight;\n prevCharCode = null;\n spaceCount = 0;\n continue;\n }\n var charData = data.chars[charCode];\n if (!charData) {\n continue;\n }\n if (prevCharCode && charData.kerning[prevCharCode]) {\n pos.x += charData.kerning[prevCharCode];\n }\n var charRenderData = charRenderDataPool.pop() || {\n texture: Texture.EMPTY,\n line: 0,\n charCode: 0,\n prevSpaces: 0,\n position: new Point(),\n };\n charRenderData.texture = charData.texture;\n charRenderData.line = line;\n charRenderData.charCode = charCode;\n charRenderData.position.x = pos.x + charData.xOffset + (this._letterSpacing / 2);\n charRenderData.position.y = pos.y + charData.yOffset;\n charRenderData.prevSpaces = spaceCount;\n chars.push(charRenderData);\n lastLineWidth = charRenderData.position.x\n + Math.max(charData.xAdvance - charData.xOffset, charData.texture.orig.width);\n pos.x += charData.xAdvance + this._letterSpacing;\n maxLineHeight = Math.max(maxLineHeight, (charData.yOffset + charData.texture.height));\n prevCharCode = charCode;\n if (lastBreakPos !== -1 && maxWidth > 0 && pos.x > maxWidth) {\n ++spacesRemoved;\n removeItems(chars, 1 + lastBreakPos - spacesRemoved, 1 + i - lastBreakPos);\n i = lastBreakPos;\n lastBreakPos = -1;\n lineWidths.push(lastBreakWidth);\n lineSpaces.push(chars.length > 0 ? chars[chars.length - 1].prevSpaces : 0);\n maxLineWidth = Math.max(maxLineWidth, lastBreakWidth);\n line++;\n pos.x = 0;\n pos.y += data.lineHeight;\n prevCharCode = null;\n spaceCount = 0;\n }\n }\n var lastChar = charsInput[charsInput.length - 1];\n if (lastChar !== '\\r' && lastChar !== '\\n') {\n if ((/(?:\\s)/).test(lastChar)) {\n lastLineWidth = lastBreakWidth;\n }\n lineWidths.push(lastLineWidth);\n maxLineWidth = Math.max(maxLineWidth, lastLineWidth);\n lineSpaces.push(-1);\n }\n var lineAlignOffsets = [];\n for (var i = 0; i <= line; i++) {\n var alignOffset = 0;\n if (this._align === 'right') {\n alignOffset = maxLineWidth - lineWidths[i];\n }\n else if (this._align === 'center') {\n alignOffset = (maxLineWidth - lineWidths[i]) / 2;\n }\n else if (this._align === 'justify') {\n alignOffset = lineSpaces[i] < 0 ? 0 : (maxLineWidth - lineWidths[i]) / lineSpaces[i];\n }\n lineAlignOffsets.push(alignOffset);\n }\n var lenChars = chars.length;\n var pagesMeshData = {};\n var newPagesMeshData = [];\n var activePagesMeshData = this._activePagesMeshData;\n pageMeshDataPool.push.apply(pageMeshDataPool, activePagesMeshData);\n for (var i = 0; i < lenChars; i++) {\n var texture = chars[i].texture;\n var baseTextureUid = texture.baseTexture.uid;\n if (!pagesMeshData[baseTextureUid]) {\n var pageMeshData = pageMeshDataPool.pop();\n if (!pageMeshData) {\n var geometry = new MeshGeometry();\n var material = void 0;\n var meshBlendMode = void 0;\n if (data.distanceFieldType === 'none') {\n material = new MeshMaterial(Texture.EMPTY);\n meshBlendMode = BLEND_MODES.NORMAL;\n }\n else {\n material = new MeshMaterial(Texture.EMPTY, { program: Program.from(msdfVert, msdfFrag), uniforms: { uFWidth: 0 } });\n meshBlendMode = BLEND_MODES.NORMAL_NPM;\n }\n var mesh = new Mesh(geometry, material);\n mesh.blendMode = meshBlendMode;\n pageMeshData = {\n index: 0,\n indexCount: 0,\n vertexCount: 0,\n uvsCount: 0,\n total: 0,\n mesh: mesh,\n vertices: null,\n uvs: null,\n indices: null,\n };\n }\n // reset data..\n pageMeshData.index = 0;\n pageMeshData.indexCount = 0;\n pageMeshData.vertexCount = 0;\n pageMeshData.uvsCount = 0;\n pageMeshData.total = 0;\n // TODO need to get page texture here somehow..\n var _textureCache = this._textureCache;\n _textureCache[baseTextureUid] = _textureCache[baseTextureUid] || new Texture(texture.baseTexture);\n pageMeshData.mesh.texture = _textureCache[baseTextureUid];\n pageMeshData.mesh.tint = this._tint;\n newPagesMeshData.push(pageMeshData);\n pagesMeshData[baseTextureUid] = pageMeshData;\n }\n pagesMeshData[baseTextureUid].total++;\n }\n // lets find any previously active pageMeshDatas that are no longer required for\n // the updated text (if any), removed and return them to the pool.\n for (var i = 0; i < activePagesMeshData.length; i++) {\n if (newPagesMeshData.indexOf(activePagesMeshData[i]) === -1) {\n this.removeChild(activePagesMeshData[i].mesh);\n }\n }\n // next lets add any new meshes, that have not yet been added to this BitmapText\n // we only add if its not already a child of this BitmapObject\n for (var i = 0; i < newPagesMeshData.length; i++) {\n if (newPagesMeshData[i].mesh.parent !== this) {\n this.addChild(newPagesMeshData[i].mesh);\n }\n }\n // active page mesh datas are set to be the new pages added.\n this._activePagesMeshData = newPagesMeshData;\n for (var i in pagesMeshData) {\n var pageMeshData = pagesMeshData[i];\n var total = pageMeshData.total;\n // lets only allocate new buffers if we can fit the new text in the current ones..\n // unless that is, we will be batching. Currently batching dose not respect the size property of mesh\n if (!(((_a = pageMeshData.indices) === null || _a === void 0 ? void 0 : _a.length) > 6 * total) || pageMeshData.vertices.length < Mesh.BATCHABLE_SIZE * 2) {\n pageMeshData.vertices = new Float32Array(4 * 2 * total);\n pageMeshData.uvs = new Float32Array(4 * 2 * total);\n pageMeshData.indices = new Uint16Array(6 * total);\n }\n else {\n var total_1 = pageMeshData.total;\n var vertices = pageMeshData.vertices;\n // Clear the garbage at the end of the vertices buffer. This will prevent the bounds miscalculation.\n for (var i_1 = total_1 * 4 * 2; i_1 < vertices.length; i_1++) {\n vertices[i_1] = 0;\n }\n }\n // as a buffer maybe bigger than the current word, we set the size of the meshMaterial\n // to match the number of letters needed\n pageMeshData.mesh.size = 6 * total;\n }\n for (var i = 0; i < lenChars; i++) {\n var char = chars[i];\n var offset = char.position.x + (lineAlignOffsets[char.line] * (this._align === 'justify' ? char.prevSpaces : 1));\n if (this._roundPixels) {\n offset = Math.round(offset);\n }\n var xPos = offset * scale;\n var yPos = char.position.y * scale;\n var texture = char.texture;\n var pageMesh = pagesMeshData[texture.baseTexture.uid];\n var textureFrame = texture.frame;\n var textureUvs = texture._uvs;\n var index = pageMesh.index++;\n pageMesh.indices[(index * 6) + 0] = 0 + (index * 4);\n pageMesh.indices[(index * 6) + 1] = 1 + (index * 4);\n pageMesh.indices[(index * 6) + 2] = 2 + (index * 4);\n pageMesh.indices[(index * 6) + 3] = 0 + (index * 4);\n pageMesh.indices[(index * 6) + 4] = 2 + (index * 4);\n pageMesh.indices[(index * 6) + 5] = 3 + (index * 4);\n pageMesh.vertices[(index * 8) + 0] = xPos;\n pageMesh.vertices[(index * 8) + 1] = yPos;\n pageMesh.vertices[(index * 8) + 2] = xPos + (textureFrame.width * scale);\n pageMesh.vertices[(index * 8) + 3] = yPos;\n pageMesh.vertices[(index * 8) + 4] = xPos + (textureFrame.width * scale);\n pageMesh.vertices[(index * 8) + 5] = yPos + (textureFrame.height * scale);\n pageMesh.vertices[(index * 8) + 6] = xPos;\n pageMesh.vertices[(index * 8) + 7] = yPos + (textureFrame.height * scale);\n pageMesh.uvs[(index * 8) + 0] = textureUvs.x0;\n pageMesh.uvs[(index * 8) + 1] = textureUvs.y0;\n pageMesh.uvs[(index * 8) + 2] = textureUvs.x1;\n pageMesh.uvs[(index * 8) + 3] = textureUvs.y1;\n pageMesh.uvs[(index * 8) + 4] = textureUvs.x2;\n pageMesh.uvs[(index * 8) + 5] = textureUvs.y2;\n pageMesh.uvs[(index * 8) + 6] = textureUvs.x3;\n pageMesh.uvs[(index * 8) + 7] = textureUvs.y3;\n }\n this._textWidth = maxLineWidth * scale;\n this._textHeight = (pos.y + data.lineHeight) * scale;\n for (var i in pagesMeshData) {\n var pageMeshData = pagesMeshData[i];\n // apply anchor\n if (this.anchor.x !== 0 || this.anchor.y !== 0) {\n var vertexCount = 0;\n var anchorOffsetX = this._textWidth * this.anchor.x;\n var anchorOffsetY = this._textHeight * this.anchor.y;\n for (var i_2 = 0; i_2 < pageMeshData.total; i_2++) {\n pageMeshData.vertices[vertexCount++] -= anchorOffsetX;\n pageMeshData.vertices[vertexCount++] -= anchorOffsetY;\n pageMeshData.vertices[vertexCount++] -= anchorOffsetX;\n pageMeshData.vertices[vertexCount++] -= anchorOffsetY;\n pageMeshData.vertices[vertexCount++] -= anchorOffsetX;\n pageMeshData.vertices[vertexCount++] -= anchorOffsetY;\n pageMeshData.vertices[vertexCount++] -= anchorOffsetX;\n pageMeshData.vertices[vertexCount++] -= anchorOffsetY;\n }\n }\n this._maxLineHeight = maxLineHeight * scale;\n var vertexBuffer = pageMeshData.mesh.geometry.getBuffer('aVertexPosition');\n var textureBuffer = pageMeshData.mesh.geometry.getBuffer('aTextureCoord');\n var indexBuffer = pageMeshData.mesh.geometry.getIndex();\n vertexBuffer.data = pageMeshData.vertices;\n textureBuffer.data = pageMeshData.uvs;\n indexBuffer.data = pageMeshData.indices;\n vertexBuffer.update();\n textureBuffer.update();\n indexBuffer.update();\n }\n for (var i = 0; i < chars.length; i++) {\n charRenderDataPool.push(chars[i]);\n }\n this._font = data;\n this.dirty = false;\n };\n BitmapText.prototype.updateTransform = function () {\n this.validate();\n this.containerUpdateTransform();\n };\n BitmapText.prototype._render = function (renderer) {\n if (this._autoResolution && this._resolution !== renderer.resolution) {\n this._resolution = renderer.resolution;\n this.dirty = true;\n }\n // Update the uniform\n var _a = BitmapFont.available[this._fontName], distanceFieldRange = _a.distanceFieldRange, distanceFieldType = _a.distanceFieldType, size = _a.size;\n if (distanceFieldType !== 'none') {\n // Inject the shader code with the correct value\n var _b = this.worldTransform, a = _b.a, b = _b.b, c = _b.c, d = _b.d;\n var dx = Math.sqrt((a * a) + (b * b));\n var dy = Math.sqrt((c * c) + (d * d));\n var worldScale = (Math.abs(dx) + Math.abs(dy)) / 2;\n var fontScale = this.fontSize / size;\n for (var _i = 0, _c = this._activePagesMeshData; _i < _c.length; _i++) {\n var mesh = _c[_i];\n mesh.mesh.shader.uniforms.uFWidth = worldScale * distanceFieldRange * fontScale * this._resolution;\n }\n }\n _super.prototype._render.call(this, renderer);\n };\n /**\n * Validates text before calling parent's getLocalBounds\n * @returns - The rectangular bounding area\n */\n BitmapText.prototype.getLocalBounds = function () {\n this.validate();\n return _super.prototype.getLocalBounds.call(this);\n };\n /**\n * Updates text when needed\n * @private\n */\n BitmapText.prototype.validate = function () {\n var font = BitmapFont.available[this._fontName];\n if (!font) {\n throw new Error(\"Missing BitmapFont \\\"\" + this._fontName + \"\\\"\");\n }\n if (this._font !== font) {\n this.dirty = true;\n }\n if (this.dirty) {\n this.updateText();\n }\n };\n Object.defineProperty(BitmapText.prototype, \"tint\", {\n /**\n * The tint of the BitmapText object.\n * @default 0xffffff\n */\n get: function () {\n return this._tint;\n },\n set: function (value) {\n if (this._tint === value)\n { return; }\n this._tint = value;\n for (var i = 0; i < this._activePagesMeshData.length; i++) {\n this._activePagesMeshData[i].mesh.tint = value;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BitmapText.prototype, \"align\", {\n /**\n * The alignment of the BitmapText object.\n * @member {string}\n * @default 'left'\n */\n get: function () {\n return this._align;\n },\n set: function (value) {\n if (this._align !== value) {\n this._align = value;\n this.dirty = true;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BitmapText.prototype, \"fontName\", {\n /** The name of the BitmapFont. */\n get: function () {\n return this._fontName;\n },\n set: function (value) {\n if (!BitmapFont.available[value]) {\n throw new Error(\"Missing BitmapFont \\\"\" + value + \"\\\"\");\n }\n if (this._fontName !== value) {\n this._fontName = value;\n this.dirty = true;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BitmapText.prototype, \"fontSize\", {\n /** The size of the font to display. */\n get: function () {\n var _a;\n return (_a = this._fontSize) !== null && _a !== void 0 ? _a : BitmapFont.available[this._fontName].size;\n },\n set: function (value) {\n if (this._fontSize !== value) {\n this._fontSize = value;\n this.dirty = true;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BitmapText.prototype, \"anchor\", {\n /**\n * The anchor sets the origin point of the text.\n *\n * The default is `(0,0)`, this means the text's origin is the top left.\n *\n * Setting the anchor to `(0.5,0.5)` means the text's origin is centered.\n *\n * Setting the anchor to `(1,1)` would mean the text's origin point will be the bottom right corner.\n */\n get: function () {\n return this._anchor;\n },\n set: function (value) {\n if (typeof value === 'number') {\n this._anchor.set(value);\n }\n else {\n this._anchor.copyFrom(value);\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BitmapText.prototype, \"text\", {\n /** The text of the BitmapText object. */\n get: function () {\n return this._text;\n },\n set: function (text) {\n text = String(text === null || text === undefined ? '' : text);\n if (this._text === text) {\n return;\n }\n this._text = text;\n this.dirty = true;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BitmapText.prototype, \"maxWidth\", {\n /**\n * The max width of this bitmap text in pixels. If the text provided is longer than the\n * value provided, line breaks will be automatically inserted in the last whitespace.\n * Disable by setting the value to 0.\n */\n get: function () {\n return this._maxWidth;\n },\n set: function (value) {\n if (this._maxWidth === value) {\n return;\n }\n this._maxWidth = value;\n this.dirty = true;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BitmapText.prototype, \"maxLineHeight\", {\n /**\n * The max line height. This is useful when trying to use the total height of the Text,\n * i.e. when trying to vertically align.\n * @readonly\n */\n get: function () {\n this.validate();\n return this._maxLineHeight;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BitmapText.prototype, \"textWidth\", {\n /**\n * The width of the overall text, different from fontSize,\n * which is defined in the style object.\n * @readonly\n */\n get: function () {\n this.validate();\n return this._textWidth;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BitmapText.prototype, \"letterSpacing\", {\n /** Additional space between characters. */\n get: function () {\n return this._letterSpacing;\n },\n set: function (value) {\n if (this._letterSpacing !== value) {\n this._letterSpacing = value;\n this.dirty = true;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BitmapText.prototype, \"roundPixels\", {\n /**\n * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation.\n * Advantages can include sharper image quality (like text) and faster rendering on canvas.\n * The main disadvantage is movement of objects may appear less smooth.\n * To set the global default, change {@link PIXI.settings.ROUND_PIXELS}\n * @default PIXI.settings.ROUND_PIXELS\n */\n get: function () {\n return this._roundPixels;\n },\n set: function (value) {\n if (value !== this._roundPixels) {\n this._roundPixels = value;\n this.dirty = true;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BitmapText.prototype, \"textHeight\", {\n /**\n * The height of the overall text, different from fontSize,\n * which is defined in the style object.\n * @readonly\n */\n get: function () {\n this.validate();\n return this._textHeight;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BitmapText.prototype, \"resolution\", {\n /**\n * The resolution / device pixel ratio of the canvas.\n *\n * This is set to automatically match the renderer resolution by default, but can be overridden by setting manually.\n * @default 1\n */\n get: function () {\n return this._resolution;\n },\n set: function (value) {\n this._autoResolution = false;\n if (this._resolution === value) {\n return;\n }\n this._resolution = value;\n this.dirty = true;\n },\n enumerable: false,\n configurable: true\n });\n BitmapText.prototype.destroy = function (options) {\n var _textureCache = this._textureCache;\n var data = BitmapFont.available[this._fontName];\n var pageMeshDataPool = data.distanceFieldType === 'none'\n ? pageMeshDataDefaultPageMeshData : pageMeshDataMSDFPageMeshData;\n pageMeshDataPool.push.apply(pageMeshDataPool, this._activePagesMeshData);\n for (var _i = 0, _a = this._activePagesMeshData; _i < _a.length; _i++) {\n var pageMeshData = _a[_i];\n this.removeChild(pageMeshData.mesh);\n }\n this._activePagesMeshData = [];\n // Release references to any cached textures in page pool\n pageMeshDataPool\n .filter(function (page) { return _textureCache[page.mesh.texture.baseTexture.uid]; })\n .forEach(function (page) {\n page.mesh.texture = Texture.EMPTY;\n });\n for (var id in _textureCache) {\n var texture = _textureCache[id];\n texture.destroy();\n delete _textureCache[id];\n }\n this._font = null;\n this._textureCache = null;\n _super.prototype.destroy.call(this, options);\n };\n BitmapText.styleDefaults = {\n align: 'left',\n tint: 0xFFFFFF,\n maxWidth: 0,\n letterSpacing: 0,\n };\n return BitmapText;\n}(Container));\n\n/**\n * {@link PIXI.Loader Loader} middleware for loading\n * bitmap-based fonts suitable for using with {@link PIXI.BitmapText}.\n * @memberof PIXI\n */\nvar BitmapFontLoader = /** @class */ (function () {\n function BitmapFontLoader() {\n }\n /**\n * Called when the plugin is installed.\n * @see PIXI.extensions.add\n */\n BitmapFontLoader.add = function () {\n LoaderResource.setExtensionXhrType('fnt', LoaderResource.XHR_RESPONSE_TYPE.TEXT);\n };\n /**\n * Called after a resource is loaded.\n * @see PIXI.Loader.loaderMiddleware\n * @param this\n * @param {PIXI.LoaderResource} resource\n * @param {Function} next\n */\n BitmapFontLoader.use = function (resource, next) {\n var format = autoDetectFormat(resource.data);\n // Resource was not recognised as any of the expected font data format\n if (!format) {\n next();\n return;\n }\n var baseUrl = BitmapFontLoader.getBaseUrl(this, resource);\n var data = format.parse(resource.data);\n var textures = {};\n // Handle completed, when the number of textures\n // load is the same number as references in the fnt file\n var completed = function (page) {\n textures[page.metadata.pageFile] = page.texture;\n if (Object.keys(textures).length === data.page.length) {\n resource.bitmapFont = BitmapFont.install(data, textures, true);\n next();\n }\n };\n for (var i = 0; i < data.page.length; ++i) {\n var pageFile = data.page[i].file;\n var url = baseUrl + pageFile;\n var exists = false;\n // incase the image is loaded outside\n // using the same loader, resource will be available\n for (var name in this.resources) {\n var bitmapResource = this.resources[name];\n if (bitmapResource.url === url) {\n bitmapResource.metadata.pageFile = pageFile;\n if (bitmapResource.texture) {\n completed(bitmapResource);\n }\n else {\n bitmapResource.onAfterMiddleware.add(completed);\n }\n exists = true;\n break;\n }\n }\n // texture is not loaded, we'll attempt to add\n // it to the load and add the texture to the list\n if (!exists) {\n // Standard loading options for images\n var options = {\n crossOrigin: resource.crossOrigin,\n loadType: LoaderResource.LOAD_TYPE.IMAGE,\n metadata: Object.assign({ pageFile: pageFile }, resource.metadata.imageMetadata),\n parentResource: resource,\n };\n this.add(url, options, completed);\n }\n }\n };\n /**\n * Get folder path from a resource.\n * @param loader\n * @param resource\n */\n BitmapFontLoader.getBaseUrl = function (loader, resource) {\n var resUrl = !resource.isDataUrl ? BitmapFontLoader.dirname(resource.url) : '';\n if (resource.isDataUrl) {\n if (resUrl === '.') {\n resUrl = '';\n }\n if (loader.baseUrl && resUrl) {\n // if baseurl has a trailing slash then add one to resUrl so the replace works below\n if (loader.baseUrl.charAt(loader.baseUrl.length - 1) === '/') {\n resUrl += '/';\n }\n }\n }\n // remove baseUrl from resUrl\n resUrl = resUrl.replace(loader.baseUrl, '');\n // if there is an resUrl now, it needs a trailing slash. Ensure that it does if the string isn't empty.\n if (resUrl && resUrl.charAt(resUrl.length - 1) !== '/') {\n resUrl += '/';\n }\n return resUrl;\n };\n /**\n * Replacement for NodeJS's path.dirname\n * @param {string} url - Path to get directory for\n */\n BitmapFontLoader.dirname = function (url) {\n var dir = url\n .replace(/\\\\/g, '/') // convert windows notation to UNIX notation, URL-safe because it's a forbidden character\n .replace(/\\/$/, '') // replace trailing slash\n .replace(/\\/[^\\/]*$/, ''); // remove everything after the last\n // File request is relative, use current directory\n if (dir === url) {\n return '.';\n }\n // Started with a slash\n else if (dir === '') {\n return '/';\n }\n return dir;\n };\n /** @ignore */\n BitmapFontLoader.extension = ExtensionType.Loader;\n return BitmapFontLoader;\n}());\n\nexport { BitmapFont, BitmapFontData, BitmapFontLoader, BitmapText, TextFormat, XMLFormat, XMLStringFormat, autoDetectFormat };\n//# sourceMappingURL=text-bitmap.mjs.map\n","/*!\n * @pixi/filter-alpha - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/filter-alpha is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { defaultVertex, Filter } from '@pixi/core';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\nvar fragment = \"varying vec2 vTextureCoord;\\n\\nuniform sampler2D uSampler;\\nuniform float uAlpha;\\n\\nvoid main(void)\\n{\\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;\\n}\\n\";\n\n/**\n * Simplest filter - applies alpha.\n *\n * Use this instead of Container's alpha property to avoid visual layering of individual elements.\n * AlphaFilter applies alpha evenly across the entire display object and any opaque elements it contains.\n * If elements are not opaque, they will blend with each other anyway.\n *\n * Very handy if you want to use common features of all filters:\n *\n * 1. Assign a blendMode to this filter, blend all elements inside display object with background.\n *\n * 2. To use clipping in display coordinates, assign a filterArea to the same container that has this filter.\n * @memberof PIXI.filters\n */\nvar AlphaFilter = /** @class */ (function (_super) {\n __extends(AlphaFilter, _super);\n /**\n * @param alpha - Amount of alpha from 0 to 1, where 0 is transparent\n */\n function AlphaFilter(alpha) {\n if (alpha === void 0) { alpha = 1.0; }\n var _this = _super.call(this, defaultVertex, fragment, { uAlpha: 1 }) || this;\n _this.alpha = alpha;\n return _this;\n }\n Object.defineProperty(AlphaFilter.prototype, \"alpha\", {\n /**\n * Coefficient for alpha multiplication\n * @default 1\n */\n get: function () {\n return this.uniforms.uAlpha;\n },\n set: function (value) {\n this.uniforms.uAlpha = value;\n },\n enumerable: false,\n configurable: true\n });\n return AlphaFilter;\n}(Filter));\n\nexport { AlphaFilter };\n//# sourceMappingURL=filter-alpha.mjs.map\n","/*!\n * @pixi/filter-blur - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/filter-blur is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { Filter } from '@pixi/core';\nimport { settings } from '@pixi/settings';\nimport { CLEAR_MODES } from '@pixi/constants';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\nvar 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 }\";\nfunction generateBlurVertSource(kernelSize, x) {\n var halfLength = Math.ceil(kernelSize / 2);\n var vertSource = vertTemplate;\n var blurLoop = '';\n var template;\n if (x) {\n template = 'vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);';\n }\n else {\n template = 'vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);';\n }\n for (var i = 0; i < kernelSize; i++) {\n var blur = template.replace('%index%', i.toString());\n blur = blur.replace('%sampleIndex%', i - (halfLength - 1) + \".0\");\n blurLoop += blur;\n blurLoop += '\\n';\n }\n vertSource = vertSource.replace('%blur%', blurLoop);\n vertSource = vertSource.replace('%size%', kernelSize.toString());\n return vertSource;\n}\n\nvar GAUSSIAN_VALUES = {\n 5: [0.153388, 0.221461, 0.250301],\n 7: [0.071303, 0.131514, 0.189879, 0.214607],\n 9: [0.028532, 0.067234, 0.124009, 0.179044, 0.20236],\n 11: [0.0093, 0.028002, 0.065984, 0.121703, 0.175713, 0.198596],\n 13: [0.002406, 0.009255, 0.027867, 0.065666, 0.121117, 0.174868, 0.197641],\n 15: [0.000489, 0.002403, 0.009246, 0.02784, 0.065602, 0.120999, 0.174697, 0.197448],\n};\nvar fragTemplate = [\n 'varying vec2 vBlurTexCoords[%size%];',\n 'uniform sampler2D uSampler;',\n 'void main(void)',\n '{',\n ' gl_FragColor = vec4(0.0);',\n ' %blur%',\n '}' ].join('\\n');\nfunction generateBlurFragSource(kernelSize) {\n var kernel = GAUSSIAN_VALUES[kernelSize];\n var halfLength = kernel.length;\n var fragSource = fragTemplate;\n var blurLoop = '';\n var template = 'gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;';\n var value;\n for (var i = 0; i < kernelSize; i++) {\n var blur = template.replace('%index%', i.toString());\n value = i;\n if (i >= halfLength) {\n value = kernelSize - i - 1;\n }\n blur = blur.replace('%value%', kernel[value].toString());\n blurLoop += blur;\n blurLoop += '\\n';\n }\n fragSource = fragSource.replace('%blur%', blurLoop);\n fragSource = fragSource.replace('%size%', kernelSize.toString());\n return fragSource;\n}\n\n/**\n * The BlurFilterPass applies a horizontal or vertical Gaussian blur to an object.\n * @memberof PIXI.filters\n */\nvar BlurFilterPass = /** @class */ (function (_super) {\n __extends(BlurFilterPass, _super);\n /**\n * @param horizontal - Do pass along the x-axis (`true`) or y-axis (`false`).\n * @param strength - The strength of the blur filter.\n * @param quality - The quality of the blur filter.\n * @param resolution - The resolution of the blur filter.\n * @param kernelSize - The kernelSize of the blur filter.Options: 5, 7, 9, 11, 13, 15.\n */\n function BlurFilterPass(horizontal, strength, quality, resolution, kernelSize) {\n if (strength === void 0) { strength = 8; }\n if (quality === void 0) { quality = 4; }\n if (resolution === void 0) { resolution = settings.FILTER_RESOLUTION; }\n if (kernelSize === void 0) { kernelSize = 5; }\n var _this = this;\n var vertSrc = generateBlurVertSource(kernelSize, horizontal);\n var fragSrc = generateBlurFragSource(kernelSize);\n _this = _super.call(this, \n // vertex shader\n vertSrc, \n // fragment shader\n fragSrc) || this;\n _this.horizontal = horizontal;\n _this.resolution = resolution;\n _this._quality = 0;\n _this.quality = quality;\n _this.blur = strength;\n return _this;\n }\n /**\n * Applies the filter.\n * @param filterManager - The manager.\n * @param input - The input target.\n * @param output - The output target.\n * @param clearMode - How to clear\n */\n BlurFilterPass.prototype.apply = function (filterManager, input, output, clearMode) {\n if (output) {\n if (this.horizontal) {\n this.uniforms.strength = (1 / output.width) * (output.width / input.width);\n }\n else {\n this.uniforms.strength = (1 / output.height) * (output.height / input.height);\n }\n }\n else {\n if (this.horizontal) // eslint-disable-line\n {\n this.uniforms.strength = (1 / filterManager.renderer.width) * (filterManager.renderer.width / input.width);\n }\n else {\n this.uniforms.strength = (1 / filterManager.renderer.height) * (filterManager.renderer.height / input.height); // eslint-disable-line\n }\n }\n // screen space!\n this.uniforms.strength *= this.strength;\n this.uniforms.strength /= this.passes;\n if (this.passes === 1) {\n filterManager.applyFilter(this, input, output, clearMode);\n }\n else {\n var renderTarget = filterManager.getFilterTexture();\n var renderer = filterManager.renderer;\n var flip = input;\n var flop = renderTarget;\n this.state.blend = false;\n filterManager.applyFilter(this, flip, flop, CLEAR_MODES.CLEAR);\n for (var i = 1; i < this.passes - 1; i++) {\n filterManager.bindAndClear(flip, CLEAR_MODES.BLIT);\n this.uniforms.uSampler = flop;\n var temp = flop;\n flop = flip;\n flip = temp;\n renderer.shader.bind(this);\n renderer.geometry.draw(5);\n }\n this.state.blend = true;\n filterManager.applyFilter(this, flop, output, clearMode);\n filterManager.returnFilterTexture(renderTarget);\n }\n };\n Object.defineProperty(BlurFilterPass.prototype, \"blur\", {\n /**\n * Sets the strength of both the blur.\n * @default 16\n */\n get: function () {\n return this.strength;\n },\n set: function (value) {\n this.padding = 1 + (Math.abs(value) * 2);\n this.strength = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BlurFilterPass.prototype, \"quality\", {\n /**\n * Sets the quality of the blur by modifying the number of passes. More passes means higher\n * quality bluring but the lower the performance.\n * @default 4\n */\n get: function () {\n return this._quality;\n },\n set: function (value) {\n this._quality = value;\n this.passes = value;\n },\n enumerable: false,\n configurable: true\n });\n return BlurFilterPass;\n}(Filter));\n\n/**\n * The BlurFilter applies a Gaussian blur to an object.\n *\n * The strength of the blur can be set for the x-axis and y-axis separately.\n * @memberof PIXI.filters\n */\nvar BlurFilter = /** @class */ (function (_super) {\n __extends(BlurFilter, _super);\n /**\n * @param strength - The strength of the blur filter.\n * @param quality - The quality of the blur filter.\n * @param [resolution=PIXI.settings.FILTER_RESOLUTION] - The resolution of the blur filter.\n * @param kernelSize - The kernelSize of the blur filter.Options: 5, 7, 9, 11, 13, 15.\n */\n function BlurFilter(strength, quality, resolution, kernelSize) {\n if (strength === void 0) { strength = 8; }\n if (quality === void 0) { quality = 4; }\n if (resolution === void 0) { resolution = settings.FILTER_RESOLUTION; }\n if (kernelSize === void 0) { kernelSize = 5; }\n var _this = _super.call(this) || this;\n _this.blurXFilter = new BlurFilterPass(true, strength, quality, resolution, kernelSize);\n _this.blurYFilter = new BlurFilterPass(false, strength, quality, resolution, kernelSize);\n _this.resolution = resolution;\n _this.quality = quality;\n _this.blur = strength;\n _this.repeatEdgePixels = false;\n return _this;\n }\n /**\n * Applies the filter.\n * @param filterManager - The manager.\n * @param input - The input target.\n * @param output - The output target.\n * @param clearMode - How to clear\n */\n BlurFilter.prototype.apply = function (filterManager, input, output, clearMode) {\n var xStrength = Math.abs(this.blurXFilter.strength);\n var yStrength = Math.abs(this.blurYFilter.strength);\n if (xStrength && yStrength) {\n var renderTarget = filterManager.getFilterTexture();\n this.blurXFilter.apply(filterManager, input, renderTarget, CLEAR_MODES.CLEAR);\n this.blurYFilter.apply(filterManager, renderTarget, output, clearMode);\n filterManager.returnFilterTexture(renderTarget);\n }\n else if (yStrength) {\n this.blurYFilter.apply(filterManager, input, output, clearMode);\n }\n else {\n this.blurXFilter.apply(filterManager, input, output, clearMode);\n }\n };\n BlurFilter.prototype.updatePadding = function () {\n if (this._repeatEdgePixels) {\n this.padding = 0;\n }\n else {\n this.padding = Math.max(Math.abs(this.blurXFilter.strength), Math.abs(this.blurYFilter.strength)) * 2;\n }\n };\n Object.defineProperty(BlurFilter.prototype, \"blur\", {\n /**\n * Sets the strength of both the blurX and blurY properties simultaneously\n * @default 2\n */\n get: function () {\n return this.blurXFilter.blur;\n },\n set: function (value) {\n this.blurXFilter.blur = this.blurYFilter.blur = value;\n this.updatePadding();\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BlurFilter.prototype, \"quality\", {\n /**\n * Sets the number of passes for blur. More passes means higher quality bluring.\n * @default 1\n */\n get: function () {\n return this.blurXFilter.quality;\n },\n set: function (value) {\n this.blurXFilter.quality = this.blurYFilter.quality = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BlurFilter.prototype, \"blurX\", {\n /**\n * Sets the strength of the blurX property\n * @default 2\n */\n get: function () {\n return this.blurXFilter.blur;\n },\n set: function (value) {\n this.blurXFilter.blur = value;\n this.updatePadding();\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BlurFilter.prototype, \"blurY\", {\n /**\n * Sets the strength of the blurY property\n * @default 2\n */\n get: function () {\n return this.blurYFilter.blur;\n },\n set: function (value) {\n this.blurYFilter.blur = value;\n this.updatePadding();\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BlurFilter.prototype, \"blendMode\", {\n /**\n * Sets the blendmode of the filter\n * @default PIXI.BLEND_MODES.NORMAL\n */\n get: function () {\n return this.blurYFilter.blendMode;\n },\n set: function (value) {\n this.blurYFilter.blendMode = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(BlurFilter.prototype, \"repeatEdgePixels\", {\n /**\n * If set to true the edge of the target will be clamped\n * @default false\n */\n get: function () {\n return this._repeatEdgePixels;\n },\n set: function (value) {\n this._repeatEdgePixels = value;\n this.updatePadding();\n },\n enumerable: false,\n configurable: true\n });\n return BlurFilter;\n}(Filter));\n\nexport { BlurFilter, BlurFilterPass };\n//# sourceMappingURL=filter-blur.mjs.map\n","/*!\n * @pixi/filter-color-matrix - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/filter-color-matrix is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { defaultFilterVertex, Filter } from '@pixi/core';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\nvar fragment = \"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\";\n\n/**\n * The ColorMatrixFilter class lets you apply a 5x4 matrix transformation on the RGBA\n * color and alpha values of every pixel on your displayObject to produce a result\n * with a new set of RGBA color and alpha values. It's pretty powerful!\n *\n * ```js\n * let colorMatrix = new PIXI.filters.ColorMatrixFilter();\n * container.filters = [colorMatrix];\n * colorMatrix.contrast(2);\n * ```\n * @author Clément Chenebault \n * @memberof PIXI.filters\n */\nvar ColorMatrixFilter = /** @class */ (function (_super) {\n __extends(ColorMatrixFilter, _super);\n function ColorMatrixFilter() {\n var _this = this;\n var uniforms = {\n m: new Float32Array([1, 0, 0, 0, 0,\n 0, 1, 0, 0, 0,\n 0, 0, 1, 0, 0,\n 0, 0, 0, 1, 0]),\n uAlpha: 1,\n };\n _this = _super.call(this, defaultFilterVertex, fragment, uniforms) || this;\n _this.alpha = 1;\n return _this;\n }\n /**\n * Transforms current matrix and set the new one\n * @param {number[]} matrix - 5x4 matrix\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype._loadMatrix = function (matrix, multiply) {\n if (multiply === void 0) { multiply = false; }\n var newMatrix = matrix;\n if (multiply) {\n this._multiply(newMatrix, this.uniforms.m, matrix);\n newMatrix = this._colorMatrix(newMatrix);\n }\n // set the new matrix\n this.uniforms.m = newMatrix;\n };\n /**\n * Multiplies two mat5's\n * @private\n * @param out - 5x4 matrix the receiving matrix\n * @param a - 5x4 matrix the first operand\n * @param b - 5x4 matrix the second operand\n * @returns {number[]} 5x4 matrix\n */\n ColorMatrixFilter.prototype._multiply = function (out, a, b) {\n // Red Channel\n out[0] = (a[0] * b[0]) + (a[1] * b[5]) + (a[2] * b[10]) + (a[3] * b[15]);\n out[1] = (a[0] * b[1]) + (a[1] * b[6]) + (a[2] * b[11]) + (a[3] * b[16]);\n out[2] = (a[0] * b[2]) + (a[1] * b[7]) + (a[2] * b[12]) + (a[3] * b[17]);\n out[3] = (a[0] * b[3]) + (a[1] * b[8]) + (a[2] * b[13]) + (a[3] * b[18]);\n out[4] = (a[0] * b[4]) + (a[1] * b[9]) + (a[2] * b[14]) + (a[3] * b[19]) + a[4];\n // Green Channel\n out[5] = (a[5] * b[0]) + (a[6] * b[5]) + (a[7] * b[10]) + (a[8] * b[15]);\n out[6] = (a[5] * b[1]) + (a[6] * b[6]) + (a[7] * b[11]) + (a[8] * b[16]);\n out[7] = (a[5] * b[2]) + (a[6] * b[7]) + (a[7] * b[12]) + (a[8] * b[17]);\n out[8] = (a[5] * b[3]) + (a[6] * b[8]) + (a[7] * b[13]) + (a[8] * b[18]);\n out[9] = (a[5] * b[4]) + (a[6] * b[9]) + (a[7] * b[14]) + (a[8] * b[19]) + a[9];\n // Blue Channel\n out[10] = (a[10] * b[0]) + (a[11] * b[5]) + (a[12] * b[10]) + (a[13] * b[15]);\n out[11] = (a[10] * b[1]) + (a[11] * b[6]) + (a[12] * b[11]) + (a[13] * b[16]);\n out[12] = (a[10] * b[2]) + (a[11] * b[7]) + (a[12] * b[12]) + (a[13] * b[17]);\n out[13] = (a[10] * b[3]) + (a[11] * b[8]) + (a[12] * b[13]) + (a[13] * b[18]);\n out[14] = (a[10] * b[4]) + (a[11] * b[9]) + (a[12] * b[14]) + (a[13] * b[19]) + a[14];\n // Alpha Channel\n out[15] = (a[15] * b[0]) + (a[16] * b[5]) + (a[17] * b[10]) + (a[18] * b[15]);\n out[16] = (a[15] * b[1]) + (a[16] * b[6]) + (a[17] * b[11]) + (a[18] * b[16]);\n out[17] = (a[15] * b[2]) + (a[16] * b[7]) + (a[17] * b[12]) + (a[18] * b[17]);\n out[18] = (a[15] * b[3]) + (a[16] * b[8]) + (a[17] * b[13]) + (a[18] * b[18]);\n out[19] = (a[15] * b[4]) + (a[16] * b[9]) + (a[17] * b[14]) + (a[18] * b[19]) + a[19];\n return out;\n };\n /**\n * Create a Float32 Array and normalize the offset component to 0-1\n * @param {number[]} matrix - 5x4 matrix\n * @returns {number[]} 5x4 matrix with all values between 0-1\n */\n ColorMatrixFilter.prototype._colorMatrix = function (matrix) {\n // Create a Float32 Array and normalize the offset component to 0-1\n var m = new Float32Array(matrix);\n m[4] /= 255;\n m[9] /= 255;\n m[14] /= 255;\n m[19] /= 255;\n return m;\n };\n /**\n * Adjusts brightness\n * @param b - value of the brigthness (0-1, where 0 is black)\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.brightness = function (b, multiply) {\n var matrix = [\n b, 0, 0, 0, 0,\n 0, b, 0, 0, 0,\n 0, 0, b, 0, 0,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Sets each channel on the diagonal of the color matrix.\n * This can be used to achieve a tinting effect on Containers similar to the tint field of some\n * display objects like Sprite, Text, Graphics, and Mesh.\n * @param color - Color of the tint. This is a hex value.\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.tint = function (color, multiply) {\n var r = (color >> 16) & 0xff;\n var g = (color >> 8) & 0xff;\n var b = color & 0xff;\n var matrix = [\n r / 255, 0, 0, 0, 0,\n 0, g / 255, 0, 0, 0,\n 0, 0, b / 255, 0, 0,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Set the matrices in grey scales\n * @param scale - value of the grey (0-1, where 0 is black)\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.greyscale = function (scale, multiply) {\n var matrix = [\n scale, scale, scale, 0, 0,\n scale, scale, scale, 0, 0,\n scale, scale, scale, 0, 0,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Set the black and white matrice.\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.blackAndWhite = function (multiply) {\n var matrix = [\n 0.3, 0.6, 0.1, 0, 0,\n 0.3, 0.6, 0.1, 0, 0,\n 0.3, 0.6, 0.1, 0, 0,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Set the hue property of the color\n * @param rotation - in degrees\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.hue = function (rotation, multiply) {\n rotation = (rotation || 0) / 180 * Math.PI;\n var cosR = Math.cos(rotation);\n var sinR = Math.sin(rotation);\n var sqrt = Math.sqrt;\n /* a good approximation for hue rotation\n This matrix is far better than the versions with magic luminance constants\n formerly used here, but also used in the starling framework (flash) and known from this\n old part of the internet: quasimondo.com/archives/000565.php\n\n This new matrix is based on rgb cube rotation in space. Look here for a more descriptive\n implementation as a shader not a general matrix:\n https://github.com/evanw/glfx.js/blob/58841c23919bd59787effc0333a4897b43835412/src/filters/adjust/huesaturation.js\n\n This is the source for the code:\n see http://stackoverflow.com/questions/8507885/shift-hue-of-an-rgb-color/8510751#8510751\n */\n var w = 1 / 3;\n var sqrW = sqrt(w); // weight is\n var a00 = cosR + ((1.0 - cosR) * w);\n var a01 = (w * (1.0 - cosR)) - (sqrW * sinR);\n var a02 = (w * (1.0 - cosR)) + (sqrW * sinR);\n var a10 = (w * (1.0 - cosR)) + (sqrW * sinR);\n var a11 = cosR + (w * (1.0 - cosR));\n var a12 = (w * (1.0 - cosR)) - (sqrW * sinR);\n var a20 = (w * (1.0 - cosR)) - (sqrW * sinR);\n var a21 = (w * (1.0 - cosR)) + (sqrW * sinR);\n var a22 = cosR + (w * (1.0 - cosR));\n var matrix = [\n a00, a01, a02, 0, 0,\n a10, a11, a12, 0, 0,\n a20, a21, a22, 0, 0,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Set the contrast matrix, increase the separation between dark and bright\n * Increase contrast : shadows darker and highlights brighter\n * Decrease contrast : bring the shadows up and the highlights down\n * @param amount - value of the contrast (0-1)\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.contrast = function (amount, multiply) {\n var v = (amount || 0) + 1;\n var o = -0.5 * (v - 1);\n var matrix = [\n v, 0, 0, 0, o,\n 0, v, 0, 0, o,\n 0, 0, v, 0, o,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Set the saturation matrix, increase the separation between colors\n * Increase saturation : increase contrast, brightness, and sharpness\n * @param amount - The saturation amount (0-1)\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.saturate = function (amount, multiply) {\n if (amount === void 0) { amount = 0; }\n var x = (amount * 2 / 3) + 1;\n var y = ((x - 1) * -0.5);\n var matrix = [\n x, y, y, 0, 0,\n y, x, y, 0, 0,\n y, y, x, 0, 0,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /** Desaturate image (remove color) Call the saturate function */\n ColorMatrixFilter.prototype.desaturate = function () {\n this.saturate(-1);\n };\n /**\n * Negative image (inverse of classic rgb matrix)\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.negative = function (multiply) {\n var matrix = [\n -1, 0, 0, 1, 0,\n 0, -1, 0, 1, 0,\n 0, 0, -1, 1, 0,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Sepia image\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.sepia = function (multiply) {\n var matrix = [\n 0.393, 0.7689999, 0.18899999, 0, 0,\n 0.349, 0.6859999, 0.16799999, 0, 0,\n 0.272, 0.5339999, 0.13099999, 0, 0,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Color motion picture process invented in 1916 (thanks Dominic Szablewski)\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.technicolor = function (multiply) {\n var matrix = [\n 1.9125277891456083, -0.8545344976951645, -0.09155508482755585, 0, 11.793603434377337,\n -0.3087833385928097, 1.7658908555458428, -0.10601743074722245, 0, -70.35205161461398,\n -0.231103377548616, -0.7501899197440212, 1.847597816108189, 0, 30.950940869491138,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Polaroid filter\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.polaroid = function (multiply) {\n var matrix = [\n 1.438, -0.062, -0.062, 0, 0,\n -0.122, 1.378, -0.122, 0, 0,\n -0.016, -0.016, 1.483, 0, 0,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Filter who transforms : Red -> Blue and Blue -> Red\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.toBGR = function (multiply) {\n var matrix = [\n 0, 0, 1, 0, 0,\n 0, 1, 0, 0, 0,\n 1, 0, 0, 0, 0,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Color reversal film introduced by Eastman Kodak in 1935. (thanks Dominic Szablewski)\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.kodachrome = function (multiply) {\n var matrix = [\n 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502,\n -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203,\n -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Brown delicious browni filter (thanks Dominic Szablewski)\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.browni = function (multiply) {\n var matrix = [\n 0.5997023498159715, 0.34553243048391263, -0.2708298674538042, 0, 47.43192855600873,\n -0.037703249837783157, 0.8609577587992641, 0.15059552388459913, 0, -36.96841498319127,\n 0.24113635128153335, -0.07441037908422492, 0.44972182064877153, 0, -7.562075277591283,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Vintage filter (thanks Dominic Szablewski)\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.vintage = function (multiply) {\n var matrix = [\n 0.6279345635605994, 0.3202183420819367, -0.03965408211312453, 0, 9.651285835294123,\n 0.02578397704808868, 0.6441188644374771, 0.03259127616149294, 0, 7.462829176470591,\n 0.0466055556782719, -0.0851232987247891, 0.5241648018700465, 0, 5.159190588235296,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * We don't know exactly what it does, kind of gradient map, but funny to play with!\n * @param desaturation - Tone values.\n * @param toned - Tone values.\n * @param lightColor - Tone values, example: `0xFFE580`\n * @param darkColor - Tone values, example: `0xFFE580`\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.colorTone = function (desaturation, toned, lightColor, darkColor, multiply) {\n desaturation = desaturation || 0.2;\n toned = toned || 0.15;\n lightColor = lightColor || 0xFFE580;\n darkColor = darkColor || 0x338000;\n var lR = ((lightColor >> 16) & 0xFF) / 255;\n var lG = ((lightColor >> 8) & 0xFF) / 255;\n var lB = (lightColor & 0xFF) / 255;\n var dR = ((darkColor >> 16) & 0xFF) / 255;\n var dG = ((darkColor >> 8) & 0xFF) / 255;\n var dB = (darkColor & 0xFF) / 255;\n var matrix = [\n 0.3, 0.59, 0.11, 0, 0,\n lR, lG, lB, desaturation, 0,\n dR, dG, dB, toned, 0,\n lR - dR, lG - dG, lB - dB, 0, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Night effect\n * @param intensity - The intensity of the night effect.\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.night = function (intensity, multiply) {\n intensity = intensity || 0.1;\n var matrix = [\n intensity * (-2.0), -intensity, 0, 0, 0,\n -intensity, 0, intensity, 0, 0,\n 0, intensity, intensity * 2.0, 0, 0,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * Predator effect\n *\n * Erase the current matrix by setting a new indepent one\n * @param amount - how much the predator feels his future victim\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.predator = function (amount, multiply) {\n var matrix = [\n // row 1\n 11.224130630493164 * amount,\n -4.794486999511719 * amount,\n -2.8746118545532227 * amount,\n 0 * amount,\n 0.40342438220977783 * amount,\n // row 2\n -3.6330697536468506 * amount,\n 9.193157196044922 * amount,\n -2.951810836791992 * amount,\n 0 * amount,\n -1.316135048866272 * amount,\n // row 3\n -3.2184197902679443 * amount,\n -4.2375030517578125 * amount,\n 7.476448059082031 * amount,\n 0 * amount,\n 0.8044459223747253 * amount,\n // row 4\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /**\n * LSD effect\n *\n * Multiply the current matrix\n * @param multiply - if true, current matrix and matrix are multiplied. If false,\n * just set the current matrix with @param matrix\n */\n ColorMatrixFilter.prototype.lsd = function (multiply) {\n var matrix = [\n 2, -0.4, 0.5, 0, 0,\n -0.5, 2, -0.4, 0, 0,\n -0.4, -0.5, 3, 0, 0,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, multiply);\n };\n /** Erase the current matrix by setting the default one. */\n ColorMatrixFilter.prototype.reset = function () {\n var matrix = [\n 1, 0, 0, 0, 0,\n 0, 1, 0, 0, 0,\n 0, 0, 1, 0, 0,\n 0, 0, 0, 1, 0 ];\n this._loadMatrix(matrix, false);\n };\n Object.defineProperty(ColorMatrixFilter.prototype, \"matrix\", {\n /**\n * The matrix of the color matrix filter\n * @member {number[]}\n * @default [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]\n */\n get: function () {\n return this.uniforms.m;\n },\n set: function (value) {\n this.uniforms.m = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(ColorMatrixFilter.prototype, \"alpha\", {\n /**\n * The opacity value to use when mixing the original and resultant colors.\n *\n * When the value is 0, the original color is used without modification.\n * When the value is 1, the result color is used.\n * When in the range (0, 1) the color is interpolated between the original and result by this amount.\n * @default 1\n */\n get: function () {\n return this.uniforms.uAlpha;\n },\n set: function (value) {\n this.uniforms.uAlpha = value;\n },\n enumerable: false,\n configurable: true\n });\n return ColorMatrixFilter;\n}(Filter));\n// Americanized alias\nColorMatrixFilter.prototype.grayscale = ColorMatrixFilter.prototype.greyscale;\n\nexport { ColorMatrixFilter };\n//# sourceMappingURL=filter-color-matrix.mjs.map\n","/*!\n * @pixi/filter-displacement - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/filter-displacement is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { Filter } from '@pixi/core';\nimport { Matrix, Point } from '@pixi/math';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\nvar fragment = \"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\";\n\nvar vertex = \"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\";\n\n/**\n * The DisplacementFilter class uses the pixel values from the specified texture\n * (called the displacement map) to perform a displacement of an object.\n *\n * You can use this filter to apply all manor of crazy warping effects.\n * Currently the `r` property of the texture is used to offset the `x`\n * and the `g` property of the texture is used to offset the `y`.\n *\n * The way it works is it uses the values of the displacement map to look up the\n * correct pixels to output. This means it's not technically moving the original.\n * Instead, it's starting at the output and asking \"which pixel from the original goes here\".\n * For example, if a displacement map pixel has `red = 1` and the filter scale is `20`,\n * this filter will output the pixel approximately 20 pixels to the right of the original.\n * @memberof PIXI.filters\n */\nvar DisplacementFilter = /** @class */ (function (_super) {\n __extends(DisplacementFilter, _super);\n /**\n * @param {PIXI.Sprite} sprite - The sprite used for the displacement map. (make sure its added to the scene!)\n * @param scale - The scale of the displacement\n */\n function DisplacementFilter(sprite, scale) {\n var _this = this;\n var maskMatrix = new Matrix();\n sprite.renderable = false;\n _this = _super.call(this, vertex, fragment, {\n mapSampler: sprite._texture,\n filterMatrix: maskMatrix,\n scale: { x: 1, y: 1 },\n rotation: new Float32Array([1, 0, 0, 1]),\n }) || this;\n _this.maskSprite = sprite;\n _this.maskMatrix = maskMatrix;\n if (scale === null || scale === undefined) {\n scale = 20;\n }\n /**\n * scaleX, scaleY for displacements\n * @member {PIXI.Point}\n */\n _this.scale = new Point(scale, scale);\n return _this;\n }\n /**\n * Applies the filter.\n * @param filterManager - The manager.\n * @param input - The input target.\n * @param output - The output target.\n * @param clearMode - clearMode.\n */\n DisplacementFilter.prototype.apply = function (filterManager, input, output, clearMode) {\n // fill maskMatrix with _normalized sprite texture coords_\n this.uniforms.filterMatrix = filterManager.calculateSpriteMatrix(this.maskMatrix, this.maskSprite);\n this.uniforms.scale.x = this.scale.x;\n this.uniforms.scale.y = this.scale.y;\n // Extract rotation from world transform\n var wt = this.maskSprite.worldTransform;\n var lenX = Math.sqrt((wt.a * wt.a) + (wt.b * wt.b));\n var lenY = Math.sqrt((wt.c * wt.c) + (wt.d * wt.d));\n if (lenX !== 0 && lenY !== 0) {\n this.uniforms.rotation[0] = wt.a / lenX;\n this.uniforms.rotation[1] = wt.b / lenX;\n this.uniforms.rotation[2] = wt.c / lenY;\n this.uniforms.rotation[3] = wt.d / lenY;\n }\n // draw the filter...\n filterManager.applyFilter(this, input, output, clearMode);\n };\n Object.defineProperty(DisplacementFilter.prototype, \"map\", {\n /** The texture used for the displacement map. Must be power of 2 sized texture. */\n get: function () {\n return this.uniforms.mapSampler;\n },\n set: function (value) {\n this.uniforms.mapSampler = value;\n },\n enumerable: false,\n configurable: true\n });\n return DisplacementFilter;\n}(Filter));\n\nexport { DisplacementFilter };\n//# sourceMappingURL=filter-displacement.mjs.map\n","/*!\n * @pixi/filter-fxaa - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/filter-fxaa is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { Filter } from '@pixi/core';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\nvar vertex = \"\\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 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\\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, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\\n}\\n\";\n\nvar fragment = \"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 inputSize;\\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, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\\n\\n gl_FragColor = color;\\n}\\n\";\n\n/**\n * Basic FXAA (Fast Approximate Anti-Aliasing) implementation based on the code on geeks3d.com\n * with the modification that the texture2DLod stuff was removed since it is unsupported by WebGL.\n * @see https://github.com/mitsuhiko/webgl-meincraft\n * @memberof PIXI.filters\n */\nvar FXAAFilter = /** @class */ (function (_super) {\n __extends(FXAAFilter, _super);\n function FXAAFilter() {\n // TODO - needs work\n return _super.call(this, vertex, fragment) || this;\n }\n return FXAAFilter;\n}(Filter));\n\nexport { FXAAFilter };\n//# sourceMappingURL=filter-fxaa.mjs.map\n","/*!\n * @pixi/filter-noise - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/filter-noise is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { defaultFilterVertex, Filter } from '@pixi/core';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\nvar fragment = \"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\";\n\n/**\n * A Noise effect filter.\n *\n * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/adjust/noise.js\n * @memberof PIXI.filters\n * @author Vico @vicocotea\n */\nvar NoiseFilter = /** @class */ (function (_super) {\n __extends(NoiseFilter, _super);\n /**\n * @param {number} [noise=0.5] - The noise intensity, should be a normalized value in the range [0, 1].\n * @param {number} [seed] - A random seed for the noise generation. Default is `Math.random()`.\n */\n function NoiseFilter(noise, seed) {\n if (noise === void 0) { noise = 0.5; }\n if (seed === void 0) { seed = Math.random(); }\n var _this = _super.call(this, defaultFilterVertex, fragment, {\n uNoise: 0,\n uSeed: 0,\n }) || this;\n _this.noise = noise;\n _this.seed = seed;\n return _this;\n }\n Object.defineProperty(NoiseFilter.prototype, \"noise\", {\n /**\n * The amount of noise to apply, this value should be in the range (0, 1].\n * @default 0.5\n */\n get: function () {\n return this.uniforms.uNoise;\n },\n set: function (value) {\n this.uniforms.uNoise = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(NoiseFilter.prototype, \"seed\", {\n /** A seed value to apply to the random noise generation. `Math.random()` is a good value to use. */\n get: function () {\n return this.uniforms.uSeed;\n },\n set: function (value) {\n this.uniforms.uSeed = value;\n },\n enumerable: false,\n configurable: true\n });\n return NoiseFilter;\n}(Filter));\n\nexport { NoiseFilter };\n//# sourceMappingURL=filter-noise.mjs.map\n","/*!\n * @pixi/mixin-cache-as-bitmap - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/mixin-cache-as-bitmap is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { RenderTexture, BaseTexture, Texture } from '@pixi/core';\nimport { Sprite } from '@pixi/sprite';\nimport { DisplayObject } from '@pixi/display';\nimport { Matrix } from '@pixi/math';\nimport { uid } from '@pixi/utils';\nimport { settings } from '@pixi/settings';\nimport { MSAA_QUALITY } from '@pixi/constants';\n\nvar _tempMatrix = new Matrix();\nDisplayObject.prototype._cacheAsBitmap = false;\nDisplayObject.prototype._cacheData = null;\nDisplayObject.prototype._cacheAsBitmapResolution = null;\nDisplayObject.prototype._cacheAsBitmapMultisample = MSAA_QUALITY.NONE;\n// figured there's no point adding ALL the extra variables to prototype.\n// this model can hold the information needed. This can also be generated on demand as\n// most objects are not cached as bitmaps.\n/**\n * @class\n * @ignore\n * @private\n */\nvar CacheData = /** @class */ (function () {\n function CacheData() {\n this.textureCacheId = null;\n this.originalRender = null;\n this.originalRenderCanvas = null;\n this.originalCalculateBounds = null;\n this.originalGetLocalBounds = null;\n this.originalUpdateTransform = null;\n this.originalDestroy = null;\n this.originalMask = null;\n this.originalFilterArea = null;\n this.originalContainsPoint = null;\n this.sprite = null;\n }\n return CacheData;\n}());\nObject.defineProperties(DisplayObject.prototype, {\n /**\n * The resolution to use for cacheAsBitmap. By default this will use the renderer's resolution\n * but can be overriden for performance. Lower values will reduce memory usage at the expense\n * of render quality. A falsey value of `null` or `0` will default to the renderer's resolution.\n * If `cacheAsBitmap` is set to `true`, this will re-render with the new resolution.\n * @member {number} cacheAsBitmapResolution\n * @memberof PIXI.DisplayObject#\n * @default null\n */\n cacheAsBitmapResolution: {\n get: function () {\n return this._cacheAsBitmapResolution;\n },\n set: function (resolution) {\n if (resolution === this._cacheAsBitmapResolution) {\n return;\n }\n this._cacheAsBitmapResolution = resolution;\n if (this.cacheAsBitmap) {\n // Toggle to re-render at the new resolution\n this.cacheAsBitmap = false;\n this.cacheAsBitmap = true;\n }\n },\n },\n /**\n * The number of samples to use for cacheAsBitmap. If set to `null`, the renderer's\n * sample count is used.\n * If `cacheAsBitmap` is set to `true`, this will re-render with the new number of samples.\n * @member {number} cacheAsBitmapMultisample\n * @memberof PIXI.DisplayObject#\n * @default PIXI.MSAA_QUALITY.NONE\n */\n cacheAsBitmapMultisample: {\n get: function () {\n return this._cacheAsBitmapMultisample;\n },\n set: function (multisample) {\n if (multisample === this._cacheAsBitmapMultisample) {\n return;\n }\n this._cacheAsBitmapMultisample = multisample;\n if (this.cacheAsBitmap) {\n // Toggle to re-render with new multisample\n this.cacheAsBitmap = false;\n this.cacheAsBitmap = true;\n }\n },\n },\n /**\n * Set this to true if you want this display object to be cached as a bitmap.\n * This basically takes a snap shot of the display object as it is at that moment. It can\n * provide a performance benefit for complex static displayObjects.\n * To remove simply set this property to `false`\n *\n * IMPORTANT GOTCHA - Make sure that all your textures are preloaded BEFORE setting this property to true\n * as it will take a snapshot of what is currently there. If the textures have not loaded then they will not appear.\n * @member {boolean}\n * @memberof PIXI.DisplayObject#\n */\n cacheAsBitmap: {\n get: function () {\n return this._cacheAsBitmap;\n },\n set: function (value) {\n if (this._cacheAsBitmap === value) {\n return;\n }\n this._cacheAsBitmap = value;\n var data;\n if (value) {\n if (!this._cacheData) {\n this._cacheData = new CacheData();\n }\n data = this._cacheData;\n data.originalRender = this.render;\n data.originalRenderCanvas = this.renderCanvas;\n data.originalUpdateTransform = this.updateTransform;\n data.originalCalculateBounds = this.calculateBounds;\n data.originalGetLocalBounds = this.getLocalBounds;\n data.originalDestroy = this.destroy;\n data.originalContainsPoint = this.containsPoint;\n data.originalMask = this._mask;\n data.originalFilterArea = this.filterArea;\n this.render = this._renderCached;\n this.renderCanvas = this._renderCachedCanvas;\n this.destroy = this._cacheAsBitmapDestroy;\n }\n else {\n data = this._cacheData;\n if (data.sprite) {\n this._destroyCachedDisplayObject();\n }\n this.render = data.originalRender;\n this.renderCanvas = data.originalRenderCanvas;\n this.calculateBounds = data.originalCalculateBounds;\n this.getLocalBounds = data.originalGetLocalBounds;\n this.destroy = data.originalDestroy;\n this.updateTransform = data.originalUpdateTransform;\n this.containsPoint = data.originalContainsPoint;\n this._mask = data.originalMask;\n this.filterArea = data.originalFilterArea;\n }\n },\n },\n});\n/**\n * Renders a cached version of the sprite with WebGL\n * @private\n * @method _renderCached\n * @memberof PIXI.DisplayObject#\n * @param {PIXI.Renderer} renderer - the WebGL renderer\n */\nDisplayObject.prototype._renderCached = function _renderCached(renderer) {\n if (!this.visible || this.worldAlpha <= 0 || !this.renderable) {\n return;\n }\n this._initCachedDisplayObject(renderer);\n this._cacheData.sprite.transform._worldID = this.transform._worldID;\n this._cacheData.sprite.worldAlpha = this.worldAlpha;\n this._cacheData.sprite._render(renderer);\n};\n/**\n * Prepares the WebGL renderer to cache the sprite\n * @private\n * @method _initCachedDisplayObject\n * @memberof PIXI.DisplayObject#\n * @param {PIXI.Renderer} renderer - the WebGL renderer\n */\nDisplayObject.prototype._initCachedDisplayObject = function _initCachedDisplayObject(renderer) {\n var _a;\n if (this._cacheData && this._cacheData.sprite) {\n return;\n }\n // make sure alpha is set to 1 otherwise it will get rendered as invisible!\n var cacheAlpha = this.alpha;\n this.alpha = 1;\n // first we flush anything left in the renderer (otherwise it would get rendered to the cached texture)\n renderer.batch.flush();\n // this.filters= [];\n // next we find the dimensions of the untransformed object\n // this function also calls updatetransform on all its children as part of the measuring.\n // This means we don't need to update the transform again in this function\n // TODO pass an object to clone too? saves having to create a new one each time!\n var bounds = this.getLocalBounds(null, true).clone();\n // add some padding!\n if (this.filters && this.filters.length) {\n var padding = this.filters[0].padding;\n bounds.pad(padding);\n }\n bounds.ceil(settings.RESOLUTION);\n // for now we cache the current renderTarget that the WebGL renderer is currently using.\n // this could be more elegant..\n var cachedRenderTexture = renderer.renderTexture.current;\n var cachedSourceFrame = renderer.renderTexture.sourceFrame.clone();\n var cachedDestinationFrame = renderer.renderTexture.destinationFrame.clone();\n var cachedProjectionTransform = renderer.projection.transform;\n // We also store the filter stack - I will definitely look to change how this works a little later down the line.\n // const stack = renderer.filterManager.filterStack;\n // this renderTexture will be used to store the cached DisplayObject\n var renderTexture = RenderTexture.create({\n width: bounds.width,\n height: bounds.height,\n resolution: this.cacheAsBitmapResolution || renderer.resolution,\n multisample: (_a = this.cacheAsBitmapMultisample) !== null && _a !== void 0 ? _a : renderer.multisample,\n });\n var textureCacheId = \"cacheAsBitmap_\" + uid();\n this._cacheData.textureCacheId = textureCacheId;\n BaseTexture.addToCache(renderTexture.baseTexture, textureCacheId);\n Texture.addToCache(renderTexture, textureCacheId);\n // need to set //\n var m = this.transform.localTransform.copyTo(_tempMatrix).invert().translate(-bounds.x, -bounds.y);\n // set all properties to there original so we can render to a texture\n this.render = this._cacheData.originalRender;\n renderer.render(this, { renderTexture: renderTexture, clear: true, transform: m, skipUpdateTransform: false });\n renderer.framebuffer.blit();\n // now restore the state be setting the new properties\n renderer.projection.transform = cachedProjectionTransform;\n renderer.renderTexture.bind(cachedRenderTexture, cachedSourceFrame, cachedDestinationFrame);\n // renderer.filterManager.filterStack = stack;\n this.render = this._renderCached;\n // the rest is the same as for Canvas\n this.updateTransform = this.displayObjectUpdateTransform;\n this.calculateBounds = this._calculateCachedBounds;\n this.getLocalBounds = this._getCachedLocalBounds;\n this._mask = null;\n this.filterArea = null;\n this.alpha = cacheAlpha;\n // create our cached sprite\n var cachedSprite = new Sprite(renderTexture);\n cachedSprite.transform.worldTransform = this.transform.worldTransform;\n cachedSprite.anchor.x = -(bounds.x / bounds.width);\n cachedSprite.anchor.y = -(bounds.y / bounds.height);\n cachedSprite.alpha = cacheAlpha;\n cachedSprite._bounds = this._bounds;\n this._cacheData.sprite = cachedSprite;\n this.transform._parentID = -1;\n // restore the transform of the cached sprite to avoid the nasty flicker..\n if (!this.parent) {\n this.enableTempParent();\n this.updateTransform();\n this.disableTempParent(null);\n }\n else {\n this.updateTransform();\n }\n // map the hit test..\n this.containsPoint = cachedSprite.containsPoint.bind(cachedSprite);\n};\n/**\n * Renders a cached version of the sprite with canvas\n * @private\n * @method _renderCachedCanvas\n * @memberof PIXI.DisplayObject#\n * @param {PIXI.CanvasRenderer} renderer - The canvas renderer\n */\nDisplayObject.prototype._renderCachedCanvas = function _renderCachedCanvas(renderer) {\n if (!this.visible || this.worldAlpha <= 0 || !this.renderable) {\n return;\n }\n this._initCachedDisplayObjectCanvas(renderer);\n this._cacheData.sprite.worldAlpha = this.worldAlpha;\n this._cacheData.sprite._renderCanvas(renderer);\n};\n// TODO this can be the same as the WebGL version.. will need to do a little tweaking first though..\n/**\n * Prepares the Canvas renderer to cache the sprite\n * @private\n * @method _initCachedDisplayObjectCanvas\n * @memberof PIXI.DisplayObject#\n * @param {PIXI.CanvasRenderer} renderer - The canvas renderer\n */\nDisplayObject.prototype._initCachedDisplayObjectCanvas = function _initCachedDisplayObjectCanvas(renderer) {\n if (this._cacheData && this._cacheData.sprite) {\n return;\n }\n // get bounds actually transforms the object for us already!\n var bounds = this.getLocalBounds(null, true);\n var cacheAlpha = this.alpha;\n this.alpha = 1;\n var cachedRenderTarget = renderer.context;\n var cachedProjectionTransform = renderer._projTransform;\n bounds.ceil(settings.RESOLUTION);\n var renderTexture = RenderTexture.create({ width: bounds.width, height: bounds.height });\n var textureCacheId = \"cacheAsBitmap_\" + uid();\n this._cacheData.textureCacheId = textureCacheId;\n BaseTexture.addToCache(renderTexture.baseTexture, textureCacheId);\n Texture.addToCache(renderTexture, textureCacheId);\n // need to set //\n var m = _tempMatrix;\n this.transform.localTransform.copyTo(m);\n m.invert();\n m.tx -= bounds.x;\n m.ty -= bounds.y;\n // m.append(this.transform.worldTransform.)\n // set all properties to there original so we can render to a texture\n this.renderCanvas = this._cacheData.originalRenderCanvas;\n renderer.render(this, { renderTexture: renderTexture, clear: true, transform: m, skipUpdateTransform: false });\n // now restore the state be setting the new properties\n renderer.context = cachedRenderTarget;\n renderer._projTransform = cachedProjectionTransform;\n this.renderCanvas = this._renderCachedCanvas;\n // the rest is the same as for WebGL\n this.updateTransform = this.displayObjectUpdateTransform;\n this.calculateBounds = this._calculateCachedBounds;\n this.getLocalBounds = this._getCachedLocalBounds;\n this._mask = null;\n this.filterArea = null;\n this.alpha = cacheAlpha;\n // create our cached sprite\n var cachedSprite = new Sprite(renderTexture);\n cachedSprite.transform.worldTransform = this.transform.worldTransform;\n cachedSprite.anchor.x = -(bounds.x / bounds.width);\n cachedSprite.anchor.y = -(bounds.y / bounds.height);\n cachedSprite.alpha = cacheAlpha;\n cachedSprite._bounds = this._bounds;\n this._cacheData.sprite = cachedSprite;\n this.transform._parentID = -1;\n // restore the transform of the cached sprite to avoid the nasty flicker..\n if (!this.parent) {\n this.parent = renderer._tempDisplayObjectParent;\n this.updateTransform();\n this.parent = null;\n }\n else {\n this.updateTransform();\n }\n // map the hit test..\n this.containsPoint = cachedSprite.containsPoint.bind(cachedSprite);\n};\n/**\n * Calculates the bounds of the cached sprite\n * @private\n * @method\n */\nDisplayObject.prototype._calculateCachedBounds = function _calculateCachedBounds() {\n this._bounds.clear();\n this._cacheData.sprite.transform._worldID = this.transform._worldID;\n this._cacheData.sprite._calculateBounds();\n this._bounds.updateID = this._boundsID;\n};\n/**\n * Gets the bounds of the cached sprite.\n * @private\n * @method\n * @returns {Rectangle} The local bounds.\n */\nDisplayObject.prototype._getCachedLocalBounds = function _getCachedLocalBounds() {\n return this._cacheData.sprite.getLocalBounds(null);\n};\n/**\n * Destroys the cached sprite.\n * @private\n * @method\n */\nDisplayObject.prototype._destroyCachedDisplayObject = function _destroyCachedDisplayObject() {\n this._cacheData.sprite._texture.destroy(true);\n this._cacheData.sprite = null;\n BaseTexture.removeFromCache(this._cacheData.textureCacheId);\n Texture.removeFromCache(this._cacheData.textureCacheId);\n this._cacheData.textureCacheId = null;\n};\n/**\n * Destroys the cached object.\n * @private\n * @method\n * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options\n * have been set to that value.\n * Used when destroying containers, see the Container.destroy method.\n */\nDisplayObject.prototype._cacheAsBitmapDestroy = function _cacheAsBitmapDestroy(options) {\n this.cacheAsBitmap = false;\n this.destroy(options);\n};\n\nexport { CacheData };\n//# sourceMappingURL=mixin-cache-as-bitmap.mjs.map\n","/*!\n * @pixi/mixin-get-child-by-name - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/mixin-get-child-by-name is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { DisplayObject, Container } from '@pixi/display';\n\n/**\n * The instance name of the object.\n * @memberof PIXI.DisplayObject#\n * @member {string} name\n */\nDisplayObject.prototype.name = null;\n/**\n * Returns the display object in the container.\n *\n * Recursive searches are done in a preorder traversal.\n * @method getChildByName\n * @memberof PIXI.Container#\n * @param {string} name - Instance name.\n * @param {boolean}[deep=false] - Whether to search recursively\n * @returns {PIXI.DisplayObject} The child with the specified name.\n */\nContainer.prototype.getChildByName = function getChildByName(name, deep) {\n for (var i = 0, j = this.children.length; i < j; i++) {\n if (this.children[i].name === name) {\n return this.children[i];\n }\n }\n if (deep) {\n for (var i = 0, j = this.children.length; i < j; i++) {\n var child = this.children[i];\n if (!child.getChildByName) {\n continue;\n }\n var target = child.getChildByName(name, true);\n if (target) {\n return target;\n }\n }\n }\n return null;\n};\n//# sourceMappingURL=mixin-get-child-by-name.mjs.map\n","/*!\n * @pixi/mixin-get-global-position - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/mixin-get-global-position is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { DisplayObject } from '@pixi/display';\nimport { Point } from '@pixi/math';\n\n/**\n * Returns the global position of the displayObject. Does not depend on object scale, rotation and pivot.\n * @method getGlobalPosition\n * @memberof PIXI.DisplayObject#\n * @param {PIXI.Point} [point=new PIXI.Point()] - The point to write the global value to.\n * @param {boolean} [skipUpdate=false] - Setting to true will stop the transforms of the scene graph from\n * being updated. This means the calculation returned MAY be out of date BUT will give you a\n * nice performance boost.\n * @returns {PIXI.Point} The updated point.\n */\nDisplayObject.prototype.getGlobalPosition = function getGlobalPosition(point, skipUpdate) {\n if (point === void 0) { point = new Point(); }\n if (skipUpdate === void 0) { skipUpdate = false; }\n if (this.parent) {\n this.parent.toGlobal(this.position, point, skipUpdate);\n }\n else {\n point.x = this.position.x;\n point.y = this.position.y;\n }\n return point;\n};\n//# sourceMappingURL=mixin-get-global-position.mjs.map\n","/*!\n * @pixi/app - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/app is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { ExtensionType, extensions, autoDetectRenderer } from '@pixi/core';\nimport { Container } from '@pixi/display';\nimport { deprecation } from '@pixi/utils';\n\n/**\n * Middleware for for Application's resize functionality\n * @private\n * @class\n */\nvar ResizePlugin = /** @class */ (function () {\n function ResizePlugin() {\n }\n /**\n * Initialize the plugin with scope of application instance\n * @static\n * @private\n * @param {object} [options] - See application options\n */\n ResizePlugin.init = function (options) {\n var _this = this;\n Object.defineProperty(this, 'resizeTo', \n /**\n * The HTML element or window to automatically resize the\n * renderer's view element to match width and height.\n * @member {Window|HTMLElement}\n * @name resizeTo\n * @memberof PIXI.Application#\n */\n {\n set: function (dom) {\n globalThis.removeEventListener('resize', this.queueResize);\n this._resizeTo = dom;\n if (dom) {\n globalThis.addEventListener('resize', this.queueResize);\n this.resize();\n }\n },\n get: function () {\n return this._resizeTo;\n },\n });\n /**\n * Resize is throttled, so it's safe to call this multiple times per frame and it'll\n * only be called once.\n * @memberof PIXI.Application#\n * @method queueResize\n * @private\n */\n this.queueResize = function () {\n if (!_this._resizeTo) {\n return;\n }\n _this.cancelResize();\n // // Throttle resize events per raf\n _this._resizeId = requestAnimationFrame(function () { return _this.resize(); });\n };\n /**\n * Cancel the resize queue.\n * @memberof PIXI.Application#\n * @method cancelResize\n * @private\n */\n this.cancelResize = function () {\n if (_this._resizeId) {\n cancelAnimationFrame(_this._resizeId);\n _this._resizeId = null;\n }\n };\n /**\n * Execute an immediate resize on the renderer, this is not\n * throttled and can be expensive to call many times in a row.\n * Will resize only if `resizeTo` property is set.\n * @memberof PIXI.Application#\n * @method resize\n */\n this.resize = function () {\n if (!_this._resizeTo) {\n return;\n }\n // clear queue resize\n _this.cancelResize();\n var width;\n var height;\n // Resize to the window\n if (_this._resizeTo === globalThis.window) {\n width = globalThis.innerWidth;\n height = globalThis.innerHeight;\n }\n // Resize to other HTML entities\n else {\n var _a = _this._resizeTo, clientWidth = _a.clientWidth, clientHeight = _a.clientHeight;\n width = clientWidth;\n height = clientHeight;\n }\n _this.renderer.resize(width, height);\n };\n // On resize\n this._resizeId = null;\n this._resizeTo = null;\n this.resizeTo = options.resizeTo || null;\n };\n /**\n * Clean up the ticker, scoped to application\n * @static\n * @private\n */\n ResizePlugin.destroy = function () {\n globalThis.removeEventListener('resize', this.queueResize);\n this.cancelResize();\n this.cancelResize = null;\n this.queueResize = null;\n this.resizeTo = null;\n this.resize = null;\n };\n /** @ignore */\n ResizePlugin.extension = ExtensionType.Application;\n return ResizePlugin;\n}());\n\n/**\n * Convenience class to create a new PIXI application.\n *\n * This class automatically creates the renderer, ticker and root container.\n * @example\n * // Create the application\n * const app = new PIXI.Application();\n *\n * // Add the view to the DOM\n * document.body.appendChild(app.view);\n *\n * // ex, add display objects\n * app.stage.addChild(PIXI.Sprite.from('something.png'));\n * @class\n * @memberof PIXI\n */\nvar Application = /** @class */ (function () {\n /**\n * @param {PIXI.IApplicationOptions} [options] - The optional application and renderer parameters.\n * @param {boolean} [options.antialias=false] -\n * **WebGL Only.** Whether to enable anti-aliasing. This may affect performance.\n * @param {boolean} [options.autoDensity=false] -\n * Whether the CSS dimensions of the renderer's view should be resized automatically.\n * @param {boolean} [options.autoStart=true] - Automatically starts the rendering after the construction.\n * **Note**: Setting this parameter to false does NOT stop the shared ticker even if you set\n * `options.sharedTicker` to `true` in case that it is already started. Stop it by your own.\n * @param {number} [options.backgroundAlpha=1] -\n * Transparency of the background color, value from `0` (fully transparent) to `1` (fully opaque).\n * @param {number} [options.backgroundColor=0x000000] -\n * The background color used to clear the canvas. It accepts hex numbers (e.g. `0xff0000`).\n * @param {boolean} [options.clearBeforeRender=true] - Whether to clear the canvas before new render passes.\n * @param {PIXI.IRenderingContext} [options.context] - **WebGL Only.** User-provided WebGL rendering context object.\n * @param {boolean} [options.forceCanvas=false] -\n * Force using {@link PIXI.CanvasRenderer}, even if WebGL is available. This option only is available when\n * using **pixi.js-legacy** or **@pixi/canvas-renderer** packages, otherwise it is ignored.\n * @param {number} [options.height=600] - The height of the renderer's view.\n * @param {string} [options.powerPreference] -\n * **WebGL Only.** A hint indicating what configuration of GPU is suitable for the WebGL context,\n * can be `'default'`, `'high-performance'` or `'low-power'`.\n * Setting to `'high-performance'` will prioritize rendering performance over power consumption,\n * while setting to `'low-power'` will prioritize power saving over rendering performance.\n * @param {boolean} [options.premultipliedAlpha=true] -\n * **WebGL Only.** Whether the compositor will assume the drawing buffer contains colors with premultiplied alpha.\n * @param {boolean} [options.preserveDrawingBuffer=false] -\n * **WebGL Only.** Whether to enable drawing buffer preservation. If enabled, the drawing buffer will preserve\n * its value until cleared or overwritten. Enable this if you need to call `toDataUrl` on the WebGL context.\n * @param {Window|HTMLElement} [options.resizeTo] - Element to automatically resize stage to.\n * @param {number} [options.resolution=PIXI.settings.RESOLUTION] -\n * The resolution / device pixel ratio of the renderer.\n * @param {boolean} [options.sharedLoader=false] - `true` to use PIXI.Loader.shared, `false` to create new Loader.\n * @param {boolean} [options.sharedTicker=false] - `true` to use PIXI.Ticker.shared, `false` to create new ticker.\n * If set to `false`, you cannot register a handler to occur before anything that runs on the shared ticker.\n * The system ticker will always run before both the shared ticker and the app ticker.\n * @param {boolean} [options.transparent] -\n * **Deprecated since 6.0.0, Use `backgroundAlpha` instead.** \\\n * `true` sets `backgroundAlpha` to `0`, `false` sets `backgroundAlpha` to `1`.\n * @param {boolean|'notMultiplied'} [options.useContextAlpha=true] -\n * Pass-through value for canvas' context attribute `alpha`. This option is for cases where the\n * canvas needs to be opaque, possibly for performance reasons on some older devices.\n * If you want to set transparency, please use `backgroundAlpha`. \\\n * **WebGL Only:** When set to `'notMultiplied'`, the canvas' context attribute `alpha` will be\n * set to `true` and `premultipliedAlpha` will be to `false`.\n * @param {HTMLCanvasElement} [options.view=null] -\n * The canvas to use as the view. If omitted, a new canvas will be created.\n * @param {number} [options.width=800] - The width of the renderer's view.\n */\n function Application(options) {\n var _this = this;\n /**\n * The root display container that's rendered.\n * @member {PIXI.Container}\n */\n this.stage = new Container();\n // The default options\n options = Object.assign({\n forceCanvas: false,\n }, options);\n this.renderer = autoDetectRenderer(options);\n // install plugins here\n Application._plugins.forEach(function (plugin) {\n plugin.init.call(_this, options);\n });\n }\n /**\n * Use the {@link PIXI.extensions.add} API to register plugins.\n * @deprecated since 6.5.0\n * @static\n * @param {PIXI.IApplicationPlugin} plugin - Plugin being installed\n */\n Application.registerPlugin = function (plugin) {\n deprecation('6.5.0', 'Application.registerPlugin() is deprecated, use extensions.add()');\n extensions.add({\n type: ExtensionType.Application,\n ref: plugin,\n });\n };\n /** Render the current stage. */\n Application.prototype.render = function () {\n this.renderer.render(this.stage);\n };\n Object.defineProperty(Application.prototype, \"view\", {\n /**\n * Reference to the renderer's canvas element.\n * @member {HTMLCanvasElement}\n * @readonly\n */\n get: function () {\n return this.renderer.view;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Application.prototype, \"screen\", {\n /**\n * Reference to the renderer's screen rectangle. Its safe to use as `filterArea` or `hitArea` for the whole screen.\n * @member {PIXI.Rectangle}\n * @readonly\n */\n get: function () {\n return this.renderer.screen;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Destroy and don't use after this.\n * @param {boolean} [removeView=false] - Automatically remove canvas from DOM.\n * @param {object|boolean} [stageOptions] - Options parameter. A boolean will act as if all options\n * have been set to that value\n * @param {boolean} [stageOptions.children=false] - if set to true, all the children will have their destroy\n * method called as well. 'stageOptions' will be passed on to those calls.\n * @param {boolean} [stageOptions.texture=false] - Only used for child Sprites if stageOptions.children is set\n * to true. Should it destroy the texture of the child sprite\n * @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set\n * to true. Should it destroy the base texture of the child sprite\n */\n Application.prototype.destroy = function (removeView, stageOptions) {\n var _this = this;\n // Destroy plugins in the opposite order\n // which they were constructed\n var plugins = Application._plugins.slice(0);\n plugins.reverse();\n plugins.forEach(function (plugin) {\n plugin.destroy.call(_this);\n });\n this.stage.destroy(stageOptions);\n this.stage = null;\n this.renderer.destroy(removeView);\n this.renderer = null;\n };\n /** Collection of installed plugins. */\n Application._plugins = [];\n return Application;\n}());\nextensions.handleByList(ExtensionType.Application, Application._plugins);\n\nextensions.add(ResizePlugin);\n\nexport { Application, ResizePlugin };\n//# sourceMappingURL=app.mjs.map\n","/*!\n * @pixi/mesh-extras - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/mesh-extras is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { MeshGeometry, Mesh, MeshMaterial } from '@pixi/mesh';\nimport { WRAP_MODES } from '@pixi/constants';\nimport { Texture } from '@pixi/core';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\n/**\n * @memberof PIXI\n */\nvar PlaneGeometry = /** @class */ (function (_super) {\n __extends(PlaneGeometry, _super);\n /**\n * @param width - The width of the plane.\n * @param height - The height of the plane.\n * @param segWidth - Number of horizontal segments.\n * @param segHeight - Number of vertical segments.\n */\n function PlaneGeometry(width, height, segWidth, segHeight) {\n if (width === void 0) { width = 100; }\n if (height === void 0) { height = 100; }\n if (segWidth === void 0) { segWidth = 10; }\n if (segHeight === void 0) { segHeight = 10; }\n var _this = _super.call(this) || this;\n _this.segWidth = segWidth;\n _this.segHeight = segHeight;\n _this.width = width;\n _this.height = height;\n _this.build();\n return _this;\n }\n /**\n * Refreshes plane coordinates\n * @private\n */\n PlaneGeometry.prototype.build = function () {\n var total = this.segWidth * this.segHeight;\n var verts = [];\n var uvs = [];\n var indices = [];\n var segmentsX = this.segWidth - 1;\n var segmentsY = this.segHeight - 1;\n var sizeX = (this.width) / segmentsX;\n var sizeY = (this.height) / segmentsY;\n for (var i = 0; i < total; i++) {\n var x = (i % this.segWidth);\n var y = ((i / this.segWidth) | 0);\n verts.push(x * sizeX, y * sizeY);\n uvs.push(x / segmentsX, y / segmentsY);\n }\n var totalSub = segmentsX * segmentsY;\n for (var i = 0; i < totalSub; i++) {\n var xpos = i % segmentsX;\n var ypos = (i / segmentsX) | 0;\n var value = (ypos * this.segWidth) + xpos;\n var value2 = (ypos * this.segWidth) + xpos + 1;\n var value3 = ((ypos + 1) * this.segWidth) + xpos;\n var value4 = ((ypos + 1) * this.segWidth) + xpos + 1;\n indices.push(value, value2, value3, value2, value4, value3);\n }\n this.buffers[0].data = new Float32Array(verts);\n this.buffers[1].data = new Float32Array(uvs);\n this.indexBuffer.data = new Uint16Array(indices);\n // ensure that the changes are uploaded\n this.buffers[0].update();\n this.buffers[1].update();\n this.indexBuffer.update();\n };\n return PlaneGeometry;\n}(MeshGeometry));\n\n/**\n * RopeGeometry allows you to draw a geometry across several points and then manipulate these points.\n *\n * ```js\n * for (let i = 0; i < 20; i++) {\n * points.push(new PIXI.Point(i * 50, 0));\n * };\n * const rope = new PIXI.RopeGeometry(100, points);\n * ```\n * @memberof PIXI\n */\nvar RopeGeometry = /** @class */ (function (_super) {\n __extends(RopeGeometry, _super);\n /**\n * @param width - The width (i.e., thickness) of the rope.\n * @param points - An array of {@link PIXI.Point} objects to construct this rope.\n * @param textureScale - By default the rope texture will be stretched to match\n * rope length. If textureScale is positive this value will be treated as a scaling\n * factor and the texture will preserve its aspect ratio instead. To create a tiling rope\n * set baseTexture.wrapMode to {@link PIXI.WRAP_MODES.REPEAT} and use a power of two texture,\n * then set textureScale=1 to keep the original texture pixel size.\n * In order to reduce alpha channel artifacts provide a larger texture and downsample -\n * i.e. set textureScale=0.5 to scale it down twice.\n */\n function RopeGeometry(width, points, textureScale) {\n if (width === void 0) { width = 200; }\n if (textureScale === void 0) { textureScale = 0; }\n var _this = _super.call(this, new Float32Array(points.length * 4), new Float32Array(points.length * 4), new Uint16Array((points.length - 1) * 6)) || this;\n _this.points = points;\n _this._width = width;\n _this.textureScale = textureScale;\n _this.build();\n return _this;\n }\n Object.defineProperty(RopeGeometry.prototype, \"width\", {\n /**\n * The width (i.e., thickness) of the rope.\n * @readonly\n */\n get: function () {\n return this._width;\n },\n enumerable: false,\n configurable: true\n });\n /** Refreshes Rope indices and uvs */\n RopeGeometry.prototype.build = function () {\n var points = this.points;\n if (!points)\n { return; }\n var vertexBuffer = this.getBuffer('aVertexPosition');\n var uvBuffer = this.getBuffer('aTextureCoord');\n var indexBuffer = this.getIndex();\n // if too little points, or texture hasn't got UVs set yet just move on.\n if (points.length < 1) {\n return;\n }\n // if the number of points has changed we will need to recreate the arraybuffers\n if (vertexBuffer.data.length / 4 !== points.length) {\n vertexBuffer.data = new Float32Array(points.length * 4);\n uvBuffer.data = new Float32Array(points.length * 4);\n indexBuffer.data = new Uint16Array((points.length - 1) * 6);\n }\n var uvs = uvBuffer.data;\n var indices = indexBuffer.data;\n uvs[0] = 0;\n uvs[1] = 0;\n uvs[2] = 0;\n uvs[3] = 1;\n var amount = 0;\n var prev = points[0];\n var textureWidth = this._width * this.textureScale;\n var total = points.length; // - 1;\n for (var i = 0; i < total; i++) {\n // time to do some smart drawing!\n var index = i * 4;\n if (this.textureScale > 0) {\n // calculate pixel distance from previous point\n var dx = prev.x - points[i].x;\n var dy = prev.y - points[i].y;\n var distance = Math.sqrt((dx * dx) + (dy * dy));\n prev = points[i];\n amount += distance / textureWidth;\n }\n else {\n // stretch texture\n amount = i / (total - 1);\n }\n uvs[index] = amount;\n uvs[index + 1] = 0;\n uvs[index + 2] = amount;\n uvs[index + 3] = 1;\n }\n var indexCount = 0;\n for (var i = 0; i < total - 1; i++) {\n var index = i * 2;\n indices[indexCount++] = index;\n indices[indexCount++] = index + 1;\n indices[indexCount++] = index + 2;\n indices[indexCount++] = index + 2;\n indices[indexCount++] = index + 1;\n indices[indexCount++] = index + 3;\n }\n // ensure that the changes are uploaded\n uvBuffer.update();\n indexBuffer.update();\n this.updateVertices();\n };\n /** refreshes vertices of Rope mesh */\n RopeGeometry.prototype.updateVertices = function () {\n var points = this.points;\n if (points.length < 1) {\n return;\n }\n var lastPoint = points[0];\n var nextPoint;\n var perpX = 0;\n var perpY = 0;\n var vertices = this.buffers[0].data;\n var total = points.length;\n for (var i = 0; i < total; i++) {\n var point = points[i];\n var index = i * 4;\n if (i < points.length - 1) {\n nextPoint = points[i + 1];\n }\n else {\n nextPoint = point;\n }\n perpY = -(nextPoint.x - lastPoint.x);\n perpX = nextPoint.y - lastPoint.y;\n var perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY));\n var num = this.textureScale > 0 ? this.textureScale * this._width / 2 : this._width / 2;\n perpX /= perpLength;\n perpY /= perpLength;\n perpX *= num;\n perpY *= num;\n vertices[index] = point.x + perpX;\n vertices[index + 1] = point.y + perpY;\n vertices[index + 2] = point.x - perpX;\n vertices[index + 3] = point.y - perpY;\n lastPoint = point;\n }\n this.buffers[0].update();\n };\n RopeGeometry.prototype.update = function () {\n if (this.textureScale > 0) {\n this.build(); // we need to update UVs\n }\n else {\n this.updateVertices();\n }\n };\n return RopeGeometry;\n}(MeshGeometry));\n\n/**\n * The rope allows you to draw a texture across several points and then manipulate these points\n *\n *```js\n * for (let i = 0; i < 20; i++) {\n * points.push(new PIXI.Point(i * 50, 0));\n * };\n * let rope = new PIXI.SimpleRope(PIXI.Texture.from(\"snake.png\"), points);\n * ```\n * @memberof PIXI\n */\nvar SimpleRope = /** @class */ (function (_super) {\n __extends(SimpleRope, _super);\n /**\n * @param texture - The texture to use on the rope.\n * @param points - An array of {@link PIXI.Point} objects to construct this rope.\n * @param {number} textureScale - Optional. Positive values scale rope texture\n * keeping its aspect ratio. You can reduce alpha channel artifacts by providing a larger texture\n * and downsampling here. If set to zero, texture will be stretched instead.\n */\n function SimpleRope(texture, points, textureScale) {\n if (textureScale === void 0) { textureScale = 0; }\n var _this = this;\n var ropeGeometry = new RopeGeometry(texture.height, points, textureScale);\n var meshMaterial = new MeshMaterial(texture);\n if (textureScale > 0) {\n // attempt to set UV wrapping, will fail on non-power of two textures\n texture.baseTexture.wrapMode = WRAP_MODES.REPEAT;\n }\n _this = _super.call(this, ropeGeometry, meshMaterial) || this;\n /**\n * re-calculate vertices by rope points each frame\n * @member {boolean}\n */\n _this.autoUpdate = true;\n return _this;\n }\n SimpleRope.prototype._render = function (renderer) {\n var geometry = this.geometry;\n if (this.autoUpdate || geometry._width !== this.shader.texture.height) {\n geometry._width = this.shader.texture.height;\n geometry.update();\n }\n _super.prototype._render.call(this, renderer);\n };\n return SimpleRope;\n}(Mesh));\n\n/**\n * The SimplePlane allows you to draw a texture across several points and then manipulate these points\n *\n *```js\n * for (let i = 0; i < 20; i++) {\n * points.push(new PIXI.Point(i * 50, 0));\n * };\n * let SimplePlane = new PIXI.SimplePlane(PIXI.Texture.from(\"snake.png\"), points);\n * ```\n * @memberof PIXI\n */\nvar SimplePlane = /** @class */ (function (_super) {\n __extends(SimplePlane, _super);\n /**\n * @param texture - The texture to use on the SimplePlane.\n * @param verticesX - The number of vertices in the x-axis\n * @param verticesY - The number of vertices in the y-axis\n */\n function SimplePlane(texture, verticesX, verticesY) {\n var _this = this;\n var planeGeometry = new PlaneGeometry(texture.width, texture.height, verticesX, verticesY);\n var meshMaterial = new MeshMaterial(Texture.WHITE);\n _this = _super.call(this, planeGeometry, meshMaterial) || this;\n // lets call the setter to ensure all necessary updates are performed\n _this.texture = texture;\n _this.autoResize = true;\n return _this;\n }\n /**\n * Method used for overrides, to do something in case texture frame was changed.\n * Meshes based on plane can override it and change more details based on texture.\n */\n SimplePlane.prototype.textureUpdated = function () {\n this._textureID = this.shader.texture._updateID;\n var geometry = this.geometry;\n var _a = this.shader.texture, width = _a.width, height = _a.height;\n if (this.autoResize && (geometry.width !== width || geometry.height !== height)) {\n geometry.width = this.shader.texture.width;\n geometry.height = this.shader.texture.height;\n geometry.build();\n }\n };\n Object.defineProperty(SimplePlane.prototype, \"texture\", {\n get: function () {\n return this.shader.texture;\n },\n set: function (value) {\n // Track texture same way sprite does.\n // For generated meshes like NineSlicePlane it can change the geometry.\n // Unfortunately, this method might not work if you directly change texture in material.\n if (this.shader.texture === value) {\n return;\n }\n this.shader.texture = value;\n this._textureID = -1;\n if (value.baseTexture.valid) {\n this.textureUpdated();\n }\n else {\n value.once('update', this.textureUpdated, this);\n }\n },\n enumerable: false,\n configurable: true\n });\n SimplePlane.prototype._render = function (renderer) {\n if (this._textureID !== this.shader.texture._updateID) {\n this.textureUpdated();\n }\n _super.prototype._render.call(this, renderer);\n };\n SimplePlane.prototype.destroy = function (options) {\n this.shader.texture.off('update', this.textureUpdated, this);\n _super.prototype.destroy.call(this, options);\n };\n return SimplePlane;\n}(Mesh));\n\n/**\n * The Simple Mesh class mimics Mesh in PixiJS v4, providing easy-to-use constructor arguments.\n * For more robust customization, use {@link PIXI.Mesh}.\n * @memberof PIXI\n */\nvar SimpleMesh = /** @class */ (function (_super) {\n __extends(SimpleMesh, _super);\n /**\n * @param texture - The texture to use\n * @param {Float32Array} [vertices] - if you want to specify the vertices\n * @param {Float32Array} [uvs] - if you want to specify the uvs\n * @param {Uint16Array} [indices] - if you want to specify the indices\n * @param drawMode - the drawMode, can be any of the Mesh.DRAW_MODES consts\n */\n function SimpleMesh(texture, vertices, uvs, indices, drawMode) {\n if (texture === void 0) { texture = Texture.EMPTY; }\n var _this = this;\n var geometry = new MeshGeometry(vertices, uvs, indices);\n geometry.getBuffer('aVertexPosition').static = false;\n var meshMaterial = new MeshMaterial(texture);\n _this = _super.call(this, geometry, meshMaterial, null, drawMode) || this;\n _this.autoUpdate = true;\n return _this;\n }\n Object.defineProperty(SimpleMesh.prototype, \"vertices\", {\n /**\n * Collection of vertices data.\n * @type {Float32Array}\n */\n get: function () {\n return this.geometry.getBuffer('aVertexPosition').data;\n },\n set: function (value) {\n this.geometry.getBuffer('aVertexPosition').data = value;\n },\n enumerable: false,\n configurable: true\n });\n SimpleMesh.prototype._render = function (renderer) {\n if (this.autoUpdate) {\n this.geometry.getBuffer('aVertexPosition').update();\n }\n _super.prototype._render.call(this, renderer);\n };\n return SimpleMesh;\n}(Mesh));\n\nvar DEFAULT_BORDER_SIZE = 10;\n/**\n * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful\n * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically\n *\n *```js\n * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15);\n * ```\n *
\n *      A                          B\n *    +---+----------------------+---+\n *  C | 1 |          2           | 3 |\n *    +---+----------------------+---+\n *    |   |                      |   |\n *    | 4 |          5           | 6 |\n *    |   |                      |   |\n *    +---+----------------------+---+\n *  D | 7 |          8           | 9 |\n *    +---+----------------------+---+\n *  When changing this objects width and/or height:\n *     areas 1 3 7 and 9 will remain unscaled.\n *     areas 2 and 8 will be stretched horizontally\n *     areas 4 and 6 will be stretched vertically\n *     area 5 will be stretched both horizontally and vertically\n * 
\n * @memberof PIXI\n */\nvar NineSlicePlane = /** @class */ (function (_super) {\n __extends(NineSlicePlane, _super);\n /**\n * @param texture - The texture to use on the NineSlicePlane.\n * @param {number} [leftWidth=10] - size of the left vertical bar (A)\n * @param {number} [topHeight=10] - size of the top horizontal bar (C)\n * @param {number} [rightWidth=10] - size of the right vertical bar (B)\n * @param {number} [bottomHeight=10] - size of the bottom horizontal bar (D)\n */\n function NineSlicePlane(texture, leftWidth, topHeight, rightWidth, bottomHeight) {\n if (leftWidth === void 0) { leftWidth = DEFAULT_BORDER_SIZE; }\n if (topHeight === void 0) { topHeight = DEFAULT_BORDER_SIZE; }\n if (rightWidth === void 0) { rightWidth = DEFAULT_BORDER_SIZE; }\n if (bottomHeight === void 0) { bottomHeight = DEFAULT_BORDER_SIZE; }\n var _this = _super.call(this, Texture.WHITE, 4, 4) || this;\n _this._origWidth = texture.orig.width;\n _this._origHeight = texture.orig.height;\n /** The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */\n _this._width = _this._origWidth;\n /** The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */\n _this._height = _this._origHeight;\n _this._leftWidth = leftWidth;\n _this._rightWidth = rightWidth;\n _this._topHeight = topHeight;\n _this._bottomHeight = bottomHeight;\n // lets call the setter to ensure all necessary updates are performed\n _this.texture = texture;\n return _this;\n }\n NineSlicePlane.prototype.textureUpdated = function () {\n this._textureID = this.shader.texture._updateID;\n this._refresh();\n };\n Object.defineProperty(NineSlicePlane.prototype, \"vertices\", {\n get: function () {\n return this.geometry.getBuffer('aVertexPosition').data;\n },\n set: function (value) {\n this.geometry.getBuffer('aVertexPosition').data = value;\n },\n enumerable: false,\n configurable: true\n });\n /** Updates the horizontal vertices. */\n NineSlicePlane.prototype.updateHorizontalVertices = function () {\n var vertices = this.vertices;\n var scale = this._getMinScale();\n vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale;\n vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale);\n vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height;\n };\n /** Updates the vertical vertices. */\n NineSlicePlane.prototype.updateVerticalVertices = function () {\n var vertices = this.vertices;\n var scale = this._getMinScale();\n vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale;\n vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale);\n vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width;\n };\n /**\n * Returns the smaller of a set of vertical and horizontal scale of nine slice corners.\n * @returns Smaller number of vertical and horizontal scale.\n */\n NineSlicePlane.prototype._getMinScale = function () {\n var w = this._leftWidth + this._rightWidth;\n var scaleW = this._width > w ? 1.0 : this._width / w;\n var h = this._topHeight + this._bottomHeight;\n var scaleH = this._height > h ? 1.0 : this._height / h;\n var scale = Math.min(scaleW, scaleH);\n return scale;\n };\n Object.defineProperty(NineSlicePlane.prototype, \"width\", {\n /** The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */\n get: function () {\n return this._width;\n },\n set: function (value) {\n this._width = value;\n this._refresh();\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(NineSlicePlane.prototype, \"height\", {\n /** The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane. */\n get: function () {\n return this._height;\n },\n set: function (value) {\n this._height = value;\n this._refresh();\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(NineSlicePlane.prototype, \"leftWidth\", {\n /** The width of the left column. */\n get: function () {\n return this._leftWidth;\n },\n set: function (value) {\n this._leftWidth = value;\n this._refresh();\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(NineSlicePlane.prototype, \"rightWidth\", {\n /** The width of the right column. */\n get: function () {\n return this._rightWidth;\n },\n set: function (value) {\n this._rightWidth = value;\n this._refresh();\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(NineSlicePlane.prototype, \"topHeight\", {\n /** The height of the top row. */\n get: function () {\n return this._topHeight;\n },\n set: function (value) {\n this._topHeight = value;\n this._refresh();\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(NineSlicePlane.prototype, \"bottomHeight\", {\n /** The height of the bottom row. */\n get: function () {\n return this._bottomHeight;\n },\n set: function (value) {\n this._bottomHeight = value;\n this._refresh();\n },\n enumerable: false,\n configurable: true\n });\n /** Refreshes NineSlicePlane coords. All of them. */\n NineSlicePlane.prototype._refresh = function () {\n var texture = this.texture;\n var uvs = this.geometry.buffers[1].data;\n this._origWidth = texture.orig.width;\n this._origHeight = texture.orig.height;\n var _uvw = 1.0 / this._origWidth;\n var _uvh = 1.0 / this._origHeight;\n uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0;\n uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0;\n uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1;\n uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1;\n uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth;\n uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth);\n uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight;\n uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight);\n this.updateHorizontalVertices();\n this.updateVerticalVertices();\n this.geometry.buffers[0].update();\n this.geometry.buffers[1].update();\n };\n return NineSlicePlane;\n}(SimplePlane));\n\nexport { NineSlicePlane, PlaneGeometry, RopeGeometry, SimpleMesh, SimplePlane, SimpleRope };\n//# sourceMappingURL=mesh-extras.mjs.map\n","/*!\n * @pixi/sprite-animated - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * @pixi/sprite-animated is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport { Texture } from '@pixi/core';\nimport { Sprite } from '@pixi/sprite';\nimport { Ticker, UPDATE_PRIORITY } from '@pixi/ticker';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\n/**\n * An AnimatedSprite is a simple way to display an animation depicted by a list of textures.\n *\n * ```js\n * let alienImages = [\"image_sequence_01.png\",\"image_sequence_02.png\",\"image_sequence_03.png\",\"image_sequence_04.png\"];\n * let textureArray = [];\n *\n * for (let i=0; i < 4; i++)\n * {\n * let texture = PIXI.Texture.from(alienImages[i]);\n * textureArray.push(texture);\n * };\n *\n * let animatedSprite = new PIXI.AnimatedSprite(textureArray);\n * ```\n *\n * The more efficient and simpler way to create an animated sprite is using a {@link PIXI.Spritesheet}\n * containing the animation definitions:\n *\n * ```js\n * PIXI.Loader.shared.add(\"assets/spritesheet.json\").load(setup);\n *\n * function setup() {\n * let sheet = PIXI.Loader.shared.resources[\"assets/spritesheet.json\"].spritesheet;\n * animatedSprite = new PIXI.AnimatedSprite(sheet.animations[\"image_sequence\"]);\n * ...\n * }\n * ```\n * @memberof PIXI\n */\nvar AnimatedSprite = /** @class */ (function (_super) {\n __extends(AnimatedSprite, _super);\n /**\n * @param textures - An array of {@link PIXI.Texture} or frame\n * objects that make up the animation.\n * @param {boolean} [autoUpdate=true] - Whether to use PIXI.Ticker.shared to auto update animation time.\n */\n function AnimatedSprite(textures, autoUpdate) {\n if (autoUpdate === void 0) { autoUpdate = true; }\n var _this = _super.call(this, textures[0] instanceof Texture ? textures[0] : textures[0].texture) || this;\n _this._textures = null;\n _this._durations = null;\n _this._autoUpdate = autoUpdate;\n _this._isConnectedToTicker = false;\n _this.animationSpeed = 1;\n _this.loop = true;\n _this.updateAnchor = false;\n _this.onComplete = null;\n _this.onFrameChange = null;\n _this.onLoop = null;\n _this._currentTime = 0;\n _this._playing = false;\n _this._previousFrame = null;\n _this.textures = textures;\n return _this;\n }\n /** Stops the AnimatedSprite. */\n AnimatedSprite.prototype.stop = function () {\n if (!this._playing) {\n return;\n }\n this._playing = false;\n if (this._autoUpdate && this._isConnectedToTicker) {\n Ticker.shared.remove(this.update, this);\n this._isConnectedToTicker = false;\n }\n };\n /** Plays the AnimatedSprite. */\n AnimatedSprite.prototype.play = function () {\n if (this._playing) {\n return;\n }\n this._playing = true;\n if (this._autoUpdate && !this._isConnectedToTicker) {\n Ticker.shared.add(this.update, this, UPDATE_PRIORITY.HIGH);\n this._isConnectedToTicker = true;\n }\n };\n /**\n * Stops the AnimatedSprite and goes to a specific frame.\n * @param frameNumber - Frame index to stop at.\n */\n AnimatedSprite.prototype.gotoAndStop = function (frameNumber) {\n this.stop();\n var previousFrame = this.currentFrame;\n this._currentTime = frameNumber;\n if (previousFrame !== this.currentFrame) {\n this.updateTexture();\n }\n };\n /**\n * Goes to a specific frame and begins playing the AnimatedSprite.\n * @param frameNumber - Frame index to start at.\n */\n AnimatedSprite.prototype.gotoAndPlay = function (frameNumber) {\n var previousFrame = this.currentFrame;\n this._currentTime = frameNumber;\n if (previousFrame !== this.currentFrame) {\n this.updateTexture();\n }\n this.play();\n };\n /**\n * Updates the object transform for rendering.\n * @param deltaTime - Time since last tick.\n */\n AnimatedSprite.prototype.update = function (deltaTime) {\n if (!this._playing) {\n return;\n }\n var elapsed = this.animationSpeed * deltaTime;\n var previousFrame = this.currentFrame;\n if (this._durations !== null) {\n var lag = this._currentTime % 1 * this._durations[this.currentFrame];\n lag += elapsed / 60 * 1000;\n while (lag < 0) {\n this._currentTime--;\n lag += this._durations[this.currentFrame];\n }\n var sign = Math.sign(this.animationSpeed * deltaTime);\n this._currentTime = Math.floor(this._currentTime);\n while (lag >= this._durations[this.currentFrame]) {\n lag -= this._durations[this.currentFrame] * sign;\n this._currentTime += sign;\n }\n this._currentTime += lag / this._durations[this.currentFrame];\n }\n else {\n this._currentTime += elapsed;\n }\n if (this._currentTime < 0 && !this.loop) {\n this.gotoAndStop(0);\n if (this.onComplete) {\n this.onComplete();\n }\n }\n else if (this._currentTime >= this._textures.length && !this.loop) {\n this.gotoAndStop(this._textures.length - 1);\n if (this.onComplete) {\n this.onComplete();\n }\n }\n else if (previousFrame !== this.currentFrame) {\n if (this.loop && this.onLoop) {\n if (this.animationSpeed > 0 && this.currentFrame < previousFrame) {\n this.onLoop();\n }\n else if (this.animationSpeed < 0 && this.currentFrame > previousFrame) {\n this.onLoop();\n }\n }\n this.updateTexture();\n }\n };\n /** Updates the displayed texture to match the current frame index. */\n AnimatedSprite.prototype.updateTexture = function () {\n var currentFrame = this.currentFrame;\n if (this._previousFrame === currentFrame) {\n return;\n }\n this._previousFrame = currentFrame;\n this._texture = this._textures[currentFrame];\n this._textureID = -1;\n this._textureTrimmedID = -1;\n this._cachedTint = 0xFFFFFF;\n this.uvs = this._texture._uvs.uvsFloat32;\n if (this.updateAnchor) {\n this._anchor.copyFrom(this._texture.defaultAnchor);\n }\n if (this.onFrameChange) {\n this.onFrameChange(this.currentFrame);\n }\n };\n /**\n * Stops the AnimatedSprite and destroys it.\n * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options\n * have been set to that value.\n * @param {boolean} [options.children=false] - If set to true, all the children will have their destroy\n * method called as well. 'options' will be passed on to those calls.\n * @param {boolean} [options.texture=false] - Should it destroy the current texture of the sprite as well.\n * @param {boolean} [options.baseTexture=false] - Should it destroy the base texture of the sprite as well.\n */\n AnimatedSprite.prototype.destroy = function (options) {\n this.stop();\n _super.prototype.destroy.call(this, options);\n this.onComplete = null;\n this.onFrameChange = null;\n this.onLoop = null;\n };\n /**\n * A short hand way of creating an AnimatedSprite from an array of frame ids.\n * @param frames - The array of frames ids the AnimatedSprite will use as its texture frames.\n * @returns - The new animated sprite with the specified frames.\n */\n AnimatedSprite.fromFrames = function (frames) {\n var textures = [];\n for (var i = 0; i < frames.length; ++i) {\n textures.push(Texture.from(frames[i]));\n }\n return new AnimatedSprite(textures);\n };\n /**\n * A short hand way of creating an AnimatedSprite from an array of image ids.\n * @param images - The array of image urls the AnimatedSprite will use as its texture frames.\n * @returns The new animate sprite with the specified images as frames.\n */\n AnimatedSprite.fromImages = function (images) {\n var textures = [];\n for (var i = 0; i < images.length; ++i) {\n textures.push(Texture.from(images[i]));\n }\n return new AnimatedSprite(textures);\n };\n Object.defineProperty(AnimatedSprite.prototype, \"totalFrames\", {\n /**\n * The total number of frames in the AnimatedSprite. This is the same as number of textures\n * assigned to the AnimatedSprite.\n * @readonly\n * @default 0\n */\n get: function () {\n return this._textures.length;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(AnimatedSprite.prototype, \"textures\", {\n /** The array of textures used for this AnimatedSprite. */\n get: function () {\n return this._textures;\n },\n set: function (value) {\n if (value[0] instanceof Texture) {\n this._textures = value;\n this._durations = null;\n }\n else {\n this._textures = [];\n this._durations = [];\n for (var i = 0; i < value.length; i++) {\n this._textures.push(value[i].texture);\n this._durations.push(value[i].time);\n }\n }\n this._previousFrame = null;\n this.gotoAndStop(0);\n this.updateTexture();\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(AnimatedSprite.prototype, \"currentFrame\", {\n /**\n * The AnimatedSprites current frame index.\n * @readonly\n */\n get: function () {\n var currentFrame = Math.floor(this._currentTime) % this._textures.length;\n if (currentFrame < 0) {\n currentFrame += this._textures.length;\n }\n return currentFrame;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(AnimatedSprite.prototype, \"playing\", {\n /**\n * Indicates if the AnimatedSprite is currently playing.\n * @readonly\n */\n get: function () {\n return this._playing;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(AnimatedSprite.prototype, \"autoUpdate\", {\n /** Whether to use PIXI.Ticker.shared to auto update animation time. */\n get: function () {\n return this._autoUpdate;\n },\n set: function (value) {\n if (value !== this._autoUpdate) {\n this._autoUpdate = value;\n if (!this._autoUpdate && this._isConnectedToTicker) {\n Ticker.shared.remove(this.update, this);\n this._isConnectedToTicker = false;\n }\n else if (this._autoUpdate && !this._isConnectedToTicker && this._playing) {\n Ticker.shared.add(this.update, this);\n this._isConnectedToTicker = true;\n }\n }\n },\n enumerable: false,\n configurable: true\n });\n return AnimatedSprite;\n}(Sprite));\n\nexport { AnimatedSprite };\n//# sourceMappingURL=sprite-animated.mjs.map\n","/*!\n * pixi.js - v6.5.10\n * Compiled Thu, 06 Jul 2023 15:25:11 UTC\n *\n * pixi.js is licensed under the MIT License.\n * http://www.opensource.org/licenses/mit-license\n */\nimport '@pixi/polyfill';\nimport * as utils from '@pixi/utils';\nexport { utils };\nimport { AccessibilityManager } from '@pixi/accessibility';\nexport * from '@pixi/accessibility';\nimport { InteractionManager } from '@pixi/interaction';\nexport * from '@pixi/interaction';\nimport { extensions, BatchRenderer } from '@pixi/core';\nexport * from '@pixi/core';\nimport { Extract } from '@pixi/extract';\nexport * from '@pixi/extract';\nimport { AppLoaderPlugin } from '@pixi/loaders';\nexport * from '@pixi/loaders';\nimport { CompressedTextureLoader, DDSLoader, KTXLoader } from '@pixi/compressed-textures';\nexport * from '@pixi/compressed-textures';\nimport { ParticleRenderer } from '@pixi/particle-container';\nexport * from '@pixi/particle-container';\nimport { Prepare } from '@pixi/prepare';\nexport * from '@pixi/prepare';\nimport { SpritesheetLoader } from '@pixi/spritesheet';\nexport * from '@pixi/spritesheet';\nimport { TilingSpriteRenderer } from '@pixi/sprite-tiling';\nexport * from '@pixi/sprite-tiling';\nimport { BitmapFontLoader } from '@pixi/text-bitmap';\nexport * from '@pixi/text-bitmap';\nimport { TickerPlugin } from '@pixi/ticker';\nexport * from '@pixi/ticker';\nimport { AlphaFilter } from '@pixi/filter-alpha';\nimport { BlurFilter, BlurFilterPass } from '@pixi/filter-blur';\nimport { ColorMatrixFilter } from '@pixi/filter-color-matrix';\nimport { DisplacementFilter } from '@pixi/filter-displacement';\nimport { FXAAFilter } from '@pixi/filter-fxaa';\nimport { NoiseFilter } from '@pixi/filter-noise';\nimport '@pixi/mixin-cache-as-bitmap';\nimport '@pixi/mixin-get-child-by-name';\nimport '@pixi/mixin-get-global-position';\nexport * from '@pixi/app';\nexport * from '@pixi/constants';\nexport * from '@pixi/display';\nexport * from '@pixi/graphics';\nexport * from '@pixi/math';\nexport * from '@pixi/mesh';\nexport * from '@pixi/mesh-extras';\nexport * from '@pixi/runner';\nexport * from '@pixi/sprite';\nexport * from '@pixi/sprite-animated';\nexport * from '@pixi/text';\nexport * from '@pixi/settings';\n\nextensions.add(\n// Install renderer plugins\nAccessibilityManager, Extract, InteractionManager, ParticleRenderer, Prepare, BatchRenderer, TilingSpriteRenderer, \n// Install loader plugins\nBitmapFontLoader, CompressedTextureLoader, DDSLoader, KTXLoader, SpritesheetLoader, \n// Install application plugins\nTickerPlugin, AppLoaderPlugin);\n/**\n * This namespace contains WebGL-only display filters that can be applied\n * to DisplayObjects using the {@link PIXI.DisplayObject#filters filters} property.\n *\n * Since PixiJS only had a handful of built-in filters, additional filters\n * can be downloaded {@link https://github.com/pixijs/pixi-filters here} from the\n * PixiJS Filters repository.\n *\n * All filters must extend {@link PIXI.Filter}.\n * @example\n * // Create a new application\n * const app = new PIXI.Application();\n *\n * // Draw a green rectangle\n * const rect = new PIXI.Graphics()\n * .beginFill(0x00ff00)\n * .drawRect(40, 40, 200, 200);\n *\n * // Add a blur filter\n * rect.filters = [new PIXI.filters.BlurFilter()];\n *\n * // Display rectangle\n * app.stage.addChild(rect);\n * document.body.appendChild(app.view);\n * @namespace PIXI.filters\n */\nvar filters = {\n AlphaFilter: AlphaFilter,\n BlurFilter: BlurFilter,\n BlurFilterPass: BlurFilterPass,\n ColorMatrixFilter: ColorMatrixFilter,\n DisplacementFilter: DisplacementFilter,\n FXAAFilter: FXAAFilter,\n NoiseFilter: NoiseFilter,\n};\n\nexport { filters };\n//# sourceMappingURL=pixi.mjs.map\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2018-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {BaseTexture, utils} from \"pixi.js\";\n\ntype IEmitter = BaseTexture | utils.EventEmitter | {\n\taddEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n\tremoveEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;\n}\n\nexport class EventListenerCtn {\t// リソースリーク対策\n\t#aOffEvt\t: {(): void}[]\t= [];\n\n\tadd(ed: IEmitter, type: string, fnc: (e: any)=> void, ctx: any = {}): void {\n\t\tif (ed instanceof BaseTexture) {\n\t\t\tswitch (type) {\n\t\t\tcase 'loaded':\n\t\t\tcase 'update':\n\t\t\tcase 'error':\n\t\t\tcase 'dispose':\n\t\t\t\ted.on(type, fnc, ctx);\n\t\t\t\tthis.#aOffEvt.push(()=> ed.off(type, fnc, ctx));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (ed instanceof utils.EventEmitter) {\n\t\t\ted.on(type, fnc, ctx);\n\t\t\tthis.#aOffEvt.push(()=> ed.off(type, fnc, ctx));\n\t\t\treturn;\n\t\t}\n\t\ted.addEventListener(type, fnc, ctx);\n\t\tthis.#aOffEvt.push(()=> ed.removeEventListener(type, fnc, {capture: ctx.capture ?? false}));\n\t}\n\n\tclear(): void {\n\t\tfor (const f of this.#aOffEvt) f();\n\t\tthis.#aOffEvt = [];\n\t}\n\n\tget\tisEmpty() {return this.#aOffEvt.length === 0}\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2022-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {int} from './CmnLib';\n\nexport const enum SEARCH_PATH_ARG_EXT {\t// #searchPath 使用時、第二引数用\n\tDEFAULT\t= '',\n\tSP_GSM\t= 'png|jpg|jpeg|json|svg|webp|mp4|webm',\n\t\t// NOTE: ogvがそもそも再生できないので、ogvのみ保留\n\tSCRIPT\t= 'sn|ssn',\n\tFONT\t= 'woff2|woff|otf|ttf',\n\tSOUND\t= 'mp3|m4a|ogg|aac|flac|wav',\n\tHTML\t= 'htm|html',\n\tCSS\t\t=\t'css',\n\tSN\t\t=\t'sn',\n\tPSD\t\t=\t'psd',\n\n\tTST_PNGPNG_\t= 'png|png_',\n\tTST_HH\t\t= 'hh',\n\tTST_EEE\t\t= 'eee',\n\tTST_GGG\t\t= 'ggg',\n\tTST_PNGXML\t= 'png|xml',\n};\n\n\nexport type T_CFG = {\n\tbook\t: {\n\t\ttitle\t\t: string,\t// 作品タイトル\n\t\tcreator\t\t: string,\t// 著作者\n\t\tcre_url\t\t: string,\t// 連絡先URL\n\t\tpublisher\t: string,\t// 出版者\n\t\tpub_url\t\t: string,\t// 出版社URL\n\t\tdetail\t\t: string,\t// 内容紹介\n\t\tversion\t\t: string,\t// version\n\t},\n\tsave_ns\t\t: string,\n\twindow\t: {\t\t// アプリケーションウインドウサイズ\n\t\twidth\t: number,\n\t\theight\t: number,\n\t},\n\tlog\t\t: {max_len: number},\t// プレイヤーが読んだ文章を読み返せる履歴の長さ\n\tinit\t: {\n\t\tbg_color\t\t\t: string,\t// 背景色\n\t\ttagch_msecwait\t\t: number,\t// 通常文字表示待ち時間(未読/既読)\n\t\tauto_msecpagewait\t: number,\t// 自動文字表示、行待ち時間(未読/既読)\n\t\tescape\t\t\t\t: string,\t// エスケープ文字\n\t},\n\tdebug\t: {\t// デバッグ情報\n\t\tdevtool\t\t: boolean,\n\t\ttoken\t\t: boolean,\n\t\ttag\t\t\t: boolean,\n\t\tputCh\t\t: boolean,\n\t\tdebugLog\t: boolean,\n\t\tbaseTx\t\t: boolean,\n\t\tmasume\t\t: boolean,\t// テキストレイヤ:ガイドマス目を表示するか\n\t\tvariable\t: boolean,\n\t\tdumpHtm\t: boolean,\t// テキストレイヤ:HTML部分をファイル出力するか\n\t},\n\tcode\t: {[fold_nm: string]: boolean,},\t// 暗号化しないフォルダ\n\tdebuger_token\t: string,\t// デバッガとの接続トークン\n}\n\n\nexport interface IExts { [ext: string]: string; };\nexport interface IFn2Path { [fn: string]: IExts; };\n\nexport interface IConfig {\n\toCfg\t: T_CFG;\n\tgetNs()\t: string;\n\tsearchPath(fn: string, extptn?: string): string;\n\taddPath(fn: string, h_exts: IExts): void;\n}\n\nexport interface ISysRoots {\n\tloadPath(hPathFn2Exts: IFn2Path, cfg: IConfig): Promise;\n\tdec(ext: string, tx: string): Promise;\n\tdecAB(ab: ArrayBuffer): Promise;\n\n\tget cur()\t: string;\n\tget crypto(): boolean;\n\tfetch(url: string): Promise;\t// ハッシュ値作成ロード用\n\thash(str: string): string;\n}\nexport type HSysBaseArg = {\n\tcur\t\t: string;\n\tcrypto\t: boolean;\n\tdip\t\t: string;\n}\n\n\nexport class ConfigBase implements IConfig {\n\toCfg: T_CFG = {\n\t\tsave_ns\t\t: '',\t\t// 扱うセーブデータを一意に識別するキーワード文字列\n\t\twindow\t: {\t\t// アプリケーションウインドウサイズ\n\t\t\twidth\t: 300,\n\t\t\theight\t: 300,\n\t\t},\n\t\tbook\t: {\t\t// プロジェクトの詳細情報です\n\t\t\ttitle\t\t: '',\t//作品タイトル\n\t\t\tcreator\t\t: '',\t//著作者。同人ならペンネーム\n\t\t\tcre_url\t\t: '',\t//著作者URL。ツイッターやメール、サイトなど\n\t\t\tpublisher\t: '',\t//出版社。同人ならサークル名\n\t\t\tpub_url\t\t: '',\t//出版社URL。無ければ省略します\n\t\t\tdetail\t\t: '',\t// 内容紹介。端的に記入\n\t\t\tversion\t\t: '1.0',\n\t\t},\n\t\tlog\t\t: {max_len: 64},\t// プレイヤーが読んだ文章を読み返せる履歴のページ数\n\t\tinit\t: {\n\t\t\tbg_color\t\t\t: '#000000',\t// 背景色\n\t\t\ttagch_msecwait\t\t: 10,\t\t// 通常文字表示待ち時間(未読/既読)\n\t\t\tauto_msecpagewait\t: 3500,\t\t// 自動文字表示、行クリック待ち時間(未読/既読)\n\t\t\tescape\t\t\t\t: '',\t\t// エスケープ文字\n\t\t},\n\t\tdebug\t: {\n\t\t\tdevtool\t\t: false,\n\t\t\ttoken\t\t: false,\n\t\t\ttag\t\t\t: false,\n\t\t\tputCh\t\t: false,\n\t\t\tdebugLog\t: false,\n\t\t\tbaseTx\t\t: false,\n\t\t\tmasume\t\t: false,\t// テキストレイヤ:ガイドマス目を表示するか\n\t\t\tvariable\t: false,\n\t\t\tdumpHtm\t: false,\n\t\t},\n\t\tcode\t: {},\t// 暗号化しないフォルダ\n\t\tdebuger_token\t: '',\t\t// デバッガとの接続トークン\n\t};\n\n\tuserFnTail\t\t= '';\t// 4tst public\n\tprotected\thPathFn2Exts\t: IFn2Path\t= {};\n\n\tconstructor(readonly sys: ISysRoots) {}\n\tasync load(oCfg: any) {\n\t\t// this.oCfg = {...this.oCfg, ...oCfg};\t// 一階層目でコピーしてしまう\n\t\tthis.oCfg.save_ns = oCfg?.save_ns ?? this.oCfg.save_ns;\n\n\t\tthis.oCfg.window.width = Number(oCfg?.window?.width ?? this.oCfg.window.width);\n\t\tthis.oCfg.window.height = Number(oCfg?.window?.height ?? this.oCfg.window.height);\n\n\t\tthis.oCfg.book = {...this.oCfg.book, ...oCfg.book};\n\n\t\tthis.oCfg.log.max_len = oCfg.log?.max_len?.max_len ?? this.oCfg.log.max_len;\n\n\t\tthis.oCfg.init = {...this.oCfg.init, ...oCfg.init};\n\n\t\tthis.oCfg.debug = {...this.oCfg.debug, ...oCfg.debug};\n\n\t\tthis.oCfg.debuger_token = oCfg.debuger_token;\n\n\t\t// これが同期(App)非同期(Web、path.json)混在してるので、\n\t\t// (Mainのメンバ変数に入れる→他のクラスに渡す都合により)\n\t\t// 当クラスのコンストラクタとload()は分ける\n\t\tawait this.sys.loadPath(this.hPathFn2Exts, this);\n\n\t\tthis.#existsBreakline = this.matchPath('^breakline$', SEARCH_PATH_ARG_EXT.SP_GSM).length > 0;\n\t\tthis.#existsBreakpage = this.matchPath('^breakpage$', SEARCH_PATH_ARG_EXT.SP_GSM).length > 0;\n\n\t\tconst hFn2Ext: {[fn: string]: string}\t= {};\n\t\tif (! this.sys.crypto) {\n\t\t\tfor (const [fn0, hExts] of Object.entries(this.hPathFn2Exts)) {\n\t\t\t\tfor (const ext of Object.keys(hExts)) {\n\t\t\t\t\tif (ext.charAt(0) === ':') continue;\n\t\t\t\t\thFn2Ext[fn0] = ext;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\tfor (const [fn0, hExts] of Object.entries(this.hPathFn2Exts)) {\n\t\t\tfor (const [ext, v] of Object.entries(hExts)) {\n\t\t\t\tif (ext.charAt(0) !== ':') {\n\t\t\t\t\thFn2Ext[fn0] = ext;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (ext.slice(-3) !== ':id') continue;\n\t\t\t\tconst hp = v.slice(v.lastIndexOf('/') +1);\n\t\t\t\tconst fn = hExts[ext.slice(0, -10)];\n\t\t\t\tconst res = await this.sys.fetch(fn);\n\t\t\t\tconst src = await res.text();\n\t\t\t\tconst hf = this.sys.hash(src);\n\t\t\t\tif (hp !== hf) throw `ファイル改竄エラーです fn:${fn}`;\n\t\t\t}\n\t\t}\n\t}\n\t#existsBreakline = false;\n\tget existsBreakline(): boolean {return this.#existsBreakline}\n\t#existsBreakpage = false;\n\tget existsBreakpage(): boolean {return this.#existsBreakpage}\n\n\tgetNs() {return `skynovel.${this.oCfg.save_ns} - `}\n\n\treadonly\t#REG_PATH = /([^\\/\\s]+)\\.([^\\d]\\w+)/;\n\t\t// 4 match 498 step(~1ms) https://regex101.com/r/tpVgmI/1\n\tsearchPath(fn: string, extptn: SEARCH_PATH_ARG_EXT = SEARCH_PATH_ARG_EXT.DEFAULT): string {\n\t\tif (! fn) throw '[searchPath] fnが空です';\n\t\tif (fn.slice(0, 7) === 'http://') return fn;\n\n\t\tconst a = fn.match(this.#REG_PATH);\n\t\tlet fn0 = a ?a[1] :fn;\n\t\tconst ext = a ?a[2] :'';\n\t\tif (this.userFnTail) {\n\t\t\tconst utn = fn0 +'@@'+ this.userFnTail;\n\t\t\tif (utn in this.hPathFn2Exts) {\n\t\t\t\tif (extptn === '') fn0 = utn;\n\t\t\t\telse for (const e3 of Object.keys(this.hPathFn2Exts[utn])) {\n\t\t\t\t\tif (`|${extptn}|`.indexOf(`|${e3}|`) === -1) continue;\n\n\t\t\t\t\tfn0 = utn;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst h_exts = this.hPathFn2Exts[fn0];\n\t\tif (! h_exts) throw `サーチパスに存在しないファイル【${fn}】です`;\n\n\t\tlet ret = '';\n\t\tif (! ext) {\t// fnに拡張子が含まれていない\n\t\t\t//\textのどれかでサーチ(ファイル名サーチ→拡張子群にextが含まれるか)\n\t\t\tconst hcnt = int(h_exts[':cnt']);\n\t\t\tif (extptn === '') {\n\t\t\t\tif (hcnt > 1) throw `指定ファイル【${fn}】が複数マッチします。サーチ対象拡張子群【${extptn}】で絞り込むか、ファイル名を個別にして下さい。`;\n\n\t\t\t\treturn fn;\n\t\t\t}\n\n\t\t\tconst search_exts = `|${extptn}|`;\n\t\t\tif (hcnt > 1) {\n\t\t\t\tlet cnt = 0;\n\t\t\t\tfor (const e2 of Object.keys(h_exts)) {\n\t\t\t\t\tif (search_exts.indexOf(`|${e2}|`) === -1) continue;\n\t\t\t\t\tif (++cnt > 1) throw `指定ファイル【${fn}】が複数マッチします。サーチ対象拡張子群【${extptn}】で絞り込むか、ファイル名を個別にして下さい。`;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (let e of Object.keys(h_exts)) {\n\t\t\t\tif (search_exts.indexOf(`|${e}|`) > -1) return h_exts[e];\n\t\t\t}\n\t\t\tthrow `サーチ対象拡張子群【${extptn}】にマッチするファイルがサーチパスに存在しません。探索ファイル名=【${fn}】`;\n\t\t}\n\n\t\t// fnに拡張子xが含まれている\n\t\t//\tファイル名サーチ→拡張子群にxが含まれるか\n\t\tif (extptn !== '' && `|${extptn}|`.indexOf(`|${ext}|`) === -1) {\n\t\t\tthrow `指定ファイルの拡張子【${ext}】は、サーチ対象拡張子群【${extptn}】にマッチしません。探索ファイル名=【${fn}】`;\n\t\t}\n\n\t\tret = h_exts[ext];\n\t\tif (! ret) throw `サーチパスに存在しない拡張子【${ext}】です。探索ファイル名=【${fn}】、サーチ対象拡張子群【${extptn}】`;\n\n\t\treturn ret;\n\t}\n\n\tmatchPath(fnptn: string, extptn: SEARCH_PATH_ARG_EXT = SEARCH_PATH_ARG_EXT.DEFAULT): ReadonlyArray {\n\t\tconst aRet :IExts[] = [];\n\t\tconst regPtn = new RegExp(fnptn);\n\t\tconst regExt = new RegExp(extptn);\n\t\tfor (const [fn, h_exts] of Object.entries(this.hPathFn2Exts)) {\n\t\t\tif (fn.search(regPtn) === -1) continue;\n\t\t\tif (extptn === '') {aRet.push(h_exts); continue}\n\n\t\t\tconst o :IExts = {};\n\t\t\tlet isa = false;\n\t\t\tfor (const ext of Object.keys(h_exts)) {\n\t\t\t\tif (ext.search(regExt) === -1) continue;\n\n\t\t\t\to[ext] = fn;\n\t\t\t\tisa = true;\n\t\t\t}\n\t\t\tif (isa) aRet.push(o);\n\t\t}\n\t\treturn aRet;\n\t}\n\n\taddPath(fn: string, h_exts: IExts) {\n\t\tconst o: any = {};\n\t\tfor (const [ext, v] of Object.entries(h_exts)) {\n\t\t\to[ext] = (ext.at(0) === ':' ?`` :this.sys.cur) + v;\n\t\t}\n\t\tthis.hPathFn2Exts[fn] = o;\n\t}\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2018-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {CmnLib} from './CmnLib';\nimport {SysBase} from './SysBase';\nimport {ConfigBase, SEARCH_PATH_ARG_EXT} from './ConfigBase';\n\n\nexport class Config extends ConfigBase {\n\tstatic\tasync\tgenerate(sys: SysBase) {\n\t\tconst c = new Config(sys);\n\t\tconst fn = sys.cur +'prj.json';\n\t\tconst src = await (await sys.fetch(fn)).text();\n\t\tconst oJs = JSON.parse(await sys.dec(fn, src));\n\t\tawait c.load(oJs);\n\t\treturn c;\n\t}\n\n\tconstructor(override readonly sys: SysBase) {super(sys)}\n\toverride\tasync load(oCfg: any) {\t\t// test用に public\n\t\tawait super.load(oCfg);\n\n\t\tCmnLib.stageW = this.oCfg.window.width;\n\t\tCmnLib.stageH = this.oCfg.window.height;\n\t\tCmnLib.debugLog = this.oCfg.debug.debugLog;\n\t}\n\n\toverride\tsearchPath(path: string, extptn: SEARCH_PATH_ARG_EXT = SEARCH_PATH_ARG_EXT.DEFAULT): string {\n\t\tif (path.slice(0, 11) === 'downloads:/') {\n\t\t\treturn this.sys.path_downloads + path.slice(11);\n\t\t}\n\t\tif (path.slice(0, 10) === 'userdata:/') {\n\t\t\treturn this.sys.path_userdata + 'storage/'+ path.slice(10);\n\t\t}\n\n\t\treturn super.searchPath(path, extptn);\n\t}\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2019-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nexport type HArg = {\n\t':タグ名'?\t: string;\n\n\tlayer?\t: string;\t// レイヤ系\n\tclass?\t: string;\n\tindex?\t: number;\n\tdive?\t: string;\n\tpage?\t: string;\n\talpha?\t: number;\n\tpivot_x?: number;\n\tpivot_y?: number;\n\trotation?\t: number;\n\tscale_x?: number;\n\tscale_y?: number;\n\tvisible?: boolean;\n\tblendmode?\t: string;\n\n\tleft?\t: number;\n\ttop?\t: number;\n\twidth?\t: number;\n\theight?\t: number;\n\tpl?\t\t: number;\n\tpr?\t\t: number;\n\tpt?\t\t: number;\n\tpb?\t\t: number;\n\n\trotate?\t: number;\n\tin_style?\t: string;\n\tout_style?\t: string;\n\tffs?\t: string;\n\tnoffs?\t: string;\n\tkinsoku_sol?\t: string;\n\tkinsoku_eol?\t: string;\n\tkinsoku_dns?\t: string;\n\tkinsoku_bura?\t: string;\n\tbura?\t: boolean;\n\tbreak_fixed?\t\t: boolean;\n\tbreak_fixed_left?\t: number;\n\tbreak_fixed_top?\t: number;\n\n\ttime?\t: number;\n\trule?\t: string;\n\tglsl?\t: string;\n\trender?\t: boolean;\n\n\tpos?\t: string;\n\ttext?\t: string;\n\twait?\t: number;\n\trecord?\t: boolean;\n\tpic?\t: string;\n\tenabled?: boolean;\n\thint?\t\t: string;\n\thint_style?\t: string;\n\thint_opt?\t: string;\n\tclickse?\t: string;\n\tenterse?\t: string;\n\tleavese?\t: string;\n\tclicksebuf?\t: string;\n\tentersebuf?\t: string;\n\tleavesebuf?\t: string;\n\tonenter?\t: string;\n\tonleave?\t: string;\n\n\tt?\t: string;\n\tr?\t: string;\n\texp?\t: string;\n\tchar?\t: string;\n\tsesame?\t: string;\n\tcast?\t: string;\n\tval?\t: string;\n\tflags?\t: string;\n\treg?\t: string;\n\tlen?\t: string;\n\turl?\t: string;\n\tformat?\t: string;\n\tchain?\t: string;\n\tpath?\t: string;\n\n\tfn?\t\t: string;\n\tface?\t: string;\n\tlabel?\t: string;\n\tcall?\t: boolean;\n\tglobal?\t: boolean;\n\tname?\t: string;\n\tclear_local_event?\t: string;\n\n\tstyle?\t\t\t: string;\n\tstyle_hover?\t: string;\n\tstyle_clicked?\t: string;\n\tr_style?\t\t: string;\n\tr_style_hover?\t: string;\n\tr_style_clicked?: string;\n\tr_align?\t: string;\n\n\tb_width?\t: string;\n\tb_height?\t: string;\n\tb_color?\t: string;\n\tb_alpha?\t: number;\n\tb_alpha_isfixed?\t: boolean;\n\tb_pic?\t\t: string;\n\tback_clear?\t: string;\n\n\tmax_col?\t: string;\n\tmax_row?\t: string;\n\tbura_col?\t: string;\n\tchk_overrow?\t: string;\n\n\tdx?\t: number;\n\tdy?\t: number;\n\n\tkey?\t: string;\n\ttype?\t: string;\t// 3Dレイヤで使用\n\tcamera_target?\t: string;\n\n\tbreakout?\t: Function;\n\targ?\t: HArg;\n\tfnc?\t: (e: Event)=> void;\n\n\tfilter?\t: string;\n\tmatrix?\t: string;\n\tclear_filter?\t: boolean;\n\tenable_filter?\t: boolean;\n\n\tease?\t: string;\n\tcanskip?\t:boolean;\n\n\tcentering?\t:boolean;\n\tx?\t\t: number | string;\n\ty?\t\t: number | string;\n\n\tid?\t\t\t: string;\n\tsrc?\t\t: string;\n\tvar_name?\t: string;\n\tset_fnc?\t: string;\n\tbreak_fnc?\t: string;\n\n\tswipe?\t: string;\n\tf2tap?\t: string;\n\tf2move?\t: string;\n\tf3tap?\t: string;\n\n\tfrom?\t: number;\n\tto?\t\t: number | string;\n\tplace?\t: number;\n\tadd?\t: string;\n\tdel?\t: string;\n\n\tbuf?\t: string;\t// 音系\n\tbuf2?\t: string;\n\tloop?\t: boolean;\n\tvolume?\t: number;\n\tret_ms?\t: number;\n\tend_ms?\t: number;\n\tjoin?\t: boolean;\n\tdo_rec?\t: boolean;\n\tpan?\t: number;\n\tstop?\t: boolean;\n\n\tclear?\t: boolean;\n\n\t// デザインモード\n\t':id_dc'?\t: string;\n\t':id_tag'?\t: string;\n\t':path'?\t: string;\n\t':ln'?\t\t: number;\n\t':col_s'?\t: number;\n\t':col_e'?\t: number;\n\t':idx_tkn'?\t: number;\n\t':token'?\t: string;\n\t':redraw'?\t: boolean;\n\tdesign_unit?: boolean;\t// デザインモードでこのマクロへの引数変更とするか(内部をサーチさせない)\n\n//\tstepin?\t\t: boolean;\t\t// 拡張機能のみ使用:false指定でステップインしない\n//\tnowarn_unused?\t: boolean;\t// 拡張機能のみ使用:未使用警告を出さない\n}\nexport interface ITag { (hArg: HArg): boolean; }\nexport interface IHTag { [name: string]: ITag; }\n\n\nexport type Script = {\n\taToken\t: string[];\t\t// トークン群\n\tlen\t\t: number;\t\t// トークン数\n\taLNum\t: number[];\t\t// トークンの行番号\n};\n\n\nexport const\tREG_TAG\t= /(?[^\\s;\\]]+)/;\t// test用にexport\nexport function\ttagToken2Name_Args(token: string): [name: string, args: string] {\n\tconst e = REG_TAG.exec(token.slice(1, -1));\n\tconst g = e?.groups;\n\tif (! g) throw `タグ記述【${token}】異常です(タグ解析)`;\n\n\tconst nm = g.name;\n\treturn [nm, token.slice(1 +nm.length, -1)];\n}\nexport function\ttagToken2Name(token: string): string {\n\tconst e = REG_TAG.exec(token.slice(1));\n\tconst g = e?.groups;\n\tif (! g) throw `タグ記述【${token}】異常です(タグ解析)`;\n\n\treturn g.name;\n}\n\nexport function\tsplitAmpersand(token: string): {\n\t\tname: string;\n\t\ttext: string;\n\t\tcast: string | undefined;\n} {\t// テスト用にpublic\n\tconst equa = token.replaceAll('==', '=').replaceAll('!=', '≠').split('=');\n\t\t// != を弾けないので中途半端ではある\n\tconst cnt_equa = equa.length;\n\tif (cnt_equa < 2 || cnt_equa > 3) throw '「&計算」書式では「=」指定が一つか二つ必要です';\n\tif (equa[1].at(0) === '&') throw '「&計算」書式では「&」指定が不要です';\n\treturn {\n\t\tname: equa[0].replaceAll('=', '==').replaceAll('≠', '!='),\n\t\ttext: equa[1].replaceAll('=', '==').replaceAll('≠', '!='),\n\t\tcast: ((cnt_equa === 3) ?equa[2].trim() :undefined)\n\t};\n}\n\n\nexport class Grammar {\n\tconstructor() {this.setEscape('')}\n\n\t#REG_TOKEN\t: RegExp;\n\tsetEscape(ce: string) {\n\t\tif (this.#hC2M && (ce in this.#hC2M)) throw '[エスケープ文字] char【'+ ce +'】が登録済みの括弧マクロまたは一文字マクロです';\n\n\t\t// 1083 matches (14577 step, 9.9ms) https://regex101.com/r/dP0tAY/1\n\t\t/*\n\\\\\\S |\n \\n+\n| \\t+\n|\t\\[let_ml \\s+ [^\\]]+ ]\n\t.+? (?=\\[endlet_ml [\\]\\s])\n| \\[ (?: [^\"'#;\\]]+\n\t| ([\"'#]).*?\\1\n\t| ;[^\\n]* ) *? ]\n| ;[^\\n]*\n| &[^&\\n]+&\n| &&?(?: [^\"'#;\\n&]+ | ([\"'#]).*?\\2 )+\n| ^\\*[^\\s\\[&;\\\\]+\n| [^\\n\\t\\[;\\\\]+\n\t\t*/\n/*\n\t[^\"'#;\\]]++\n\t| ([\"'\\#]).*?\\1\n\t\t\t++ にしたいところだが、jsは未サポートらしい(2022/10/16)\n*/\n\t\tthis.#REG_TOKEN = new RegExp(\n\t\t(ce\t?`\\\\${ce}\\\\S|` :'')+\t// エスケープシーケンス\n\t\t'\\\\n+'+\t\t\t\t// 改行\n\t\t'|\\\\t+'+\t\t\t// タブ文字\n\t\t`|\\\\[let_ml\\\\s+[^\\\\]]+\\\\]`+\n\t\t\t`.+?`+\t\t\t// [let_ml]〜[endlet_ml]間のテキスト\n\t\t`(?=\\\\[endlet_ml[\\\\]\\\\s])`+\n\t\t`|\\\\[(?:`+\n\t\t\t`[^\"'#;\\\\]]+|`+\t// タグ\n\t\t\t`([\"'#]).*?\\\\1` +\n\t\t\t\t// . は (?:\\\\${ ce??'\\\\' }.|[^\\\\1]) でなくてよさげ\n\t\t`|;[^\\\\n]*)*?]`+\n\t\t'|;[^\\\\n]*'+\t\t// コメント\n\t\t'|&[^&\\\\n]+&'+\t\t// &表示&\n\t\t`|&&?(?:[^\"'#;\\\\n&]+|([\"'#]).*?\\\\2)+`+\t// &代入\n\t\t'|^\\\\*[^\\\\s\\\\[&;\\\\\\\\]+'+\t// ラベル\n\t\t`|[^\\\\n\\\\t\\\\[;${ce ?`\\\\${ce}` :''}]+`,\t\t// 本文\n\t\t'gs');\n\t\tthis.#REG_CANTC2M = new RegExp(`[\\\\w\\\\s;[\\\\]*=&|《》${ce ?`\\\\${ce}` :''}]`);\n\t\tthis.#REG_TOKEN_NOTXT = new RegExp(`[\\\\n\\\\t;\\\\[*&${ce ?`\\\\${ce}` :''}]`);\n\t}\n\n\n\t// 括弧マクロの定義\n\tbracket2macro(hArg: HArg, hTag: IHTag, scr: Script, start_idx: number) {\n\t\tconst {name, text} = hArg;\n\t\tif (! name) throw '[bracket2macro] nameは必須です';\n\t\tif (! text) throw '[bracket2macro] textは必須です';\n\t\tconst op = text.at(0);\n\t\tif (! op) throw '[bracket2macro] textは必須です';\n\t\tif (text.length !== 2) throw '[bracket2macro] textは括弧の前後を示す二文字を指定してください';\n\t\tif (! (name in hTag)) throw `[bracket2macro] 未定義のタグ又はマクロ[${name}]です`;\n\n\t\tthis.#hC2M ??= {};\n\t\tconst cl = text.charAt(1);\n\t\tif (op in this.#hC2M) throw '[bracket2macro] text【'+ op +'】が登録済みの括弧マクロまたは一文字マクロです';\n\t\tif (cl in this.#hC2M) throw '[bracket2macro] text【'+ cl +'】が登録済みの括弧マクロまたは一文字マクロです';\n\t\tif (this.#REG_CANTC2M.test(op)) throw '[bracket2macro] text【'+ op +'】は括弧マクロに使用できない文字です';\n\t\tif (this.#REG_CANTC2M.test(cl)) throw '[bracket2macro] text【'+ cl +'】は括弧マクロに使用できない文字です';\n\n\t\tthis.#hC2M[cl] = '0';\t// チェック用ダミー\n\t\tthis.#hC2M[op] = `[${name} text=`;\n\n\t\tthis.addC2M(`\\\\${op}[^\\\\${cl}]*\\\\${cl}`, `\\\\${op}\\\\${cl}`);\n\n\t\tthis.#replaceScr_C2M(scr, start_idx);\n\t}\n\t// 一文字マクロの定義\n\tchar2macro(hArg: HArg, hTag: IHTag, scr: Script, start_idx: number) {\n\t\tconst {char, name} = hArg;\n\t\tif (! char) throw '[char2macro] charは必須です';\n\t\tthis.#hC2M ??= {};\n\t\tif (char in this.#hC2M) throw '[char2macro] char【'+ char +'】が登録済みの括弧マクロまたは一文字マクロです';\n\t\tif (this.#REG_CANTC2M.test(char)) throw '[char2macro] char【'+ char +'】は一文字マクロに使用できない文字です';\n\n\t\tif (! name) throw '[char2macro] nameは必須です';\n\t\tif (! (name in hTag)) throw `[char2macro] 未定義のタグ又はマクロ[${name}]です`;\n\n\t\tthis.#hC2M[char] = `[${name}]`;\n\n\t\tthis.addC2M(`\\\\${char}`, `\\\\${char}`);\n\n\t\tthis.#replaceScr_C2M(scr, start_idx);\n\t}\n\t#REG_CANTC2M\t: RegExp;\n\t#REGC2M\t\t\t= new RegExp('');\n\t#regStrC2M\t\t= '';\n\t#regStrC2M4not\t= '';\n\taddC2M(a: string, b: string) {\n\t\tthis.#regStrC2M += `${a}|`;\n\t\tthis.#regStrC2M4not += `${b}`;\n\t\tthis.#REGC2M = new RegExp(\n\t\t\t`(${this.#regStrC2M}[^${this.#regStrC2M4not}]+)`, 'g');\n\t}\n\n\n\tresolveScript(txt: string): Script {\n\t\tconst a = txt\n\t\t.replaceAll(/(\\r\\n|\\r)/g, '\\n')\n\t\t.match(this.#REG_TOKEN)\n\t\t?.flatMap(tkn=> {\n\t\t\tif (! this.testTagLetml(tkn)) return tkn;\n\n\t\t\tconst r = /^([^\\]]+?])(.*)$/s.exec(tkn);\n\t\t\tif (! r) return tkn;\n\t\t\tconst [, a, b] = r;\n\t\t\treturn [a, b];\n\t\t}) ?? [];\n\n\t\tconst scr = {aToken :a, len :a.length, aLNum :[]};\n\t\tthis.#replaceScr_C2M(scr);\n\t\treturn scr;\n\t}\n\ttestTagLetml(tkn: string): boolean {return /^\\[let_ml\\s/.test(tkn)};\n\ttestTagEndLetml(tkn: string): boolean {return /^\\[endlet_ml\\s*]/.test(tkn)};\n\n\tanalyzToken(token: string): RegExpExecArray | null {\t// 4LspWs\n\t\tthis.#REG_TOKEN.lastIndex = 0;\t// /gなので必要\n\t\treturn this.#REG_TOKEN.exec(token);\n\t}\n\n\n\t#hC2M\t: {[char: string]: string};\n\t#REG_TOKEN_NOTXT\t: RegExp;\n\t#replaceScr_C2M(scr: Script, start_idx = 0): void {\n\t\tif (! this.#hC2M) return;\n\n\t\tfor (let i=scr.len- 1; i >= start_idx; --i) {\n\t\t\tconst token = scr.aToken[i];\n\t\t\tif (this.testNoTxt(token.at(0) ?? '\\n')) continue;\n\t\t\t\t// 省略時は #REG_TOKEN_NOTXT に引っかかる \\n に\n\n\t\t\tconst lnum = scr.aLNum[i];\n\t\t\tconst a = token.match(this.#REGC2M);\n\t\t\tif (! a) continue;\n\t\t\tlet del = 1;\n\t\t\tfor (let j=a.length -1; j>=0; --j) {\n\t\t\t\tlet ch = a[j];\n\t\t\t\tconst macro = this.#hC2M[ch.at(0) ?? ' '];\n\t\t\t\t\t// 省略時は #REG_CANTC2M に引っかかる ' ' に\n\t\t\t\tif (macro) {\n\t\t\t\t\tch = macro +((macro.at(-1) === ']')\n\t\t\t\t\t\t? ''\n\t\t\t\t\t\t: (`'${ch.slice(1, -1)}']`));\n\t\t\t\t\t// 文字列は半角空白を意識して''で囲むが、いずれ変えたい場合がある?\n\t\t\t\t}\n\t\t\t\tscr.aToken.splice(i, del, ch);\n\n\t\t\t\tscr.aLNum.splice(i, del, lnum);\n\t\t\t\tdel = 0;\n\t\t\t}\n\t\t}\n\t\tscr.len = scr.aToken.length;\n\t}\n\ttestNoTxt(ch: string): boolean {return this.#REG_TOKEN_NOTXT.test(ch)};\t//4tst\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2018-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nexport interface PRM {\n\tval\t\t: string;\n\tdef?\t: string;\n};\nexport interface HPRM {\n\t[key: string]: PRM,\n};\n\nexport interface PRM_RANGE {\n\tk_ln\t: number;\n\tk_ch\t: number;\n\tv_ln\t: number;\n\tv_ch\t: number;\n\tv_len\t: number;\n};\n\nexport class AnalyzeTagArg {\n\t// 87 match 2725 step(0.5ms) PCRE2 https://regex101.com/r/aeN57J/1\n\t/*\n;[^\\n]*\n|\t(?[^\\s=\"'#|;]+)\n\t(?: \\s | ;[^\\n]*\\n)*\n\t=\n\t(?: \\s | ;[^\\n]*\\n)*\n\t(?:\t(? [^\\s\"'#|;]+)\n\t|\t([\"'#]) (?.*?) \\3 )\n\t(?: \\|\n\t\t(?: (? [^\\s\"'#;]+)\n\t|\t([\"'#]) (?.*?) \\6 ) )?\n|\t(?[^\\s;]+)\n\t*/\n\treadonly\t#REG_TAGARG\t= /;[^\\n]*|(?[^\\s=\"'#|;]+)(?:\\s|;[^\\n]*\\n)*=(?:\\s|;[^\\n]*\\n)*(?:(?[^\\s\"'#|;]+)|([\"'#])(?.*?)\\3)(?:\\|(?:(?[^\\s\"'#;]+)|([\"'#])(?.*?)\\6))?|(?[^\\s;]+)/g;\n\n\t// 【属性 = 値 | 省略値】の分析\n\tparse(args: string): void {\n\t\tthis.#hPrm = {};\n\t\tthis.#isKomeParam = false;\n\t\tfor (const {groups} of args.matchAll(this.#REG_TAGARG)) {\n\t\t\tconst {key, val, val2, def, def2, literal} = groups!;\n\t\t\tif (key) this.#hPrm[key] = {\n\t\t\t\tval: val ?? val2,\n\t\t\t\tdef: def ?? def2\n\t\t\t};\n\t\t\telse if (literal) {\n\t\t\t\tif (literal === '*') this.#isKomeParam = true;\n\t\t\t\telse this.#hPrm[literal] = {val: '1'};\n\t\t\t}\n\t\t}\n\t}\n\n\t// 属性と値の位置をまとめて返す\n\tparseinDetail(token: string, lenNm: number, ln: number, ch: number): {[key: string]: PRM_RANGE} {\n\t\tconst hRng: {[key: string]: PRM_RANGE} = {};\n\n\t\tconst args = token.slice(1+lenNm, -1);\n\t\tfor (const {groups, index, 0: z} of args.matchAll(this.#REG_TAGARG)) {\n\t\t\tif (index === undefined) continue;\n\t\t\tconst {key, val, val2, literal} = groups!;\n\t\t\tif (literal) {\n\t\t\t\tif (literal.at(-1) === '=') {\n\t\t\t\t\tconst lenVnm = literal.length -1;\n\t\t\t\t\tconst {ch: k_ch} = this.#idx2LnCol(lenNm, ln, ch, args, index +lenVnm);\n\t\t\t\t\thRng[literal.slice(0, -1)] = {\n\t\t\t\t\t\tk_ln: ln,\n\t\t\t\t\t\tk_ch: k_ch -lenVnm,\n\t\t\t\t\t\tv_ln: ln,\n\t\t\t\t\t\tv_ch: k_ch +1,\n\t\t\t\t\t//\tv_ch: ch +1+lenNm +literal.length +1,\n\t\t\t\t\t\tv_len: 0,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (! key) continue;\n\n\t\t\tconst {ln: k_ln, ch: k_ch} = this.#idx2LnCol(lenNm, ln, ch, args, index);\n\t\t\tconst {ln: v_ln, ch: v_ch} = this.#idx2LnCol(lenNm, ln, ch, args, index +z.lastIndexOf(val ?? val2) -(val ?0 :1));\n\t\t\thRng[key] = {k_ln, k_ch, v_ln, v_ch, v_len: val ?val.length :val2.length +2};\n\t\t}\n\n\t\treturn hRng;\n\t}\n\t\t#idx2LnCol(lenNm: number, ln: number, ch: number, args: string, idx: number): {ln: number; ch: number;} {\n\t\t\tconst sBefore = args.slice(0, idx);\n\t\t\tconst a = sBefore.split('\\n');\n\t\t\tconst len = a.length;\n\t\t\treturn {\n\t\t\t\tln\t: ln +len -1,\n\t\t\t\tch\t: len < 2 ?ch +1+lenNm +idx :a.at(-1)!.length,\n\t\t\t};\n\t\t}\n\n\t#hPrm: HPRM\t= {};\n\tget hPrm() {return this.#hPrm}\n\n\t#isKomeParam\t= false;\n\tget isKomeParam() {return this.#isKomeParam}\n\n}\n","!function(n,t){\"object\"==typeof exports&&\"object\"==typeof module?module.exports=t():\"function\"==typeof define&&define.amd?define([],t):\"object\"==typeof exports?exports.Parsimmon=t():n.Parsimmon=t()}(\"undefined\"!=typeof self?self:this,function(){return function(n){var t={};function r(e){if(t[e])return t[e].exports;var u=t[e]={i:e,l:!1,exports:{}};return n[e].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=n,r.c=t,r.d=function(n,t,e){r.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:e})},r.r=function(n){Object.defineProperty(n,\"__esModule\",{value:!0})},r.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(t,\"a\",t),t},r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.p=\"\",r(r.s=0)}([function(n,t,r){\"use strict\";function e(n){if(!(this instanceof e))return new e(n);this._=n}var u=e.prototype;function o(n,t){for(var r=0;r>7),buf:function(n){var t=i(function(n,t,r,e){return n.concat(r===e.length-1?Buffer.from([t,0]).readUInt16BE(0):e.readUInt16BE(r))},[],n);return Buffer.from(a(function(n){return(n<<1&65535)>>8},t))}(r.buf)}}),r}function c(){return\"undefined\"!=typeof Buffer}function s(){if(!c())throw new Error(\"Buffer global does not exist; please use webpack if you need to parse Buffers in the browser.\")}function l(n){s();var t=i(function(n,t){return n+t},0,n);if(t%8!=0)throw new Error(\"The bits [\"+n.join(\", \")+\"] add up to \"+t+\" which is not an even number of bytes; the total should be divisible by 8\");var r,u=t/8,o=(r=function(n){return n>48},i(function(n,t){return n||(r(t)?t:n)},null,n));if(o)throw new Error(o+\" bit range requested exceeds 48 bit (6 byte) Number max.\");return new e(function(t,r){var e=u+r;return e>t.length?x(r,u.toString()+\" bytes\"):b(e,i(function(n,t){var r=f(t,n.buf);return{coll:n.coll.concat(r.v),buf:r.buf}},{coll:[],buf:t.slice(r,e)},n).coll)})}function h(n,t){return new e(function(r,e){return s(),e+t>r.length?x(e,t+\" bytes for \"+n):b(e+t,r.slice(e,e+t))})}function p(n,t){if(\"number\"!=typeof(r=t)||Math.floor(r)!==r||t<0||t>6)throw new Error(n+\" requires integer length in range [0, 6].\");var r}function d(n){return p(\"uintBE\",n),h(\"uintBE(\"+n+\")\",n).map(function(t){return t.readUIntBE(0,n)})}function v(n){return p(\"uintLE\",n),h(\"uintLE(\"+n+\")\",n).map(function(t){return t.readUIntLE(0,n)})}function g(n){return p(\"intBE\",n),h(\"intBE(\"+n+\")\",n).map(function(t){return t.readIntBE(0,n)})}function m(n){return p(\"intLE\",n),h(\"intLE(\"+n+\")\",n).map(function(t){return t.readIntLE(0,n)})}function y(n){return n instanceof e}function E(n){return\"[object Array]\"==={}.toString.call(n)}function w(n){return c()&&Buffer.isBuffer(n)}function b(n,t){return{status:!0,index:n,value:t,furthest:-1,expected:[]}}function x(n,t){return E(t)||(t=[t]),{status:!1,index:-1,value:null,furthest:n,expected:t}}function B(n,t){if(!t)return n;if(n.furthest>t.furthest)return n;var r=n.furthest===t.furthest?function(n,t){if(function(){if(void 0!==e._supportsSet)return e._supportsSet;var n=\"undefined\"!=typeof Set;return e._supportsSet=n,n}()&&Array.from){for(var r=new Set(n),u=0;u=0;){if(i in r){e=r[i].line,0===o&&(o=r[i].lineStart);break}(\"\\n\"===n.charAt(i)||\"\\r\"===n.charAt(i)&&\"\\n\"!==n.charAt(i+1))&&(u++,0===o&&(o=i+1)),i--}var a=e+u,f=t-o;return r[t]={line:a,lineStart:o},{offset:t,line:a+1,column:f+1}}function _(n){if(!y(n))throw new Error(\"not a parser: \"+n)}function L(n,t){return\"string\"==typeof n?n.charAt(t):n[t]}function O(n){if(\"number\"!=typeof n)throw new Error(\"not a number: \"+n)}function k(n){if(\"function\"!=typeof n)throw new Error(\"not a function: \"+n)}function P(n){if(\"string\"!=typeof n)throw new Error(\"not a string: \"+n)}var q=2,A=3,I=8,F=5*I,M=4*I,z=\" \";function R(n,t){return new Array(t+1).join(n)}function U(n,t,r){var e=t-n.length;return e<=0?n:R(r,e)+n}function W(n,t,r,e){return{from:n-t>0?n-t:0,to:n+r>e?e:n+r}}function D(n,t){var r,e,u,o,f,c=t.index,s=c.offset,l=1;if(s===n.length)return\"Got the end of the input\";if(w(n)){var h=s-s%I,p=s-h,d=W(h,F,M+I,n.length),v=a(function(n){return a(function(n){return U(n.toString(16),2,\"0\")},n)},function(n,t){var r=n.length,e=[],u=0;if(r<=t)return[n.slice()];for(var o=0;o=4&&(r+=1),l=2,u=a(function(n){return n.length<=4?n.join(\" \"):n.slice(0,4).join(\" \")+\" \"+n.slice(4).join(\" \")},v),(f=(8*(o.to>0?o.to-1:o.to)).toString(16).length)<2&&(f=2)}else{var g=n.split(/\\r\\n|[\\n\\r\\u2028\\u2029]/);r=c.column-1,e=c.line-1,o=W(e,q,A,g.length),u=g.slice(o.from,o.to),f=o.to.toString().length}var m=e-o.from;return w(n)&&(f=(8*(o.to>0?o.to-1:o.to)).toString(16).length)<2&&(f=2),i(function(t,e,u){var i,a=u===m,c=a?\"> \":z;return i=w(n)?U((8*(o.from+u)).toString(16),f,\"0\"):U((o.from+u+1).toString(),f,\" \"),[].concat(t,[c+i+\" | \"+e],a?[z+R(\" \",f)+\" | \"+U(\"\",r,\" \")+R(\"^\",l)]:[])},[],u).join(\"\\n\")}function N(n,t){return[\"\\n\",\"-- PARSING FAILED \"+R(\"-\",50),\"\\n\\n\",D(n,t),\"\\n\\n\",(r=t.expected,1===r.length?\"Expected:\\n\\n\"+r[0]:\"Expected one of the following: \\n\\n\"+r.join(\", \")),\"\\n\"].join(\"\");var r}function G(n){return void 0!==n.flags?n.flags:[n.global?\"g\":\"\",n.ignoreCase?\"i\":\"\",n.multiline?\"m\":\"\",n.unicode?\"u\":\"\",n.sticky?\"y\":\"\"].join(\"\")}function C(){for(var n=[].slice.call(arguments),t=n.length,r=0;r=2?O(t):t=0;var r=function(n){return RegExp(\"^(?:\"+n.source+\")\",G(n))}(n),u=\"\"+n;return e(function(n,e){var o=r.exec(n.slice(e));if(o){if(0<=t&&t<=o.length){var i=o[0],a=o[t];return b(e+i.length,a)}return x(e,\"valid match group (0 to \"+o.length+\") in \"+u)}return x(e,u)})}function X(n){return e(function(t,r){return b(r,n)})}function Y(n){return e(function(t,r){return x(r,n)})}function Z(n){if(y(n))return e(function(t,r){var e=n._(t,r);return e.index=r,e.value=\"\",e});if(\"string\"==typeof n)return Z(K(n));if(n instanceof RegExp)return Z(Q(n));throw new Error(\"not a string, regexp, or parser: \"+n)}function $(n){return _(n),e(function(t,r){var e=n._(t,r),u=t.slice(r,e.index);return e.status?x(r,'not \"'+u+'\"'):b(r,null)})}function nn(n){return k(n),e(function(t,r){var e=L(t,r);return r=n.length?x(t,\"any character/byte\"):b(t+1,L(n,t))}),on=e(function(n,t){return b(n.length,n.slice(t))}),an=e(function(n,t){return t=0}).desc(t)},e.optWhitespace=hn,e.Parser=e,e.range=function(n,t){return nn(function(r){return n<=r&&r<=t}).desc(n+\"-\"+t)},e.regex=Q,e.regexp=Q,e.sepBy=V,e.sepBy1=H,e.seq=C,e.seqMap=J,e.seqObj=function(){for(var n,t={},r=0,u=(n=arguments,Array.prototype.slice.call(n)),o=u.length,i=0;i255)throw new Error(\"Value specified to byte constructor (\"+n+\"=0x\"+n.toString(16)+\") is larger in value than a single byte.\");var t=(n>15?\"0x\":\"0x0\")+n.toString(16);return e(function(r,e){var u=L(r,e);return u===n?b(e+1,u):x(e,t)})},buffer:function(n){return h(\"buffer\",n).map(function(n){return Buffer.from(n)})},encodedString:function(n,t){return h(\"string\",t).map(function(t){return t.toString(n)})},uintBE:d,uint8BE:d(1),uint16BE:d(2),uint32BE:d(4),uintLE:v,uint8LE:v(1),uint16LE:v(2),uint32LE:v(4),intBE:g,int8BE:g(1),int16BE:g(2),int32BE:g(4),intLE:m,int8LE:m(1),int16LE:m(2),int32LE:m(4),floatBE:h(\"floatBE\",4).map(function(n){return n.readFloatBE(0)}),floatLE:h(\"floatLE\",4).map(function(n){return n.readFloatLE(0)}),doubleBE:h(\"doubleBE\",8).map(function(n){return n.readDoubleBE(0)}),doubleLE:h(\"doubleLE\",8).map(function(n){return n.readDoubleLE(0)})},n.exports=e}])});","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2018-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {alt, lazy, of, optWhitespace, regex, seq, seqMap, string} from 'parsimmon';\nimport {int} from './CmnLib';\nimport {IPropParser, IVariable} from './CmnInterface';\n\ninterface IFncCalc { (a: any[]): any;}\ninterface IHFncCalc { [key: string]: IFncCalc; }\n\nexport class PropParser implements IPropParser {\n\t#parser: any = null;\n\n\tconstructor(private readonly val: IVariable, ce = '\\\\') {\n\t\tfunction ope(a: (string | RegExp)[]) {\n\t\t\tconst ps: any = [];\n\t\t\tfor (const v of a) ps.push(\n\t\t\t\t((typeof v === 'string') ?string(v) :regex(v))\n\t\t\t\t.trim(optWhitespace)\n\t\t\t);\n\t\t\treturn alt.apply(null, ps);\n\t\t}\n\t\tfunction opeH(ops: {[name: string]: string | RegExp}) {\n\t\t\tlet keys = Object.keys(ops).sort();\n\t\t\tlet ps = keys.map(k=>\n\t\t\t\t((typeof ops[k] === 'string')\n\t\t\t\t\t? string(ops[k] as string) :regex(ops[k] as RegExp))\n\t\t\t\t.trim(optWhitespace)\n\t\t\t\t.result(k)\n\t\t\t);\n\t\t\treturn alt.apply(null, ps);\n\t\t}\n\n\t\tfunction PREFIX(operatorsParser: any, nextParser: any) {\n\t\t\tconst parser: any = lazy(()=> seq(operatorsParser, parser).or(nextParser));\n\t\t\treturn parser;\n\t\t}\n\t\tfunction POSTFIX(operatorsParser: any, nextParser: any) {\n\t\t\treturn seqMap(nextParser, operatorsParser.many(), (x, suffixes: any)=> suffixes.reduce((acc: any, x: any) => [x, acc], x));\n\t\t}\n\n\t\t// right. (e.g. 1^2^3 is 1^(2^3) not (1^2)^3)\n\t\tfunction BINARY_RIGHT(operatorsParser: any, nextParser: any) {\n\t\t\tlet parser = lazy(\n\t\t\t\t()=> nextParser.chain(\n\t\t\t\t\t(next: any)=> seq(\n\t\t\t\t\t\toperatorsParser,\n\t\t\t\t\t\tof(next),\n\t\t\t\t\t\tparser\n\t\t\t\t\t).or(of(next))\n\t\t\t\t)\n\t\t\t);\n\t\t\treturn parser;\n\t\t}\n\n\t\t// left. (e.g. 1-2-3 is (1-2)-3 not 1-(2-3))\n\t\tfunction BINARY_LEFT(operatorsParser: any, nextParser: any) {\n\t\t\treturn seqMap(\n\t\t\t\tnextParser,\n\t\t\t\tseq(operatorsParser, nextParser).many(),\n\t\t\t\t(first, rest)=> rest.reduce((acc, ch)=> [ch[0], acc, ch[1]], first)\n\t\t\t);\n\t\t}\n\n\t\tconst Num = alt(\n\t\t\talt(\n\t\t\t\tregex(/-?(0|[1-9][0-9]*)\\.[0-9]+/),\n\t\t\t\tregex(/0x[0-9a-fA-F]+/)\n\t\t\t).map(Number),\n\t\t\talt(\n\t\t\t\tregex(/-?(0|[1-9][0-9]*)/)\n\t\t\t).map(n=> int(n))\n\t\t)\n\t\t.map(str=> ['!num!', str])\n\t\t.desc('number');\n\n\t\tconst NullLiteral = string('null')\n\t\t.map(()=> ['!str!', null]);\n\n\t\tconst BooleanLiteral = regex(/(true|false)/)\n\t\t.map(b=> ['!bool!', b === 'true'])\n\t\t.desc('boolean');\n\n\t\tconst StringLiteral = regex(new RegExp(`(?:\"(?:\\\\${ce}[\"'#\\\\n]|[^\"])*\"|'(?:\\\\${ce}[\"'#\\\\n]|[^'])*'|\\\\#(?:\\\\${ce}[\"'#\\\\n]|[^#])*\\\\#)`))\n\t\t\t// https://regex101.com/r/Fs5wL3/1\n\t\t\t// 15 matches (279 steps, 0.1ms) by PCRE2\n\t\t.map(b=> ['!str!', b.slice(1, -1).replaceAll(ce, '')])\n\t\t.desc('string');\n\n\t\tconst REG_BRACKETS = /\\[[^\\]]+\\]/g;\n\t\tconst VarLiteral = regex(/-?(?:(?:tmp|sys|save|mp):)?[^\\s!-\\/:-@[-^`{-~]+(?:\\.[^\\s!-\\/:-@[-^`{-~]+|\\[[^\\]]+\\])*(?:@str)?/)\n\t\t.map(b=> {\n\t\t\t//console.log(' 👺 VarLiteral:0 b:%O:', b);\n\t\t\tconst s = String(b).replaceAll(REG_BRACKETS, v=>\n\t\t\t\t'.'+ this.parse(v.slice(1, -1))\n\t\t\t);\n\t\t\tconst val = this.val.getVal(s);\n\t\t\t//console.log(' 👹 s:%O: val:%O:', s, val);\n\t\t\tif (val == null) return ['!str!', val];\t\t// undefined も\n\t\t\tif (typeof val === 'boolean') return ['!bool!', val];\n\n\t\t\treturn (Object.prototype.toString.call(val) === '[object String]')\n\t\t\t\t? ['!str!', String(val)]\n\t\t\t\t: ['!num!', Number(val)];\n\t\t})\n\t\t.desc('string');\n\n\t\tconst Basic = lazy(()=> \n\t\t\tstring('(').then(this.#parser).skip(string(')'))\n\t\t\t.or(Num)\n\t\t\t.or(NullLiteral)\n\t\t\t.or(BooleanLiteral)\n\t\t\t.or(StringLiteral)\n\t\t\t.or(VarLiteral)\n\t\t);\n\n\t\tconst table = [\n\t\t\t// 演算子の優先順位 - JavaScript | MDN https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Operator_precedence\n\t\t\t// 優先順位:18(メンバーへのアクセス、計算値によるメンバーへのアクセス)\n\t\t\t\t// a.b a[b]\n\t\t\t{type: PREFIX, ops: ope([/[A-Za-z_][A-Za-z0-9_]*(?=\\()/])},\n\n\t\t\t// 優先順位:16\n\t\t\t{type: POSTFIX, ops: opeH({PostfixInc: '++'})},\n\t\t\t{type: POSTFIX, ops: opeH({PostfixDec: '--'})},\n\t\t\t\t// 【未サポート】後置インクリメント・デクリメント\n\t\t\t// 優先順位:15\n\t\t\t{type: PREFIX, ops: ope([/!(?!=)|~/])},\t// 論理 NOT (!)、ビット単位 NOT (~)\n\t\t\t{type: PREFIX, ops: opeH({PrefixInc: '++'})},\n\t\t\t{type: PREFIX, ops: opeH({PrefixDec: '--'})},\n\t\t\t\t// 【未サポート】前置インクリメント・デクリメント\n\t\t//\t{type: PREFIX, ops: opeH({Unaryplus: /\\+(?!\\+)/})},\t// 単項プラス\n\t\t\t{type: PREFIX, ops: opeH({UnaryNegate: /-(?!-)/})},\t// 単項マイナス\n\n\t\t\t// 優先順位:14以下(並びに注意)\n\t\t\t{type: BINARY_RIGHT, ops: ope(['**'])},\n\t\t\t{type: BINARY_LEFT, ops: ope(['*', '/', '¥', '%'])},\n\t\t\t{type: BINARY_LEFT, ops: ope(['+', '-'])},\n\t\t\t{type: BINARY_LEFT, ops: ope([/>>>|<<|>>/])},\n\t\t\t{type: BINARY_LEFT, ops: ope([/<=|<|>=|>/])},\n\t\t\t{type: BINARY_LEFT, ops: ope([/===|!==|==|!=/])},\n\t\t\t{type: BINARY_LEFT, ops: ope([/&(?!&)/])},\n\t\t\t{type: BINARY_LEFT, ops: ope(['^'])},\n\t\t\t{type: BINARY_LEFT, ops: ope([/\\|(?!\\|)/])},\n\t\t\t{type: BINARY_LEFT, ops: ope(['&&'])},\n\t\t\t{type: BINARY_LEFT, ops: ope(['||'])},\n\t\t\t{type: BINARY_RIGHT, ops: ope([':'])},\n\t\t\t{type: BINARY_RIGHT, ops: ope(['?'])},\n\t\t];\n\n\t\tconst tableParser = table.reduce(\n\t\t\t(acc, level)=> level.type(level.ops, acc),\n\t\t\tBasic\n\t\t);\n\t\tthis.#parser = tableParser.trim(optWhitespace);\n\t}\n\n\tparse(s: string): any {\n\t\t//console.log(\"🌱 Parsimmon'%s'\", s);\n\t\tconst p = this.#parser.parse(s);\n\t\tif (! p.status) throw Error('(PropParser)文法エラー【'+ s +'】');\n\n\t\tconst a = p.value;\n\t\tif (a[0] === '!str!') return this.#procEmbedVar(a[1]);\n\n\t\treturn this.#calc(a);\n\t}\n\t#calc(a: any[]): object {\n\t\t//console.log('🌷 calc%O', {...a});\n\t\tconst elm = a.shift();\n\t\tif (elm instanceof Array) return this.#calc(elm);\n\n\t\tconst fnc = this.#hFnc[elm];\n\t\treturn (fnc) ?fnc(a) :Object(null);\n\t}\n\t#hFnc: IHFncCalc = {\n\t\t'!num!': a=> a.shift(),\n\t\t'!str!': a=> this.#procEmbedVar(a.shift()),\n\t\t'!bool!':a=> a.shift(),\n\n\t\tPostfixInc:\t_=> {throw Error('(PropParser)後置インクリメントは未サポートです')},\n\t\tPostfixDec:\t_=> {throw Error('(PropParser)後置デクリメントは未サポートです')},\n\t\tPrefixInc:\t_=> {throw Error('(PropParser)前置インクリメントは未サポートです')},\n\t\tPrefixDec:\t_=> {throw Error('(PropParser)前置デクリメントは未サポートです')},\n\n\t\t// 論理 NOT\n\t\t'!':\ta=> ! this.#hFnc['Boolean'](a),\n\t\t// チルダ演算子(ビット反転)\n\t\t'~':\ta=> ~ Number(this.#calc(a.shift())),\n\n//\t\tUnaryNegate:\ta=> - Number(this.#calc(a.shift())),\n\t\tUnaryNegate:\ta=> - this.#hFnc['Number'](a),\n\t//\tUnaryplus:\t\ta=> this.#hFnc['Number'](a),\n\n\t\t// 乗算、除算、剰余\n\t\t'**':\ta=> Number(this.#calc(a.shift())) **\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\t\t'*':\ta=> Number(this.#calc(a.shift())) *\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\t\t'/':\ta=> Number(this.#calc(a.shift())) /\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\t\t'¥':\ta=> Math.floor( this.#hFnc['/'](a) ),\n\t\t'%':\ta=> Number(this.#calc(a.shift())) %\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\n\t\t// 加算、減算、文字列の連結\n\t\t'+':\ta=> {\n\t\t\tconst b = this.#calc(a.shift());\n\t\t\tconst c = this.#calc(a.shift());\n\t\t\treturn (Object.prototype.toString.call(b) === '[object String]'\n\t\t\t\t|| Object.prototype.toString.call(c) === '[object String]')\n\t\t\t\t\t? String(b) + String(c) : Number(b) + Number(c);\n\t\t},\n\t\t'-':\ta=> Number(this.#calc(a.shift())) -\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\n\t\t// 関数\n\t\t'int':\t\ta=> int(this.#fncSub_ChkNum(a.shift())),\n\t\t'parseInt':\ta=> int(this.#hFnc['Number'](a)),\n\t\t'Number':\ta=> {\n\t\t\tconst b = this.#calc(a.shift());\n\t\t\treturn Object.prototype.toString.call(b) === '[object String]'\n\t\t\t\t? this.#fncSub_ChkNum(this.#parser.parse(String(b)).value)\n\t\t\t\t: Number(b);\n\t\t},\n\t\t'Boolean':\ta=> {\n\t\t\tconst b = a.shift();\n\t\t\treturn (b[0] === '!bool!')\n\t\t\t\t? Boolean( b[1] )\n\t\t\t\t: Boolean(this.#calc(b));\n\t\t},\n\t\t'ceil':\t\ta=> Math.ceil( this.#fncSub_ChkNum(a.shift()) ),\n\t\t'floor':\ta=> Math.floor( this.#fncSub_ChkNum(a.shift()) ),\n\t\t'round':\ta=> Math.round( this.#fncSub_ChkNum(a.shift()) ),\n\t\t'isNaN':\ta=> Number.isNaN( this.#fncSub_ChkNum(a.shift()) ),\n\n\t\t// ビットシフト\n\t\t'<<':\ta=> Number(this.#calc(a.shift())) <<\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\t\t'>>':\ta=> Number(this.#calc(a.shift())) >>\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\t\t'>>>':\ta=> Number(this.#calc(a.shift())) >>>\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\n\t\t// 等値、非等値、厳密等価、厳密非等価\n\t\t'<':\ta=> Number(this.#calc(a.shift())) <\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\t\t'<=':\ta=> Number(this.#calc(a.shift())) <=\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\t\t'>':\ta=> Number(this.#calc(a.shift())) >\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\t\t'>=':\ta=> Number(this.#calc(a.shift())) >=\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\n\t\t// 小なり、以下、大なり、以上\n\t\t'==':\ta=> {\n\t\t\tconst b = this.#calc(a.shift());\n\t\t\tconst c = this.#calc(a.shift());\n\t\t\treturn ((b == null) && (c == null) && (!b || !c))\n\t\t\t\t? (b == c) : String(b) === String(c);\n\t\t},\n\t\t'!=':\ta=> ! this.#hFnc['=='](a),\n\t\t'===':\ta=> {\n\t\t\tconst b = this.#calc(a.shift());\n\t\t\tconst c = this.#calc(a.shift());\n\t\t\treturn (Object.prototype.toString.call(b) !=\n\t\t\t\t\tObject.prototype.toString.call(c))\n\t\t\t\t\t? false : String(b) === String(c);\n\t\t},\n\t\t'!==':\ta=> ! this.#hFnc['==='](a),\n\n\t\t// ビット演算子\n\t\t'&':\ta=> Number(this.#calc(a.shift())) &\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\t\t'^':\ta=> Number(this.#calc(a.shift())) ^\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\t\t'|':\ta=> Number(this.#calc(a.shift())) |\n\t\t\t\t\tNumber(this.#calc(a.shift())),\n\n\t\t// 論理 AND,OR\n\t\t'&&':\ta=> (String(this.#calc(a.shift())) === 'true') &&\n\t\t\t\t\t(String(this.#calc(a.shift())) === 'true'),\n\t\t'||':\ta=> (String(this.#calc(a.shift())) === 'true') ||\n\t\t\t\t\t(String(this.#calc(a.shift())) === 'true'),\n\n\t\t// 条件\n\t\t'?':\ta=> {\n\t\t\tconst cond = this.#hFnc['Boolean'](a);\n\t\t\tconst elm2 = a.shift();\n\t\t\tif (elm2[0] !== ':') throw Error('(PropParser)三項演算子の文法エラーです。: が見つかりません');\n\n\t\t\treturn this.#calc(elm2[cond ?1 :2]);\n\t\t},\n\t\t':':\t()=> {throw Error('(PropParser)三項演算子の文法エラーです。? が見つかりません')},\n\t}\n\t#fncSub_ChkNum(v: any[]): number {\n\t\tconst b = this.#calc(v);\n\t\tif (Object.prototype.toString.call(b) !== '[object Number]') throw Error('(PropParser)引数【'+ b +'】が数値ではありません');\n\t\treturn Number(b);\n\t}\n\n\treadonly #REG_EMBEDVAR\n\t\t= /(\\$((tmp|sys|save|mp):)?[^\\s!--\\/:-@[-^`{-~]+|\\#\\{[^\\}]+})/g;\n\t#procEmbedVar(b: object): any {\n\t\tif (b == null) return b;\t// undefined も\n\n\t\treturn String(b).replaceAll(\n\t\t\tthis.#REG_EMBEDVAR,\n\t\t\tv=> (v.at(0) === '$')\n\t\t\t\t? this.val.getVal(v.slice(1))\n\t\t\t\t: this.parse(v.slice(2, -1))\n\t\t);\n\t}\n\n\n\tgetValAmpersand = (val: string)=> (val.at(0) === '&')\n\t\t? String(this.parse(val.slice(1)))\n\t\t: val;\n\n\n\tstatic\treadonly\t#REG_VAL\n\t\t= /^((?\\w+?):)?(?[^\\s :@]+)(?\\@str)?$/;\n\t\t// 522 match 18413 step(~10ms) https://regex101.com/r/tmCKuE/1\n\t\t\t// →これは改良しようがない。いい意味で改善の余地なし\n\tstatic\tgetValName(arg_name: string): {[name: string]: string} | null {\n\t\tconst e = this.#REG_VAL.exec(arg_name.trim());\n\t\tconst g = e?.groups;\n\t\tif (! g) return null;\n\n\t\tconst {scope='tmp', name, at=''} = g;\n\t\treturn {\n\t\t\tscope,\n\t\t\tname\t: PropParser.#getValName_B2D(name),\n\t\t\tat,\n\t\t};\n\t}\n\n\tstatic\t#getValName_B2D(str: string): string {\n\t\tlet i = 0, e = 0;\n\t\twhile (true) {\n\t\t\ti = str.indexOf('[\"');\n\t\t\tif (i < 0) {\n\t\t\t\ti = str.indexOf(\"['\");\n\t\t\t\tif (i < 0) break;\n\n\t\t\t\te = str.indexOf(\"']\", i+2);\n\t\t\t}\n\t\t\telse {\n\t\t\t\te = str.indexOf('\"]', i+2);\n\t\t\t}\n\t\t\tif (e < 0) break;\n\n\t\t\tstr = str.slice(0, i) +'.'+ str.slice(i+2, e)\n\t\t\t\t+ str.slice(e+2);\n\t\t\ti = e-2;\t// -3+1\n\t\t}\n\n\t\treturn str;\n\t}\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2018-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {CmnLib, getDateStr} from './CmnLib';\nimport {HArg, ITag, IHTag} from './Grammar';\nimport {SysBase} from './SysBase';\nimport {ScriptIterator} from './ScriptIterator';\n\nimport platform from 'platform';\n\nexport class DebugMng {\n\tstatic\t#scrItr\t: ScriptIterator;\n\tstatic\t#hTag\t: IHTag;\n\tstatic\t#title\t: ITag;\n\tstatic\t#spnDbg\t: HTMLSpanElement;\n\n\tconstructor(private readonly sys: SysBase, hTag: IHTag, scrItr: ScriptIterator) {\n\t\tDebugMng.#scrItr = scrItr;\n\t\tDebugMng.#hTag = hTag;\n\t\tDebugMng.#title = hTag.title;\n\t\tDebugMng.myTrace = DebugMng.#st_trace;\n\n\t\t//\tデバッグ・その他\n\t\t//hTag.clearsysvar\t// Variableで定義\t\t\t\t// システム変数の全消去\n\t\t//hTag.clearvar\t\t// Variableで定義\t\t\t\t// ゲーム変数の全消去\n\t\t//hTag.dump_lay\t\t// LayerMngで定義\t\t\t\t// レイヤのダンプ\n\t\t//hTag.dump_val\t\t// Variableで定義\t\t\t\t// 変数のダンプ\n\t\t//hTag.dump_stack\t// ScriptIteratorで定義\t\t\t// スタックのダンプ\n\t\thTag.log\t\t\t= o=> this.#log(o);\t\t\t\t// ログ出力\n\t\t//hTag.reload_script// ScriptIterator.ts内で定義\t// スクリプト再読込\n\t\thTag.trace\t\t\t= o=> this.#trace(o);\t\t\t// デバッグ表示へ出力\n\n\t\tDebugMng.#spnDbg = document.createElement('span');\n\t\tDebugMng.#spnDbg.hidden = true;\n\t\tDebugMng.#spnDbg.textContent = '';\n\t\tDebugMng.#spnDbg.style.cssText =\n\t\t`\tz-index: ${Number.MAX_SAFE_INTEGER};\n\t\t\tposition: absolute; left: 0; top: 0;\n\t\t\tcolor: black;\n\t\t\tbackground-color: rgba(255, 255, 255, 0.7);`\n\t\tdocument.body.appendChild(DebugMng.#spnDbg);\n\t}\n\tdestroy() {\n\t\tDebugMng.#title = ()=> false;\n\t\tdocument.body.removeChild(DebugMng.#spnDbg);\n\n\t\tDebugMng.myTrace = DebugMng.trace_beforeNew;\n\t}\n\n\t// ログ出力\n\t#first = true;\n\t#log(hArg: HArg) {\n\t\tlet dat = '';\n\t\tif (this.#first) {\n\t\t\tthis.#first = false;\n\t\t\tdat = `== ${platform.description} ==\\n`;\n\t\t}\n\t\tthis.sys.appendFile(\n\t\t\tthis.sys.path_downloads +'log.txt',\n\t\t\t`${dat}--- ${getDateStr('-', '_', '')\n\t\t\t} [fn:${DebugMng.#scrItr.scriptFn} line:${DebugMng.#scrItr.lineNum\n\t\t\t}] prj:${this.sys.cur\n\t\t\t}\\n${hArg.text || `(text is ${hArg.text})`}\\n`,\n\t\t);\n\n\t\treturn false;\n\t}\n\n\t#trace(hArg: HArg) {\n\t\tDebugMng.myTrace(hArg.text || `(text is ${hArg.text})`, 'I');\n\n\t\treturn false;\n\t}\n\n\t// private禁止、galleryでエラーになる\n\tstatic trace_beforeNew(txt: string, lvl: 'D'|'W'|'F'|'E'|'I'|'ET' = 'E') {\n\t\tlet mes = `{${lvl}} `+ txt;\n\t\tlet sty = '';\n\t\tswitch (lvl) {\n\t\t\tcase 'D':\tsty = `color:#${CmnLib.isDarkMode ?'49F' :'05A'};`;\tbreak;\n\t\t\tcase 'W':\tsty = 'color:#FF8800;';\tbreak;\n\t\t\tcase 'F':\tsty = 'color:#BB0000;';\tbreak;\n\t\t\tcase 'ET':\tthrow mes;\n\t\t\tcase 'E':\tconsole.error('%c'+ mes, 'color:#FF3300;');\treturn;\n\t\t\tdefault:\tsty = 'color:black;';\tmes = ' '+ mes;\n\t\t}\n\t\tconsole.info('%c'+ mes, sty);\n\t}\n\tstatic myTrace = DebugMng.trace_beforeNew;\n\tstatic strPos = ()=> DebugMng.#scrItr.lineNum > 0\n\t\t? `(fn:${DebugMng.#scrItr.scriptFn} line:${DebugMng.#scrItr.lineNum}) `\n\t\t: '';\n\tstatic #st_trace(txt: string, lvl: 'D'|'W'|'F'|'E'|'I'|'ET' = 'E') {\n\t\tlet mes = `{${lvl}} `+ DebugMng.strPos() + txt;\n\t\tDebugMng.#dspDbg(mes, lvl);\n\n\t\tlet sty = '';\n\t\tswitch (lvl) {\n\t\t\tcase 'D':\tsty = `color:#${CmnLib.isDarkMode ?'49F' :'05A'};`;\tbreak;\n\t\t\tcase 'W':\tsty = 'color:#F80;';\tbreak;\n\t\t\tcase 'F':\tsty = 'color:#B00;';\tbreak;\n\t\t\tcase 'ET':\n\t\t\tcase 'E':\tDebugMng.#title({text: txt});\n\t\t\t\t/*if (CmnLib.osName === \"AND\") {\n\t\t\t\t\tconst buf = \"mailto:foo@hoge.co.jp\"\n\t\t\t\t\t\t+ \"?subject=AIRNovel_ERR&body=\"\n\t\t\t\t\t\t+ CmnLib.escapeZenkaku(mes) + \"\\n\"\n\t\t\t\t\t\t+ \"※一部記号は全角表示しています。\";\n\t\t\t\t\tflash.net.navigateToURL(new URLRequest(buf));\n\t\t\t\t}*/\n\t\t\t\tthis.#hTag.dump_lay({});\n\t\t\t\tthis.#hTag.dump_val({});\n\t\t\t\tDebugMng.#scrItr.dumpErrForeLine();\n\t\t\t\tthis.#hTag.dump_stack({});\n\n\t\t\t\tif (lvl === 'ET') throw mes;\n\t\t\t\tconsole.error('%c'+ mes, 'color:#F30;');\treturn;\n\t\t\tdefault:\tsty = '';\tmes = ' '+ mes;\n\t\t}\n\t\tconsole.info('%c'+ mes, sty);\n\t}\n\n\tstatic\t#dspDbg(mes: string, lvl: 'D'|'W'|'F'|'E'|'I'|'ET') {\n\t\tlet sty = '';\n\t\tswitch (lvl) {\n\t\t\tcase 'D':\tsty = 'color:#05A;';\tbreak;\n\t\t\tcase 'W':\tsty = 'color:#F80;';\tbreak;\n\t\t\tcase 'F':\tsty = 'color:#B00;';\tbreak;\n\t\t\tcase 'ET':\n\t\t\tcase 'E':\tsty = 'color:#F30;';\tbreak;\n\t\t\tdefault:\tsty = '';\n\t\t}\n\t\tDebugMng.#spnDbg.innerHTML += `${mes}
`;\n\t\tDebugMng.#spnDbg.hidden = false;\n\t};\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2018-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {IAreas} from './CmnInterface';\n\nexport class Areas implements IAreas {\n\thAreas\t: {[name: string]: number}\t= Object.create(null);\n\n\tclear() {this.hAreas = {}}\n\n\tsearch(idx: number): boolean {\n\t\treturn Object.entries(this.hAreas)\n\t\t.some(([begin, v])=> (idx >= parseInt(begin) && idx <= v));\n\t}\n\n\trecord(idx: number): void {\n\t\tif (this.search(idx)) return;\n\n\t\tfor (const [begin, v] of Object.entries(this.hAreas)) {\n\t\t\t// 領域末尾+1とマッチ\n\t\t\tif (v +1 === idx) {\n\t\t\t\tif (String(idx +1) in this.hAreas) {\n\t\t\t\t\t// 二つの領域がマージできる場合\n\t\t\t\t\tthis.hAreas[begin] = this.hAreas[idx +1];\n\t\t\t\t\tdelete this.hAreas[idx +1]\n\t\t\t\t}\n\t\t\t\telse this.hAreas[begin] = idx;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// 領域先頭-1とマッチ\n\t\tif (String(idx +1) in this.hAreas) {\n\t\t\tthis.hAreas[idx] = this.hAreas[idx +1];\n\t\t\tdelete this.hAreas[idx +1];\n\t\t\treturn;\n\t\t}\n\n\t\tthis.hAreas[idx] = idx;\n\t}\n\n\terase(idx: number): void {\n\t\tif (! this.search(idx)) return;\n\n\t\t// 領域先頭とマッチ\n\t\tif (String(idx) in this.hAreas) {\n\t\t\tif (this.hAreas[idx] > idx) this.hAreas[idx +1] = this.hAreas[idx];\n\t\t\tdelete this.hAreas[idx];\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const [begin, v] of Object.entries(this.hAreas)) {\n\t\t\tif (idx < parseInt(begin) || v < idx) continue;\n\n\t\t\t// 領域末尾とマッチ\n\t\t\tif (this.hAreas[begin] === idx) {\n\t\t\t\tthis.hAreas[begin] = idx -1;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// 領域内とマッチ、二つの領域に分割\n\t\t\tthis.hAreas[idx +1] = v;\n\t\t\tthis.hAreas[begin] = idx -1;\n\t\t\treturn;\n\t\t}\n\t}\n\n\tget count(): number {return Object.keys(this.hAreas).length}\t// 4tst\n\n\ttoString(): string {\n\t\tlet ret = '';\n\n\t\tfor (const k of Object.keys(this.hAreas)\n\t\t.map(k=> parseInt(k))\n\t\t.sort((x, y)=> x-y)) {\n\t\t\tret += k === this.hAreas[k]\n\t\t\t? ','+ k\n\t\t\t: ','+ k +'~'+ this.hAreas[k];\n\t\t}\n\n\t\treturn ret;\t// 先頭に , が付いている。削除したいが、修正すると互換性に問題あり凍結\n\t}\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2018-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {uint, int, getDateStr, argChk_Boolean, argChk_Num} from './CmnLib';\nimport {HArg, IHTag} from './Grammar';\nimport {IVariable, ISetVal, typeProcVal, ISysBase, IData4Vari, IMark, IFncHook, IValMp, Scope} from './CmnInterface';\nimport {Config} from './Config';\nimport {Areas} from './Areas';\nimport {PropParser} from './PropParser';\n\nimport platform from 'platform';\n\nexport class Variable implements IVariable {\n\t#hScopes\t: {[name: string]: any}\t= {sys:{}, save:{}, tmp:{}, mp:{}};\n\t#hSave\t: any\t= this.#hScopes.save;\n\t#hTmp\t: any\t= this.#hScopes.tmp;\n\n\n\tconstructor(private readonly cfg: Config, hTag: IHTag) {\n\t\t//\t変数操作\n\t\thTag.let\t\t\t= o=> this.#let(o);\t\t\t// 変数代入・演算\n\t\thTag.let_abs\t\t= o=> this.#let_abs(o);\t\t// 絶対値\n\t\thTag.let_char_at\t= o=> this.#let_char_at(o);\t// 文字列から一字取りだし\n\t\thTag.let_index_of\t= o=> this.#let_index_of(o);\t// 文字列で検索\n\t\thTag.let_length\t\t= o=> this.#let_length(o);\t// 文字列の長さ\n\t\t// let_mlはScriptIteratorにて定義\t\t\t\t// インラインテキスト代入\n\t\thTag.let_replace\t= o=> this.#let_replace(o);\t// 正規表現で置換\n\t\thTag.let_round\t\t= o=> this.#let_round(o);\t// 四捨五入\n\t\thTag.let_search\t\t= o=> this.#let_search(o);\t// 正規表現で検索\n\t\thTag.let_substr\t\t= o=> this.#let_substr(o);\t// 文字列から抜きだし\n\n\t\t//\tデバッグ・その他\n\t\thTag.clearsysvar\t= ()=> this.#clearsysvar();\t// システム変数の全消去\n\t\thTag.clearvar\t\t= ()=> this.#clearvar();\t\t// ゲーム変数の全消去\n\t\thTag.dump_val\t\t= ()=> this.#dump_val();\t\t// 変数のダンプ\n\n\t\t// しおり\n\t\thTag.copybookmark\t= o=> this.#copybookmark(o);\t// しおりの複写\n\t\thTag.erasebookmark\t= o=> this.#erasebookmark(o);// しおりの消去\n\t\t//hTag.load\t\t\t// ScriptIterator.ts内で定義\t// しおりの読込\n\t\t//hTag.record_place\t// ScriptIterator.ts内で定義\t// セーブポイント指定\n\t\t//hTag.save\t\t\t// ScriptIterator.ts内で定義\t// しおりの保存\n\n\t\t// save:\n\t\tthis.#hSave['sn.userFnTail']\t= '';\n\t\tthis.defTmp('const.sn.bookmark.json', ()=> {\n\t\t\tconst a: object[] = [];\n\t\t\tfor (const k of Object.keys(this.#data.mark).sort()) {\n\t\t\t\tconst o = {...this.#data.mark[k].json};\n\t\t\t\to.place = k;\n\t\t\t\ta.push(o);\t// パスを searchPath() で展開してはいけない\n\t\t\t}\n\t\t\treturn JSON.stringify(a);\n\t\t});\n\n\t\t// tmp:\n\t\tthis.#hTmp['const.sn.isFirstBoot'] = true;\n\n\t\tthis.#hTmp['const.sn.last_page_text'] = '';\n\t\tthis.#hTmp['const.sn.last_page_plain_text'] = '';\n\n\t\t//this.hTmp['const.sn.mouse.middle']\t// ScriptIterator で定義\n\n\t\t//this.hTmp['const.sn.vctCallStk.length']\t// ScriptIterator で定義\n\n/*\t\tthis.hTmp['const.Stage.supportsOrientationChange']\n\t\t\t= Stage.supportsOrientationChange;\n\t\tif (this.hTmp['const.Stage.supportsOrientationChange']) {\n\t\t\tthis.hTmp['const.Stage.orientation']\n\t\t\t\t= ()=> {return stage.orientation};\n\t\t\tthis.hTmp['const.Stage.deviceOrientation']\n\t\t\t\t= ()=> {return stage.deviceOrientation};\n\n\t\t\tconst lenSO:uint = stage.supportedOrientations.length;\n\t\t\tfor (let iSO:uint=0; iSO (new Date).getTime();\n\t\tthis.#hTmp['const.Date.getDateStr'] = ()=> getDateStr();\n\n\t\tthis.#hTmp['const.sn.platform'] = JSON.stringify(platform);\n\n\t\tthis.#clearsysvar();\n\t\tthis.#clearvar();\n\n\t\t// prj.json\n\t\tthis.#hTmp['const.sn.config.window.width'] = cfg.oCfg.window.width;\n\t\tthis.#hTmp['const.sn.config.window.height']= cfg.oCfg.window.height;\n\t\tthis.#hTmp['const.sn.config.book.title'] = cfg.oCfg.book.title;\n\t\tthis.#hTmp['const.sn.config.book.version'] = cfg.oCfg.book.version;\n\n\t\tthis.#hTmp['const.sn.Math.PI'] = Math.PI;\n\n\n\t\tif (typeof window === 'undefined') return;\n\t\tconst win: any = window;\n\t\tconst ac = win['AudioContext'] ?? win['webkitAudioContext'];\n\t\tthis.#hTmp['const.sn.needClick2Play'] = ()=> new ac().state === 'suspended';\n\t}\n\n\n\t#sys\t: ISysBase;\n\t#data\t: IData4Vari\t= {sys:{}, mark:{}, kidoku:{}};\n\t#hSys\t: any;\n\t#hAreaKidoku\t: {[name: string]: Areas}\t= {};\n\t#callHook\t\t: IFncHook;\n\tasync\tsetSys(sys: ISysBase) {\n\t\tthis.#sys = sys;\n\t\tawait sys.initVal(this.#data, this.#hTmp, data=> {\n\t\t\tthis.updateData(data);\n\n\t\t\tsessionStorage.clear();\n\t\t\tconst ns = this.cfg.getNs();\n\t\t\tthis.#flush = this.cfg.oCfg.debug.variable ?()=> {\n\t\t\t\tconst oSys: any = {};\n\t\t\t\tfor (const [k, v] of Object.entries(this.#hSys)) {\n\t\t\t\t\toSys['sys:'+ k] = (v instanceof Function) ?v(): v;\n\t\t\t\t}\n\t\t\t\tsessionStorage[ns +'sys'] = JSON.stringify(oSys);\n\n\t\t\t\tconst oSave: any = {};\n\t\t\t\tfor (const [k, v] of Object.entries(this.#hSave)) {\n\t\t\t\t\toSave['save:'+ k] = (v instanceof Function) ?v(): v;\n\t\t\t\t}\n\t\t\t\tsessionStorage[ns+'save'] = JSON.stringify(oSave);\n\n\t\t\t\tconst oTmp: any = {};\n\t\t\t\tfor (const [k, v] of Object.entries(this.#hTmp)) {\n\t\t\t\t\toTmp[k] = (v instanceof Function) ?v(): v;\n\t\t\t\t}\n\t\t\t\tsessionStorage[ns +'tmp'] = JSON.stringify(oTmp);\n\n\t\t\t\tconst oMp: any = {};\n\t\t\t\tfor (const [k, v] of Object.entries(this.#hScopes.mp)) {\n\t\t\t\t\toMp[k] = (v instanceof Function) ?v(): v;\n\t\t\t\t}\n\t\t\t\tsessionStorage[ns +'mp'] = JSON.stringify(oMp);\n\n\t\t\t\tconst oMark: any = {};\n\t\t\t\tfor (const [k, v] of Object.entries(this.#data.mark)) {\n\t\t\t\t\toMark[k] = (v instanceof Function) ?v(): v;\n\t\t\t\t}\n\t\t\t\tsessionStorage[ns+'mark'] = JSON.stringify(oMark);\n\n\t\t\t\tconst oKidoku: any = {};\n\t\t\t\tfor (const [k, v] of Object.entries(this.#data.kidoku)) {\n\t\t\t\t\toKidoku[k] = (v instanceof Function) ?v(): v;\n\t\t\t\t}\n\t\t\t\tsessionStorage[ns +'kidoku'] = JSON.stringify(oKidoku);\n\n\t\t\t\tsys.flush();\n\t\t\t}\n\t\t\t: ()=> sys.flush();\n\n\t\t\tthis.#callHook = (type, o)=> sys.callHook(type, o);\n\t\t//x\tthis.callHook = sys.callHook;\n\t\t\tsys.addHook((type, o)=> this.#hProcDbgRes[type]?.(type, o));\n\n\t\t\t// 初回の初期化と、v1.11.0 まで未初期化変数があった件の対策\n\t\t\tconst tm = this.getVal('sys:sn.tagCh.msecWait', -1);\n\t\t\tif (this.#hTmp['const.sn.isFirstBoot'] || tm === -1) this.#clearsysvar();\n\n\t\t\tthis.#tagCh_doWait = this.getVal('sys:sn.tagCh.doWait');\n\t\t\tthis.#tagCh_doWait_Kidoku = this.getVal('sys:sn.tagCh.doWait_Kidoku');\n\t\t\tthis.#tagCh_msecWait = this.getVal('sys:sn.tagCh.msecWait');\n\t\t\tthis.#tagCh_msecWait_Kidoku = this.getVal('sys:sn.tagCh.msecWait_Kidoku');\n\t});\n\t}\n\treadonly\t#hProcDbgRes\n\t: {[type: string]: (type: string, o: any)=> void}\t= {\n\t\tauth: (_, o)=> this.#set_data_break(o.hBreakpoint.aData),\n\t\tvar\t: (_,o)=> this.#sys.send2Dbg(o.ri, {v: this.#hScopes[o.scope] ?? {}}),\n\t\tset_var\t: (_, o)=> {\n\t\t\ttry {this.#setVal(o.nm, o.val); this.#sys.send2Dbg(o.ri, {})} catch {}\n\t\t},\n\t\tset_data_break\t: (_, o)=> {\n\t\t\tthis.#set_data_break(o.a);\n\t\t\tthis.#sys.send2Dbg(o.ri, {});\n\t\t},\n\t\tdisconnect: _=> Variable.#hSetEvent = {},\n\t}\n\t#set_data_break(a: any[]) {\t// o.a.length === 0 なら削除\n\t\tVariable.#hSetEvent = {};\n\t\tfor (const v of a) Variable.#hSetEvent[v.dataId] = 1;\n\t}\n\n\tupdateData(data: IData4Vari): void {\n\t\tthis.#data = data;\n\t\tthis.#hSys = this.#hScopes.sys = this.#data.sys;\n\n\t\tthis.#hAreaKidoku = {};\n\t\tfor (const [fn, v] of Object.entries(this.#data.kidoku)) {\n\t\t\tconst areas = new Areas;\n\t\t\tareas.hAreas = {...v};\n\t\t\tthis.#hAreaKidoku[fn] = areas;\n\t\t}\n\t}\n\t#flush\t= ()=> {};\n\tflush() {this.#flush()}\t// 先にこのメソッドへの参照を配ってしまうので、中身を入れ替える\n\n\tsetDoRecProc(fnc: (doRec: boolean)=> void) {this.#doRecProc = fnc}\n\t#doRecProc = (_doRec: boolean)=> {};\n\n\tdefTmp(name: string, fnc: typeProcVal) {this.#hTmp[name] = fnc};\n\tcloneMp() {return {...this.#hScopes.mp}}\n\tsetMp(mp: IValMp) {this.#hScopes.mp = mp}\n\tsetMark(place: number, mark: IMark) {this.#data.mark[place] = mark; this.flush()}\n\treadonly\tgetMark = (place: number)=> this.#data.mark[place];\n\tcloneSave() {return {...this.#hScopes.save}}\n\tmark2save(mark: IMark) {\n\t\tthis.#hSave = this.#hScopes.save = {...mark.hSave};\n\t\tthis.#doRecLog\t= this.#hSave['sn.doRecLog'] ?? false;\n\t}\n\n\n\t// 既読系\n\ttouchAreaKidoku(fn: string): Areas {return this.#hAreaKidoku[fn] ??= new Areas}\n\treadonly\tgetAreaKidoku = (fn: string)=> this.#hAreaKidoku[fn];\n\tsaveKidoku() {\n\t\tfor (const [fn, {hAreas}] of Object.entries(this.#hAreaKidoku)) {\n\t\t\tthis.#data.kidoku[fn] = {...hAreas};\n\t\t}\n\t\tthis.flush();\n\t}\n\n\n//\t// しおり\n\t// しおりの複写\n\t#copybookmark(hArg: HArg) {\n\t\tif (! ('from' in hArg)) throw 'fromは必須です';\n\t\tif (! ('to' in hArg)) throw 'toは必須です';\n\n\t\tconst from = Number(hArg.from);\n\t\tconst to = Number(hArg.to);\n\t\tif (from === to) return false;\n\n\t\tif (! (from in this.#data.mark)) throw `from:${from} のセーブデータは存在しません`;\n\t\tthis.setMark(to, {...this.#data.mark[from]});\n\t\tthis.#sys.copyBMFolder(from, to);\n\n\t\treturn false;\n\t}\n\n\t// しおりの消去\n\t#erasebookmark(hArg: HArg) {\n\t\tconst {place} = hArg;\n\t\tif (! place) throw 'placeは必須です';\n\n\t\tdelete this.#data.mark[place];\n\t\tthis.flush();\n\n\t\tthis.#sys.eraseBMFolder(place);\n\n\t\treturn false;\n\t}\n\n\n//\t//\t変数操作\n\t// 変数代入・演算\n\t#let(hArg: HArg) {\n\t\tif (! hArg.name) throw 'nameは必須です';\n\n\t\tlet autocast = true;\n\t\tif (hArg.cast) {\n\t\t\t//switch (trim(hArg.cast)) {\n\t\t\tswitch (hArg.cast) {\n\t\t\tcase 'num':\n\t\t\t\targChk_Num(hArg, 'text', NaN);\n\t\t\t\tbreak;\n\t\t\tcase 'int':\n\t\t\t\thArg.text = String(int(argChk_Num(hArg, 'text', NaN)));\n\t\t\t\tbreak;\n\t\t\tcase 'uint':\n\t\t\t\thArg.text = String(uint(argChk_Num(hArg, 'text', NaN)));\n\t\t\t\tbreak;\n\t\t\tcase 'bool':\n\t\t\t\targChk_Boolean(hArg, 'text', false);\n\t\t\t\tbreak;\n\t\t\tcase 'str':\n\t\t\t\tautocast = false;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow 'cast【'+ hArg.cast +'】は未定義です';\n\t\t\t}\n\t\t}\n\n\t\tthis.#setVal(hArg.name, hArg.text, autocast);\n\n\t\treturn false;\n\t}\n\n\t// 絶対値\n\t#let_abs(hArg: HArg) {\n\t\tconst n = argChk_Num(hArg, 'text', 0);\n\t\t//hArg.text = Math.abs(n);\n\t\thArg.text = String((n < 0) ?-n :n);\n\t\t\t// JavaScriptのMath.abs()で絶対値を取得しないほうが良い理由 | iwb.jp https://iwb.jp/javascript-math-abs-deprecated/\n\t\t\t// 数値以外だとほとんどがNaNを返し、booleanは0や1を返しているため使い方によってはバグの原因になることがある。\n\t\tthis.#let(hArg);\n\n\t\treturn false;\n\t}\n\n\t// 文字列から一字取りだし\n\t#let_char_at(hArg: HArg) {\n\t\thArg.text = (hArg.text ?? '').charAt(argChk_Num(hArg, 'pos', 0));\n\t\tthis.#let(hArg);\n\n\t\treturn false;\n\t}\n\n\t// 文字列で検索\n\t#let_index_of(hArg: HArg) {\n\t\tconst {val} = hArg;\n\t\tif (! val) throw 'valは必須です';\n\t\tconst start = argChk_Num(hArg, 'start', 0);\n\n\t\thArg.text = String((hArg.text ?? '').indexOf(val, start));\n\t\tthis.#let(hArg);\n\n\t\treturn false;\n\t}\n\n\t// 文字列の長さ\n\t#let_length(hArg: HArg) {\n\t\thArg.text = String((hArg.text ?? '').length);\n\t\tthis.#let(hArg);\n\n\t\treturn false;\n\t}\n\n\t// 正規表現で置換\n\t#let_replace(hArg: HArg) {\n\t\tif (! hArg.reg) throw 'regは必須です';\n\n\t\tconst {flags} = hArg;\n\t\tconst reg = (! flags)\n\t\t\t? new RegExp(hArg.reg)\n\t\t\t: new RegExp(hArg.reg, flags);\n\t\thArg.text = String(hArg.text ?? '').replace(reg, String(hArg.val));\n\t\tthis.#let(hArg);\n\n\t\treturn false;\n\t}\n\n\t// 四捨五入\n\t#let_round(hArg: HArg) {\n\t\tconst n = argChk_Num(hArg, 'text', 0);\n\t\thArg.text = String(Math.round(n));\n\t\tthis.#let(hArg);\n\n\t\treturn false;\n\t}\n\n\t// 正規表現で検索\n\t#let_search(hArg: HArg) {\n\t\tif (! hArg.reg) throw 'regは必須です';\n\n\t\tconst {flags} = hArg;\n\t\tconst reg = (! flags)\n\t\t\t? new RegExp(hArg.reg)\n\t\t\t: new RegExp(hArg.reg, flags);\n\t\thArg.text = String((hArg.text ?? '').search(reg));\n\t\tthis.#let(hArg);\n\n\t\treturn false;\n\t}\n\n\t// 文字列から抜きだし\n\t#let_substr(hArg: HArg) {\n\t\tconst i = argChk_Num(hArg, 'pos', 0);\n\t\thArg.text = (hArg.len !== 'all')\n\t\t\t? (hArg.text ?? '').slice(i, i +int(argChk_Num(hArg, 'len', 1)))\n\t\t\t: (hArg.text ?? '').slice(i);\n\t\tthis.#let(hArg);\n\n\t\treturn false;\n\t}\n\n\n//\t// デバッグ・その他\n\t// システム変数の全消去\n\t#clearsysvar() {\n\t\tconst sys = this.#hSys = this.#hScopes['sys'] = this.#data.sys = {};\n\n\t\tconst is_nw = (typeof process !== 'undefined');\n\t\tif (is_nw) {\n\t\t//\t//\tthis.setVal_Sub('sys:const.sn.window.x', stage.nativeWindow.x);\n\t\t//\t//\tthis.setVal_Sub('sys:const.sn.window.y', stage.nativeWindow.y);\n\t\t}\n\t\telse {\n\t\t\tthis.setVal_Nochk('sys', 'const.sn.window.x', 0);\n\t\t\tthis.setVal_Nochk('sys', 'const.sn.window.y', 0);\n\t\t}\n\n\t\t// 文字表示Waitをかけるか\n\t\tthis.setVal_Nochk('sys', 'sn.tagCh.doWait', true);\n\t\tthis.setVal_Nochk('sys', 'sn.tagCh.doWait_Kidoku', true);\t// 【既読】\n\t\t// 文字表示Wait時間\n\t\tthis.setVal_Nochk('sys', 'sn.tagCh.msecWait', this.cfg.oCfg.init.tagch_msecwait);\n\t\tthis.setVal_Nochk('sys', 'sn.tagCh.msecWait_Kidoku', this.cfg.oCfg.init.tagch_msecwait);\n\t\t\t// 【既読】\n\t\t// 文字表示Wait中スキップのモード\n\t\tthis.setVal_Nochk('sys', 'sn.tagCh.canskip', true);\n\n\t\t// スキップのモード\n\t\tthis.setVal_Nochk('sys', 'sn.skip.mode', 's');\t// l, p, s\n\n\t\t// 自動読みすすみモード時の改ページ時のウェイト\n\t\t//\t//\trunFirst_sys_an_auto_msecPageWait('sn.auto.msecPageWait', '');\n\t\tthis.setVal_Nochk('sys', 'sn.auto.msecPageWait', argChk_Num(sys, 'sn.auto.msecPageWait', this.cfg.oCfg.init.auto_msecpagewait ?? 3500));\n\t\tthis.setVal_Nochk('sys', 'sn.auto.msecPageWait_Kidoku', argChk_Num(sys, 'sn.auto.msecPageWait', this.cfg.oCfg.init.auto_msecpagewait ?? 3500));\n\t\t// 自動読みすすみモード時の行クリック待ち時のウェイト\n\t\tthis.setVal_Nochk('sys', 'sn.auto.msecLineWait', 500);\n\t\tthis.setVal_Nochk('sys', 'sn.auto.msecLineWait_Kidoku', 500);\t// 【既読】\n\n\t\t//\tSoundMixer.soundTransform = new SoundTransform(\n\t\t//\t\t(sys['flash.media.SoundMixer.soundTransform.volume'] = 1)\n\t\t//\t);\n\t\tthis.setVal_Nochk('sys', 'const.sn.sound.BGM.volume', 1);\n\t\tthis.setVal_Nochk('sys', 'const.sn.sound.SE.volume', 1);\n\t\tthis.setVal_Nochk('sys', 'const.sn.sound.SYS.volume', 1);\n\t\tfor (const [fn, v] of Object.entries(this.#data.kidoku)) {\n\t\t\tv.hAreas = {};\n\t\t\tthis.#hAreaKidoku[fn].clear();\n\t\t}\n\n\n\t\tthis.setVal_Nochk('sys', 'TextLayer.Back.Alpha', 0.5);\n\n\n\t\tthis.#hScopes['mark'] = this.#data.mark = {};\n\t\tthis.setVal_Nochk('sys', 'const.sn.save.place', 1);\n\n\n\t\tthis.flush();\n\n\t\treturn false;\n\t}\n\n\t// ゲーム変数の全消去\n\t#clearvar() {\n\t\tconst mesLayer\t= this.#hSave['const.sn.mesLayer'] ?? '';\n\t\tconst doRecLog\t= this.#hSave['sn.doRecLog'] ?? false;\n\t\tconst sLog\t\t= this.#hSave['const.sn.sLog'] ?? '[]';\n\n\t\tthis.#hSave = this.#hScopes.save = {};\n\n\t\tthis.setVal_Nochk('save', 'const.sn.mesLayer', mesLayer);\n\t\tthis.setVal_Nochk('save', 'sn.doRecLog', doRecLog);\n\t\tthis.setVal_Nochk('save', 'const.sn.sLog', sLog);\n\n\t\treturn false;\n\t}\n\n\treadonly #setVal = (arg_name: string, val: any, autocast = true)=> {\n\t\tif (! arg_name) throw '[変数に値セット] nameは必須です';\n\t\tif (val == null) throw '[変数に値セット] textは必須です(空文字はOK)';\n\n\t\tconst o = PropParser.getValName(arg_name);\n\t\tif (o === null) throw '[変数参照] name('+ arg_name +')が変数名として異常です';\n\n\t\tconst hScope = this.#hScopes[o.scope];\n\t\tif (! hScope) throw '[変数に値セット] scopeが異常【'+ o.scope +'】です';\n\n\t\tconst nm = o['name'];\n\t\tif (nm.slice(0, 6) === 'const.' && (nm in hScope)) {\n\t\t\tthrow '[変数に値セット] 変数【'+ nm +'】は書き換え不可です';\n\t\t}\n\n\t\tthis.setVal_Nochk(o.scope, nm, val, autocast);\n\t}\n\tsetVal_Nochk(scope: Scope, nm: string, val: any, autocast = false) {\n\t\tconst hScope = this.#hScopes[scope];\n\t\tif (autocast) val = this.#castAuto(val);\n\n\t\tconst fullnm = scope +':'+ nm;\n\t\tif (fullnm in Variable.#hSetEvent) {\n\t\t\tconst old_v = hScope[nm];\n\t\t\tconst new_v = val;\n\t\t\tif (old_v != new_v) this.#callHook('data_break', {\n\t\t\t\tdataId: fullnm,\n\t\t\t\told_v: old_v,\n\t\t\t\tnew_v: new_v,\n\t\t\t});\n\t\t}\n\n\t\thScope[nm] = val;\n\n\t\tthis.#hValTrg[fullnm]?.(nm, val);\n\n\t\t// if (scope === 'sys') this.flush()\n\t\t\t// 厳密にはここですべきだが、パフォーマンスに問題があるので\n\t\t\t// クリック待ちを期待できるwait、waitclick、s、l、pタグで\n\t\t\t// saveKidoku()をコール。(中で保存しているのでついでに)\n\n\t\t//console.log(`\\tlet s[${scope}] n[${nm}]='${val}' trg[${(trg)}]`);\n\t}\n\t// reload 再生成 Main に受け渡すため static\n\tstatic\t#hSetEvent: {[fullnm: string]: 1} = {};\n\n\treadonly getVal = (arg_name: string, def?: number | string)=> {\n\t\tif (! arg_name) throw '[変数参照] nameは必須です';\n\n\t\tconst o = PropParser.getValName(arg_name);\n\t\tif (o === null) throw '[変数参照] name('+ arg_name +')が変数名として異常です';\n\n\t\tconst hScope = this.#hScopes[o['scope']];\n\t\tif (! hScope) throw '[変数参照] scopeが異常【'+ o['scope'] +'】です';\n\n\t\tconst val_name = o['name'];\n\t\tlet val = hScope[val_name];\n//console.log(`fn:Variable.ts line:527 ・getVal arg_name=${arg_name}= val_name=${val_name}= A:${! (val_name in hScope)} val:%o`, val);\n\t\tif (! (val_name in hScope)) {\t// 存在しない変数名の場合、刻んで調べていく\n\t\t\tval = def;\n\n\t\t\tlet nm = '';\n\t\t\tconst aNm = val_name.split('.');\n\t\t\tconst len = aNm.length;\n\t\t\tfor (let i=0; i s['+ o['scope'] +'] a['+ o['at'] +'] n['+ name +'] ret['+ val +']('+ typeof val +')');\n\n\t\treturn (o['at'] === '@str') ?val :this.#castAuto(val);\n\t}\n\n\t#castAuto(val: Object): any {\n\t\tconst s_val = val as string;\n\t\tif (s_val === 'true') return true;\n\t\tif (s_val === 'false') return false;\n\t\tif (s_val === 'null') return null;\n\t\tif (s_val === 'undefined') return undefined;\n\t\tif (this.#REG_NUMERICLITERAL.test(s_val)) return parseFloat(s_val);\n\n\t\treturn val;\n\t}\n\t#REG_NUMERICLITERAL\t:RegExp\t= /^-?[\\d\\.]+$/;\n\n\n\t// 変数のダンプ\n\treadonly #dump_val = ()=> {\n\t\tconst val: {[nm: string]: any} = {tmp:{}, sys:{}, save:{}, mp:{}};\n\t\tfor (let scope in val) {\n\t\t\tconst hVal: {[nm: string]: any} = this.#hScopes[scope];\n\t\t\tconst hRet = val[scope];\n\t\t\tfor (let [key, v] of Object.entries(hVal)) {\n\t\t\t\thRet[key] = Object.prototype.toString.call(v) === '[object Function]' ?v() :v;\n\t\t\t}\n\t\t}\n\t\tconsole.info('🥟 [dump_val]', val);\n\n\t\treturn false;\n\t}\n\n\t#doRecLog\t= false;\n\tdoRecLog() {return this.#doRecLog}\n\n\n\t#tagCh_doWait = false;\n\tget tagCh_doWait() {return this.#tagCh_doWait;}\n\t#tagCh_doWait_Kidoku = false;\n\tget tagCh_doWait_Kidoku() {return this.#tagCh_doWait_Kidoku;}\n\t#tagCh_msecWait\t\t= 0;\n\tget tagCh_msecWait() {return this.#tagCh_msecWait;}\n\t#tagCh_msecWait_Kidoku= 0;\n\tget tagCh_msecWait_Kidoku() {return this.#tagCh_msecWait_Kidoku;}\n\n\t#hValTrg\t: {[name: string]: ISetVal}\t= {\n\t\t// sys\n\t\t'sys:sn.tagCh.doWait'\t\t\t: name=> {\n\t\t\tthis.#tagCh_doWait =\n\t\t\tthis.#runFirst_Bool_hSysVal_true(name);\n\t\t},\n\t\t'sys:sn.tagCh.doWait_Kidoku'\t: name=> {\n\t\t\tthis.#tagCh_doWait_Kidoku =\n\t\t\tthis.#runFirst_Bool_hSysVal_true(name);\n\t\t},\n\t\t'sys:sn.tagCh.msecWait'\t\t\t: name=> {\n\t\t\tthis.#tagCh_msecWait =\n\t\t\tthis.#runFirst_sys_an_tagCh_msecWait(name);\n\t\t},\n\t\t'sys:sn.tagCh.msecWait_Kidoku'\t: name=> {\n\t\t\tthis.#tagCh_msecWait_Kidoku =\n\t\t\tthis.#runFirst_sys_an_tagCh_msecWait_Kidoku(name);\n\t\t},\n\t\t'sys:sn.tagCh.canskip'\t\t\t: name=> this.#runFirst_Bool_hSysVal_true(name),\n\n\t\t'sys:sn.auto.msecPageWait'\t\t\t: name=>\n\t\t\tthis.#runFirst_sys_an_auto_msecPageWait(name),\n\t\t'sys:sn.auto.msecPageWait_Kidoku'\t: name=>\n\t\t\tthis.#runFirst_sys_an_auto_msecPageWait(name),\n\t\t'sys:sn.auto.msecLineWait'\t\t\t: name=>\n\t\t\tthis.#runFirst_sys_an_auto_msecLineWait(name),\n\t\t'sys:sn.auto.msecLineWait_Kidoku'\t: name=>\n\t\t\tthis.#runFirst_sys_an_auto_msecLineWait(name),\n\n\t\t// save\n\t\t'save:sn.doRecLog'\t\t: name=> {\n\t\t\tthis.#doRecProc(\n\t\t\t\tthis.#doRecLog = this.#runFirst_Bool_hSaveVal_true(name)\n\t\t\t);\n\t\t},\n\t\t'save:sn.userFnTail'\t: (_name, val)=> {\n\t\t\tif (val.includes('@')) throw `この変数では文字「@」は禁止です`;\n\t\t\tthis.cfg.userFnTail = val;\n\t\t},\n\n\t\t// tmp\n\t\t'tmp:flash.desktop.NativeApplication.nativeApplication.systemIdleMode'\t: (\n\t\t\t()=> {\n\t\t\t//\tNativeApplication.nativeApplication.systemIdleMode = val;\n\t\t\t}\n\t\t),\n\t};\n\tdefValTrg(name: string, fnc: ISetVal) {this.#hValTrg[name] = fnc}\n\treadonly\t#runFirst_Bool_hSysVal_true = (name: string)=> argChk_Boolean(this.#hSys, name, true);\n\treadonly\t#runFirst_sys_an_tagCh_msecWait = (name: string)=> argChk_Num(this.#hSys, name, 10);\n\treadonly\t#runFirst_sys_an_tagCh_msecWait_Kidoku = (name: string)=> argChk_Num(\n\t\tthis.#hSys, name,\n\t\t(this.cfg.oCfg.init.tagch_msecwait === undefined)\n\t\t\t? 10\n\t\t\t: this.cfg.oCfg.init.tagch_msecwait\n\t);\n\treadonly\t#runFirst_sys_an_auto_msecPageWait = (name: string)=> argChk_Num(\n\t\tthis.#hSys, name,\n\t\t(this.cfg.oCfg.init.auto_msecpagewait === undefined)\n\t\t\t? 3500\n\t\t\t: this.cfg.oCfg.init.auto_msecpagewait\n\t);\n\treadonly\t#runFirst_sys_an_auto_msecLineWait = (name: string)=> argChk_Num(this.#hSys, name, 500);\n\n\t#runFirst_Bool_hSaveVal_true(name: string) {\n\t\treturn argChk_Boolean(this.#hSave, name, true);\n\t}\n\n};\n","/**\n * The Ease class provides a collection of easing functions for use with tween.js.\n */\nvar Easing = Object.freeze({\n Linear: Object.freeze({\n None: function (amount) {\n return amount;\n },\n In: function (amount) {\n return amount;\n },\n Out: function (amount) {\n return amount;\n },\n InOut: function (amount) {\n return amount;\n },\n }),\n Quadratic: Object.freeze({\n In: function (amount) {\n return amount * amount;\n },\n Out: function (amount) {\n return amount * (2 - amount);\n },\n InOut: function (amount) {\n if ((amount *= 2) < 1) {\n return 0.5 * amount * amount;\n }\n return -0.5 * (--amount * (amount - 2) - 1);\n },\n }),\n Cubic: Object.freeze({\n In: function (amount) {\n return amount * amount * amount;\n },\n Out: function (amount) {\n return --amount * amount * amount + 1;\n },\n InOut: function (amount) {\n if ((amount *= 2) < 1) {\n return 0.5 * amount * amount * amount;\n }\n return 0.5 * ((amount -= 2) * amount * amount + 2);\n },\n }),\n Quartic: Object.freeze({\n In: function (amount) {\n return amount * amount * amount * amount;\n },\n Out: function (amount) {\n return 1 - --amount * amount * amount * amount;\n },\n InOut: function (amount) {\n if ((amount *= 2) < 1) {\n return 0.5 * amount * amount * amount * amount;\n }\n return -0.5 * ((amount -= 2) * amount * amount * amount - 2);\n },\n }),\n Quintic: Object.freeze({\n In: function (amount) {\n return amount * amount * amount * amount * amount;\n },\n Out: function (amount) {\n return --amount * amount * amount * amount * amount + 1;\n },\n InOut: function (amount) {\n if ((amount *= 2) < 1) {\n return 0.5 * amount * amount * amount * amount * amount;\n }\n return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2);\n },\n }),\n Sinusoidal: Object.freeze({\n In: function (amount) {\n return 1 - Math.sin(((1.0 - amount) * Math.PI) / 2);\n },\n Out: function (amount) {\n return Math.sin((amount * Math.PI) / 2);\n },\n InOut: function (amount) {\n return 0.5 * (1 - Math.sin(Math.PI * (0.5 - amount)));\n },\n }),\n Exponential: Object.freeze({\n In: function (amount) {\n return amount === 0 ? 0 : Math.pow(1024, amount - 1);\n },\n Out: function (amount) {\n return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount);\n },\n InOut: function (amount) {\n if (amount === 0) {\n return 0;\n }\n if (amount === 1) {\n return 1;\n }\n if ((amount *= 2) < 1) {\n return 0.5 * Math.pow(1024, amount - 1);\n }\n return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2);\n },\n }),\n Circular: Object.freeze({\n In: function (amount) {\n return 1 - Math.sqrt(1 - amount * amount);\n },\n Out: function (amount) {\n return Math.sqrt(1 - --amount * amount);\n },\n InOut: function (amount) {\n if ((amount *= 2) < 1) {\n return -0.5 * (Math.sqrt(1 - amount * amount) - 1);\n }\n return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1);\n },\n }),\n Elastic: Object.freeze({\n In: function (amount) {\n if (amount === 0) {\n return 0;\n }\n if (amount === 1) {\n return 1;\n }\n return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);\n },\n Out: function (amount) {\n if (amount === 0) {\n return 0;\n }\n if (amount === 1) {\n return 1;\n }\n return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1;\n },\n InOut: function (amount) {\n if (amount === 0) {\n return 0;\n }\n if (amount === 1) {\n return 1;\n }\n amount *= 2;\n if (amount < 1) {\n return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);\n }\n return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1;\n },\n }),\n Back: Object.freeze({\n In: function (amount) {\n var s = 1.70158;\n return amount === 1 ? 1 : amount * amount * ((s + 1) * amount - s);\n },\n Out: function (amount) {\n var s = 1.70158;\n return amount === 0 ? 0 : --amount * amount * ((s + 1) * amount + s) + 1;\n },\n InOut: function (amount) {\n var s = 1.70158 * 1.525;\n if ((amount *= 2) < 1) {\n return 0.5 * (amount * amount * ((s + 1) * amount - s));\n }\n return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2);\n },\n }),\n Bounce: Object.freeze({\n In: function (amount) {\n return 1 - Easing.Bounce.Out(1 - amount);\n },\n Out: function (amount) {\n if (amount < 1 / 2.75) {\n return 7.5625 * amount * amount;\n }\n else if (amount < 2 / 2.75) {\n return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75;\n }\n else if (amount < 2.5 / 2.75) {\n return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375;\n }\n else {\n return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375;\n }\n },\n InOut: function (amount) {\n if (amount < 0.5) {\n return Easing.Bounce.In(amount * 2) * 0.5;\n }\n return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5;\n },\n }),\n generatePow: function (power) {\n if (power === void 0) { power = 4; }\n power = power < Number.EPSILON ? Number.EPSILON : power;\n power = power > 10000 ? 10000 : power;\n return {\n In: function (amount) {\n return Math.pow(amount, power);\n },\n Out: function (amount) {\n return 1 - Math.pow((1 - amount), power);\n },\n InOut: function (amount) {\n if (amount < 0.5) {\n return Math.pow((amount * 2), power) / 2;\n }\n return (1 - Math.pow((2 - amount * 2), power)) / 2 + 0.5;\n },\n };\n },\n});\n\nvar now = function () { return performance.now(); };\n\n/**\n * Controlling groups of tweens\n *\n * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.\n * In these cases, you may want to create your own smaller groups of tween\n */\nvar Group = /** @class */ (function () {\n function Group() {\n this._tweens = {};\n this._tweensAddedDuringUpdate = {};\n }\n Group.prototype.getAll = function () {\n var _this = this;\n return Object.keys(this._tweens).map(function (tweenId) {\n return _this._tweens[tweenId];\n });\n };\n Group.prototype.removeAll = function () {\n this._tweens = {};\n };\n Group.prototype.add = function (tween) {\n this._tweens[tween.getId()] = tween;\n this._tweensAddedDuringUpdate[tween.getId()] = tween;\n };\n Group.prototype.remove = function (tween) {\n delete this._tweens[tween.getId()];\n delete this._tweensAddedDuringUpdate[tween.getId()];\n };\n Group.prototype.update = function (time, preserve) {\n if (time === void 0) { time = now(); }\n if (preserve === void 0) { preserve = false; }\n var tweenIds = Object.keys(this._tweens);\n if (tweenIds.length === 0) {\n return false;\n }\n // Tweens are updated in \"batches\". If you add a new tween during an\n // update, then the new tween will be updated in the next batch.\n // If you remove a tween during an update, it may or may not be updated.\n // However, if the removed tween was added during the current batch,\n // then it will not be updated.\n while (tweenIds.length > 0) {\n this._tweensAddedDuringUpdate = {};\n for (var i = 0; i < tweenIds.length; i++) {\n var tween = this._tweens[tweenIds[i]];\n var autoStart = !preserve;\n if (tween && tween.update(time, autoStart) === false && !preserve) {\n delete this._tweens[tweenIds[i]];\n }\n }\n tweenIds = Object.keys(this._tweensAddedDuringUpdate);\n }\n return true;\n };\n return Group;\n}());\n\n/**\n *\n */\nvar Interpolation = {\n Linear: function (v, k) {\n var m = v.length - 1;\n var f = m * k;\n var i = Math.floor(f);\n var fn = Interpolation.Utils.Linear;\n if (k < 0) {\n return fn(v[0], v[1], f);\n }\n if (k > 1) {\n return fn(v[m], v[m - 1], m - f);\n }\n return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);\n },\n Bezier: function (v, k) {\n var b = 0;\n var n = v.length - 1;\n var pw = Math.pow;\n var bn = Interpolation.Utils.Bernstein;\n for (var i = 0; i <= n; i++) {\n b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);\n }\n return b;\n },\n CatmullRom: function (v, k) {\n var m = v.length - 1;\n var f = m * k;\n var i = Math.floor(f);\n var fn = Interpolation.Utils.CatmullRom;\n if (v[0] === v[m]) {\n if (k < 0) {\n i = Math.floor((f = m * (1 + k)));\n }\n return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);\n }\n else {\n if (k < 0) {\n return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]);\n }\n if (k > 1) {\n return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);\n }\n return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i);\n }\n },\n Utils: {\n Linear: function (p0, p1, t) {\n return (p1 - p0) * t + p0;\n },\n Bernstein: function (n, i) {\n var fc = Interpolation.Utils.Factorial;\n return fc(n) / fc(i) / fc(n - i);\n },\n Factorial: (function () {\n var a = [1];\n return function (n) {\n var s = 1;\n if (a[n]) {\n return a[n];\n }\n for (var i = n; i > 1; i--) {\n s *= i;\n }\n a[n] = s;\n return s;\n };\n })(),\n CatmullRom: function (p0, p1, p2, p3, t) {\n var v0 = (p2 - p0) * 0.5;\n var v1 = (p3 - p1) * 0.5;\n var t2 = t * t;\n var t3 = t * t2;\n return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;\n },\n },\n};\n\n/**\n * Utils\n */\nvar Sequence = /** @class */ (function () {\n function Sequence() {\n }\n Sequence.nextId = function () {\n return Sequence._nextId++;\n };\n Sequence._nextId = 0;\n return Sequence;\n}());\n\nvar mainGroup = new Group();\n\n/**\n * Tween.js - Licensed under the MIT license\n * https://github.com/tweenjs/tween.js\n * ----------------------------------------------\n *\n * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.\n * Thank you all, you're awesome!\n */\nvar Tween = /** @class */ (function () {\n function Tween(_object, _group) {\n if (_group === void 0) { _group = mainGroup; }\n this._object = _object;\n this._group = _group;\n this._isPaused = false;\n this._pauseStart = 0;\n this._valuesStart = {};\n this._valuesEnd = {};\n this._valuesStartRepeat = {};\n this._duration = 1000;\n this._isDynamic = false;\n this._initialRepeat = 0;\n this._repeat = 0;\n this._yoyo = false;\n this._isPlaying = false;\n this._reversed = false;\n this._delayTime = 0;\n this._startTime = 0;\n this._easingFunction = Easing.Linear.None;\n this._interpolationFunction = Interpolation.Linear;\n // eslint-disable-next-line\n this._chainedTweens = [];\n this._onStartCallbackFired = false;\n this._onEveryStartCallbackFired = false;\n this._id = Sequence.nextId();\n this._isChainStopped = false;\n this._propertiesAreSetUp = false;\n this._goToEnd = false;\n }\n Tween.prototype.getId = function () {\n return this._id;\n };\n Tween.prototype.isPlaying = function () {\n return this._isPlaying;\n };\n Tween.prototype.isPaused = function () {\n return this._isPaused;\n };\n Tween.prototype.getDuration = function () {\n return this._duration;\n };\n Tween.prototype.to = function (target, duration) {\n if (duration === void 0) { duration = 1000; }\n if (this._isPlaying)\n throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');\n this._valuesEnd = target;\n this._propertiesAreSetUp = false;\n this._duration = duration < 0 ? 0 : duration;\n return this;\n };\n Tween.prototype.duration = function (duration) {\n if (duration === void 0) { duration = 1000; }\n this._duration = duration < 0 ? 0 : duration;\n return this;\n };\n Tween.prototype.dynamic = function (dynamic) {\n if (dynamic === void 0) { dynamic = false; }\n this._isDynamic = dynamic;\n return this;\n };\n Tween.prototype.start = function (time, overrideStartingValues) {\n if (time === void 0) { time = now(); }\n if (overrideStartingValues === void 0) { overrideStartingValues = false; }\n if (this._isPlaying) {\n return this;\n }\n // eslint-disable-next-line\n this._group && this._group.add(this);\n this._repeat = this._initialRepeat;\n if (this._reversed) {\n // If we were reversed (f.e. using the yoyo feature) then we need to\n // flip the tween direction back to forward.\n this._reversed = false;\n for (var property in this._valuesStartRepeat) {\n this._swapEndStartRepeatValues(property);\n this._valuesStart[property] = this._valuesStartRepeat[property];\n }\n }\n this._isPlaying = true;\n this._isPaused = false;\n this._onStartCallbackFired = false;\n this._onEveryStartCallbackFired = false;\n this._isChainStopped = false;\n this._startTime = time;\n this._startTime += this._delayTime;\n if (!this._propertiesAreSetUp || overrideStartingValues) {\n this._propertiesAreSetUp = true;\n // If dynamic is not enabled, clone the end values instead of using the passed-in end values.\n if (!this._isDynamic) {\n var tmp = {};\n for (var prop in this._valuesEnd)\n tmp[prop] = this._valuesEnd[prop];\n this._valuesEnd = tmp;\n }\n this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);\n }\n return this;\n };\n Tween.prototype.startFromCurrentValues = function (time) {\n return this.start(time, true);\n };\n Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat, overrideStartingValues) {\n for (var property in _valuesEnd) {\n var startValue = _object[property];\n var startValueIsArray = Array.isArray(startValue);\n var propType = startValueIsArray ? 'array' : typeof startValue;\n var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]);\n // If `to()` specifies a property that doesn't exist in the source object,\n // we should not set that property in the object\n if (propType === 'undefined' || propType === 'function') {\n continue;\n }\n // Check if an Array was provided as property value\n if (isInterpolationList) {\n var endValues = _valuesEnd[property];\n if (endValues.length === 0) {\n continue;\n }\n // Handle an array of relative values.\n // Creates a local copy of the Array with the start value at the front\n var temp = [startValue];\n for (var i = 0, l = endValues.length; i < l; i += 1) {\n var value = this._handleRelativeValue(startValue, endValues[i]);\n if (isNaN(value)) {\n isInterpolationList = false;\n console.warn('Found invalid interpolation list. Skipping.');\n break;\n }\n temp.push(value);\n }\n if (isInterpolationList) {\n // if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp.\n _valuesEnd[property] = temp;\n // }\n }\n }\n // handle the deepness of the values\n if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) {\n _valuesStart[property] = startValueIsArray ? [] : {};\n var nestedObject = startValue;\n for (var prop in nestedObject) {\n _valuesStart[property][prop] = nestedObject[prop];\n }\n // TODO? repeat nested values? And yoyo? And array values?\n _valuesStartRepeat[property] = startValueIsArray ? [] : {};\n var endValues = _valuesEnd[property];\n // If dynamic is not enabled, clone the end values instead of using the passed-in end values.\n if (!this._isDynamic) {\n var tmp = {};\n for (var prop in endValues)\n tmp[prop] = endValues[prop];\n _valuesEnd[property] = endValues = tmp;\n }\n this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues);\n }\n else {\n // Save the starting value, but only once unless override is requested.\n if (typeof _valuesStart[property] === 'undefined' || overrideStartingValues) {\n _valuesStart[property] = startValue;\n }\n if (!startValueIsArray) {\n // eslint-disable-next-line\n // @ts-ignore FIXME?\n _valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings\n }\n if (isInterpolationList) {\n // eslint-disable-next-line\n // @ts-ignore FIXME?\n _valuesStartRepeat[property] = _valuesEnd[property].slice().reverse();\n }\n else {\n _valuesStartRepeat[property] = _valuesStart[property] || 0;\n }\n }\n }\n };\n Tween.prototype.stop = function () {\n if (!this._isChainStopped) {\n this._isChainStopped = true;\n this.stopChainedTweens();\n }\n if (!this._isPlaying) {\n return this;\n }\n // eslint-disable-next-line\n this._group && this._group.remove(this);\n this._isPlaying = false;\n this._isPaused = false;\n if (this._onStopCallback) {\n this._onStopCallback(this._object);\n }\n return this;\n };\n Tween.prototype.end = function () {\n this._goToEnd = true;\n this.update(Infinity);\n return this;\n };\n Tween.prototype.pause = function (time) {\n if (time === void 0) { time = now(); }\n if (this._isPaused || !this._isPlaying) {\n return this;\n }\n this._isPaused = true;\n this._pauseStart = time;\n // eslint-disable-next-line\n this._group && this._group.remove(this);\n return this;\n };\n Tween.prototype.resume = function (time) {\n if (time === void 0) { time = now(); }\n if (!this._isPaused || !this._isPlaying) {\n return this;\n }\n this._isPaused = false;\n this._startTime += time - this._pauseStart;\n this._pauseStart = 0;\n // eslint-disable-next-line\n this._group && this._group.add(this);\n return this;\n };\n Tween.prototype.stopChainedTweens = function () {\n for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {\n this._chainedTweens[i].stop();\n }\n return this;\n };\n Tween.prototype.group = function (group) {\n if (group === void 0) { group = mainGroup; }\n this._group = group;\n return this;\n };\n Tween.prototype.delay = function (amount) {\n if (amount === void 0) { amount = 0; }\n this._delayTime = amount;\n return this;\n };\n Tween.prototype.repeat = function (times) {\n if (times === void 0) { times = 0; }\n this._initialRepeat = times;\n this._repeat = times;\n return this;\n };\n Tween.prototype.repeatDelay = function (amount) {\n this._repeatDelayTime = amount;\n return this;\n };\n Tween.prototype.yoyo = function (yoyo) {\n if (yoyo === void 0) { yoyo = false; }\n this._yoyo = yoyo;\n return this;\n };\n Tween.prototype.easing = function (easingFunction) {\n if (easingFunction === void 0) { easingFunction = Easing.Linear.None; }\n this._easingFunction = easingFunction;\n return this;\n };\n Tween.prototype.interpolation = function (interpolationFunction) {\n if (interpolationFunction === void 0) { interpolationFunction = Interpolation.Linear; }\n this._interpolationFunction = interpolationFunction;\n return this;\n };\n // eslint-disable-next-line\n Tween.prototype.chain = function () {\n var tweens = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n tweens[_i] = arguments[_i];\n }\n this._chainedTweens = tweens;\n return this;\n };\n Tween.prototype.onStart = function (callback) {\n this._onStartCallback = callback;\n return this;\n };\n Tween.prototype.onEveryStart = function (callback) {\n this._onEveryStartCallback = callback;\n return this;\n };\n Tween.prototype.onUpdate = function (callback) {\n this._onUpdateCallback = callback;\n return this;\n };\n Tween.prototype.onRepeat = function (callback) {\n this._onRepeatCallback = callback;\n return this;\n };\n Tween.prototype.onComplete = function (callback) {\n this._onCompleteCallback = callback;\n return this;\n };\n Tween.prototype.onStop = function (callback) {\n this._onStopCallback = callback;\n return this;\n };\n /**\n * @returns true if the tween is still playing after the update, false\n * otherwise (calling update on a paused tween still returns true because\n * it is still playing, just paused).\n */\n Tween.prototype.update = function (time, autoStart) {\n var _a;\n if (time === void 0) { time = now(); }\n if (autoStart === void 0) { autoStart = true; }\n if (this._isPaused)\n return true;\n var endTime = this._startTime + this._duration;\n if (!this._goToEnd && !this._isPlaying) {\n if (time > endTime)\n return false;\n if (autoStart)\n this.start(time, true);\n }\n this._goToEnd = false;\n if (time < this._startTime) {\n return true;\n }\n if (this._onStartCallbackFired === false) {\n if (this._onStartCallback) {\n this._onStartCallback(this._object);\n }\n this._onStartCallbackFired = true;\n }\n if (this._onEveryStartCallbackFired === false) {\n if (this._onEveryStartCallback) {\n this._onEveryStartCallback(this._object);\n }\n this._onEveryStartCallbackFired = true;\n }\n var elapsedTime = time - this._startTime;\n var durationAndDelay = this._duration + ((_a = this._repeatDelayTime) !== null && _a !== void 0 ? _a : this._delayTime);\n var totalTime = this._duration + this._repeat * durationAndDelay;\n var elapsed = this._calculateElapsedPortion(elapsedTime, durationAndDelay, totalTime);\n var value = this._easingFunction(elapsed);\n var status = this._calculateCompletionStatus(elapsedTime, durationAndDelay);\n if (status === 'repeat') {\n // the current update is happening after the instant the tween repeated\n this._processRepetition(elapsedTime, durationAndDelay);\n }\n this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);\n if (status === 'about-to-repeat') {\n // the current update is happening at the exact instant the tween is going to repeat\n // the values should match the end of the tween, not the beginning,\n // that's why _processRepetition happens after _updateProperties\n this._processRepetition(elapsedTime, durationAndDelay);\n }\n if (this._onUpdateCallback) {\n this._onUpdateCallback(this._object, elapsed);\n }\n if (status === 'repeat' || status === 'about-to-repeat') {\n if (this._onRepeatCallback) {\n this._onRepeatCallback(this._object);\n }\n this._onEveryStartCallbackFired = false;\n }\n else if (status === 'completed') {\n this._isPlaying = false;\n if (this._onCompleteCallback) {\n this._onCompleteCallback(this._object);\n }\n for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {\n // Make the chained tweens start exactly at the time they should,\n // even if the `update()` method was called way past the duration of the tween\n this._chainedTweens[i].start(this._startTime + this._duration, false);\n }\n }\n return status !== 'completed';\n };\n Tween.prototype._calculateElapsedPortion = function (elapsedTime, durationAndDelay, totalTime) {\n if (this._duration === 0 || elapsedTime > totalTime) {\n return 1;\n }\n var timeIntoCurrentRepeat = elapsedTime % durationAndDelay;\n var portion = Math.min(timeIntoCurrentRepeat / this._duration, 1);\n if (portion === 0 && elapsedTime !== 0 && elapsedTime % this._duration === 0) {\n return 1;\n }\n return portion;\n };\n Tween.prototype._calculateCompletionStatus = function (elapsedTime, durationAndDelay) {\n if (this._duration !== 0 && elapsedTime < this._duration) {\n return 'playing';\n }\n if (this._repeat <= 0) {\n return 'completed';\n }\n if (elapsedTime === this._duration) {\n return 'about-to-repeat';\n }\n return 'repeat';\n };\n Tween.prototype._processRepetition = function (elapsedTime, durationAndDelay) {\n var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat);\n if (isFinite(this._repeat)) {\n this._repeat -= completeCount;\n }\n // Reassign starting values, restart by making startTime = now\n for (var property in this._valuesStartRepeat) {\n var valueEnd = this._valuesEnd[property];\n if (!this._yoyo && typeof valueEnd === 'string') {\n this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(valueEnd);\n }\n if (this._yoyo) {\n this._swapEndStartRepeatValues(property);\n }\n this._valuesStart[property] = this._valuesStartRepeat[property];\n }\n if (this._yoyo) {\n this._reversed = !this._reversed;\n }\n this._startTime += durationAndDelay * completeCount;\n };\n Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) {\n for (var property in _valuesEnd) {\n // Don't update properties that do not exist in the source object\n if (_valuesStart[property] === undefined) {\n continue;\n }\n var start = _valuesStart[property] || 0;\n var end = _valuesEnd[property];\n var startIsArray = Array.isArray(_object[property]);\n var endIsArray = Array.isArray(end);\n var isInterpolationList = !startIsArray && endIsArray;\n if (isInterpolationList) {\n _object[property] = this._interpolationFunction(end, value);\n }\n else if (typeof end === 'object' && end) {\n // eslint-disable-next-line\n // @ts-ignore FIXME?\n this._updateProperties(_object[property], start, end, value);\n }\n else {\n // Parses relative end values with start as base (e.g.: +10, -3)\n end = this._handleRelativeValue(start, end);\n // Protect against non numeric properties.\n if (typeof end === 'number') {\n // eslint-disable-next-line\n // @ts-ignore FIXME?\n _object[property] = start + (end - start) * value;\n }\n }\n }\n };\n Tween.prototype._handleRelativeValue = function (start, end) {\n if (typeof end !== 'string') {\n return end;\n }\n if (end.charAt(0) === '+' || end.charAt(0) === '-') {\n return start + parseFloat(end);\n }\n return parseFloat(end);\n };\n Tween.prototype._swapEndStartRepeatValues = function (property) {\n var tmp = this._valuesStartRepeat[property];\n var endValue = this._valuesEnd[property];\n if (typeof endValue === 'string') {\n this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(endValue);\n }\n else {\n this._valuesStartRepeat[property] = this._valuesEnd[property];\n }\n this._valuesEnd[property] = tmp;\n };\n return Tween;\n}());\n\nvar VERSION = '23.1.2';\n\n/**\n * Tween.js - Licensed under the MIT license\n * https://github.com/tweenjs/tween.js\n * ----------------------------------------------\n *\n * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.\n * Thank you all, you're awesome!\n */\nvar nextId = Sequence.nextId;\n/**\n * Controlling groups of tweens\n *\n * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.\n * In these cases, you may want to create your own smaller groups of tweens.\n */\nvar TWEEN = mainGroup;\n// This is the best way to export things in a way that's compatible with both ES\n// Modules and CommonJS, without build hacks, and so as not to break the\n// existing API.\n// https://github.com/rollup/rollup/issues/1961#issuecomment-423037881\nvar getAll = TWEEN.getAll.bind(TWEEN);\nvar removeAll = TWEEN.removeAll.bind(TWEEN);\nvar add = TWEEN.add.bind(TWEEN);\nvar remove = TWEEN.remove.bind(TWEEN);\nvar update = TWEEN.update.bind(TWEEN);\nvar exports = {\n Easing: Easing,\n Group: Group,\n Interpolation: Interpolation,\n now: now,\n Sequence: Sequence,\n nextId: nextId,\n Tween: Tween,\n VERSION: VERSION,\n getAll: getAll,\n removeAll: removeAll,\n add: add,\n remove: remove,\n update: update,\n};\n\nexport { Easing, Group, Interpolation, Sequence, Tween, VERSION, add, exports as default, getAll, nextId, now, remove, removeAll, update };\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2019-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {IEvtMng, CmnLib, argChk_Boolean, argChk_Num} from './CmnLib';\nimport {HArg} from './Grammar';\n\nimport {Tween, Easing, removeAll, update} from '@tweenjs/tween.js'\nimport {Application} from 'pixi.js';\n\ninterface ITwInf {\n\ttw\t\t: Tween | undefined;\n\tonEnd?\t: ()=> void;\n}\n\nexport class CmnTween {\n\tstatic\t#hTwInf\t: {[tw_nm: string]: ITwInf}\t= {};\n\n\tstatic\t#evtMng\t: IEvtMng;\n\tstatic\t#appPixi: Application;\n\tstatic\tinit(evtMng: IEvtMng, appPixi: Application) {\n\t\tCmnTween.#hTwInf = {};\n\t\tCmnTween.#evtMng = evtMng;\n\t\tCmnTween.#appPixi = appPixi;\n\n\t\tCmnTween.#appPixi.ticker.add(CmnTween.#fncTicker);\t// TWEEN 更新\n\t}\n\tstatic\t#fncTicker = ()=> update();\n\tstatic\tdestroy() {\n\t\tCmnTween.stopAllTw();\n\t\tCmnTween.#appPixi.ticker.remove(CmnTween.#fncTicker);\n\t}\n\n\tstatic\tsetTwProp(tw: Tween, hArg: HArg): Tween {\n\t\tconst repeat = argChk_Num(hArg, 'repeat', 1);\n\t\treturn tw.delay(argChk_Num(hArg, 'delay', 0))\n\t\t.easing(CmnTween.ease(hArg.ease))\n\t\t.repeat(repeat > 0 ?repeat -1 :Infinity)\t// 一度リピート→計二回なので\n\t\t.yoyo(argChk_Boolean(hArg, 'yoyo', false));\n\t}\n\tstatic\treadonly #hEase: {[name: string]: (k: number)=> number}\t= {\n\t\t'Back.In'\t\t\t: k=> Easing.Back.In(k),\n\t\t'Back.InOut'\t\t: k=> Easing.Back.InOut(k),\n\t\t'Back.Out'\t\t\t: k=> Easing.Back.Out(k),\n\t\t'Bounce.In'\t\t\t: k=> Easing.Bounce.In(k),\n\t\t'Bounce.InOut'\t\t: k=> Easing.Bounce.InOut(k),\n\t\t'Bounce.Out'\t\t: k=> Easing.Bounce.Out(k),\n\t\t'Circular.In'\t\t: k=> Easing.Circular.In(k),\n\t\t'Circular.InOut'\t: k=> Easing.Circular.InOut(k),\n\t\t'Circular.Out'\t\t: k=> Easing.Circular.Out(k),\n\t\t'Cubic.In'\t\t\t: k=> Easing.Cubic.In(k),\n\t\t'Cubic.InOut'\t\t: k=> Easing.Cubic.InOut(k),\n\t\t'Cubic.Out'\t\t\t: k=> Easing.Cubic.Out(k),\n\t\t'Elastic.In'\t\t: k=> Easing.Elastic.In(k),\n\t\t'Elastic.InOut'\t\t: k=> Easing.Elastic.InOut(k),\n\t\t'Elastic.Out'\t\t: k=> Easing.Elastic.Out(k),\n\t\t'Exponential.In'\t: k=> Easing.Exponential.In(k),\n\t\t'Exponential.InOut'\t: k=> Easing.Exponential.InOut(k),\n\t\t'Exponential.Out'\t: k=> Easing.Exponential.Out(k),\n\t\t'Linear.None'\t\t: k=> Easing.Linear.None(k),\n\t\t'Quadratic.In'\t\t: k=> Easing.Quadratic.In(k),\n\t\t'Quadratic.InOut'\t: k=> Easing.Quadratic.InOut(k),\n\t\t'Quadratic.Out'\t\t: k=> Easing.Quadratic.Out(k),\n\t\t'Quartic.In'\t\t: k=> Easing.Quartic.In(k),\n\t\t'Quartic.InOut'\t\t: k=> Easing.Quartic.InOut(k),\n\t\t'Quartic.Out'\t\t: k=> Easing.Quartic.Out(k),\n\t\t'Quintic.In'\t\t: k=> Easing.Quintic.In(k),\n\t\t'Quintic.InOut'\t\t: k=> Easing.Quintic.InOut(k),\n\t\t'Quintic.Out'\t\t: k=> Easing.Quintic.Out(k),\n\t\t'Sinusoidal.In'\t\t: k=> Easing.Sinusoidal.In(k),\n\t\t'Sinusoidal.InOut'\t: k=> Easing.Sinusoidal.InOut(k),\n\t\t'Sinusoidal.Out'\t: k=> Easing.Sinusoidal.Out(k),\n\t};\n\tstatic\tease(nm: string | undefined): (k: number)=> number {\n\t\tif (! nm) return k=> Easing.Linear.None(k);\n\t\tif (! (nm in CmnTween.#hEase)) throw '異常なease指定です';\n\n\t\treturn CmnTween.#hEase[nm];\n\t}\n\n\tstatic readonly hMemberCnt\t= {\n\t\talpha\t\t: 0,\n\t\theight\t\t: 0,\n\t\trotation\t: 0,\t// rotationX〜Z、scaleZ、zは設定すると\n\t\tscale_x\t\t: 0,\t// 三次元方向の拡大縮小ルーチンが働き画像がぼやけるので\n\t\tscale_y\t\t: 0,\t// backlayで設定しない方針\n\t\tpivot_x\t\t: 0,\n\t\tpivot_y\t\t: 0,\n\t\twidth\t\t: 0,\n\t\tx\t\t\t: 0,\n\t\ty\t\t\t: 0,\n\t};\n\tstatic cnvTweenArg(hArg: HArg, lay: any): {} {\n\t\tconst hTo: any = {};\n\t\tfor (const nm of Object.keys(CmnTween.hMemberCnt)) {\n\t\t\tif (! (nm in hArg)) continue;\n\t\n\t\t\t// {x:500}\t\t\tX位置を500に\n\t\t\t// {x:'=500'}\t\t現在のX位置に+500加算した位置\n\t\t\t// {x:'=-500'}\t\t現在のX位置に-500加算した位置\n\t\t\t// {x:'250,500'}\t+250から+500までの間でランダムな値をX位置に\n\t\t\t// {x:'=250,500'}\t+250から+500までの間でランダムな値を現在のX位置に加算\n\t\t\tconst v = String((hArg as any)[nm]);\n\t\t\tconst a = ((v.at(0) === '=') ?v.slice(1) :v).split(',');\n\t\t\tconst a0 = hTo[nm] = parseFloat(a[0]);\n\t\t\tif (a.length > 1) hTo[nm] += Math.round(Math.random()\n\t\t\t\t* (parseFloat(a[1]) -a0 +1));\n\t\t\tif (v.at(0) === '=') hTo[nm] += parseFloat(lay[nm]);\t// 相対に\n\t\t}\n\t\treturn hTo;\n\t}\n\n\n\t// トゥイーン全停止\n\tstatic\tstopAllTw() {CmnTween.#hTwInf = {}; removeAll()}\n\n\tstatic\ttween(tw_nm: string, hArg: HArg, hNow: any, hTo: any, onUpdate: ()=> void, onComplete: ()=> void, onEnd: ()=> void): void {\n\t\tconst tw = CmnTween.tweenA(tw_nm, hArg, hNow, hTo, onUpdate, onComplete, onEnd);\n\t\tCmnTween.tweenB(hArg.chain, tw);\n\t}\n\tstatic\ttweenA(tw_nm: string, hArg: HArg, hNow: any, hTo: any, onUpdate: ()=> void, onComplete: ()=> void, onEnd: ()=> void): Tween {\n\t\tconst time = this.#evtMng.isSkipping ?0 :argChk_Num(hArg, 'time', NaN);\n\t\tconst tw = new Tween(hNow)\n\t\t.to(hTo, time)\n\t\t.onUpdate(onUpdate);\n\t\tCmnTween.setTwProp(tw, hArg);\n\t\tCmnTween.#hTwInf[tw_nm] = {tw, onEnd};\n\n\t\tconst {path} = hArg;\n\t\tlet twLast = tw;\n\t\tif (path) {\n\t\t\tif (CmnLib.debugLog) console.group(`🍝 [${hArg[':タグ名']}] path=${path}= start(${hNow.x},${hNow.y},${hNow.alpha})`);\n\t\t\tfor (const {groups} of path.matchAll(CmnTween.#REG_TSY_PATH)) {\n\t\t\t\tconst {x, x2, y, y2, o, o2, json} = groups!;\n\t\t\t\tlet hArg2: any = {};\n\t\t\t\tif (json) try {hArg2 = JSON.parse(json)} catch (e) {\n\t\t\t\t\tconsole.error(`🍝 json=${json} `+ e);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (x ?? x2) hArg2.x = x ?? x2;\n\t\t\t\t\tif (y ?? y2) hArg2.y = y ?? y2;\n\t\t\t\t\tif (o ?? o2) hArg2.alpha = o ?? o2;\n\t\t\t\t}\n\n\t\t\t\tconst hTo2 = CmnTween.cnvTweenArg(hArg2, hNow);\n\t\t\t\tif (CmnLib.debugLog) console.info(`🍝 ${\n\t\t\t\t\tjson ?? `{x:${x} y:${y} o:${o}}`\n\t\t\t\t} => hTo:${JSON.stringify(hTo2)}`);\n\n\t\t\t\tconst twNew = new Tween(hNow)\n\t\t\t\t.to(hTo2, time);\n\t\t\t\tCmnTween.setTwProp(twNew, hArg);\n\t\t\t\ttwLast.chain(twNew);\n\n\t\t\t\ttwLast = twNew;\n\t\t\t}\n\t\t\tif (CmnLib.debugLog) console.groupEnd();\n\t\t}\n\t\ttwLast.onComplete(()=> {\n\t\t\tconst ti = CmnTween.#hTwInf[tw_nm];\n\t\t\tif (! ti) return;\n\t\t\tdelete CmnTween.#hTwInf[tw_nm];\n\n\t\t\tti.tw = undefined;\n\t\t\ttw.stop();\n\t\t\tCmnTween.#evtMng.breakEvent('tsy nm:'+ tw_nm);\t// waitEvent 使用者の通常 break 時義務\n\t\t\tti.onEnd?.();\n\n\t\t\tonComplete();\n\t\t});\n\n\t\treturn tw;\n\t}\n\tstatic\ttweenB(chain: string | undefined, tw: Tween) {\n\t\tif (chain) {\t// 指定レイヤのアニメ終了に、このトゥイーンを続ける\n\t\t\tconst twFrom = CmnTween.#hTwInf[chain];\n\t\t\tif (! twFrom?.tw) throw `${chain}は存在しない・または終了したトゥイーンです`;\n\t\t\tdelete twFrom.onEnd;\n\t\t\ttwFrom.tw.chain(tw);\n\t\t}\n\t\telse tw.start();\n\t}\n\t// 11 match 301 step (0.1ms) PCRE2 https://regex101.com/r/reinpq/1\n\t\t// List ${x}${x2}/${y}${y2}/${o}${o2}=${json}\\n\n/*\n\\(\\s*\n(?:\t(?[-=\\d\\.]+)\t|\t(['\"])\t(?.*?)\t\\2\t)?\n(?:\n\t\\s*,\\s*\n\t(?:\t(?[-=\\d\\.]+)\t|\t(['\"])\t(?.*?)\t\\5\t)?\n\t(?:\n\t\t\\s*,\\s*\n\t\t(?:\t(?[-=\\d\\.]+)\t|\t(['\"])\t(?.*?)\t\\8\t)\n\n\t)?\n)?\n|\n(?\\{[^{}]*})\n*/\n\tstatic\treadonly\t#REG_TSY_PATH\t= /\\(\\s*(?:(?[-=\\d\\.]+)|(['\"])(?.*?)\\2)?(?:\\s*,\\s*(?:(?[-=\\d\\.]+)|(['\"])(?.*?)\\5)?(?:\\s*,\\s*(?:(?[-=\\d\\.]+)|(['\"])(?.*?)\\8))?)?|(?\\{[^{}]*})/g;\n\n\t// トランス終了待ち\n\tstatic\twt(hArg: HArg) {\n\t\tconst ti = CmnTween.#hTwInf[CmnTween.TW_INT_TRANS];\n\t\tif (! ti?.tw) return false;\n\n\t\treturn CmnTween.#evtMng.waitEvent('tsy nm:'+ CmnTween.TW_INT_TRANS, hArg, ()=> CmnTween.finish_trans());\n\t}\n\tstatic\treadonly\tTW_INT_TRANS = 'trans\\n';\t// 改行でスクリプトから絶対指定できない値に\n\tstatic\tget\tisTrans(): boolean {return CmnTween.#hTwInf[CmnTween.TW_INT_TRANS]?.tw !== undefined}\n\n\t// レイヤのトランジションの停止\n\tstatic\tfinish_trans(): boolean {CmnTween.#hTwInf[CmnTween.TW_INT_TRANS]?.tw?.stop().end(); return false}\t// stop()とend()は別\n\n\n\t// トゥイーン終了待ち\n\tstatic\twait_tsy(hArg: HArg) {\n\t\tconst {layer='', id, name} = hArg;\n\t\tconst tw_nm = id ?`frm\\n${id}` :(name ?? layer);\n\t\tif (! tw_nm) throw 'トゥイーンが指定されていません';\n\t\tconst ti = CmnTween.#hTwInf[tw_nm];\n\t\tif (! ti?.tw) {\n\t\t\tif (argChk_Boolean(hArg, 'chk_exist_tw', false)) throw id\n\t\t\t?`フレームトゥイーン ${id} が見つかりません。`\n\t\t\t:`トゥイーン ${tw_nm} が見つかりません。(layer:${layer} name:${name})`;\n\n\t\t\treturn false;\n\t\t}\n\n\t\treturn CmnTween.#evtMng.waitEvent('tsy nm:'+ tw_nm, hArg, ()=> ti.tw?.end());\t// stop()とend()は別\n\t}\n\n\t// トゥイーン中断\n\tstatic\tstop_tsy(hArg: HArg) {\n\t\tconst {layer='', id, name} = hArg;\n\t\tconst tw_nm = id ?`frm\\n${id}` :(name ?? layer);\n\t\tif (! tw_nm) throw 'トゥイーンが指定されていません';\n\n\t\tCmnTween.#hTwInf[tw_nm]?.tw?.stop().end();\t// stop()とend()は別\n\n\t\treturn false;\n\t}\n\n\t// 一時停止\n\tstatic\tpause_tsy(hArg: HArg) {\n\t\tconst {layer='', id, name} = hArg;\n\t\tconst tw_nm = id ?`frm\\n${id}` :(name ?? layer);\n\t\tif (! tw_nm) throw 'トゥイーンが指定されていません';\n\n\t\tCmnTween.#hTwInf[tw_nm]?.tw?.pause();\n\n\t\treturn false;\n\t}\n\n\t// 一時停止再開\n\tstatic\tresume_tsy(hArg: HArg) {\n\t\tconst {layer='', id, name} = hArg;\n\t\tconst tw_nm = id ?`frm\\n${id}` :(name ?? layer);\n\t\tif (! tw_nm) throw 'トゥイーンが指定されていません';\n\n\t\tCmnTween.#hTwInf[tw_nm]?.tw?.resume();\n\n\t\treturn false;\n\t}\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2023-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {IVariable, IMain, IHEvt2Fnc, IEvt2Fnc, IMark} from './CmnInterface';\nimport {CmnLib, argChk_Boolean, argChk_Num} from './CmnLib';\nimport {HArg, IHTag, ITag} from './Grammar';\nimport {LayerMng} from './LayerMng';\nimport {ScriptIterator} from './ScriptIterator';\nimport {EventListenerCtn} from './EventListenerCtn';\nimport {SoundMng} from './SoundMng';\nimport {FocusMng} from './FocusMng';\nimport {Config} from './Config';\n\nimport {Container, utils} from 'pixi.js';\nimport {Tween, remove} from '@tweenjs/tween.js'\n\nlet\tchgSt\t: (rs: ReadState)=> void;\nlet main\t: IMain;\nlet val\t\t: IVariable;\nlet layMng\t: LayerMng;\nlet scrItr\t: ScriptIterator;\nlet sndMng\t: SoundMng;\nlet hTag\t: IHTag;\nlet fcs\t\t: FocusMng;\nlet\tgoTxt\t: ()=> void;\nlet procWheel4wle: (elc: EventListenerCtn, onIntr: ()=> void)=> void\t= ()=> {};\nlet\telmHint\t: HTMLElement;\nlet\tcfg\t\t: Config;\n\nlet\ttagL_enabled\t= true;\t\t// 頁末まで一気に読み進むか(l無視)\nlet\tskip_all\t\t= false;\t// falseなら既読のみをスキップ\nlet\tskip_enabled\t= false;\t// 次の選択肢(/未読)まで進むが有効か\nlet\tauto_enabled\t= false;\t// 自動読みすすみモードかどうか\n\nlet\thLocalEvt2Fnc\t: IHEvt2Fnc = {};\nlet\thGlobalEvt2Fnc\t: IHEvt2Fnc = {};\n//let\tisDbgBreak\t\t= false;\n\nfunction\tcancelAutoSkip() {\n\tif (! tagL_enabled) {\t// 頁末まで一気に読み進むか(l無視)\n\t\ttagL_enabled = true;\n\t\tval.setVal_Nochk('tmp', 'sn.tagL.enabled', true);\n\t}\n\n\tif (skip_enabled) {\t\t// 次の選択肢(/未読)まで進むが有効か\n\t\tskip_enabled = false;\n\t\tval.setVal_Nochk('tmp', 'sn.skip.enabled', false);\n\t}\n\tif (auto_enabled) {\t\t// 自動読みすすみモードかどうか\n\t\tauto_enabled = false;\n\t\tval.setVal_Nochk('tmp', 'sn.auto.enabled', false);\n\t}\n}\n\nexport\tfunction\tenableEvent() {new RsEvtRsv}\nexport\tfunction\tdisableEvent() {new Rs_BanEvent}\n\ninterface IPageLog {\n\tkey\t\t: string;\n\tfn\t\t: string;\n\tindex\t: number;\n\tmark\t: IMark;\n\tweek\t: boolean;\n};\n\nclass WaitLimitedEventer {\n\treadonly\t#elc\t= new EventListenerCtn;\n\n\tconstructor(hArg: HArg, onIntr: ()=> void) {\n\t\tif (skip_enabled) {\t\t// Fスキップ時\n\t\t\tif (! skip_all && ! scrItr.isNextKidoku) cancelAutoSkip();\t// 未読で停止\n\t\t//\telse {fnc(); return false}\t// これを有効にすると Fスキップ時速すぎて文字が見えない\n\t\t}\n\n\t\tif (argChk_Boolean(hArg, 'canskip', true)) {\n\t\t\tconst fnc = ()=> {this.destroy(); cancelAutoSkip(); onIntr()};\n\t\t\tthis.#elc.add(window, 'pointerdown', e=> {e.stopPropagation(); fnc()});\n\t\t\tthis.#elc.add(window, 'keydown', (e: any)=> {\n\t\t\t\t//if (! e.isTrusted) return;\n\t\t\t\tif (e['isComposing']) return; // サポートしてない環境でもいける書き方\n\t\t\t\te.stopPropagation();\n\t\t\t\tfnc();\n\t\t\t});\n\t\t\tprocWheel4wle(this.#elc, fnc);\n\t\t}\n\t}\n\tdestroy() {this.#elc.clear()}\n\n}\n\n\nexport class ReadState {\n\tstatic\tinit($chgSt: (rs: ReadState)=> void, $main: IMain, $val: IVariable, $layMng: LayerMng, $scrItr: ScriptIterator, $sndMng: SoundMng, $hTag: IHTag, $fcs: FocusMng, $procWheel4wle: (elc: EventListenerCtn, onIntr: ()=> void)=> void, $elmHint: HTMLElement, $cfg: Config) {\n\t\tchgSt = $chgSt;\n\t\tmain = $main;\n\t\tval = $val;\n\t\tlayMng = $layMng;\n\t\tscrItr = $scrItr;\n\t\tsndMng = $sndMng;\n\t\thTag = $hTag;\n\t\tfcs = $fcs;\n\t\tgoTxt = ()=> layMng.goTxt();\n\t\tprocWheel4wle = $procWheel4wle;\n\t\telmHint = $elmHint;\n\t\tcfg = $cfg;\n\t\tnew RsEvtRsv;\n\n\t\tval.defTmp('sn.tagL.enabled', ()=> tagL_enabled);\n\t\tval.defValTrg('tmp:sn.tagL.enabled', (_name: string, val: any)=> tagL_enabled = String(val) !== 'false');\n\t\tval.defTmp('sn.skip.all', ()=> skip_all);\n\t\tval.defValTrg('tmp:sn.skip.all', (_name: string, val: any)=> skip_all = String(val) !== 'false');\n\t\tval.defTmp('sn.skip.enabled', ()=> skip_enabled);\n\t\tval.defValTrg('tmp:sn.skip.enabled', (_name: string, val: any)=> skip_enabled = String(val) !== 'false');\n\t\tval.defTmp('sn.auto.enabled', ()=> auto_enabled);\n\t\tval.defValTrg('tmp:sn.auto.enabled', (_name: string, val: any)=> auto_enabled = String(val) !== 'false');\n\n\t\thLocalEvt2Fnc = {};\n\t\thGlobalEvt2Fnc = {};\n\t}\n\n\tprotected\tconstructor(protected readonly hArg: HArg) {chgSt(this)}\n\n\tget\tisSkipping(): boolean {return skip_enabled}\n\n\tstatic\tgetHtmlElmList(KeY: string): {el: NodeListOf, id: string, sel: string} {\n\t\tconst idx = KeY.indexOf(':');\n\t\tlet sel = '';\n\t\tif (idx >= 0) {\t\t// key='dom=config:#ctrl2val\n\t\t\tconst id = KeY.slice(4, idx);\n\t\t\tconst frmnm = `const.sn.frm.${id}`;\n\t\t\tif (! val.getVal(`tmp:${frmnm}`, 0)) throw `HTML【${id}】が読み込まれていません`;\n\n\t\t\tconst ifrm = document.getElementById(id) as HTMLIFrameElement;\n\t\t\tconst win = ifrm.contentWindow!;\n\t\t\tsel = KeY.slice(idx +1);\n\t\t\treturn {el: win.document.querySelectorAll(sel), id, sel};\n\t\t}\n\n\t\tsel = KeY.slice(4);\n\t\treturn {el: document.querySelectorAll(sel), id: '', sel};\n\t}\n\n\n\tstatic\tsetEvt2Fnc(glb: boolean, key: string, fnc: IEvt2Fnc) {\n\t\tif (glb)\n\t\t\thGlobalEvt2Fnc[key] = fnc;\n\t\telse hLocalEvt2Fnc[key] = fnc;\n\t}\n\tstatic\tgetEvt2Fnc = (key: string): IEvt2Fnc | undefined => hLocalEvt2Fnc[key] ?? hGlobalEvt2Fnc[key];\n\tstatic\tclear_eventer(KeY: string, glb: boolean, key: string) {\n\t\tif (KeY.slice(0, 4) !== 'dom=') return;\n\n\t\tconst e2f = glb ? hGlobalEvt2Fnc[key] : hLocalEvt2Fnc[key];\n\t\tReadState.getHtmlElmList(KeY).el.forEach(v=> v.removeEventListener('click', e2f));\n\t\tif (glb) delete hGlobalEvt2Fnc[key]; else delete hLocalEvt2Fnc[key];\n\t}\n\n\n\tstatic\tclear_event(hArg: HArg): boolean {\n\t\tconst glb = argChk_Boolean(hArg, 'global', false);\n\t\tconst h = glb ?hGlobalEvt2Fnc :hLocalEvt2Fnc;\n\t\tfor (const [KeY, e2f] of Object.entries(h)) {\n\t\t\tif (KeY.slice(0, 4) !== 'dom=') continue;\n\n\t\t\tReadState.getHtmlElmList(KeY).el.forEach(v=> v.removeEventListener('click', e2f));\n\t\t}\n\t\tif (glb) hGlobalEvt2Fnc = {}; else hLocalEvt2Fnc = {};\n\n\t\treturn false;\n\t}\n\n\ts(hArg: HArg) {this.#recodePage(); return Rs_S.go(hArg)}\n\n\treadonly\twait: ITag = hArg=> {\n\t\tif (skip_enabled) {\t\t// Fスキップ時\n\t\t\tif (! skip_all && ! scrItr.isNextKidoku) {cancelAutoSkip(); return false}\n\n\t\t\treturn false;\n\t\t}\n\n\t\treturn Rs_Wait.go(hArg);\n\t}\n\treadonly\twaitclick: ITag = hArg=> Rs_WaitClick.go(hArg);\n\n\tprotected\twaitTxtAndTimer(time: number, hArg: HArg): boolean {\n\t\tReadState.#eeCompTxt.once(ReadState.#EENM_COMP_TXT, ()=> {\t// 1)文字表示待ち\n//console.log(`fn:ReadState.ts B) Txt Fin... time Wait:${time}`);\n\t\t\tthis.#wle.destroy();\t// waitEvent 使用者の通常 break 時義務\n\t\t\tif (time === 0) {this.onFinish(); return}\n\n\t\t\tconst tw = new Tween({})\n\t\t\t.to({}, time)\n\t\t\t.onComplete(()=> {\t// 2)時間待ち\n//console.log(`fn:ReadState.ts 2) COMP`);\n\t\t\t\tthis.#wle.destroy();\t// waitEvent 使用者の通常 break 時義務\n\t\t\t\tremove(tw);\n\t\t\t\tthis.onFinish();\n\t\t\t})\n\t\t\t.start();\n\t\t\tthis.waitLimitedEvent(hArg, ()=> {\t// 2)時間待ち\n//console.log(`fn:ReadState.ts 2) CANCEL`);\n\t\t\t\ttw.stop();\n\t\t\t\tremove(tw);\t//x\ttw.end();\n\t\t\t\tthis.onUserAct();\n\t\t\t});\n\t\t});\n\t\tgoTxt();\n\t\tval.saveKidoku();\n\n\t\treturn this.waitLimitedEvent(hArg, ()=> {\t// 1)文字表示待ち\n//console.log(`fn:ReadState.ts b) Txt Skip`);\n\t\t\tReadState.#eeCompTxt.removeAllListeners();\n\t\t\tthis.onUserAct();\t// 並び重要\n\t\t});\n\t}\n\tstatic\tnoticeCompTxt() {ReadState.#eeCompTxt.emit(ReadState.#EENM_COMP_TXT)}\n\tstatic\treadonly\t#eeCompTxt\t\t= new utils.EventEmitter;\t// static必須\n\tstatic\treadonly\t#EENM_COMP_TXT\t= 'sn:notice_comp_txt';\n\n\n\tstatic\tpopLocalEvts(): IHEvt2Fnc {\n\t\tconst ret = hLocalEvt2Fnc;\n\t\thLocalEvt2Fnc = {};\n\t\treturn ret;\n\t}\n\tstatic\tpushLocalEvts(h: IHEvt2Fnc) {hLocalEvt2Fnc = h}\n\n\t// 予約イベントの発生待ち\n\tprotected\twaitRsvEvent(canUserAct: boolean, glb: boolean): void {\n\t\tval.saveKidoku();\n\n\t\tif (canUserAct) {\n\t\t\t//hTag.event({key:'click', breakout: fnc});\n\t\t\t//hTag.event({key:'middleclick', breakout: fnc});\n\t\t\t//\thTag.event()は内部で使わず、こうする\n\t\t\thLocalEvt2Fnc['click'] =\n\t\t\t//this.hTag.event({key:'enter', breakout: fnc});\n\t\t\t//hTag.event({key:'down', breakout: fnc});\n\t\t\t//\thTag.event()は内部で使わず、こうする\n\t\t\thLocalEvt2Fnc['enter'] =\n\t\t\thLocalEvt2Fnc['arrowdown'] =\n\n\t\t\t// hTag.event({key:'downwheel', breakout: fnc});\n\t\t\t//\thTag.event()は内部で使わず、こうする\n\t\t\thLocalEvt2Fnc['wheel.y>0'] = ()=> this.onUserAct();\n\t\t}\n\t\telse {\n\t\t\tdelete hLocalEvt2Fnc['click'];\n\t\t\tdelete hLocalEvt2Fnc['enter'];\n\t\t\tdelete hLocalEvt2Fnc['arrowdown'];\n\t\t\tdelete hLocalEvt2Fnc['wheel.y>0'];\n\t\t}\n\t\tReadState.getEvt2Fnc = glb\n\t\t\t? key=> hLocalEvt2Fnc[key]\n\t\t\t\t?? hGlobalEvt2Fnc[key]\n\t\t\t: key=> hLocalEvt2Fnc[key];\n\n\t\tscrItr.noticeWait();\n\t\tif (CmnLib.debugLog) {\n\t\t\tconst o = Object.create(null);\n\t\t\to.local = Object.keys(hLocalEvt2Fnc);\n\t\t\to.global= Object.keys(hGlobalEvt2Fnc);\n\t\t\tconsole.log(`🎍 wait event... %o`, o);\n\t\t}\n\t}\n\n\n\tl(hArg: HArg): boolean {\n\t\tif (! tagL_enabled) return false;\n\t\tthis.#recodePage(true);\n\n\t\tif (auto_enabled) {\n\t\t\tconst time = Number(val.getVal(`sys:sn.auto.msecLineWait${scrItr.isKidoku ?'_Kidoku' :''}`));\n\t\t\treturn Rs_L_AutoSkip.go(time, hArg);\n\t\t}\n\t\tif (skip_enabled) {\t\t// Fスキップ時\n\t\t\tif (! skip_all && ! scrItr.isNextKidoku) return Rs_L_Wait.go(hArg);\t// 未読で停止\n\n\t\t\tif ('ps'.includes(val.getVal('sys:sn.skip.mode'))) return Rs_L_AutoSkip.go(50, hArg);\t// 改行待ち=しない\t// 魔法数字、見えるぐらい少し待つ\n\t\t}\n\n\t\treturn Rs_L.go(hArg);\n\t}\n\n\tp(hArg: HArg): boolean {\n\t\tthis.#recodePage();\n\n\t\tif (auto_enabled) {\n\t\t\tconst time = Number(val.getVal(`sys:sn.auto.msecPageWait${scrItr.isKidoku ?'_Kidoku' :''}`));\n\t\t\treturn Rs_P_AutoSkip.go(time, hArg);\n\t\t}\n\t\tif (skip_enabled) {\t\t// Fスキップ時\n\t\t\tif (! skip_all && ! scrItr.isNextKidoku) return Rs_P_Wait.go(hArg);\t// 未読で停止\n\n\t\t\tif ('s' == val.getVal('sys:sn.skip.mode')) {\t// 改行待ち&改ページ待ち=しない\n\t\t\t\treturn Rs_P_AutoSkip.go(50, hArg);\t// 魔法数字、見えるぐらい少し待つ\n\t\t\t\t//return false;\t// このほうが高速だが、Fスキップ時文字を見せたい\n\t\t\t}\n\t\t}\n\n\t\treturn Rs_P.go(hArg);\n\t}\n\n\n\t// 予約イベントの発生待ちしない waitRsvEvent()\n\t// 使う場合、外部要因でキャンセルした際は breakLimitedEvent() で後始末を忘れないこと\n\twaitLimitedEvent(hArg: HArg, onIntr: ()=> void): boolean {\n\t\tthis.#wle.destroy();\n\t\tthis.#wle = new WaitLimitedEventer(hArg, onIntr);\n\n\t\treturn true;\n\t}\n\tbreakEvent(evnm: string) {\n\t\tif (ReadState.evnm !== evnm) return;\n\t\tReadState.evnm = '';\n\n\t\tthis.#wle.destroy();\n\t\tenableEvent();\n\t}\n\t#wle\t= new WaitLimitedEventer({}, ()=> {});\t// ':タグ名' は未定義、デバッグ時に無視を\n\tprotected\tstatic\tevnm\t= '';\t// 状態保存する変数はすべて static に\n\n\twaitEvent(evnm: string, hArg: HArg, onFire: ()=> void) {\n\t\t// waitEvent 使用者は、通常 break 時義務として、breakEvent()を呼ぶこと\n\t\tReadState.evnm = evnm;\n\n\t//\tif (auto_enabled)\t// いまのとこ高速化せず\n\t\tif (skip_enabled) {\t\t// Fスキップ時\n\t\t\tif (! skip_all && ! scrItr.isNextKidoku) return Rs_Any_Wait.go(hArg, onFire);\t// 未読で停止\n\t\t}\n\n\t\treturn Rs_Any.go(hArg, onFire);\n\t}\n\n\tprotected\tonFinish(): void {}\n\tprotected\tonUserAct(): void {}\n\n\treadonly\tisWait: boolean\t\t= false;\t// 予約イベントの発生待ち中か\n\tfire(_KEY: string, _e: Event) {}\n\n\tprotected\tstatic\taPage\t: IPageLog[]\t= [];\n\tprotected\tstatic\tstylePage\t= 'color: yellow;';\n\tpage(hArg: HArg): boolean {\n\t\tif (! ('clear' in hArg || 'style' in hArg || 'to' in hArg)) throw 'clear か style か to は必須です';\n\n\t\tif (argChk_Boolean(hArg, 'clear', false)) ReadState.aPage = [];\n\n\t\tconst {to, style} = hArg;\n\t\tif (style) ReadState.stylePage = style;\n\n\t\tswitch (to) {\n\t\t\tcase 'prev':\tif (ReadState.aPage.length < 2) return false;\tbreak;\n\t\t//\tcase 'next':\treturn false;\n\t\t\tdefault:\treturn false;\n\t\t}\n\n\t\treturn RsPagination.go(hArg);\t// ページ移動開始\n\t}\n\n\t#recodePage(week = false) {\n\t\tif (! val.getVal('save:sn.doRecLog')) return;\n\n\t\tconst {fn, idx} = scrItr.nowScrIdx();\n\t\tconst key = (idx -1) +':'+ fn;\n\t\tif (ReadState.aPage.findIndex(p=> p.key === key) > -1) return;\n\n\t\tif (ReadState.aPage.at(-1)?.week) ReadState.aPage.pop();\n\t\tconst max_len = cfg.oCfg.log.max_len;\t// 一定数を保つ\n\t\tif (ReadState.aPage.push({key, week,\n\t\t\tfn\t\t: val.getVal('save:const.sn.scriptFn', fn),\n\t\t\tindex\t: val.getVal('save:const.sn.scriptIdx', 0),\n\t\t\tmark\t: scrItr.nowMark(),\n\t\t}) > max_len) ReadState.aPage = ReadState.aPage.slice(-max_len);\n\t}\n}\n\n\n// === イベント予約受付中 ===\nclass RsEvtRsv extends ReadState {\n\tconstructor() {super({}); main.resume(); elmHint.hidden = true}\n\toverride\tbreakEvent() {}\n}\n\n\n// === [s] ===\nclass Rs_S_fire extends ReadState {\n\toverride\treadonly\tisWait\t\t= true;\t// 予約イベントの発生待ち中か\n\toverride\tfire(KEY: string, e: Event) {\n\t\t//if (this.#isDbgBreak) return;\n\n\t\t// 予約実行\n\t\tconst key = KEY.toLowerCase();\n\t\tif (CmnLib.debugLog) console.log(`👺 fire<(key:\\`${key}\\` type:${e.type} e:%o)`, {...e});\n\t\tif (key === 'enter') {\n\t\t\tconst em = fcs.getFocus();\n\t\t\tif (em instanceof Container) {\n\t\t\t\tem.emit('pointerdown', new Event('pointerdown'));\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tconst ke = ReadState.getEvt2Fnc(key);\n\t\tif (! ke) {\n\t\t\t// スマホ用疑似スワイプスクロール\n\t\t\tif (key.slice(0, 5) === 'swipe') globalThis.scrollBy(\n\t\t\t\t-(e).deltaX || 0,\t// NaN なので ?? ではダメ\n\t\t\t\t-(e).deltaY || 0,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tif (key.slice(-5) !== 'wheel') e.preventDefault?.();\n\t\te.stopPropagation();\n\t\tif (key.slice(0, 4) !== 'dom=') if (layMng.clickTxtLay()) return;\n\n\t\tke(e);\n\t\t//this.hLocalEvt2Fnc = {};\t// ここで消去禁止、Main.resumeByJumpOrCall()が担当\n\t}\n}\nclass Rs_S extends Rs_S_fire {\n\tstatic\treadonly\tgo: ITag = hArg=> new Rs_S(hArg).waitTxtAndTimer(0, {});\n\toverride\tbreakEvent() {}\n\tprotected\toverride\tonFinish() {\n\t\tcancelAutoSkip();\n\t\tconst glb = argChk_Boolean(this.hArg, 'global', true);\n\t\tthis.waitRsvEvent(false, glb);\n\t}\n\tprotected\toverride\tonUserAct() {this.onFinish()}\n}\n\n\n// === [wait] ===\nclass Rs_Wait extends ReadState {\t// 文字表示終了待ち→[wait]\n\tstatic\treadonly\tgo: ITag = hArg=> {\n\t\tconst time = argChk_Num(hArg, 'time', NaN);\t// skip時でもエラーは出したげたい\n\t\treturn new Rs_Wait(hArg).waitTxtAndTimer(time, hArg);\n\t}\n\tprotected\toverride\tonFinish() {enableEvent()}\n\tprotected\toverride\tonUserAct() {this.onFinish()}\n}\n\n\n// === [l] ===\nclass Rs_L extends ReadState {\t\t// 文字表示終了待ち(そして[l])\n\tstatic\treadonly\tgo: ITag = hArg=> new Rs_L(hArg).waitTxtAndTimer(0, hArg);\n\toverride\tbreakEvent() {}\n\tprotected\toverride\tonFinish() {Rs_L_Wait.go(this.hArg)}\n\tprotected\toverride\tonUserAct() {this.onFinish()}\n}\n\nclass Rs_L_AutoSkip extends ReadState {\t// 文字表示終了待ち(そして[l]auto/skipウェイト待ち)\n\tstatic\treadonly\tgo = (time: number, hArg: HArg)=> new Rs_L_AutoSkip(hArg).waitTxtAndTimer(time, hArg);\n\toverride\tbreakEvent() {}\n\tprotected\toverride\tonFinish() {enableEvent()}\n\tprotected\toverride\tonUserAct() {Rs_L_Wait.go(this.hArg)}\n}\n\nclass Rs_L_Wait extends Rs_S_fire {\t\t// [l] クリック待ち\n\tstatic\treadonly\tgo: ITag = hArg=> {\n\t\tif (argChk_Boolean(hArg, 'visible', true)) {layMng.breakLine(hArg); goTxt()}\n\n\t\tconst glb = argChk_Boolean(hArg, 'global', true);\n\t\tnew Rs_L_Wait(hArg).waitRsvEvent(true, glb);\n\t\treturn true;\n\t}\n\tprotected\toverride\tonFinish() {enableEvent()}\n\tprotected\toverride\tonUserAct() {enableEvent()}\n}\n\n\n// === [p] ===\nclass Rs_P extends ReadState {\t\t// 文字表示終了待ち(そして[p])\n\tstatic\treadonly\tgo: ITag = hArg=> new Rs_P(hArg).waitTxtAndTimer(0, hArg);\n\toverride\tbreakEvent() {}\n\tprotected\toverride\tonFinish() {Rs_P_Wait.go(this.hArg)}\n\tprotected\toverride\tonUserAct() {this.onFinish()}\n}\n\nclass Rs_P_AutoSkip extends ReadState {\t// 文字表示終了待ち(そして[p]auto/skipウェイト待ち)\n\tstatic\treadonly\tgo = (time: number, hArg: HArg)=> new Rs_P_AutoSkip(hArg).waitTxtAndTimer(time, hArg);\n\toverride\tbreakEvent() {}\n\tprotected\toverride\tonFinish() {enableEvent()}\n\tprotected\toverride\tonUserAct() {Rs_P_Wait.go(this.hArg)}\n}\n\nclass Rs_P_Wait extends Rs_S_fire {\t\t// [p] クリック待ち\n\tstatic\treadonly\tgo: ITag = hArg=> {\n\t\t// [p]メソッド内でやるとスキップの利きが悪い\n\t\tif (argChk_Boolean(hArg, 'visible', true)) {layMng.breakPage(hArg); goTxt()}\n\n\t\tconst glb = argChk_Boolean(hArg, 'global', true);\n\t\tnew Rs_P_Wait(hArg).waitRsvEvent(true, glb);\n\t\treturn true;\n\t}\n\tprotected\toverride\tonFinish() {\n\t\tif (argChk_Boolean(this.hArg, 'er', false)) hTag.er(this.hArg);\n\n\t\tsndMng.clearCache();\n\t\t//scrItr.turnPage();\n\t\tenableEvent();\n\t}\n\tprotected\toverride\tonUserAct() {this.onFinish()}\n}\n\n\n// === [waitclick] ===\nclass Rs_WaitClick extends Rs_S_fire {\n\tstatic\treadonly\tgo: ITag = hArg=> new Rs_WaitClick(hArg).waitTxtAndTimer(0, hArg);\n\tprotected\toverride\tonFinish() {\n\t\tcancelAutoSkip();\n\t\tconst glb = argChk_Boolean(this.hArg, 'global', true);\n\t\tthis.waitRsvEvent(true, glb);\n\t}\n\tprotected\toverride\tonUserAct() {enableEvent()}\n}\n\n\n// === [wt][wait_tsy][wv][ws][wl][wf][wb] ===\nclass Rs_Any extends ReadState {\t\t// 文字表示終了待ち(そして[*])\n\tstatic\treadonly\tgo = (hArg: HArg, onIntr: ()=> void)=> new Rs_Any(hArg, onIntr).waitTxtAndTimer(0, hArg);\n\tprivate\tconstructor(hArg: HArg, private readonly onIntr: ()=> void) {super(hArg)}\n\tprotected\toverride\tonFinish() {Rs_Any_Wait.go(this.hArg, this.onIntr)}\n\tprotected\toverride\tonUserAct() {this.onFinish()}\n}\n\n//\tclass Rs_Any_AutoSkip extends... {\t// 文字表示終了待ち(そして[*]auto/skipウェイト待ち)\n\nclass Rs_Any_Wait extends Rs_S_fire {\t// fireがある → イベント受付する\n//class Rs_Any_Wait extends ReadState {\t// fireがない → イベント受付しない\n\tstatic\treadonly\tgo = (hArg: HArg, onFire: ()=> void)=> new Rs_Any_Wait(hArg, onFire).waitLimitedEvent(hArg, onFire);\n\tprivate\tconstructor(hArg: HArg, private readonly onIntr: ()=> void) {super(hArg)}\n\tprotected\toverride\tonFinish() {enableEvent()}\n\tprotected\toverride\tonUserAct() {this.onIntr(); this.onFinish()}\n}\n\n\n// === イベント禁止(内部処理用) ===\nclass Rs_BanEvent extends ReadState {\t// fireがない → イベント受付しない\n\tconstructor() {super({})}\n\toverride\tbreakEvent() {}\n}\n\n\n// === ページ移動中 ===\nexport class RsPagination extends Rs_S {\n\toverride\tget\tisSkipping(): boolean {return ! ReadState.aPage[this.#pos].week}\n\t\t// return true で良いのだが、[l]でページ移動モードになったあと、[l]に戻ってモード終了してから、[p]に至る文字表示が瞬時表示になる対策\n\n\toverride\treadonly\ts: ITag = hArg=> Rs_S.go(hArg);\n\n\toverride\treadonly\twait = ()=> false;\n\toverride\treadonly\twaitclick = ()=> false;\n\tprotected\toverride\treadonly\twaitTxtAndTimer = ()=> false;\n\n\toverride\tl(hArg: HArg): boolean {\n\t\tif (! ReadState.aPage[this.#pos].week) return false;\n\n\t\tconst len = ReadState.aPage.length;\n\t\tif (this.#pos === len -1) return Rs_L_Wait.go(hArg);\t// ページ末尾ならページ移動終了\n\n\t\tif (argChk_Boolean(hArg, 'visible', true)) {layMng.breakLine(hArg); goTxt()}\n\t\tthis.waitRsvEvent(false, true);\n\t\treturn true;\n\t}\n\n\toverride\tp(hArg: HArg): boolean {\n\t\tconst len = ReadState.aPage.length;\n\t\tif (this.#pos === len -1) return Rs_P_Wait.go(hArg);\t// ページ末尾ならページ移動終了\n\n\t\tif (argChk_Boolean(hArg, 'visible', true)) {layMng.breakPage(hArg); goTxt()}\n\t\tthis.waitRsvEvent(false, true);\n\t\treturn true;\n\t}\n\n\tstatic\toverride\treadonly\tgo: ITag = hArg=> new RsPagination(hArg).page(hArg);\n\t#pos\t= ReadState.aPage.length -1;\n\toverride\tpage(hArg: HArg): boolean {\n\t\tconst {to} = hArg;\n\t\tif (! to) return false;\n\n\t\tconst len = ReadState.aPage.length;\n\t\tswitch (to) {\n\t\t\tcase 'prev':\tif (this.#pos === 0) return false;\n\t\t\t\t--this.#pos;\tbreak;\n\n\t\t\tcase 'next':\tif (this.#pos === len -1) return false;\n\t\t\t\t++this.#pos;\tbreak;\n\n\t\t\tdefault:\tthrow `属性to「${to}」は異常です`;\n\t\t}\n\n\t\tconst {fn, index, mark} = ReadState.aPage[this.#pos];\n\t\treturn scrItr.loadFromMark({fn, index,\n\t\t\tstyle\t: (this.#pos === len -1) ?undefined :ReadState.stylePage,\n\t\t\t//r_style までは不要か\n\t\t}, mark);\n\t}\n\n\tprotected\toverride\tonFinish() {}\n\tprotected\toverride\tonUserAct() {}\n}\n","/*!\n * @pixi/sound - v4.4.1\n * https://github.com/pixijs/pixi-sound\n * Compiled Tue, 15 Aug 2023 19:22:13 UTC\n *\n * @pixi/sound is licensed under the MIT license.\n * http://www.opensource.org/licenses/mit-license\n */\nimport{LoaderResource as t,Loader as e}from\"@pixi/loaders\";import*as n from\"@pixi/core\";import{BaseTexture as o}from\"@pixi/core\";import{EventEmitter as i}from\"@pixi/utils\";import{Ticker as r}from\"@pixi/ticker\";var s;function u(){return s}var a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function c(t,e){if(\"function\"!=typeof e&&null!==e)throw new TypeError(\"Class extends value \"+String(e)+\" is not a constructor or null\");function n(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var l=function(){return(l=Object.assign||function(t){for(var e,n=1,o=arguments.length;n-1?t.sound=u().add(t.name,{loaded:e,preload:!0,url:t.url,source:t.data}):e()},e.extension=\"loader\",e}(),b=0,g=function(t){function e(e){var n=t.call(this)||this;return n.id=b++,n.init(e),n}return c(e,t),e.prototype.set=function(t,e){if(void 0===this[t])throw new Error(\"Property with name \".concat(t,\" does not exist.\"));switch(t){case\"speed\":this.speed=e;break;case\"volume\":this.volume=e;break;case\"paused\":this.paused=e;break;case\"loop\":this.loop=e;break;case\"muted\":this.muted=e}return this},Object.defineProperty(e.prototype,\"progress\",{get:function(){return this._source.currentTime/this._duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"paused\",{get:function(){return this._paused},set:function(t){this._paused=t,this.refreshPaused()},enumerable:!1,configurable:!0}),e.prototype._onPlay=function(){this._playing=!0},e.prototype._onPause=function(){this._playing=!1},e.prototype.init=function(t){this._playing=!1,this._duration=t.source.duration;var e=this._source=t.source.cloneNode(!1);e.src=t.parent.url,e.onplay=this._onPlay.bind(this),e.onpause=this._onPause.bind(this),t.context.on(\"refresh\",this.refresh,this),t.context.on(\"refreshPaused\",this.refreshPaused,this),this._media=t},e.prototype._internalStop=function(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())},e.prototype.stop=function(){this._internalStop(),this._source&&this.emit(\"stop\")},Object.defineProperty(e.prototype,\"speed\",{get:function(){return this._speed},set:function(t){this._speed=t,this.refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"volume\",{get:function(){return this._volume},set:function(t){this._volume=t,this.refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"loop\",{get:function(){return this._loop},set:function(t){this._loop=t,this.refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"muted\",{get:function(){return this._muted},set:function(t){this._muted=t,this.refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"filters\",{get:function(){return null},set:function(t){},enumerable:!1,configurable:!0}),e.prototype.refresh=function(){var t=this._media.context,e=this._media.parent;this._source.loop=this._loop||e.loop;var n=t.volume*(t.muted?0:1),o=e.volume*(e.muted?0:1),i=this._volume*(this._muted?0:1);this._source.volume=i*n*o,this._source.playbackRate=this._speed*t.speed*e.speed},e.prototype.refreshPaused=function(){var t=this._media.context,e=this._media.parent,n=this._paused||e.paused||t.paused;n!==this._pausedReal&&(this._pausedReal=n,n?(this._internalStop(),this.emit(\"paused\")):(this.emit(\"resumed\"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,speed:this._speed,loop:this._loop})),this.emit(\"pause\",n))},e.prototype.play=function(t){var n=this,o=t.start,i=t.end,s=t.speed,u=t.loop,a=t.volume,c=t.muted;this._speed=s,this._volume=a,this._loop=!!u,this._muted=c,this.refresh(),this.loop&&null!==i&&(this.loop=!1),this._start=o,this._end=i||this._duration,this._start=Math.max(0,this._start-e.PADDING),this._end=Math.min(this._end+e.PADDING,this._duration),this._source.onloadedmetadata=function(){n._source&&(n._source.currentTime=o,n._source.onloadedmetadata=null,n.emit(\"progress\",o,n._duration),r.shared.add(n._onUpdate,n))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit(\"start\")},e.prototype._onUpdate=function(){this.emit(\"progress\",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete()},e.prototype._onComplete=function(){r.shared.remove(this._onUpdate,this),this._internalStop(),this.emit(\"progress\",1,this._duration),this.emit(\"end\",this)},e.prototype.destroy=function(){r.shared.remove(this._onUpdate,this),this.removeAllListeners();var t=this._source;t&&(t.onended=null,t.onplay=null,t.onpause=null,this._internalStop()),this._source=null,this._speed=1,this._volume=1,this._loop=!1,this._end=null,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._media&&(this._media.context.off(\"refresh\",this.refresh,this),this._media.context.off(\"refreshPaused\",this.refreshPaused,this),this._media=null)},e.prototype.toString=function(){return\"[HTMLAudioInstance id=\".concat(this.id,\"]\")},e.PADDING=.1,e}(i),v=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return c(e,t),e.prototype.init=function(t){this.parent=t,this._source=t.options.source||new Audio,t.url&&(this._source.src=t.url)},e.prototype.create=function(){return new g(this)},Object.defineProperty(e.prototype,\"isPlayable\",{get:function(){return!!this._source&&4===this._source.readyState},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"duration\",{get:function(){return this._source.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"context\",{get:function(){return this.parent.context},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"filters\",{get:function(){return null},set:function(t){},enumerable:!1,configurable:!0}),e.prototype.destroy=function(){this.removeAllListeners(),this.parent=null,this._source&&(this._source.src=\"\",this._source.load(),this._source=null)},Object.defineProperty(e.prototype,\"source\",{get:function(){return this._source},enumerable:!1,configurable:!0}),e.prototype.load=function(t){var e=this._source,n=this.parent;if(4!==e.readyState)if(n.url){e.src=n.url;var o=function(){s(),n.isLoaded=!0;var e=n.autoPlayStart();t&&t(null,n,e)},i=function(){s(),t&&t(new Error(\"Sound loading has been aborted\"))},r=function(){s();var n=\"Failed to load audio element (code: \".concat(e.error.code,\")\");t&&t(new Error(n))},s=function(){e.removeEventListener(\"canplaythrough\",o),e.removeEventListener(\"load\",o),e.removeEventListener(\"abort\",i),e.removeEventListener(\"error\",r)};e.addEventListener(\"canplaythrough\",o,!1),e.addEventListener(\"load\",o,!1),e.addEventListener(\"abort\",i,!1),e.addEventListener(\"error\",r,!1),e.load()}else t(new Error(\"sound.url or sound.source must be set\"));else{n.isLoaded=!0;var u=n.autoPlayStart();t&&setTimeout((function(){t(null,n,u)}),0)}},e}(i),P=function(){function t(t,e){this.parent=t,Object.assign(this,e),this.duration=this.end-this.start}return t.prototype.play=function(t){return this.parent.play({complete:t,speed:this.speed||this.parent.speed,end:this.end,start:this.start,loop:this.loop})},t.prototype.destroy=function(){this.parent=null},t}(),x=function(){function t(){}return t.setParamValue=function(t,e){if(t.setValueAtTime){var n=u().context;t.setValueAtTime(e,n.audioContext.currentTime)}else t.value=e;return e},t}(),O=0,j=function(t){function e(e){var n=t.call(this)||this;return n.id=O++,n._media=null,n._paused=!1,n._muted=!1,n._elapsed=0,n.init(e),n}return c(e,t),e.prototype.set=function(t,e){if(void 0===this[t])throw new Error(\"Property with name \".concat(t,\" does not exist.\"));switch(t){case\"speed\":this.speed=e;break;case\"volume\":this.volume=e;break;case\"muted\":this.muted=e;break;case\"loop\":this.loop=e;break;case\"paused\":this.paused=e}return this},e.prototype.stop=function(){this._source&&(this._internalStop(),this.emit(\"stop\"))},Object.defineProperty(e.prototype,\"speed\",{get:function(){return this._speed},set:function(t){this._speed=t,this.refresh(),this._update(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"volume\",{get:function(){return this._volume},set:function(t){this._volume=t,this.refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"muted\",{get:function(){return this._muted},set:function(t){this._muted=t,this.refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"loop\",{get:function(){return this._loop},set:function(t){this._loop=t,this.refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"filters\",{get:function(){return this._filters},set:function(t){var e;this._filters&&(null===(e=this._filters)||void 0===e||e.filter((function(t){return t})).forEach((function(t){return t.disconnect()})),this._filters=null,this._source.connect(this._gain)),this._filters=(null==t?void 0:t.length)?t.slice(0):null,this.refresh()},enumerable:!1,configurable:!0}),e.prototype.refresh=function(){if(this._source){var t=this._media.context,e=this._media.parent;this._source.loop=this._loop||e.loop;var n=t.volume*(t.muted?0:1),o=e.volume*(e.muted?0:1),i=this._volume*(this._muted?0:1);x.setParamValue(this._gain.gain,i*o*n),x.setParamValue(this._source.playbackRate,this._speed*e.speed*t.speed),this.applyFilters()}},e.prototype.applyFilters=function(){var t;if(null===(t=this._filters)||void 0===t?void 0:t.length){this._source.disconnect();var e=this._source;this._filters.forEach((function(t){e.connect(t.destination),e=t})),e.connect(this._gain)}},e.prototype.refreshPaused=function(){var t=this._media.context,e=this._media.parent,n=this._paused||e.paused||t.paused;n!==this._pausedReal&&(this._pausedReal=n,n?(this._internalStop(),this.emit(\"paused\")):(this.emit(\"resumed\"),this.play({start:this._elapsed%this._duration,end:this._end,speed:this._speed,loop:this._loop,volume:this._volume})),this.emit(\"pause\",n))},e.prototype.play=function(t){var e=t.start,n=t.end,o=t.speed,i=t.loop,r=t.volume,s=t.muted,u=t.filters;this._paused=!1;var a=this._media.nodes.cloneBufferSource(),c=a.source,l=a.gain;this._source=c,this._gain=l,this._speed=o,this._volume=r,this._loop=!!i,this._muted=s,this._filters=u,this.refresh();var p=this._source.buffer.duration;this._duration=p,this._end=n,this._lastUpdate=this._now(),this._elapsed=e,this._source.onended=this._onComplete.bind(this),this._loop?(this._source.loopEnd=n,this._source.loopStart=e,this._source.start(0,e)):n?this._source.start(0,e,n-e):this._source.start(0,e),this.emit(\"start\"),this._update(!0),this.enableTicker(!0)},e.prototype.enableTicker=function(t){r.shared.remove(this._updateListener,this),t&&r.shared.add(this._updateListener,this)},Object.defineProperty(e.prototype,\"progress\",{get:function(){return this._progress},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"paused\",{get:function(){return this._paused},set:function(t){this._paused=t,this.refreshPaused()},enumerable:!1,configurable:!0}),e.prototype.destroy=function(){var t;this.removeAllListeners(),this._internalStop(),this._gain&&(this._gain.disconnect(),this._gain=null),this._media&&(this._media.context.events.off(\"refresh\",this.refresh,this),this._media.context.events.off(\"refreshPaused\",this.refreshPaused,this),this._media=null),null===(t=this._filters)||void 0===t||t.forEach((function(t){return t.disconnect()})),this._filters=null,this._end=null,this._speed=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1},e.prototype.toString=function(){return\"[WebAudioInstance id=\".concat(this.id,\"]\")},e.prototype._now=function(){return this._media.context.audioContext.currentTime},e.prototype._updateListener=function(){this._update()},e.prototype._update=function(t){if(void 0===t&&(t=!1),this._source){var e=this._now(),n=e-this._lastUpdate;if(n>0||t){var o=this._source.playbackRate.value;this._elapsed+=n*o,this._lastUpdate=e;var i=this._duration,r=void 0;if(this._source.loopStart){var s=this._source.loopEnd-this._source.loopStart;r=(this._source.loopStart+this._elapsed%s)/i}else r=this._elapsed%i/i;this._progress=r,this.emit(\"progress\",this._progress,i)}}},e.prototype.init=function(t){this._media=t,t.context.events.on(\"refresh\",this.refresh,this),t.context.events.on(\"refreshPaused\",this.refreshPaused,this)},e.prototype._internalStop=function(){if(this._source){this.enableTicker(!1),this._source.onended=null,this._source.stop(0),this._source.disconnect();try{this._source.buffer=null}catch(t){}this._source=null}},e.prototype._onComplete=function(){if(this._source){this.enableTicker(!1),this._source.onended=null,this._source.disconnect();try{this._source.buffer=null}catch(t){}}this._source=null,this._progress=1,this.emit(\"progress\",1,this._duration),this.emit(\"end\",this)},e}(i),w=function(){function t(t,e){this._output=e,this._input=t}return Object.defineProperty(t.prototype,\"destination\",{get:function(){return this._input},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"filters\",{get:function(){return this._filters},set:function(t){var e=this;if(this._filters&&(this._filters.forEach((function(t){t&&t.disconnect()})),this._filters=null,this._input.connect(this._output)),t&&t.length){this._filters=t.slice(0),this._input.disconnect();var n=null;t.forEach((function(t){null===n?e._input.connect(t.destination):n.connect(t.destination),n=t})),n.connect(this._output)}},enumerable:!1,configurable:!0}),t.prototype.destroy=function(){this.filters=null,this._input=null,this._output=null},t}(),A=function(t){function e(e){var n=this,o=e.audioContext,i=o.createBufferSource(),r=o.createGain(),s=o.createAnalyser();return i.connect(s),s.connect(r),r.connect(e.destination),(n=t.call(this,s,r)||this).context=e,n.bufferSource=i,n.gain=r,n.analyser=s,n}return c(e,t),Object.defineProperty(e.prototype,\"script\",{get:function(){return this._script||(this._script=this.context.audioContext.createScriptProcessor(e.BUFFER_SIZE),this._script.connect(this.context.destination)),this._script},enumerable:!1,configurable:!0}),e.prototype.destroy=function(){t.prototype.destroy.call(this),this.bufferSource.disconnect(),this._script&&this._script.disconnect(),this.gain.disconnect(),this.analyser.disconnect(),this.bufferSource=null,this._script=null,this.gain=null,this.analyser=null,this.context=null},e.prototype.cloneBufferSource=function(){var t=this.bufferSource,e=this.context.audioContext.createBufferSource();e.buffer=t.buffer,x.setParamValue(e.playbackRate,t.playbackRate.value),e.loop=t.loop;var n=this.context.audioContext.createGain();return e.connect(n),n.connect(this.destination),{source:e,gain:n}},Object.defineProperty(e.prototype,\"bufferSize\",{get:function(){return this.script.bufferSize},enumerable:!1,configurable:!0}),e.BUFFER_SIZE=0,e}(w),F=function(){function t(){}return t.prototype.init=function(t){this.parent=t,this._nodes=new A(this.context),this._source=this._nodes.bufferSource,this.source=t.options.source},t.prototype.destroy=function(){this.parent=null,this._nodes.destroy(),this._nodes=null;try{this._source.buffer=null}catch(t){}this._source=null,this.source=null},t.prototype.create=function(){return new j(this)},Object.defineProperty(t.prototype,\"context\",{get:function(){return this.parent.context},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"isPlayable\",{get:function(){return!!this._source&&!!this._source.buffer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"filters\",{get:function(){return this._nodes.filters},set:function(t){this._nodes.filters=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"duration\",{get:function(){return this._source.buffer.duration},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buffer\",{get:function(){return this._source.buffer},set:function(t){this._source.buffer=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"nodes\",{get:function(){return this._nodes},enumerable:!1,configurable:!0}),t.prototype.load=function(t){this.source?this._decode(this.source,t):this.parent.url?this._loadUrl(t):t&&t(new Error(\"sound.url or sound.source must be set\"))},t.prototype._loadUrl=function(t){var e=this,n=new XMLHttpRequest,o=this.parent.url;n.open(\"GET\",o,!0),n.responseType=\"arraybuffer\",n.onload=function(){e.source=n.response,e._decode(n.response,t)},n.send()},t.prototype._decode=function(t,e){var n=this,o=function(t,o){if(t)e&&e(t);else{n.parent.isLoaded=!0,n.buffer=o;var i=n.parent.autoPlayStart();e&&e(null,n.parent,i)}};t instanceof AudioBuffer?o(null,t):this.parent.context.decode(t,o)},t}(),E=function(){function t(t,e){this.media=t,this.options=e,this._instances=[],this._sprites={},this.media.init(this);var n=e.complete;this._autoPlayOptions=n?{complete:n}:null,this.isLoaded=!1,this.isPlaying=!1,this.autoPlay=e.autoPlay,this.singleInstance=e.singleInstance,this.preload=e.preload||this.autoPlay,this.url=e.url,this.speed=e.speed,this.volume=e.volume,this.loop=e.loop,e.sprites&&this.addSprites(e.sprites),this.preload&&this._preload(e.loaded)}return t.from=function(e){var n={};return\"string\"==typeof e?n.url=e:e instanceof ArrayBuffer||e instanceof AudioBuffer||e instanceof HTMLAudioElement?n.source=e:n=e,(n=l({autoPlay:!1,singleInstance:!1,url:null,source:null,preload:!1,volume:1,speed:1,complete:null,loaded:null,loop:!1},n)).url&&(n.url=_(n.url)),Object.freeze(n),new t(u().useLegacy?new v:new F,n)},Object.defineProperty(t.prototype,\"context\",{get:function(){return u().context},enumerable:!1,configurable:!0}),t.prototype.pause=function(){return this.isPlaying=!1,this.paused=!0,this},t.prototype.resume=function(){return this.isPlaying=this._instances.length>0,this.paused=!1,this},Object.defineProperty(t.prototype,\"paused\",{get:function(){return this._paused},set:function(t){this._paused=t,this.refreshPaused()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"speed\",{get:function(){return this._speed},set:function(t){this._speed=t,this.refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"filters\",{get:function(){return this.media.filters},set:function(t){this.media.filters=t},enumerable:!1,configurable:!0}),t.prototype.addSprites=function(t,e){if(\"object\"==typeof t){var n={};for(var o in t)n[o]=this.addSprites(o,t[o]);return n}var i=new P(this,e);return this._sprites[t]=i,i},t.prototype.destroy=function(){this._removeInstances(),this.removeSprites(),this.media.destroy(),this.media=null,this._sprites=null,this._instances=null},t.prototype.removeSprites=function(t){if(t){var e=this._sprites[t];void 0!==e&&(e.destroy(),delete this._sprites[t])}else for(var n in this._sprites)this.removeSprites(n);return this},Object.defineProperty(t.prototype,\"isPlayable\",{get:function(){return this.isLoaded&&this.media&&this.media.isPlayable},enumerable:!1,configurable:!0}),t.prototype.stop=function(){if(!this.isPlayable)return this.autoPlay=!1,this._autoPlayOptions=null,this;this.isPlaying=!1;for(var t=this._instances.length-1;t>=0;t--)this._instances[t].stop();return this},t.prototype.play=function(t,e){var n,o=this;\"string\"==typeof t?n={sprite:r=t,loop:this.loop,complete:e}:\"function\"==typeof t?(n={}).complete=t:n=t;if((n=l({complete:null,loaded:null,sprite:null,end:null,start:0,volume:1,speed:1,muted:!1,loop:!1},n||{})).sprite){var i=n.sprite,r=this._sprites[i];n.start=r.start+(n.start||0),n.end=r.end,n.speed=r.speed||1,n.loop=r.loop||n.loop,delete n.sprite}if(n.offset&&(n.start=n.offset),!this.isLoaded)return new Promise((function(t,e){o.autoPlay=!0,o._autoPlayOptions=n,o._preload((function(o,i,r){o?e(o):(n.loaded&&n.loaded(o,i,r),t(r))}))}));(this.singleInstance||n.singleInstance)&&this._removeInstances();var s=this._createInstance();return this._instances.push(s),this.isPlaying=!0,s.once(\"end\",(function(){n.complete&&n.complete(o),o._onComplete(s)})),s.once(\"stop\",(function(){o._onComplete(s)})),s.play(n),s},t.prototype.refresh=function(){for(var t=this._instances.length,e=0;e=0;t--)this._poolInstance(this._instances[t]);this._instances.length=0},t.prototype._onComplete=function(t){if(this._instances){var e=this._instances.indexOf(t);e>-1&&this._instances.splice(e,1),this.isPlaying=this._instances.length>0}this._poolInstance(t)},t.prototype._createInstance=function(){if(t._pool.length>0){var e=t._pool.pop();return e.init(this.media),e}return this.media.create()},t.prototype._poolInstance=function(e){e.destroy(),t._pool.indexOf(e)<0&&t._pool.push(e)},t._pool=[],t}(),C=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.speed=1,e.muted=!1,e.volume=1,e.paused=!1,e}return c(e,t),e.prototype.refresh=function(){this.emit(\"refresh\")},e.prototype.refreshPaused=function(){this.emit(\"refreshPaused\")},Object.defineProperty(e.prototype,\"filters\",{get:function(){return null},set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"audioContext\",{get:function(){return null},enumerable:!1,configurable:!0}),e.prototype.toggleMute=function(){return this.muted=!this.muted,this.refresh(),this.muted},e.prototype.togglePause=function(){return this.paused=!this.paused,this.refreshPaused(),this.paused},e.prototype.destroy=function(){this.removeAllListeners()},e}(i),L=function(t){function e(){var n=t.call(this,null,null)||this;n.autoPause=!0;var o=window,r=new e.AudioContext,s=r.createDynamicsCompressor(),u=r.createAnalyser();return u.connect(s),s.connect(r.destination),n._input=u,n._output=r.destination,n._ctx=r,n._offlineCtx=new e.OfflineAudioContext(1,2,o.OfflineAudioContext?Math.max(8e3,Math.min(96e3,r.sampleRate)):44100),n.compressor=s,n.analyser=u,n.events=new i,n.volume=1,n.speed=1,n.muted=!1,n.paused=!1,n._locked=\"suspended\"===r.state&&(\"ontouchstart\"in globalThis||\"onclick\"in globalThis),n._locked&&(n._unlock(),n._unlock=n._unlock.bind(n),document.addEventListener(\"mousedown\",n._unlock,!0),document.addEventListener(\"touchstart\",n._unlock,!0),document.addEventListener(\"touchend\",n._unlock,!0)),n.onFocus=n.onFocus.bind(n),n.onBlur=n.onBlur.bind(n),globalThis.addEventListener(\"focus\",n.onFocus),globalThis.addEventListener(\"blur\",n.onBlur),n}return c(e,t),e.prototype.onFocus=function(){if(this.autoPause){var t=this._ctx.state;\"suspended\"!==t&&\"interrupted\"!==t&&this._locked||(this.paused=this._pausedOnBlur,this.refreshPaused())}},e.prototype.onBlur=function(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))},e.prototype._unlock=function(){this._locked&&(this.playEmptySound(),\"running\"===this._ctx.state&&(document.removeEventListener(\"mousedown\",this._unlock,!0),document.removeEventListener(\"touchend\",this._unlock,!0),document.removeEventListener(\"touchstart\",this._unlock,!0),this._locked=!1))},e.prototype.playEmptySound=function(){var t=this._ctx.createBufferSource();t.buffer=this._ctx.createBuffer(1,1,22050),t.connect(this._ctx.destination),t.start(0,0,0),\"suspended\"===t.context.state&&t.context.resume()},Object.defineProperty(e,\"AudioContext\",{get:function(){var t=window;return t.AudioContext||t.webkitAudioContext||null},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"OfflineAudioContext\",{get:function(){var t=window;return t.OfflineAudioContext||t.webkitOfflineAudioContext||null},enumerable:!1,configurable:!0}),e.prototype.destroy=function(){t.prototype.destroy.call(this);var e=this._ctx;void 0!==e.close&&e.close(),globalThis.removeEventListener(\"focus\",this.onFocus),globalThis.removeEventListener(\"blur\",this.onBlur),this.events.removeAllListeners(),this.analyser.disconnect(),this.compressor.disconnect(),this.analyser=null,this.compressor=null,this.events=null,this._offlineCtx=null,this._ctx=null},Object.defineProperty(e.prototype,\"audioContext\",{get:function(){return this._ctx},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"offlineContext\",{get:function(){return this._offlineCtx},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"paused\",{get:function(){return this._paused},set:function(t){t&&\"running\"===this._ctx.state?this._ctx.suspend():t||\"suspended\"!==this._ctx.state||this._ctx.resume(),this._paused=t},enumerable:!1,configurable:!0}),e.prototype.refresh=function(){this.events.emit(\"refresh\")},e.prototype.refreshPaused=function(){this.events.emit(\"refreshPaused\")},e.prototype.toggleMute=function(){return this.muted=!this.muted,this.refresh(),this.muted},e.prototype.togglePause=function(){return this.paused=!this.paused,this.refreshPaused(),this._paused},e.prototype.decode=function(t,e){var n=function(t){e(new Error((null==t?void 0:t.message)||\"Unable to decode file\"))},o=this._offlineCtx.decodeAudioData(t,(function(t){e(null,t)}),n);o&&o.catch(n)},e}(w),S=function(){function t(){this.init()}return t.prototype.init=function(){return this.supported&&(this._webAudioContext=new L),this._htmlAudioContext=new C,this._sounds={},this.useLegacy=!this.supported,this},Object.defineProperty(t.prototype,\"context\",{get:function(){return this._context},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"filtersAll\",{get:function(){return this.useLegacy?[]:this._context.filters},set:function(t){this.useLegacy||(this._context.filters=t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"supported\",{get:function(){return null!==L.AudioContext},enumerable:!1,configurable:!0}),t.prototype.add=function(t,e){if(\"object\"==typeof t){var n={};for(var o in t){var i=this._getOptions(t[o],e);n[o]=this.add(o,i)}return n}if(e instanceof E)return this._sounds[t]=e,e;var r=this._getOptions(e),s=E.from(r);return this._sounds[t]=s,s},t.prototype._getOptions=function(t,e){var n;return n=\"string\"==typeof t?{url:t}:t instanceof ArrayBuffer||t instanceof AudioBuffer||t instanceof HTMLAudioElement?{source:t}:t,n=l(l({},n),e||{})},Object.defineProperty(t.prototype,\"useLegacy\",{get:function(){return this._useLegacy},set:function(t){m.setLegacy(t),this._useLegacy=t,this._context=!t&&this.supported?this._webAudioContext:this._htmlAudioContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"disableAutoPause\",{get:function(){return!this._webAudioContext.autoPause},set:function(t){this._webAudioContext.autoPause=!t},enumerable:!1,configurable:!0}),t.prototype.remove=function(t){return this.exists(t,!0),this._sounds[t].destroy(),delete this._sounds[t],this},Object.defineProperty(t.prototype,\"volumeAll\",{get:function(){return this._context.volume},set:function(t){this._context.volume=t,this._context.refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"speedAll\",{get:function(){return this._context.speed},set:function(t){this._context.speed=t,this._context.refresh()},enumerable:!1,configurable:!0}),t.prototype.togglePauseAll=function(){return this._context.togglePause()},t.prototype.pauseAll=function(){return this._context.paused=!0,this._context.refreshPaused(),this},t.prototype.resumeAll=function(){return this._context.paused=!1,this._context.refreshPaused(),this},t.prototype.toggleMuteAll=function(){return this._context.toggleMute()},t.prototype.muteAll=function(){return this._context.muted=!0,this._context.refresh(),this},t.prototype.unmuteAll=function(){return this._context.muted=!1,this._context.refresh(),this},t.prototype.removeAll=function(){for(var t in this._sounds)this._sounds[t].destroy(),delete this._sounds[t];return this},t.prototype.stopAll=function(){for(var t in this._sounds)this._sounds[t].stop();return this},t.prototype.exists=function(t,e){return void 0===e&&(e=!1),!!this._sounds[t]},t.prototype.find=function(t){return this.exists(t,!0),this._sounds[t]},t.prototype.play=function(t,e){return this.find(t).play(e)},t.prototype.stop=function(t){return this.find(t).stop()},t.prototype.pause=function(t){return this.find(t).pause()},t.prototype.resume=function(t){return this.find(t).resume()},t.prototype.volume=function(t,e){var n=this.find(t);return void 0!==e&&(n.volume=e),n.volume},t.prototype.speed=function(t,e){var n=this.find(t);return void 0!==e&&(n.speed=e),n.speed},t.prototype.duration=function(t){return this.find(t).duration},t.prototype.close=function(){return this.removeAll(),this._sounds=null,this._webAudioContext&&(this._webAudioContext.destroy(),this._webAudioContext=null),this._htmlAudioContext&&(this._htmlAudioContext.destroy(),this._htmlAudioContext=null),this._context=null,this},t}(),k={__proto__:null,HTMLAudioMedia:v,HTMLAudioInstance:g,HTMLAudioContext:C},M=function(){function t(t,e){this.init(t,e)}return t.prototype.init=function(t,e){this.destination=t,this.source=e||t},t.prototype.connect=function(t){this.source.connect(t)},t.prototype.disconnect=function(){this.source.disconnect()},t.prototype.destroy=function(){this.disconnect(),this.destination=null,this.source=null},t}(),T={__proto__:null,Filter:M,EqualizerFilter:function(t){function e(n,o,i,r,s,a,c,l,p,h){void 0===n&&(n=0),void 0===o&&(o=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===a&&(a=0),void 0===c&&(c=0),void 0===l&&(l=0),void 0===p&&(p=0),void 0===h&&(h=0);var f=this;if(!u().useLegacy){var d=[{f:e.F32,type:\"lowshelf\",gain:n},{f:e.F64,type:\"peaking\",gain:o},{f:e.F125,type:\"peaking\",gain:i},{f:e.F250,type:\"peaking\",gain:r},{f:e.F500,type:\"peaking\",gain:s},{f:e.F1K,type:\"peaking\",gain:a},{f:e.F2K,type:\"peaking\",gain:c},{f:e.F4K,type:\"peaking\",gain:l},{f:e.F8K,type:\"peaking\",gain:p},{f:e.F16K,type:\"highshelf\",gain:h}].map((function(t){var e=u().context.audioContext.createBiquadFilter();return e.type=t.type,x.setParamValue(e.Q,1),e.frequency.value=t.f,x.setParamValue(e.gain,t.gain),e}));(f=t.call(this,d[0],d[d.length-1])||this).bands=d,f.bandsMap={};for(var _=0;_0&&f.bands[_-1].connect(y),f.bandsMap[y.frequency.value]=y}return f}f=t.call(this,null)||this}return c(e,t),e.prototype.setGain=function(t,e){if(void 0===e&&(e=0),!this.bandsMap[t])throw new Error(\"No band found for frequency \".concat(t));x.setParamValue(this.bandsMap[t].gain,e)},e.prototype.getGain=function(t){if(!this.bandsMap[t])throw new Error(\"No band found for frequency \".concat(t));return this.bandsMap[t].gain.value},Object.defineProperty(e.prototype,\"f32\",{get:function(){return this.getGain(e.F32)},set:function(t){this.setGain(e.F32,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"f64\",{get:function(){return this.getGain(e.F64)},set:function(t){this.setGain(e.F64,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"f125\",{get:function(){return this.getGain(e.F125)},set:function(t){this.setGain(e.F125,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"f250\",{get:function(){return this.getGain(e.F250)},set:function(t){this.setGain(e.F250,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"f500\",{get:function(){return this.getGain(e.F500)},set:function(t){this.setGain(e.F500,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"f1k\",{get:function(){return this.getGain(e.F1K)},set:function(t){this.setGain(e.F1K,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"f2k\",{get:function(){return this.getGain(e.F2K)},set:function(t){this.setGain(e.F2K,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"f4k\",{get:function(){return this.getGain(e.F4K)},set:function(t){this.setGain(e.F4K,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"f8k\",{get:function(){return this.getGain(e.F8K)},set:function(t){this.setGain(e.F8K,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"f16k\",{get:function(){return this.getGain(e.F16K)},set:function(t){this.setGain(e.F16K,t)},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this.bands.forEach((function(t){x.setParamValue(t.gain,0)}))},e.prototype.destroy=function(){this.bands.forEach((function(t){t.disconnect()})),this.bands=null,this.bandsMap=null},e.F32=32,e.F64=64,e.F125=125,e.F250=250,e.F500=500,e.F1K=1e3,e.F2K=2e3,e.F4K=4e3,e.F8K=8e3,e.F16K=16e3,e}(M),DistortionFilter:function(t){function e(e){void 0===e&&(e=0);var n=this;if(!u().useLegacy){var o=u().context.audioContext.createWaveShaper();return(n=t.call(this,o)||this)._distortion=o,n.amount=e,n}n=t.call(this,null)||this}return c(e,t),Object.defineProperty(e.prototype,\"amount\",{get:function(){return this._amount},set:function(t){this._amount=t;for(var e,n=1e3*t,o=44100,i=new Float32Array(o),r=Math.PI/180,s=0;sf&&(f=_)}s.fillRect(p,(1+h)*c,1,Math.max(1,(f-h)*c))}return i},resolveUrl:_,sineTone:function(t,e){void 0===t&&(t=200),void 0===e&&(e=1);var n=E.from({singleInstance:!0});if(!(n.media instanceof F))return n;for(var o=n.media,i=n.context.audioContext.createBuffer(1,48e3*e,48e3),r=i.getChannelData(0),s=0;s 1) return 1;\n\t\treturn vol;\n\t}\n\tstatic\txchgbuf(hArg: HArg) {\n\t\tconst {buf: buf1 = 'SE', buf2 = 'SE'} = hArg;\n\t\tif (buf1 === buf2) return;\n\n\t\tconst n1 = 'const.sn.sound.'+ buf1 +'.';\n\t\tconst v1 = Number(val.getVal('save:'+ n1 +'volume'));\n\t\tconst f1 = String(val.getVal('save:'+ n1 +'fn'));\n\t\tconst n2 = 'const.sn.sound.'+ buf2 +'.';\n\t\tconst v2 = Number(val.getVal('save:'+ n2 +'volume'));\n\t\tconst f2 = String(val.getVal('save:'+ n2 +'fn'));\n\t\tval.setVal_Nochk('save', n1 +'volume', v2);\n\t\tval.setVal_Nochk('save', n2 +'volume', v1);\n\t\tval.setVal_Nochk('save', n1 +'fn', f2);\n\t\tval.setVal_Nochk('save', n2 +'fn', f1);\n\n\t\tif (buf1 in SndBuf.#hLP !== buf2 in SndBuf.#hLP) {\t// 演算子の優先順位確認済\n\t\t\tif (buf1 in SndBuf.#hLP)\n\t\t\t\t\t{delete SndBuf.#hLP[buf1]; SndBuf.#hLP[buf2] = 0}\n\t\t\telse\t{delete SndBuf.#hLP[buf2]; SndBuf.#hLP[buf1] = 0}\n\t\t\tval.setVal_Nochk('save', 'const.sn.loopPlaying', JSON.stringify(SndBuf.#hLP));\n\t\t}\n\t\tval.flush();\n\t}\n\n\n\t#sb\t\t: ISndBuf;\n\n\tstatic\treadonly\t#MAX_END_MS\t= 999000;\n\tinit(hArg: HArg): boolean {\n\t\tconst {buf = 'SE', fn = ''} = hArg;\n\n\t\tconst start_ms = argChk_Num(hArg, 'start_ms', 0);\n\t\tconst end_ms = argChk_Num(hArg, 'end_ms', SndBuf.#MAX_END_MS);\n\t\tconst ret_ms = argChk_Num(hArg, 'ret_ms', 0);\n\t\tconst pan = argChk_Num(hArg, 'pan', 0);\n\t\tconst speed = argChk_Num(hArg, 'speed', 1);\n\n\t\tif (start_ms < 0) throw `[playse] start_ms:${start_ms} が負の値です`;\n\t\tif (ret_ms < 0) throw `[playse] ret_ms:${ret_ms} が負の値です`;\n\t\tif (0 < end_ms) {\n\t\t\tif (end_ms <= start_ms) throw `[playse] start_ms:${start_ms} >= end_ms:${end_ms} は異常値です`;\n\t\t\tif (end_ms <= ret_ms) throw `[playse] ret_ms:${ret_ms} >= end_ms:${end_ms} は異常値です`;\n\t\t}\n\n\t\t// この辺で属性を増減したら、loadFromSaveObj()にも反映する\n\t\tconst vn = 'const.sn.sound.'+ buf +'.';\n\t\tval.setVal_Nochk('save', vn +'fn', fn);\n\t\tconst savevol = SndBuf.getVol(hArg, 1);\n\t\tval.setVal_Nochk('save', vn +'volume', savevol);// 目標音量(save:)\n\t\tconst volume = savevol * Number(val.getVal('sys:'+ vn +'volume', 1));\n\n\t\tconst loop = argChk_Boolean(hArg, 'loop', false);\n\t\tif (loop) {\n\t\t\tSndBuf.#hLP[buf] = 0;\n\t\t\tval.setVal_Nochk('save', 'const.sn.loopPlaying', JSON.stringify(SndBuf.#hLP));\n\t\t}\n\t\telse SndBuf.delLoopPlay(buf);\n\t\tval.setVal_Nochk('save', vn +'start_ms', start_ms);\n\t\tval.setVal_Nochk('save', vn +'end_ms', end_ms);\n\t\tval.setVal_Nochk('save', vn +'ret_ms', ret_ms);\n\t\tval.setVal_Nochk('tmp', vn +'playing', true);\n\t\tval.flush();\n\n\t\tconst snd = sound.find(fn);\t// キャッシュにあるか\n\t\tthis.#sb = {\n\t\t\tfn,\n\t\t\tstt\t\t: snd ?new SsPlaying :new SsLoading,\n\t\t\tsnd,\n\t\t\tloop,\n\t\t\tstart_ms,\n\t\t\tend_ms,\n\t\t\tret_ms\t: 0,\n\t\t\tpan,\n\t\t};\n\t\t// @pixi/sound用基本パラメータ\n\t\tconst o: Options = {\n\t\t\tloop,\n\t\t\tspeed,\n\t\t\tvolume,\n\t\t\tloaded\t: (e, s2)=> {\n\t\t\t\tif (this.#sb.stt.isDestroy) return;\n\t\t\t\tif (e) {main.errScript(`Sound ロード失敗ですa fn:${fn} ${e}`, false); return}\n\t\t\t\tif (! s2) return;\n\n\t\t\t\tthis.#sb.snd = s2;\n\t\t\t\tthis.#sb.stt.onLoad(this.#sb);\n\t\t\t\tif (pan !== 0) s2.filters = [new filters.StereoFilter(pan)];\n\t\t\t//\tif (! o.loop) sound.add(fn, snd);\t// 手動キャッシュすると単発連打で無音に\n\t\t\t},\n\t\t};\n\n\t\t// start_ms・end_ms機能→@pixi/sound準備\n\t\tlet sp_nm = '';\n\t\tif (0 < start_ms || end_ms < SndBuf.#MAX_END_MS) {\n\t\t\tsp_nm = `${fn};${start_ms};${end_ms};${ret_ms}`;\n\t\t\tconst os = (o.sprites ??= {})[sp_nm] = {\n\t\t\t\tstart\t: start_ms /1000,\n\t\t\t\tend\t\t: end_ms /1000,\n\t\t\t};\n\t\t\to.preload = true;\t\t// loaded発生用、トラブルの元なので使用を控えたい\n\t\t\tconst old = o.loaded!;\n\t\t\to.loaded = (e, s0)=> {\n\t\t\t\tif (this.#sb.stt.isDestroy) return;\n\n\t\t\t\told(e, s0);\n\t\t\t\tconst s2 = s0!;\n\t\t\t\tconst d = s2.duration;\n\t\t\t\tif (os.end < 0) {\t// 負の値は末尾から\n\t\t\t\t\tos.end += d;\n\t\t\t\t\ts2.removeSprites(sp_nm);\n\t\t\t\t\ts2.addSprites(sp_nm, os);\n\t\t\t\t}\n\t\t\t\tif (os.end <= os.start) main.errScript(`[playse] end_ms:${end_ms}(${os.end *1000}) >= start_ms:${start_ms} は異常値です`);\n\t\t\t\tif (os.end *1000 <= ret_ms) main.errScript(`[playse] end_ms:${end_ms}(${os.end *1000}) <= ret_ms:${ret_ms} は異常値です`);\n\t\t\t\tif (d <= os.start) main.errScript(`[playse] 音声ファイル再生時間:${d *1000} <= start_ms:${start_ms} は異常値です`);\n\t\t\t\tif (end_ms !== SndBuf.#MAX_END_MS && d <= os.end) main.errScript(`[playse] 音声ファイル再生時間:${d *1000} <= end_ms:${end_ms} は異常値です`);\n\n\t\t\t\ts2.play(sp_nm, snd=> {\n\t\t\t\t\to.complete?.(snd);\t// 流れ的にはすぐ下の「ループなし/あり」を呼ぶ\n\t\t\t\t\tif (! loop) this.#sb.stt.onPlayEnd(buf);\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\t\telse o.autoPlay = true;\n\n\t\t// ループなし ... 再生完了イベント\n\t\tif (! loop) o.complete = ()=> {stop2var(this.#sb, buf); this.#sb.stt.onPlayEnd(buf)};\n\t\t// ループあり ... ret_ms処理\n\t\telse if (ret_ms !== 0) {\n\t\t\to.loop = false;\t// 一周目はループなしとする\n\t\t\to.complete = async snd=> {\n\t\t\t\tconst d = snd.duration;\n\t\t\t\tconst start\t= ret_ms /1000;\n\t\t\t\tconst end\t= end_ms /1000;\n\t\t\t\tif (d <= start) main.errScript(`[playse] 音声ファイル再生時間:${d *1000} <= ret_ms:${ret_ms} は異常値です`);\n\n\t\t\t\tawait snd.play({\t// 一周目はループなし、なのでキャッシュされてる\n\t\t\t\t\t...o,\n\t\t\t\t\tstart,\n\t\t\t\t\tend\t\t: (end < 0) ?end +d :end,// 負の値は末尾から\n\t\t\t\t//\tspeed,\t\t// 重複\n\t\t\t\t\tloop\t: true,\n\t\t\t\t//\tvolume,\t\t// 重複\n\t\t\t\t//-\tmuted?: boolean;\n\t\t\t\t\tfilters\t: (pan !== 0) ?[new filters.StereoFilter(pan)] :[],\n\t\t\t\t//-\tcomplete?: CompleteCallback;\n\t\t\t\t//-\tloaded?: LoadedCallback;\n\t\t\t\t//-\tsingleInstance?: boolean;\n\t\t\t\t});\n\t\t\t\t//不要 this.#sb.snd = snd;\t// this.#sb.snd === snd (true)\n\t\t\t};\n\t\t}\n\n\t\tthis.#initVol();\n\t\tif (snd) {\n\t\t\tsnd.volume = volume;\t// 再生のたびに音量を戻す\n\t\t\tif (sp_nm) this.#playseSub(fn, o);\n\t\t\telse if (snd.isPlayable) {\n\t\t\t\tconst ab = snd.options.source;\n\t\t\t\tif (! (ab instanceof ArrayBuffer)\n\t\t\t\t\t|| ab.byteLength === 0) snd.play(o);\n\t\t\t\telse {\n\t\t\t\t\tthis.#sb.snd = Sound.from({\n\t\t\t\t\t...o,\n\t\t\t\t\turl\t\t: snd.options.url,\n\t\t\t\t\tsource\t: ab,\n\t\t\t\t})}\n\t\t\t\tif (pan !== 0) snd.filters = [new filters.StereoFilter(pan)];\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tconst join = argChk_Boolean(hArg, 'join', true);\n\t\tif (join) {\n\t\t\tdisableEvent();\n\t\t\tconst old = o.loaded!;\n\t\t\to.loaded = (e, s2)=> {\n\t\t\t\tif (! this.#sb.stt.isDestroy) old(e, s2);\n\t\t\t\tenableEvent();\n\t\t\t};\n\t\t}\n\t\tthis.#playseSub(fn, o);\n\n\t\treturn join;\n\t}\n\t#initVol = ()=> {\n\t\tsound.volumeAll = Number(val.getVal('sys:sn.sound.global_volume', 1));\n\t\tthis.#initVol = ()=> {};\n\t};\n\t#playseSub(fn: string, o: Options): void {\n\t\tconst url = cfg.searchPath(fn, SEARCH_PATH_ARG_EXT.SOUND);\n\t//\tconst url = 'http://localhost:8080/prj/audio/title.{ogg,mp3}';\n\t\tif (url.slice(-4) !== '.bin') {\n\t\t\to.url = url;\n\t\t\tSound.from(o);\n\t\t\treturn;\n\t\t}\n\n\t\t(new Loader).add({name: fn, url, xhrType: LoaderResource.XHR_RESPONSE_TYPE.BUFFER,})\n\t\t.use(async (res, next)=> {\n\t\t\ttry {\n\t\t\t\tres.data = await sys.decAB(res.data);\n\t\t\t} catch (e) {\n\t\t\t\tmain.errScript(`Sound ロード失敗ですc fn:${res.name} ${e}`, false);\n\t\t\t}\n\t\t\tnext();\n\t\t})\n\t\t.load((_ldr, hRes)=> {\t// このあと o.loaded() もコールされる\n\t\t\to.source = hRes[fn]?.data;\n\t\t\tSound.from(o);\n\t\t});\n\t}\n\n\n\tws =(hArg: HArg)=> this.#sb.stt.ws(this.#sb, hArg);\n\tstopse(hArg: HArg) {\n\t\tconst {buf = 'SE'} = hArg;\n\t\tstop2var(this.#sb, buf);\n\t\tthis.#sb.stt.stopse(this.#sb);\n\t}\n\n\tfade =(hArg: HArg)=> this.#sb.stt.fade(this.#sb, hArg);\n\twf =(hArg: HArg)=> this.#sb.stt.wf(this.#sb, hArg);\n\tstopfadese =(hArg: HArg)=> this.#sb.stt.stopfadese(this.#sb, hArg);\n\n}\n\n\n// =================================================\nfunction stop2var(sb: ISndBuf, buf: string): void {\n\tif (sb.loop) SndBuf.delLoopPlay(buf);\n\telse {\n\t\tconst vn = 'const.sn.sound.'+ buf +'.';\n\t\tval.setVal_Nochk('tmp', vn +'playing', false);\n\t\tval.flush();\n\t}\n}\n\n\nfunction stopfadese(tw: Tween): void {tw.stop().end()}\t// stop()とend()は別\n\n// =================================================\n\n\ninterface ISndState {\n\tonLoad(sb: ISndBuf)\t: void;\n\tstopse(sb: ISndBuf)\t: void;\n\tws(sb: ISndBuf, hArg: HArg): boolean;\n\tonPlayEnd(buf: string)\t: void;\n\tfade(sb: ISndBuf, hArg: HArg): void;\n\twf(sb: ISndBuf, hArg: HArg): boolean;\n\tcompFade(buf: string)\t: void;\n\tstopfadese(sb: ISndBuf, hArg: HArg): void;\n\tisDestroy\t: boolean;\n}\n\nclass SsLoading implements ISndState {\n\tonLoad(sb: ISndBuf)\t{sb.stt = new SsPlaying}\n\tstopse(sb: ISndBuf)\t{sb.stt = new SsStop(sb, false)}\n\tws =()=> false;\n\tonPlayEnd() {}\t\t// ok\n\tfade() {}\t\t\t// ok\n\twf =()=> false;\t\t// ok\n\tcompFade() {}\t\t// ok\n\tstopfadese() {}\t\t// ok\n\treadonly\tisDestroy\t= false;\n}\n\nclass SsPlaying implements ISndState {\n\tonLoad() {}\t\t\t// ok\n\tstopse(sb: ISndBuf)\t{sb.stt = new SsStop(sb)}\n\tws(sb: ISndBuf, hArg: HArg) {\n\t\tif (sb.loop) return false;\n\n\t\tconst {buf = 'SE'} = hArg;\n\t\tconst stop = argChk_Boolean(hArg, 'stop', true);\n\t\targChk_Boolean(hArg, 'canskip', false);\t// waitEvent() のデフォルトと違うので先行上書き\n\t\tif (evtMng.waitEvent('buf:'+ buf, hArg, ()=> {\t// 順番固定\n\t\t\tstop2var(sb, buf);\n\t\t\tsb.stt.onPlayEnd(buf);\t// まず一回やる\n\t\t\tif (stop) sb.stt.stopse(sb); else sb.stt.onPlayEnd = ()=> {};\n\t\t\t\t// else後は SsWaitingStop か SsStop の想定\n\t\t})) {\n\t\t\tsb.stt = new SsWaitingStop;\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\tonPlayEnd() {}\t\t// ok\n\tfade(sb: ISndBuf, hArg: HArg) {\n\t\tconst {buf = 'SE'} = hArg;\n\n\t\tconst vn = 'const.sn.sound.'+ buf +'.';\n\t\tconst bnV = vn +'volume';\n\t\tconst savevol = SndBuf.getVol(hArg, NaN);\n\t\tval.setVal_Nochk('save', bnV, savevol);\t// 目標音量(save:)\n\t\tconst vol = savevol * Number(val.getVal('sys:'+ bnV, 1))\n\t\tconst stop = argChk_Boolean(hArg, 'stop', (savevol === 0));\n\t\t\t// this.getVol() により savevol = hArg.volume\n\t\tif (stop) SndBuf.delLoopPlay(buf);\t// fade中reloadなど、できるだけ早く情報更新か\n\t\tval.flush();\n\n\t\tconst time = argChk_Num(hArg, 'time', NaN);\n\t\tconst delay = argChk_Num(hArg, 'delay', 0);\n\t\tif ((time === 0 && delay === 0) || evtMng.isSkipping) {\n\t\t\tsb.snd.volume = vol;\n\t\t\tsb.stt = stop ? new SsStop(sb) : new SsPlaying;\n\t\t\treturn;\n\t\t}\n\n//console.log('fadese start from:%f to:%f', sb.snd.volume, vol);\n\t\tconst tw = new Tween(sb.snd);\n\t\tCmnTween.setTwProp(tw, hArg)\n\t\t.to({volume: vol}, time)\n\t\t.onComplete(()=> {\n\t\t\tremove(tw);\n\t\t\tsb.stt.compFade(buf);\n\t\t\tsb.stt = stop ? new SsStop(sb) : new SsPlaying;\n\t\t})\n\t\t.start();\n\n\t\tsb.stt = new SsFade(tw);\n\t}\n\twf =()=> false;\t\t// ok\n\tcompFade() {}\t\t// ok\n\tstopfadese() {}\t\t// ok\n\treadonly\tisDestroy\t= false;\n}\n\nclass SsWaitingStop implements ISndState {\n\tonLoad() {}\t\t\t// ok\n\tstopse(sb: ISndBuf)\t{sb.stt = new SsStop(sb)}\n\tws =()=> false;\t\t// ok\n\tonPlayEnd(buf: string)\t{evtMng.breakEvent('buf:'+ buf)}\n\tfade() {}\t\t\t// ok\n\twf =()=> false;\t\t// ok\n\tcompFade() {}\t\t// ok\n\tstopfadese() {}\t\t// ok\n\treadonly\tisDestroy\t= false;\n}\n\nclass SsFade implements ISndState {\n\tconstructor(readonly tw: Tween) {}\n\tonLoad() {}\t\t\t// ok\n\tstopse(sb: ISndBuf)\t{stopfadese(this.tw); sb.stt = new SsStop(sb)}\t// 順番厳守\n\tws =()=> false;\t\t// ok ?\n\tonPlayEnd() {}\t\t// ok\n\tfade() {}\t\t\t// ok\n\twf(sb: ISndBuf, hArg: HArg) {\n\t\tconst {buf = 'SE'} = hArg;\n\t\targChk_Boolean(hArg, 'canskip', false);\t// waitEvent() のデフォルトと違うので先行上書き\n\t\tif (evtMng.waitEvent('buf:'+ buf, hArg, ()=> stopfadese(this.tw))) {\n\t\t\tsb.stt = new SsWaitingFade(this.tw);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\tcompFade() {}\t\t// ok\n\tstopfadese =()=> stopfadese(this.tw);\n\treadonly\tisDestroy\t= false;\n}\n\nclass SsWaitingFade implements ISndState {\n\tconstructor(readonly tw: Tween) {}\n\tonLoad() {}\t\t\t// ok\n\tstopse(sb: ISndBuf)\t{stopfadese(this.tw); sb.stt = new SsStop(sb)}\n\tws =()=> false;\t\t// ok\n\tonPlayEnd() {}\t\t// ok\n\tfade() {}\t\t\t// ok\n\twf =()=> false;\t\t// ok\n\tcompFade(buf: string) {evtMng.breakEvent('buf:'+ buf)}\n\tstopfadese =()=> stopfadese(this.tw);\n\treadonly\tisDestroy\t= false;\n}\n\nclass SsStop implements ISndState {\n\tconstructor(readonly sb: ISndBuf, readonly stop = true) {\n\t\tif (stop) {\n\t\t\tsb.snd.stop();\n\t\t\tif (! sb.loop) return;\n\n\t\t\tsb.snd.destroy();\n\t\t\tsb.snd.destroy = ()=> {};\t// 再度コール時エラー対策\n\t\t}\n\t}\t// destroy がないと再生が残るケースが。効果音だと破棄が激しいのでループモノ(BGM)だけにする\n\tonLoad() {}\t\t\t// ok\n\tstopse() {}\t\t\t// ok\n\tws =()=> false;\t\t// ok\n\tonPlayEnd() {}\t\t// ok\n\tfade() {}\t\t\t// ok\n\twf =()=> false;\t\t// ok\n\tcompFade() {}\t\t// ok\n\tstopfadese() {}\t\t// ok\n\treadonly\tisDestroy\t= true;\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2018-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {IEvtMng, argChk_Boolean, argChk_Num} from './CmnLib';\nimport {IHTag, HArg} from './Grammar';\nimport {IVariable, IMain, INoticeChgVolume} from './CmnInterface';\nimport {Config} from './Config';\nimport {SysBase} from './SysBase';\nimport {SndBuf} from './SndBuf';\n\nimport {sound, utils} from '@pixi/sound';\n\nexport class SoundMng {\n\t#hSndBuf\t: {[buf: string]: SndBuf}\t= {};\n\t#hLP\t\t: {[buf: string]: 0}\t\t= {};\n\n\tconstructor(cfg: Config, hTag: IHTag, readonly val: IVariable, main: IMain, sys: SysBase) {\n\t\thTag.volume\t\t= o=> this.#volume(o);\t\t// 音量設定(独自拡張)\n\t\thTag.fadebgm\t= o=> this.#fadebgm(o);\t\t// BGMのフェード\n\t\thTag.fadeoutbgm\t= o=> this.#fadeoutbgm(o);\t// BGMのフェードアウト\n\t\thTag.fadeoutse\t= o=> this.#fadeoutse(o);\t// 効果音のフェードアウト\n\t\thTag.fadese\t\t= o=> this.#fadese(o);\t\t// 効果音のフェード\n\t\thTag.playbgm\t= o=> this.#playbgm(o);\t\t// BGM の演奏\n\t\thTag.playse\t\t= o=> this.#playse(o);\t\t// 効果音の再生\n\t\thTag.stop_allse\t= ()=> this.#stop_allse();\t// 全効果音再生の停止\n\t\thTag.stopbgm\t= o=> this.#stopbgm(o);\t\t// BGM 演奏の停止\n\t\thTag.stopse\t\t= o=> this.#stopse(o);\t\t// 効果音再生の停止\n\t\thTag.wb\t\t\t= o=> this.#wb(o);\t\t\t// BGM フェードの終了待ち\n\t\thTag.wf\t\t\t= o=> this.#wf(o);\t\t\t// 効果音フェードの終了待ち\n\t\thTag.stopfadese\t= o=> this.#stopfadese(o);\t// 音声フェードの停止\n\t\thTag.wl\t\t\t= o=> this.#wl(o);\t\t\t// BGM 再生の終了待ち\n\t\thTag.ws\t\t\t= o=> this.#ws(o);\t\t\t// 効果音再生の終了待ち\n\t\thTag.xchgbuf\t= o=> this.#xchgbuf(o);\t\t// 再生トラックの交換\n\n\t\tval.setVal_Nochk('save', 'const.sn.loopPlaying', '{}');\n\n\t\tval.setVal_Nochk('tmp', 'const.sn.sound.codecs', JSON.stringify(utils.supported));\n\n\t\tSndBuf.init(cfg, val, main, sys);\n\t\tsound.disableAutoPause = true;\n\t}\n\n\t#evtMng\t: IEvtMng;\n\tsetEvtMng(evtMng: IEvtMng) {this.#evtMng = evtMng; SndBuf.setEvtMng(evtMng)}\n\tsetNoticeChgVolume(setGlbVol: INoticeChgVolume, setMovVol: INoticeChgVolume) {\n\t\tthis.val.defValTrg('sys:sn.sound.global_volume', (_name: string, val: any)=> setGlbVol(sound.volumeAll = Number(val)));\n\t\tthis.val.defValTrg('sys:sn.sound.movie_volume', (_name: string, val: any)=> setMovVol(Number(val)));\n\n\t\t// 起動時初期値セット\n\t\tthis.val.setVal_Nochk('sys', 'sn.sound.global_volume', this.val.getVal('sys:sn.sound.global_volume', 1));\n\t\tthis.val.setVal_Nochk('sys', 'sn.sound.movie_volume', this.val.getVal('sys:sn.sound.movie_volume', 1));\n\t}\n\n\t//MARK: 音量設定(独自拡張)\n\t#volume(hArg: HArg) {\n\t\tconst {buf = 'SE'} = hArg;\n\t\tconst vnV = 'const.sn.sound.'+ buf +'.volume';\n\t\tconst arg_vol = this.#getVol(hArg, 1);\n\t\tif (Number(this.val.getVal('sys:'+ vnV)) === arg_vol) return false;\n\n\t\tthis.val.setVal_Nochk('sys', vnV, arg_vol)\t// 基準音量(sys:)\n\t\tthis.val.flush();\t// fadese()内で必ずしも呼ばれないので\n\n\t\t// 再生中音声の一時的音量も変更\n\t\thArg.time = 0;\n\t\thArg.volume = Number(this.val.getVal('save:'+ vnV));\t// 目標音量(save:)\n\t\treturn this.#fadese(hArg);\n\t}\n\t#getVol(hArg: HArg, def: number) {\n\t\tconst vol = argChk_Num(hArg, 'volume', def);\n\t\tif (vol < 0) return 0;\n\t\tif (vol > 1) return 1;\n\t\treturn vol;\n\t}\n\n\t//MARK: BGM/効果音のフェードアウト(loadから使うのでマクロ化禁止)\n\t#fadeoutbgm(hArg: HArg) {hArg.volume = 0; return this.#fadebgm(hArg)}\n\t//MARK: 効果音のフェードアウト(loadから使うのでマクロ化禁止)\n\t#fadeoutse(hArg: HArg) {hArg.volume = 0; return this.#fadese(hArg)}\n\t//MARK: BGMのフェード(loadから使うのでマクロ化禁止)\n\t#fadebgm(hArg: HArg) {hArg.buf = 'BGM'; return this.#fadese(hArg)}\n\t//MARK: 効果音のフェード\n\t#fadese(hArg: HArg) {\n\t\tconst {buf = 'SE'} = hArg;\n\t\tthis.#stopfadese(hArg);\n\t\tthis.#hSndBuf[buf]?.fade(hArg);\n\n\t\treturn false;\n\t}\n\n\t//MARK: BGM の演奏\n\t#playbgm(hArg: HArg) {\n\t\thArg.buf = 'BGM';\n\t\thArg.canskip = false;\n\t\targChk_Boolean(hArg, 'loop', true);\n\t\treturn this.#playse(hArg);\n\t}\n\n\t//MARK: 効果音の再生\n\t#playse(hArg: HArg) {\n\t\tconst {buf = 'SE', fn} = hArg;\n\t\tthis.#stopse({buf});\n\t\tif (! fn) throw `[playse] fnは必須です buf:${buf}`;\n\n\t\t// isSkipKeyDown()は此処のみとする。タイミングによって変わる\n\t\tif (argChk_Boolean(hArg, 'canskip', true) && this.#evtMng.isSkipping) return false;\n\n\t\tconst sb = this.#hSndBuf[buf] = new SndBuf;\n\t\treturn sb.init(hArg);\n\t}\n\n\tclearCache() {sound.removeAll()}\n\n\t//MARK: 全効果音再生の停止\n\t#stop_allse() {\n\t\tfor (const buf of Object.keys(this.#hSndBuf)) this.#stopse({buf});\n\t\tthis.#hSndBuf = {};\n\n\t\tsound.stopAll();\t// 念のため\n\n\t\treturn false;\n\t}\n\t//MARK: BGM 演奏の停止(loadから使うのでマクロ化禁止)\n\t#stopbgm(hArg: HArg) {hArg.buf = 'BGM'; return this.#stopse(hArg)}\n\t//MARK: 効果音再生の停止\n\t#stopse(hArg: HArg) {\n\t\tconst {buf = 'SE'} = hArg;\n\t\tthis.#hSndBuf[buf]?.stopse(hArg);\n\n\t\treturn false;\n\t}\n\n\t//MARK: BGM フェードの終了待ち\n\t#wb(hArg: HArg) {hArg.buf = 'BGM'; return this.#wf(hArg)}\n\n\t//MARK: 効果音フェードの終了待ち\n\t#wf(hArg: HArg) {\n\t\tconst {buf = 'SE'} = hArg;\n\t\treturn this.#hSndBuf[buf]?.wf(hArg);\n\t}\n\n\t//MARK: 音声フェードの停止\n\t#stopfadese(hArg: HArg) {\n\t\tconst {buf = 'SE'} = hArg;\n\t\tthis.#hSndBuf[buf]?.stopfadese(hArg);\n\n\t\treturn false;\n\t}\n\n\t//MARK: BGM 再生の終了待ち\n\t#wl(hArg: HArg) {hArg.buf = 'BGM'; return this.#ws(hArg)}\n\t//MARK: 効果音再生の終了待ち\n\t#ws(hArg: HArg) {\n\t\tconst {buf = 'SE'} = hArg;\n\t\treturn this.#hSndBuf[buf]?.ws(hArg);\n\t}\n\n\t//MARK: 再生トラックの交換\n\t#xchgbuf(hArg: HArg) {\n\t\tconst {buf: buf1 = 'SE', buf2 = 'SE'} = hArg;\n\t\tif (buf1 === buf2) return false;\n\n\t\t[this.#hSndBuf[buf1], this.#hSndBuf[buf2]] =\n\t\t[this.#hSndBuf[buf2], this.#hSndBuf[buf1]];\n\t\tSndBuf.xchgbuf(hArg);\n\n\t\treturn false;\n\t}\n\n\t//MARK: しおりの読込(BGM状態復元)\n\tplayLoopFromSaveObj(): void {\n\t\tthis.#stop_allse();\n\t\tconst lp = String(this.val.getVal('save:const.sn.loopPlaying', '{}'));\n\t\tif (lp === '{}') return;\n\n\t\tthis.#hLP = JSON.parse(lp);\n\t\tconst a = Object.keys(this.#hLP).map(buf=> ()=> {\n\t\t\tconst vm = 'save:const.sn.sound.'+ buf +'.';\n\t\t\tif (this.val.getVal(vm +'start_ms') === undefined) return;\t// この値で不具合発見したので\n\t\t\tconst hArg = {\n\t\t\t\tfn\t\t: String(this.val.getVal(vm +'fn')),\n\t\t\t\tbuf,\n\t\t\t\tjoin\t: false,\n\t\t\t\tloop\t: true,\n\t\t\t\tvolume\t: Number(this.val.getVal(vm +'volume')),\n\t\t\t\tstart_ms: Number(this.val.getVal(vm +'start_ms')),\n\t\t\t\tend_ms\t: Number(this.val.getVal(vm +'end_ms')),\n\t\t\t\tret_ms\t: Number(this.val.getVal(vm +'ret_ms')),\n\t\t\t};\n\t\t\tif (hArg.buf === 'BGM') this.#playbgm(hArg);\n\t\t\telse this.#playse(hArg);\n\t\t});\n\t\tfor (const f of a) f();\n\t}\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2018-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {HArg} from './Grammar';\nimport {IVariable} from './CmnInterface';\nimport {Layer} from './Layer';\nimport {SysBase} from './SysBase';\nimport {argChk_Boolean} from './CmnLib';\n\nimport {Container} from 'pixi.js';\n\nexport class Pages {\n\t#pg: {fore: Layer, back: Layer};\n\n\tconstructor(layer: string, readonly cls: string, fore: Container, back: Container, readonly hArg: HArg, readonly sys: SysBase, readonly val: IVariable, readonly ret: {isWait: boolean}) {\n\t\tconst fncF = sys.hFactoryCls[cls];\n\t\tif (! fncF) throw `属性 class【${cls}】が不正です`;\n\n\t\tconst f = fncF();\n\t\tconst b = fncF();\n\t\tf.layname =\n\t\tb.layname = layer;\n\t\tconst nm = hArg[':id_tag'] = `layer:${layer} cls:${cls} page:`;\n\t\tf.spLay.name = f.name = nm +'A';\n\t\tb.spLay.name = b.name = nm +'B';\n\t\tfore.addChild(f.spLay);\n\t\tback.addChild(b.spLay);\n\t\targChk_Boolean(hArg, 'visible', true);\n\t\targChk_Boolean(hArg, 'visible', true);// SKYNovelではデフォルトはtrueとする\n\t\tret.isWait = f.lay(hArg) || b.lay(hArg);\n\t\tthis.#pg = {fore: f, back: b};\n\n\t\t// 組み込み変数\n\t\tconst valnm = `const.sn.lay.${layer}`;\n\t\tval.setVal_Nochk('tmp', valnm, true);\n\t\tval.defTmp(valnm +'.fore.alpha', ()=> this.#pg.fore.alpha);\n\t\tval.defTmp(valnm +'.back.alpha', ()=> this.#pg.back.alpha);\n\t\tval.defTmp(valnm +'.fore.height', ()=> this.#pg.fore.height);\n\t\tval.defTmp(valnm +'.back.height', ()=> this.#pg.back.height);\n\t\tval.defTmp(valnm +'.fore.visible', ()=> this.#pg.fore.spLay.visible);\n\t\tval.defTmp(valnm +'.back.visible', ()=> this.#pg.back.spLay.visible);\n\t\tval.defTmp(valnm +'.fore.width', ()=> this.#pg.fore.width);\n\t\tval.defTmp(valnm +'.back.width', ()=> this.#pg.back.width);\n\t\tval.defTmp(valnm +'.fore.x', ()=> this.#pg.fore.x);\n\t\tval.defTmp(valnm +'.back.x', ()=> this.#pg.back.x);\n\t\tval.defTmp(valnm +'.fore.y', ()=> this.#pg.fore.y);\n\t\tval.defTmp(valnm +'.back.y', ()=> this.#pg.back.y);\n\t}\n\tdestroy() {\n\t\tthis.#pg.fore.destroy();\n\t\tthis.#pg.back.destroy();\n\t}\n\n\treadonly lay = (hArg: HArg)=> this.getPage(hArg).lay(hArg);\n\treadonly getPage = (hArg: HArg)=>\n\t\t(Pages.argChk_page(hArg, 'fore') !== 'back')\n\t\t\t? this.#pg.fore\n\t\t\t: this.#pg.back;\n\tstatic\targChk_page(hash: HArg, def: string): string {\n\t\tconst v = hash.page ?? def;\n\t\tif (v === 'fore') return hash.page = v;\n\t\tif (v === 'back') return hash.page = v;\n\n\t\tthrow Error('属性 page【'+ v +'】が不正です');\n\t}\n\tget fore(): Layer {return this.#pg.fore}\n\tget back(): Layer {return this.#pg.back}\n\n\ttransPage(aPrm: Promise[]): void {\n\t\t[this.#pg.back, this.#pg.fore] = [this.#pg.fore, this.#pg.back];\n\t\tthis.#pg.back.copy(this.#pg.fore, aPrm);\n\t}\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2018-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {CmnLib, int, argChk_Boolean, argChk_Num, uint} from './CmnLib';\nimport {HArg} from './Grammar';\nimport {IMakeDesignCast} from './LayerMng';\n\nimport {BLEND_MODES, DisplayObject, Container, Sprite, Texture, AbstractRenderer, filters, Filter} from 'pixi.js';\nconst {BlurFilter, ColorMatrixFilter, NoiseFilter} = filters;\n\nexport class Layer {\n\t\t\t\tlayname\t= '';\n\tprotected\tname_\t= '';\n\tset name(nm) {this.name_ = nm}\n\tget name() {return this.name_}\n\treadonly\tspLay\t= new Sprite(Texture.EMPTY);\n\n\t// tsy用\n\tget\talpha() {return this.spLay.alpha}\n\tset alpha(v) {this.spLay.alpha = v}\n\tget\theight() {return this.spLay.height}\n\tget\trotation() {return this.spLay.angle}\n\tset rotation(v) {this.spLay.angle = v}\n\tget\tscale_x() {return this.spLay.scale.x}\n\tset scale_x(v) {this.spLay.scale.x = v}\n\tget\tscale_y() {return this.spLay.scale.y}\n\tset scale_y(v) {this.spLay.scale.y = v}\n\tget\twidth() {return this.spLay.width}\n\tget\tx() {return this.spLay.x}\n\tset x(v) {this.procSetX(v); this.spLay.x = v}\n\t\tprotected\tprocSetX(_x: number) {}\t// set を override できないので\n\tget\ty() {return this.spLay.y}\n\tset y(v) {this.procSetY(v); this.spLay.y = v}\n\t\tprotected\tprocSetY(_y: number) {}\t// set を override できないので\n\n\tdestroy() {}\n\n\tlay(hArg: HArg): boolean {\n\t\tconst s = this.spLay;\n\t\tif ('alpha' in hArg) s.alpha = argChk_Num(hArg, 'alpha', 1);\n\n\t\tLayer.setBlendmode(s, hArg);\n\n\t\tif ('pivot_x' in hArg || 'pivot_y' in hArg) s.pivot.set(\n\t\t\targChk_Num(hArg, 'pivot_x', s.pivot.x),\n\t\t\targChk_Num(hArg, 'pivot_y', s.pivot.y)\n\t\t);\n\n\t\tif ('rotation' in hArg) s.angle = argChk_Num(hArg, 'rotation', 0);\n\t\t\t// flash : rotation is in degrees.\n\t\t\t// pixijs: rotation is in radians, angle is in degrees.\n\n\t\tif ('scale_x' in hArg || 'scale_y' in hArg) s.scale.set(\n\t\t\targChk_Num(hArg, 'scale_x', s.scale.x),\n\t\t\targChk_Num(hArg, 'scale_y', s.scale.y)\n\t\t);\n\n\t\tif ('visible' in hArg) s.visible = argChk_Boolean(hArg, 'visible', true);\n\n\t\tif ('filter' in hArg) {\n\t\t\ts.filters = [Layer.bldFilters(hArg)];\n\t\t\tthis.aFltHArg = [hArg];\n\t\t}\n\n\t\treturn false;\n\t}\n\taFltHArg: HArg[]\t= [];\n\n\t/*\n\t* 現状未サポート\n\t\t* FXAAFilter\t\tgeeks3d.com のコードに基づいた基本的な FXAA (高速近似アンチエイリアシング) の実装ですが、WebGL でサポートされていないため、texture2DLod 要素が削除されたという変更が加えられています。\n\t\t* \thttps://pixijs.download/v6.5.10/docs/PIXI.filters.FXAAFilter.html\n\t\t* DisplacementFilter\t指定されたテクスチャ (ディスプレイスメント マップと呼ばれる) のピクセル値を使用して、オブジェクトのディスプレイスメントを実行します。\n\t\t* \thttps://pixijs.download/v6.5.10/docs/PIXI.filters.DisplacementFilter.html\n\t\t* \t\t人形城のヒビキとかのやつ?\n\t*/\n\t// フィルター生成\n\tstatic\tbldFilters(hArg: HArg): Filter {\n\t\tconst {filter=''} = hArg;\n\t\tconst fnc = Layer.hBldFilter[filter];\n\t\tif (! fnc) throw 'filter が異常です';\n\n\t\tconst f = fnc(hArg);\n\t\tf.enabled = argChk_Boolean(hArg, 'enable_filter', true);\n\t\tconst {blendmode} = hArg;\t// フィルターのブレンドモード\n\t\tif (blendmode) f.blendMode = Layer.getBlendmodeNum(blendmode);\n\t\treturn f;\n\t}\n\t// https://github.com/pixijs/filters\n\tstatic\treadonly\thBldFilter: {[nm: string]: (hArg: HArg)=> Filter} = {\n\t\t// https://pixijs.download/v6.5.10/docs/PIXI.filters.BlurFilter.html\n\t\tblur: hArg=> {\t// ガウスぼかし\n\t\t\tconst f = new BlurFilter(\n\t\t\t\targChk_Num(hArg, 'strength', 8),\t// 強さ\n\t\t\t\targChk_Num(hArg, 'quality', 4),\t\t// 品質\n\t\t\t\t'resolution' in hArg ?argChk_Num(hArg, 'resolution', 0) :undefined,\t\t\t\t\t\t\t// 解像度\n\t\t\t\targChk_Num(hArg, 'kernel_size', 5),\t// カーネルサイズ。値は 5、7、9、11、13、15。\n\t\t\t);\n\t\t\tf.blurX = uint(argChk_Num(hArg, 'blur_x', 2));\t// X強度\n\t\t\tf.blurY = uint(argChk_Num(hArg, 'blur_y', 2));\t// Y強度\n\t//略\tf.quality = uint(argChk_Num(hArg, 'quality', 1));\n\t\t\t\t// ブラーのパス数。パス数が多いほど、ブラーの品質が高くなります。\n\t\t\tf.repeatEdgePixels = argChk_Boolean(hArg, 'repeat_edge_pixels', false);\t// true に設定すると、ターゲットのエッジがクランプされます。\n\t\t\treturn f;\n\t\t},\n\n\t\t// https://pixijs.download/v6.5.10/docs/PIXI.filters.NoiseFilter.html\n\t\tnoise: hArg=> new NoiseFilter(\t// ノイズエフェクト\n\t\t\targChk_Num(hArg, 'noise', 0.5),\n\t\t\t\t// 適用するノイズの量。この値は (0, 1] の範囲内\n\t\t\t'seed' in hArg ?argChk_Num(hArg, 'seed', 0) :undefined,\n\t\t\t\t// ランダム ノイズの生成に適用するシード値。 Math.random() を使用するのが適切な値です。\n\t\t),\n\n\t\t// https://pixijs.download/v6.5.10/docs/PIXI.filters.ColorMatrixFilter.html\n\t\tcolor_matrix: hArg=> {\t// カラーマトリックス\n\t\t\t\t// displayObject 上のすべてのピクセルの RGBA カラーとアルファ値に 5x4 マトリックス変換を適用して、新しい RGBA カラーとアルファ値のセットを含む結果を生成できます。 かなり強力ですよ!\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.alpha = uint(argChk_Num(hArg, 'alpha', 1));\n\t\t\t\n\t\t\tconst {matrix=''} = hArg;\n\t\t\tif (matrix) {\n\t\t\t\tconst m = matrix.split(',');\n\t\t\t\tconst len = m.length;\n\t\t\t\tif (len !== 20) throw `matrix の個数(${len})が 20 ではありません`;\n\t\t\t\tm.forEach((v, i)=> f.matrix[i] = uint(v));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tf.matrix[0] = uint(argChk_Num(hArg, 'rtor', 1));\n\t\t\t\tf.matrix[1] = uint(argChk_Num(hArg, 'gtor', 0));\n\t\t\t\tf.matrix[2] = uint(argChk_Num(hArg, 'btor', 0));\n\t\t\t\tf.matrix[3] = uint(argChk_Num(hArg, 'ator', 0));\n\t\t\t\tf.matrix[4] = uint(argChk_Num(hArg, 'pr', 0));\n\t\t\t\tf.matrix[5] = uint(argChk_Num(hArg, 'rtog', 0));\n\t\t\t\tf.matrix[6] = uint(argChk_Num(hArg, 'gtog', 1));\n\t\t\t\tf.matrix[7] = uint(argChk_Num(hArg, 'btog', 0));\n\t\t\t\tf.matrix[8] = uint(argChk_Num(hArg, 'atog', 0));\n\t\t\t\tf.matrix[9] = uint(argChk_Num(hArg, 'pg', 0));\n\t\t\t\tf.matrix[10] = uint(argChk_Num(hArg, 'rtob', 0));\n\t\t\t\tf.matrix[11] = uint(argChk_Num(hArg, 'gtob', 0));\n\t\t\t\tf.matrix[12] = uint(argChk_Num(hArg, 'btob', 1));\n\t\t\t\tf.matrix[13] = uint(argChk_Num(hArg, 'atob', 0));\n\t\t\t\tf.matrix[14] = uint(argChk_Num(hArg, 'pb', 0));\n\t\t\t\tf.matrix[15] = uint(argChk_Num(hArg, 'rtoa', 0));\n\t\t\t\tf.matrix[16] = uint(argChk_Num(hArg, 'gtoa', 0));\n\t\t\t\tf.matrix[17] = uint(argChk_Num(hArg, 'btoa', 0));\n\t\t\t\tf.matrix[18] = uint(argChk_Num(hArg, 'atoa', 1));\n\t\t\t\tf.matrix[19] = uint(argChk_Num(hArg, 'pa', 0));\n\t\t\t}\n\t\t\treturn f;\n\t\t},\n\t\tblack_and_white: hArg=> {\t// 白黒\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.blackAndWhite(\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tbrightness: hArg=> {\t// 明るさを調整\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.brightness(\n\t\t\t\targChk_Num(hArg, 'b', 0.5),\n\t\t\t\t\t// 明るさの値 (0 ~ 1、0 は黒)\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tbrowni: hArg=> {\t// おいしいブラウニー\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.browni(\n\t\t\t\targChk_Boolean(hArg, 'multiply', true),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tcolor_tone: hArg=> {\t// カラートーン。グラデーション マップのようなもので、正確に何をするのかはわかりませんが、遊んでみると面白いです。\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.colorTone(\n\t\t\t\targChk_Num(hArg, 'desaturation', 0.5),\n\t\t\t\targChk_Num(hArg, 'toned', 0.5),\n\t\t\t\targChk_Num(hArg, 'light_color', 0xFFE580),\n\t\t\t\targChk_Num(hArg, 'dark_color', 0xFFE580),\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tcontrast: hArg=> {\t// コントラスト マトリクスを設定し、暗い部分と明るい部分の分離を増やします。 コントラストを上げる : シャドウをより暗くし、ハイライトをより明るくします。 コントラストを下げる : シャドウを上げ、ハイライトを下げます。\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.contrast(\n\t\t\t\targChk_Num(hArg, 'amount', 0.5),\n\t\t\t\t\t// コントラストの値 (0-1)\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tgrayscale: hArg=> {\t// グレースケール\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.grayscale(\n\t\t\t\targChk_Num(hArg, 'scale', 0.5),\n\t\t\t\t\t// グレーの値 (0 ~ 1、0 は黒)\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\thue: hArg=> {\t// 色相\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.hue(\n\t\t\t\targChk_Num(hArg, 'f_rotation', 90),\t// 0だと変化なしで分かりづらいので\n\t\t\t\t\t// 度単位\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tkodachrome: hArg=> {\t// コダクローム。1935 年に Eastman Kodak によって導入されたカラー リバーサル フィルム。(Dominic Szablewski に感謝)\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.kodachrome(\n\t\t\t\targChk_Boolean(hArg, 'multiply', true),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tlsd: hArg=> {\t// LSD効果、現在の行列を乗算します\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.lsd(\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tnegative: hArg=> {\t// ネガティブ画像 (古典的なRGBマトリックスの逆)\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.negative(\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tnight: hArg=> {\t// ナイトエフェクト\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.night(\n\t\t\t\targChk_Num(hArg, 'intensity', 0.5),\n\t\t\t\t\t// 夜の効果の強さ\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tpolaroid: hArg=> {\t// ポラロイド\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.polaroid(\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tpredator: hArg=> {\t// 捕食者効果、新しい独立したマトリックスを設定して現在のマトリックスを消去します\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.predator(\n\t\t\t\targChk_Num(hArg, 'amount', 0.5),\n\t\t\t\t\t// 捕食者は自分の将来の犠牲者をどれほど感じているか\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tsaturate: hArg=> {\t// 彩度。色の間の分離を増やします。 彩度を増やす: コントラスト、明るさ、シャープネスを増やします。\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.saturate(\n\t\t\t\targChk_Num(hArg, 'amount', 0.5),\n\t\t\t\t\t// 飽和量(0~1)\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tsepia: hArg=> {\t\t// セピア\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.sepia(\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\ttechnicolor: hArg=> {\t// テクニカラー。1916 年に発明されたカラー動画プロセス (Dominic Szablewski に感謝)\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.technicolor(\n\t\t\t\targChk_Boolean(hArg, 'multiply', true),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\ttint: hArg=> {\t// 色合い。カラー マトリクスの対角線上に各チャネルを設定します。 これを使用すると、スプライト、テキスト、グラフィックス、メッシュなどの一部の表示オブジェクトの色合いフィールドと同様の色合い効果をコンテナ上で実現できます。\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.tint(\n\t\t\t\targChk_Num(hArg, 'f_color', 0x888888),\n\t\t\t\t\t// 色合いの色。 これは 16 進数値です。\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tto_bgr: hArg=> {\t// 赤→青、青→赤\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.toBGR(\n\t\t\t\targChk_Boolean(hArg, 'multiply', false),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t\tvintage: hArg=> {\t// ビンテージ\n\t\t\tconst f = new ColorMatrixFilter;\n\t\t\tf.vintage(\n\t\t\t\targChk_Boolean(hArg, 'multiply', true),\n\t\t\t\t\t// true の場合、現在の行列と行列を乗算\n\t\t\t);\n\t\t\treturn f;\n\t\t},\n\t};\n\n\tstatic\tsetBlendmode(cnt: Container, hArg: HArg) {\n\t\tconst {blendmode} = hArg;\n\t\tif (! blendmode) return;\t// 省略時になにもしない\n\n\t\tconst bmn = Layer.getBlendmodeNum(blendmode);\n\t\tif (cnt instanceof Sprite) cnt.blendMode = bmn;\n\t\tfor (const c of cnt.children) {\n\t\t\tif (c instanceof Sprite) c.blendMode = bmn;\n\t\t}\n\t}\n\n\tstatic getBlendmodeNum(bm_name: string): number {\n\t\tif (! bm_name) return BLEND_MODES.NORMAL;\t// 省略時にデフォルトを返す\n\n\t\tconst bmn = Layer.#hBlendmode[bm_name];\n\t\tif (bmn !== undefined) return bmn;\n\t\tthrow `${bm_name} はサポートされない blendmode です`;\n\t}\n\tstatic\treadonly\t#hBlendmode: {[bm_name: string]: number} = {\n\t\t'normal'\t\t: BLEND_MODES.NORMAL,\n\t\t'add'\t\t\t: BLEND_MODES.ADD,\n\t\t'multiply'\t\t: BLEND_MODES.MULTIPLY,\n\t\t'screen'\t\t: BLEND_MODES.SCREEN,\n/*\n\t\t'overlay'\t\t: BLEND_MODES.OVERLAY,\n\t\t'darken'\t\t: BLEND_MODES.DARKEN,\n\t\t'lighten'\t\t: BLEND_MODES.LIGHTEN,\n\t\t'color_dodge'\t: BLEND_MODES.COLOR_DODGE,\n\t\t'color_burn'\t: BLEND_MODES.COLOR_BURN,\n\t\t'hard_light'\t: BLEND_MODES.HARD_LIGHT,\n\t\t'soft_light'\t: BLEND_MODES.SOFT_LIGHT,\n\t\t'difference'\t: BLEND_MODES.DIFFERENCE,\n\t\t'exclusion'\t\t: BLEND_MODES.EXCLUSION,\n\t\t'hue'\t\t\t: BLEND_MODES.HUE,\n\t\t'saturation'\t: BLEND_MODES.SATURATION,\n\t\t'color'\t\t\t: BLEND_MODES.COLOR,\n\t\t'luminosity'\t: BLEND_MODES.LUMINOSITY,\n\n\t\t'normal_npm'\t: BLEND_MODES.NORMAL_NPM,\n\t\t'add_npm'\t\t: BLEND_MODES.ADD_NPM,\n\t\t'screen_npm'\t: BLEND_MODES.SCREEN_NPM,\n\t\t'none'\t\t\t: BLEND_MODES.NONE,\n\t\t'src_in'\t\t: BLEND_MODES.SRC_IN,\n\t\t'src_out'\t\t: BLEND_MODES.SRC_OUT,\n\t\t'src_atop'\t\t: BLEND_MODES.SRC_ATOP,\n\t\t'dst_over'\t\t: BLEND_MODES.DST_OVER,\n\t\t'dst_in'\t\t: BLEND_MODES.DST_IN,\n\t\t'dst_out'\t\t: BLEND_MODES.DST_OUT,\n\t\t'dst_atop'\t\t: BLEND_MODES.DST_ATOP,\n\t\t'subtract'\t\t: BLEND_MODES.SUBTRACT,\n\t\t'src_over'\t\t: BLEND_MODES.SRC_OVER,\n\t\t'erase'\t\t\t: BLEND_MODES.ERASE,\n\t\t'xor'\t\t\t: BLEND_MODES.XOR,\n*/\n\t};\n\tstatic getNum2Blendmode(bmn: number): string {\n\t\treturn Layer.#hNum2Blendmode[bmn] ?? 'normal';\n\t}\n\tstatic\treadonly\t#hNum2Blendmode: {[bmn: number]: string} = {\n\t\t0\t/* NORMAL */\t\t: 'normal',\n\t\t1\t/* ADD */\t\t\t: 'add',\n\t\t2\t/* MULTIPLY */\t\t: 'multiply',\n\t\t3\t/* SCREEN */\t\t: 'screen',\n\t}\n\n\t// アニメ・動画があるか\n\tget containMovement(): boolean {return false}\n\n\trenderStart() {}\n\trenderEnd() {}\n\n\tclearLay(hArg: HArg): void {\n\t\tthis.spLay.alpha = 1;\n\t\tthis.spLay.blendMode = BLEND_MODES.NORMAL;\n\t\t// visibleは触らない\n\t\tthis.spLay.pivot.set(0, 0);\n\t\tthis.spLay.angle = 0;\n\t\tthis.spLay.scale.set(1, 1);\n\t\tif (argChk_Boolean(hArg, 'clear_filter', false)) {\n\t\t\tthis.spLay.filters = null;\n\t\t\tthis.aFltHArg = [];\n\t\t}\n\t\t//transform.colorTransform = nulColTrfm;\n\t}\n\tcopy(fromLayer: Layer, aPrm: Promise[]): void {\n\t\tconst org_name = this.name_;\n\t\tthis.playback(fromLayer.record(), aPrm);\n\t\tthis.name = org_name;\n\t}\n\trecord() {return {\n\t\tname\t: this.name_,\n\t\tidx\t\t: this.spLay.parent.getChildIndex(this.spLay),\n\t\talpha\t: this.spLay.alpha,\n\t\tblendMode\t: this.spLay.blendMode,\n\t\trotation\t: this.spLay.angle,\n\t\tscale_x\t: this.spLay.scale.x,\n\t\tscale_y\t: this.spLay.scale.y,\n\t\tpivot_x\t: this.spLay.pivot.x,\n\t\tpivot_y\t: this.spLay.pivot.y,\n\t\tx\t\t: this.spLay.x,\n\t\ty\t\t: this.spLay.y,\n\t\tvisible\t: this.spLay.visible,\n\t\taFltHArg: this.aFltHArg,\n\t}}\n\tplayback(hLay: any, _aPrm: Promise[]): void {\n\t\tthis.name = hLay.name;\n\t\t//idx\t// コール順に意味があるので親でやる\n\n\t\tthis.clearLay({clear_filter: true});\n\t\tthis.spLay.alpha = hLay.alpha;\n\t\tthis.spLay.blendMode = hLay.blendMode;\n\t\tthis.spLay.angle = hLay.rotation;\n\t\tthis.spLay.scale.set(hLay.scale_x, hLay.scale_y);\n\t\tthis.spLay.pivot.set(hLay.pivot_x, hLay.pivot_y);\n\t\tthis.spLay.position.set(hLay.x, hLay.y);\n\t\tthis.spLay.visible = hLay.visible;\n\n\t\tthis.aFltHArg = hLay.aFltHArg ?? [];\n\t\tthis.spLay.filters = (this.aFltHArg.length === 0)\n\t\t\t? null\n\t\t\t: this.aFltHArg.map(f=> Layer.bldFilters(f));\n\t}\n\n\tsnapshot(rnd: AbstractRenderer, re: ()=> void) {\n\t\trnd.render(this.spLay, {clear: false});\n\t\tre();\n\t}\n\tsnapshot_end() {}\n\n\tmakeDesignCast(_gdc: IMakeDesignCast) {}\n\tmakeDesignCastChildren(_gdc: IMakeDesignCast) {}\n\n\tshowDesignCast() {}\n\tshowDesignCastChildren() {}\n\n\tcvsResize() {}\n\tcvsResizeChildren() {}\n\n\tdump(): string {\n\t\treturn ` \"idx\":${this.spLay.parent.getChildIndex(this.spLay)\n\t\t}, \"visible\":\"${this.spLay.visible\n\t\t}\", \"left\":${this.spLay.x}, \"top\":${this.spLay.y\n\t\t}, \"alpha\":${this.spLay.alpha}, \"rotation\":${this.spLay.angle\n//\t\t}, \"blendMode\":${this.spLay.blendMode\n\t\t}, \"name\":\"${this.name_}\", \"scale_x\":${this.spLay.scale.x\n\t\t}, \"scale_y\":${this.spLay.scale.y\n\t\t}, \"filters\": [${this.aFltHArg.map(f=> `\"${f.filter}\"`).join(',')}]`;\n\t}\n\n\tstatic\tsetXY(base: DisplayObject, hArg: HArg, ret: Container, isGrp = false, isButton = false): void {\n\t\tif (hArg.pos) {Layer.setXYByPos(base, hArg.pos, ret); return}\n\n\t\tconst rct_base = base.getBounds();\n\t\tconst r_absclX\t= (ret.scale.x < 0)? -ret.scale.x : ret.scale.x;\n\t\tconst b_width\t= (r_absclX === 1)\n\t\t\t\t\t\t? rct_base.width : rct_base.width *r_absclX;\n\t\tconst r_absclY\t= (ret.scale.y < 0)? -ret.scale.y : ret.scale.y;\n\t\tconst b_height\t= (r_absclY === 1)\n\t\t\t\t\t\t? rct_base.height: rct_base.height*r_absclY;\n\n\t\t// 横位置計算\n\t\tlet x = ret.x;\t// AIRNovelでは 0\n\t\tif ('left' in hArg) {\n\t\t\tx = argChk_Num(hArg, 'left', 0);\n\t\t\tif ((x > -1) && (x < 1)) x *= CmnLib.stageW;\n\t\t}\n\t\telse if ('center' in hArg) {\n\t\t\tx = argChk_Num(hArg, 'center', 0);\n\t\t\tif ((x > -1) && (x < 1)) x *= CmnLib.stageW;\n\t\t\tx = x - (isButton ?b_width/3 :b_width)/2;\n\t\t}\n\t\telse if ('right' in hArg) {\n\t\t\tx = argChk_Num(hArg, 'right', 0);\n\t\t\tif ((x > -1) && (x < 1)) x *= CmnLib.stageW;\n\t\t\tx = x - (isButton ?b_width/3 :b_width);\n\t\t}\n\t\telse if ('s_right' in hArg) {\n\t\t\tx = argChk_Num(hArg, 's_right', 0);\n\t\t\tif ((x > -1) && (x < 1)) x *= CmnLib.stageW;\n\t\t\tx = CmnLib.stageW - x\n\t\t\t\t- (isButton ?b_width/3 :b_width);\n\t\t}\n\t\tret.x = int( ((ret.scale.x < 0)\n\t\t\t? x +(isButton ?b_width/3 :b_width)\n\t\t\t: x) );\n\n\t\t// 縦位置計算\n\t\tlet y = ret.y;\t// AIRNovelでは 0\n\t\tif ('top' in hArg) {\n\t\t\ty = argChk_Num(hArg, 'top', 0);\n\t\t\tif ((y > -1) && (y < 1)) y *= CmnLib.stageH;\n\t\t}\n\t\telse if ('middle' in hArg) {\n\t\t\ty = argChk_Num(hArg, 'middle', 0);\n\t\t\tif ((y > -1) && (y < 1)) y *= CmnLib.stageH;\n\t\t\ty = y - b_height/2;\n\t\t}\n\t\telse if ('bottom' in hArg) {\n\t\t\ty = argChk_Num(hArg, 'bottom', 0);\n\t\t\tif ((y > -1) && (y < 1)) y *= CmnLib.stageH;\n\t\t\ty = y - b_height;\n\t\t}\n\t\telse if ('s_bottom' in hArg) {\n\t\t\ty = argChk_Num(hArg, 's_bottom', 0);\n\t\t\tif ((y > -1) && (y < 1)) y *= CmnLib.stageH;\n\t\t\ty = CmnLib.stageH - y - b_height;\n\t\t}\n\t\tret.y = int( ((ret.scale.y < 0) ?y +b_height :y) );\n\n\t\tif (isGrp) {\t// これを上の方に持っていってはいけない。\n\t\t\t\t\t\t// iPhone6など中途半端な画面サイズの際に\n\t\t\t\t\t\t// 縦位置が異常になる(素材が画面外下に)\n\t\t\tif (!('left' in hArg)\n\t\t\t&& !('center' in hArg)\n\t\t\t&& !('right' in hArg)\n\t\t\t&& !('s_right' in hArg)\n\t\t\t&& !('top' in hArg)\n\t\t\t&& !('middle' in hArg)\n\t\t\t&& !('bottom' in hArg)\n\t\t\t&& !('s_bottom' in hArg)) {\n\t\t\t\tLayer.setXYByPos(base, 'c', ret);\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic\tsetXYByPos(base: DisplayObject, pos: string, ret: DisplayObject): void {\n\t\tif (pos === 'stay') return;\n\t\tif (base === undefined) throw 'setXYByPos base === undefined';\n\t\tif (ret === undefined) throw 'setXYByPos result === undefined';\n\n\t\tconst rct_base = base.getBounds();\n\t\tconst r_absclX = (ret.scale.x < 0)? -ret.scale.x : ret.scale.x;\n\t\tconst b_width = (r_absclX === 1)? rct_base.width : rct_base.width *r_absclX;\n\t\tconst r_absclY = (ret.scale.y < 0)? -ret.scale.y : ret.scale.y;\n\t\tconst b_height = (r_absclY === 1)? rct_base.height: rct_base.height*r_absclY;\n\n\t\tlet c = 0;\t// 忘れたけど、プルプルするからintなんだっけ\n\t\tif (! pos || pos === 'c') {c = CmnLib.stageW *0.5}\n\t\telse if (pos === 'r') {c = CmnLib.stageW - b_width *0.5}\n\t\telse if (pos === 'l') {c = b_width *0.5}\n\t\telse {c = int(pos)}\n\n\t\tret.x = int(c -b_width *0.5);\n\t\tret.y = CmnLib.stageH -b_height;\n\n\t\tif (ret.scale.x < 0) ret.x += b_width;\n\t\tif (ret.scale.y < 0) ret.y += b_height;\n\t}\n\n\tstatic\tsetXYCenter(dsp: DisplayObject): void {\n\t\tconst rct = dsp.getBounds();\n\t\tdsp.x = (CmnLib.stageW - rct.width) *0.5;\n\t\tdsp.y = (CmnLib.stageH - rct.height) *0.5;\n\t}\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2021-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {HArg} from './Grammar';\nimport {IPropParser} from './CmnInterface';\nimport {SysBase} from './SysBase';\nimport {ScriptIterator} from './ScriptIterator';\nimport {HPage} from './LayerMng';\nimport {AnalyzeTagArg, HPRM} from './AnalyzeTagArg';\nimport {TxtStage} from './TxtStage';\nimport {Button} from './Button';\nimport {GrpLayer} from './GrpLayer';\nimport {Config} from './Config';\n\nimport {Application, Text, Sprite} from 'pixi.js';\n\n\nexport class DesignCast {\n\tstatic\tinit(_appPixi: Application, _sys: SysBase, _scrItr: ScriptIterator, _prpPrs: IPropParser, _alzTagArg: AnalyzeTagArg, _cfg: Config, _hPages: HPage) {}\n\tstatic\tcvsResizeDesign() {}\n\n\n\tconstructor(readonly bg_col: string, readonly isLay = false) {}\n\tdestroy() {}\n\n\tgethArg(): HArg {return this.hArg}\n\tprotected\thArg\t: HArg\t= {};\n\tsethArg(hArg: HArg): void {\n\t\tthis.hArg = hArg;\n\t}\n\n\tsetOther(_hPrm: HPRM) {}\n\n\tadopt(_idcCh: DesignCast) {\t// 養子縁組\n\t}\n\n\tstatic\tenterMode() {}\n\tstatic\tallHide() {}\n\tset visible(_v: boolean) {}\n\tstatic\tleaveMode() {}\n\n\n\tcvsResize() {}\n\tmake() {}\n\tstatic replaceToken(_o: any) {}\n\n}\n\n\n// 画像レイヤ\nexport class GrpLayDesignCast extends DesignCast {\n\tconstructor(_spLay: Sprite, _gl: GrpLayer) {super('#29e', true)}\n\tsetSp(_sp: Sprite) {}\n}\n\n// 文字レイヤ\nexport class TxtLayDesignCast extends DesignCast {\n\tconstructor(_spLay: Sprite, _ts: TxtStage) {\n\t\tsuper('#29e', true);\n\t}\n}\n// 文字レイヤ・パディング\nexport class TxtLayPadDesignCast extends DesignCast {\n\tconstructor(_ts: TxtStage) {super('#9e2')}\n}\n\n// 文字レイヤ・ボタン基本\nexport class BtnDesignCast extends DesignCast {\n\tconstructor(protected readonly btn: Button, override readonly hArg: HArg) {\n\t\tsuper('#e92');\n\t}\n}\n// 文字レイヤ・文字ボタン\nexport class TxtBtnDesignCast extends BtnDesignCast {\n\tconstructor(btn: Button, hArg: HArg, _txt: Text) {\n\t\tsuper(btn, hArg);\n\t}\n}\n\n// 文字レイヤ・画像ボタン\nexport class PicBtnDesignCast extends BtnDesignCast {\n\tconstructor(btn: Button, hArg: HArg) {super(btn, hArg)}\n\tsetSp(_sp: Sprite) {}\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2023-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {Sprite, Container, Texture, AnimatedSprite, LoaderResource, utils, Loader, Rectangle, BLEND_MODES} from 'pixi.js';\nimport {Config} from './Config';\nimport {IEvtMng, argChk_Boolean, argChk_Num, getFn, int} from './CmnLib';\nimport {IMain, IVariable, SYS_DEC_RET} from './CmnInterface';\nimport {DebugMng} from './DebugMng';\nimport {SEARCH_PATH_ARG_EXT} from './ConfigBase';\nimport {SysBase} from './SysBase';\nimport {SoundMng} from './SoundMng';\nimport {HArg} from './Grammar';\nimport {Layer} from './Layer';\n\ntype IFncCompSpr = (sp: Sprite)=> void;\n\ninterface Iface {\n\tfn\t\t\t: string;\n\tdx\t\t\t: number;\n\tdy\t\t\t: number;\n\tblendmode\t: number;\n};\ninterface Ihface { [name: string]: Iface; };\n\ninterface IResAniSpr {\n\taTex\t: Texture[];\n\tmeta\t: {\n\t\tanimationSpeed? :number;\n\t};\n}\n\n\nexport class SpritesMng {\n\tstatic\t#cfg\t: Config;\n\tstatic\t#val\t: IVariable;\n\tstatic\t#sys\t: SysBase;\n\tstatic\t#main\t: IMain;\n\tstatic\tinit(cfg: Config, val: IVariable, sys: SysBase, main: IMain, sndMng: SoundMng) {\n\t\tSpritesMng.#cfg = cfg;\n\t\tSpritesMng.#val = val;\n\t\tSpritesMng.#sys = sys;\n\t\tSpritesMng.#main = main;\n\t\tif (sys.crypto) {\n\t\t\tSpritesMng.#cachePicMov = SpritesMng.#dec2cachePicMov;\n\t\t\tSpritesMng.#cacheAniSpr = SpritesMng.#dec2cacheAniSpr;\n\t\t}\n\n\t\tconst fnc = ()=> {\n\t\t\tconst vol = SpritesMng.#glbVol * SpritesMng.#movVol;\n\t\t\tfor (const v of Object.values(SpritesMng.#hFn2VElm)) v.volume = vol;\n\t\t};\n\t\tsndMng.setNoticeChgVolume(\n\t\t\tvol=> {SpritesMng.#glbVol = vol; fnc()},\n\t\t\tvol=> {SpritesMng.#movVol = vol; fnc()}\n\t\t);\n\t}\n\tstatic\t#movVol\t= 1;\n\tstatic\t#glbVol\t= 1;\n\n\tstatic\t#evtMng\t: IEvtMng;\n\tstatic\tsetEvtMng(evtMng: IEvtMng) {SpritesMng.#evtMng = evtMng}\n\n\n\tconstructor(readonly csvFn = '', readonly spLay?: Container, private fncFirstComp: IFncCompSpr = ()=> {}, private fncAllComp: (isStop: boolean)=> void = ()=> {}) {\n\t\tif (! csvFn) return;\n\n\t\tthis.#addChild = spLay ? sp=> {spLay.addChild(sp); this.#aSp.push(sp)} : ()=> {};\n\t\tthis.ret = SpritesMng.#csv2Sprites(\n\t\t\tcsvFn,\n\t\t\tsp=> this.fncFirstComp(sp),\t\t\t// 差し替え考慮\n\t\t\tisStop=> this.fncAllComp(isStop),\t// 差し替え考慮\n\t\t\tsp=> this.#addChild(sp)\t\t\t\t// 差し替え考慮\n\t\t);\n\t}\n\treadonly ret: boolean\t\t= false;\n\t#addChild\t: (sp: Sprite)=> void;\n\t#aSp\t\t: Container[]\t= [];\n\n\tdestroy() {\t\t// これをやるためのクラス、とすら云える\n\t\tthis.fncFirstComp\t= ()=> {};\n\t\tthis.fncAllComp\t\t= ()=> {};\n\t\tthis.#addChild\t\t= sp=> sp.destroy();\n\n\t\tthis.#aSp.forEach(sp=> {\n\t\t\tSpritesMng.stopVideo(sp.name);\n\t\t\tsp.parent?.removeChild(sp);\n\t\t\tsp.destroy();\n\t\t});\n\t\tthis.#aSp = [];\n\t}\n\n\tstatic\tdestroy() {\n\t\tSpritesMng.#hFace\t= {};\n\t\tSpritesMng.#hFn2ResAniSpr\t= {};\n\t\t//SpritesMng.#ldrHFn\t= {};\n\t\tSpritesMng.#hFn2VElm\t= {};\n\t}\n\n\n\t//static #ldrHFn: {[fn: string]: 1} = {};\n\tstatic #csv2Sprites(csv: string, fncFirstComp: IFncCompSpr, fncAllComp: (isStop: boolean)=> void, addChild: (sp: Sprite)=> void): boolean {\n\t\t// Data URI\n\t\tlet needLoad = false;\n\t\tif (csv.slice(0, 5) === 'data:') {\n\t\t\tconst fnc = ()=> {\n\t\t\t\tconst sp = Sprite.from(csv);\n\t\t\t\taddChild(sp);\n\t\t\t\tfncFirstComp(sp);\n\t\t\t\tfncAllComp(needLoad);\n\t\t\t};\n\t\t\tif (csv in utils.TextureCache) fnc();\n\t\t\telse {needLoad = true; (new Loader).add(csv, csv).load(fnc)}\n\n\t\t\treturn needLoad;\n\t\t}\n\n\t\tconst aComp: {fn: string, fnc: IFncCompSpr}[] = [];\n\t\tconst ldr = new Loader;\n\t\tcsv.split(',').forEach((fn0, i)=> {\n\t\t\tif (! fn0) throw 'face属性に空要素が含まれます';\n\n\t\t\t// 差分絵を重ねる\n\t\t\tconst {dx, dy, blendmode, fn} = SpritesMng.#hFace[fn0] || {\n\t\t\t\tfn\t: fn0,\n\t\t\t\tdx\t: 0,\n\t\t\t\tdy\t: 0,\n\t\t\t\tblendmode\t: BLEND_MODES.NORMAL\n\t\t\t};\n\t\t\tconst fnc = (i === 0) ?fncFirstComp :(sp: Sprite)=> {\n\t\t\t\tsp.x = dx;\n\t\t\t\tsp.y = dy;\n\t\t\t\tsp.blendMode = blendmode;\n\t\t\t};\n\t\t\taComp.push({fn, fnc});\n\n\t\t\tif (fn in SpritesMng.#hFn2ResAniSpr) return;\n\t\t\tif (fn in utils.TextureCache) return;\n\t\t\t//if (fn in utils.BaseTextureCache) return;\t\t// 警告に変化なし\n\t\t\tif (fn in Loader.shared.resources) return;\n\t\t\t//if (fn in SpritesMng.#ldrHFn) {\n\t\t\t\t// ここに来るという中途半端な状態がある。お陰で警告が出てしまう\n\t\t\t\t// (警告を消そうとする)以下の試みは効かない。直前の if でそもそもここに来ない\n\t\t\t\t//\tTexture.removeFromCache(fn);\n\t\t\t\t//\tdelete utils.TextureCache[fn];\n\t\t\t\t//\tdelete Loader.shared.resources[fn];\n\t\t\t\t// return;\t// これは厳禁、御法度。\n\t\t\t\t\t// 画像ボタンや文字ボタン背景で同じ画像を、間を置かずロードした場合に最初一つしか表示されなくなる。以下は確認用ギャラリー\n\t\t\t\t\t// http://localhost:8082/index.html?cur=ch_button\n\t\t\t//}\n\t\t\t//SpritesMng.#ldrHFn[fn] = 1;\n\n\t\t\tneedLoad = true;\n\t\t\tconst url = SpritesMng.#cfg.searchPath(fn, SEARCH_PATH_ARG_EXT.SP_GSM);\n\t\t\tconst xt = this.#sys.crypto\n\t\t\t? {xhrType: (url.slice(-5) === '.json')\n\t\t\t\t? LoaderResource.XHR_RESPONSE_TYPE.TEXT\n\t\t\t\t: LoaderResource.XHR_RESPONSE_TYPE.BUFFER}\n\t\t\t: {};\n\t\t\tldr.add({...xt, name: fn, url});\n\t\t});\n\n\t\tconst fncLoaded = (_: any, hRes: {[fn: string]: LoaderResource})=> {\n\t\t\tfor (const {fn, fnc} of aComp) {\n\t\t\t\tconst sp = SpritesMng.#mkSprite(fn, hRes);\n\t\t\t\tsp.name = fn;\t// 4 Debug?\n\t\t\t\taddChild(sp);\n\t\t\t\tfnc(sp);\n\t\t\t}\n\t\t\tfncAllComp(needLoad);\n\t\t}\n\t\tif (needLoad) {\n\t\t\tldr.use(async (res, next)=> {\n\t\t\t\ttry {\n\t\t\t\t\tif (res.extension === 'json') {\n\t\t\t\t\t\tconst str = await this.#sys.dec('json', res.data);\n\t\t\t\t\t\tSpritesMng.#cacheAniSpr(str, res, next);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst aiv = await this.#sys.decAB(res.data);\n\t\t\t\t\tSpritesMng.#cachePicMov(aiv, res, next);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconst mes = `画像/動画ロード失敗です fn:${res.name} ${e}`;\n\t\t\t\t\tif (SpritesMng.#evtMng.isSkipping) console.warn(mes); else console.error('%c'+ mes, 'color:#FF3300;');\n\t\t\t\t//\tif (SpritesMng.#evtMng.isSkipping) console.warn(mes); else this.#main.errScript(mes, false);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.load(fncLoaded);\n\t\t}\n\t\telse fncLoaded(0, {});\n\n\t\treturn needLoad;\n\t}\n\tstatic\t#hFace\t\t\t: Ihface\t= {};\n\tstatic\t#hFn2ResAniSpr\t: {[fn: string]: IResAniSpr} = {};\n\n\n\tstatic #cachePicMov = (_r: SYS_DEC_RET, {type, name, data}: any, next: ()=> void)=> {\n\t\tswitch (type) {\n\t\t\tcase LoaderResource.TYPE.VIDEO:\n\t\t\t\tconst hve = data as HTMLVideoElement;\n\t\t\t\thve.volume = SpritesMng.#glbVol;\n\t\t\t\tSpritesMng.#hFn2VElm[name] = SpritesMng.#charmVideoElm(hve);\n\t\t}\n\t\tnext();\n\t}\n\tstatic #sortAFrameName(aFn: string[]): string[] {\n\t\tconst a_base_name = /([^\\d]+)\\d+\\.(\\w+)/.exec(aFn[0]);\n\t\tif (! a_base_name) return [];\n\n\t\tconst is = a_base_name[1].length;\n\t\tconst ie = -a_base_name[2].length -1;\n\t\treturn aFn.sort((a, b)=> int(a.slice(is, ie)) > int(b.slice(is, ie)) ?1 :-1);\n\t}\n\n\tstatic async #dec2cachePicMov(r: SYS_DEC_RET, res: any, next: ()=> void) {\n\t\tres.data = r;\n\t\tif (res.extension !== 'bin') next();\n\n\t\tif (r instanceof HTMLImageElement) {\n\t\t\tres.texture = await Texture.fromLoader(r, res.url, res.name);\n\t\t\t//Texture.addToCache(Texture.from(r), res.name);\n\t\t\t// res.texture = Texture.from(r);\n\t\t\t\t// でも良いが、キャッシュ追加と、それでcsv2Sprites()内で使用するので\n\t\t\tres.type = LoaderResource.TYPE.IMAGE;\n//\t\t\tURL.revokeObjectURL(r.src);\t// TODO: キャッシュ破棄\n\t\t}\n\t\telse if (r instanceof HTMLVideoElement) {\n\t\t\tr.volume = SpritesMng.#glbVol;\n\t\t\tSpritesMng.#hFn2VElm[res.name] = SpritesMng.#charmVideoElm(r);\n\n\t\t\tres.type = LoaderResource.TYPE.VIDEO;\n//\t\t\tURL.revokeObjectURL(r.src);\n\t\t}\n\t\tnext();\n\t}\n\tstatic #charmVideoElm(v: HTMLVideoElement): HTMLVideoElement {\n\t\t// 【PixiJS】iOSとChromeでAutoPlay可能なビデオSpriteの設定 - Qiita https://qiita.com/masato_makino/items/8316e7743acac514e361\n\t\t// v.muted = true;// Chrome対応:自動再生を許可。ないと再開時に DOMException\n\t\tif (SpritesMng.#val.getVal('const.sn.needClick2Play')) {\n\t\t\t// ブラウザ実行で、クリックされるまで音声再生が差し止められている状態か。なにかクリックされれば falseになる\n\t\t\tDebugMng.trace_beforeNew(`[lay系] ${DebugMng.strPos()}未クリック状態で動画を自動再生します。音声はミュートされます`, 'W');\n\t\t\tv.muted = true;\n\t\t}\n\t\tv.setAttribute('playsinline', '');\t// iOS対応\n\t\treturn v;\n\t}\n\n\tstatic #cacheAniSpr = (_r: string, {type, spritesheet, name, data}: any, next: ()=> void)=> {\n\t\tswitch (type) {\n\t\t\tcase LoaderResource.TYPE.JSON:\t// switchは必須\n\t\t\t\tconst aFn: string[] = spritesheet._frameKeys;\n\t\t\t\tSpritesMng.#sortAFrameName(aFn);\n\t\t\t\tSpritesMng.#hFn2ResAniSpr[name] = {\n\t\t\t\t\taTex: aFn.map(fn=> Texture.from(fn)),\n\t\t\t\t\tmeta: data.meta,\n\t\t\t\t};\n\t\t}\n\t\tnext();\n\t}\n\n\tstatic #dec2cacheAniSpr(r: string, res: any, next: ()=> void) {\n\t\tconst {meta, frames} = res.data = JSON.parse(r);\n\t\tres.type = LoaderResource.TYPE.JSON;\n\t\tif (! meta?.image) {next(); return}\n\n\t\tconst fn = getFn(meta.image);\n\t\tconst url = SpritesMng.#cfg.searchPath(fn, SEARCH_PATH_ARG_EXT.SP_GSM);\n\t\t(new Loader)\n\t\t.use((res2, next2)=> {\n\t\t\tthis.#sys.decAB(res2.data)\n\t\t\t.then(r2=> {\n\t\t\t\tres2.data = r2;\n\t\t\t\tif (r2 instanceof HTMLImageElement) {\n\t\t\t\t\tres2.type = LoaderResource.TYPE.IMAGE;\n\t\t\t\t\tURL.revokeObjectURL(r2.src);\n\t\t\t\t}\n\t\t\t\tnext2();\n\t\t\t})\n\t\t\t.catch(e=> this.#main.errScript(`画像/動画ロード失敗です dec2res4Cripto fn:${res2.name} ${e}`, false));\n\t\t})\n\t\t.add({name: fn, url, xhrType: LoaderResource.XHR_RESPONSE_TYPE.BUFFER})\n\t\t.load((ldr, _hRes)=> {\n\t\t\tfor (const {data} of Object.values(ldr.resources)) {\n\t\t\t\tconst {baseTexture} = Texture.from(data);\n\t\t\t\tconst aFr = Object.values(<{[nm: string]: {\n\t\t\t\t\tframe: {x: number; y: number; w: number; h: number;}\n\t\t\t\t}}>frames);\n\t\t\t\tSpritesMng.#hFn2ResAniSpr[res.name] = {\n\t\t\t\t\taTex: aFr.map(({frame: {x, y, w, h}})=> new Texture(\n\t\t\t\t\t\tbaseTexture,\n\t\t\t\t\t\tnew Rectangle(x, y, w, h),\n\t\t\t\t\t)),\n\t\t\t\t\tmeta,\n\t\t\t\t};\n\t\t\t}\n\t\t\tnext();\n\t\t});\n\t}\n\n\tstatic #mkSprite(fn: string, hRes: {[fn: string]: LoaderResource}): Sprite {\n\t\tconst ras = SpritesMng.#hFn2ResAniSpr[fn];\n\t\tif (ras) {\n\t\t\tconst asp = new AnimatedSprite(ras.aTex);\n\t\t\tasp.animationSpeed = ras.meta.animationSpeed ?? 1.0;\n\t\t\tasp.play();\n\t\t\treturn asp;\n\t\t}\n\t\tif (fn in utils.TextureCache) return Sprite.from(fn);\n\t\tif (fn in SpritesMng.#hFn2VElm) return Sprite.from(SpritesMng.#hFn2VElm[fn]);\n\n\t\treturn (fn in hRes) ?new Sprite(hRes[fn].texture) :new Sprite;\n\t}\n\tstatic #hFn2VElm\t: {[fn: string]: HTMLVideoElement} = {};\n\tstatic\tgetHFn2VElm(fn: string) {return SpritesMng.#hFn2VElm[fn]}\n\n\tstatic\twv(hArg: HArg): boolean {\n\t\t// 動画ファイル名指定でいいかなと。なぜなら「ループで再生しつつ」\n\t\t// 同ファイル名の別の動画の再生は待ちたい、なんて状況は普通は無いだろうと\n\t\tconst {fn} = hArg;\n\t\tif (! fn) throw 'fnは必須です';\n\t\tconst hve = SpritesMng.#hFn2VElm[fn];\n\t\tif (! hve || hve.loop) return false;\n\n\t\tif (SpritesMng.#evtMng.isSkipping || hve.ended) {SpritesMng.stopVideo(fn); return false}\n\n\t\tconst fncBreak = ()=> SpritesMng.#evtMng.breakEvent('wv fn:'+ fn);\t// waitEvent 使用者の通常 break 時義務\n\t\thve.addEventListener('ended', fncBreak, {once: true, passive: true});\n\n\t\tconst stop = argChk_Boolean(hArg, 'stop', true);\n\t\treturn SpritesMng.#evtMng.waitEvent('wv fn:'+ fn, hArg, ()=> {\n\t\t\thve.removeEventListener('ended', fncBreak);\n\t\t\tif (stop) SpritesMng.stopVideo(fn);\n\t\t\tfncBreak()\n\t\t});\n\t}\n\n\tstatic\tstopVideo(fn: string) {\n\t\tconst hve = SpritesMng.#hFn2VElm[fn];\n\t\tif (! hve) return;\n\n\t\tdelete SpritesMng.#hFn2VElm[fn];\n\t\thve.pause();\n\t\thve.currentTime = hve.duration;\n\t}\n\n\n\tstatic\tadd_face(hArg: HArg): boolean {\n\t\tconst {name} = hArg;\n\t\tif (! name) throw 'nameは必須です';\n\t\tif (name in SpritesMng.#hFace) throw '一つのname('+ name +')に対して同じ画像を複数割り当てられません';\n\n\t\tconst {fn = name} = hArg;\n\t\tSpritesMng.#hFace[name] = {\n\t\t\tfn,\n\t\t\tdx: argChk_Num(hArg, 'dx', 0),\n\t\t\tdy: argChk_Num(hArg, 'dy', 0),\n\t\t\tblendmode: Layer.getBlendmodeNum(hArg.blendmode || '')\n\t\t};\n\n\t\treturn false;\n\t}\n//\tstatic\tclearFace2Name(): void {SpritesMng.hFace = {}}\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2018-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {Layer} from './Layer';\n\nimport {CmnLib, argChk_Boolean, argChk_Num} from './CmnLib';\nimport {HArg} from './Grammar';\nimport {IMain, IVariable} from './CmnInterface';\nimport {Config} from './Config';\nimport {SysBase} from './SysBase';\nimport {EventListenerCtn} from './EventListenerCtn';\nimport {SoundMng} from './SoundMng';\nimport {IMakeDesignCast} from './LayerMng';\nimport {GrpLayDesignCast} from './DesignCast';\nimport {SpritesMng} from './SpritesMng';\nimport {enableEvent, disableEvent} from './ReadState';\n\nimport {Sprite, AnimatedSprite, RenderTexture, Application} from 'pixi.js';\n\n\nexport class GrpLayer extends Layer {\n\tstatic\treadonly\t#elc\t= new EventListenerCtn;\n\n\tstatic\t#appPixi: Application;\n\tstatic\tinit(main: IMain, cfg: Config, appPixi: Application, sys: SysBase, sndMng: SoundMng, val: IVariable): void {\n\t\tGrpLayer.#appPixi = appPixi;\n\t\tSpritesMng.init(cfg, val, sys, main, sndMng);\n\t}\n\tstatic\tdestroy() {GrpLayer.#elc.clear(); SpritesMng.destroy()}\n\n\treadonly\t#idc\t= new GrpLayDesignCast(this.spLay, this);\n\tconstructor() {\n\t\tsuper();\n\t\tif (CmnLib.isDbg) {\n\t\t\tthis.#setIdcSp = sp=> this.#idc.setSp(sp);\n\t\t\tthis.cvsResize = ()=> {super.cvsResize(); this.#idc.cvsResize()}\n\t\t}\n\t}\n\t#setIdcSp\t: (sp: Sprite)=> void\t= ()=> {};\n\n\t#csvFn\t\t= '';\n\t#sBkFn\t\t= '';\n\t#sBkFace\t= '';\n\toverride readonly\tlay = (hArg: HArg)=> {\n\t\tconst ret = this.#laySub(hArg, isStop=> {\n\t\t\tif (isStop) enableEvent();\n\t\t});\n\t\tif (ret) disableEvent();\n\t\treturn ret;\n\t}\n\t#laySub(hArg: HArg, resolve: (isStop: boolean)=> void): boolean {\n\t\tconst {fn, face = ''} = hArg;\n\t\tthis.#idc.sethArg(hArg);\n\t\tif (! fn) {\n\t\t\tsuper.lay(hArg);\n\n\t\t\tif (this.spLay.children.length > 0) this.setPos(hArg);\n\t\t\tthis.#sBkFn = '';\n\t\t\tthis.#csvFn = this.#sBkFace = face;\n\t\t\tresolve(false);\n\t\t\treturn false;\n\t\t}\n\n\t\tconst inFn = 'fn' in hArg;\n\t\tconst inFace = 'face' in hArg;\n\n\t\tthis.clearLay({clear_filter: argChk_Boolean(hArg, 'clear_filter', true)});\n\t\tif (inFn) this.#sBkFn = fn;\t// clearLay()後に置く事\n\t\tif (inFace) this.#sBkFace = face;\n\t\tsuper.lay(hArg);\t// filter設定してる場合も\n\n\t\thArg.dx = 0;\n\t\thArg.dy = 0;\n\n\t\tthis.#sps.destroy();\n\t\tthis.#sps = new SpritesMng(\n\t\t\tthis.#csvFn = fn + (face ? ','+ face : ''),\n\t\t\tthis.spLay,\n\t\t\tsp=> {\n\t\t\t\tif ('width' in hArg || 'height' in hArg) {\n\t\t\t\t\tsp.width = argChk_Num(hArg, 'width', 0);\n\t\t\t\t\tsp.height = argChk_Num(hArg, 'height', 0);\n\t\t\t\t}\n\t\t\t\tthis.#width = sp.width;\n\t\t\t\tthis.#height = sp.height;\n\t\t\t\tLayer.setXY(sp, hArg, this.spLay, true);\n\t\t\t\tLayer.setBlendmode(this.spLay, hArg);\n\t\t\t//\tif (hArg.page === 'fore') this.rsvEvent(sp);\t// ======\n\t\t\t\t\t// [lay page=fore]のみswfアニメ終了イベント発生\n\t\t\t\tthis.#setIdcSp(sp);\n\t\t\t},\n\t\t\tisStop=> resolve(isStop),\n\t\t);\n\t\treturn this.#sps.ret;\n\t}\n\t#sps\t= new SpritesMng;\n\t#width\t= 0;\n\t#height\t= 0;\n\toverride\tget\twidth() {return this.#width}\n\toverride\tget\theight() {return this.#height}\n\n\n\toverride\trenderStart() {\n\t\tthis.#rtTsy = RenderTexture.create({\n\t\t\twidth\t: CmnLib.stageW,\n\t\t\theight\t: CmnLib.stageH,\n\t\t});\n\t\tthis.#spTsy = new Sprite(this.#rtTsy);\n\t\tthis.#spTsy.visible = false;\n\t\tthis.spLay.addChildAt(this.#spTsy, 0);\n\t\tthis.#spTsy.position.set(-this.spLay.x, -this.spLay.y);\n\n\t\tlet fncRenderFore = ()=> {\n\t\t\tconst a = this.spLay.alpha;\n\t\t\tthis.spLay.alpha = 1;\n\t\t\tfor (const s of this.spLay.children) s.visible = true;\n\t\t\tthis.#spTsy.visible = false;\n\t\t\tGrpLayer.#appPixi.renderer.render(this.spLay, {renderTexture: this.#rtTsy});\t// clear: true\n\t\t\tthis.spLay.alpha = a;\n\t\t\tfor (const s of this.spLay.children) s.visible = false;\n\t\t}\n\t\tif (! this.containMovement) {\n\t\t\tlet oldFnc = fncRenderFore;\t// 動きがないなら最初に一度\n\t\t\tfncRenderFore = ()=> {fncRenderFore = ()=> {}; oldFnc()};\n\t\t}\n\t\tthis.#fncRender = ()=> {\n\t\t\tfncRenderFore();\n\t\t\tthis.#spTsy.visible = true;\n\t\t};\n\t\tGrpLayer.#appPixi.ticker.add(this.#fncRender);\n\t}\n\t#rtTsy\t: RenderTexture;\n\t#spTsy\t: Sprite;\n\t#fncRender = ()=> {};\n\toverride\trenderEnd() {\n\t\tGrpLayer.#appPixi.ticker.remove(this.#fncRender);\n\t\tthis.spLay.removeChild(this.#spTsy);\n\t\tfor (const s of this.spLay.children) s.visible = true;\n\t\tthis.#spTsy.destroy(true);\n\t}\n\n\n\tsetPos(hArg: HArg): void {\n\t\tLayer.setXY(\n\t\t\t(this.spLay.children.length === 0) ?this.spLay :this.spLay.children[0],\n\t\t\thArg,\n\t\t\tthis.spLay,\n\t\t\ttrue\n\t\t);\n\t}\n\n\t// アニメ・動画を含むか\n\toverride get containMovement(): boolean {\n\t\tif (this.#csvFn === '') return false;\n\n\t\tconst c = this.spLay.children;\n\t\treturn this.#csvFn.split(',').some(\n\t\t\t(fn, i)=> c[i] instanceof AnimatedSprite || SpritesMng.getHFn2VElm(fn)\n\t\t);\n\t}\n\n\toverride clearLay(hArg: HArg): void {\n\t\tsuper.clearLay(hArg);\n\t\tthis.#sps.destroy();\n\t\tthis.#sBkFn\t\t= '';\n\t\tthis.#sBkFace\t= '';\n\t\tthis.#csvFn\t\t= '';\n\t}\n\toverride readonly record = ()=> ({...super.record(),\n\t\tsBkFn\t\t: this.#sBkFn,\n\t\tsBkFace\t\t: this.#sBkFace,\n\t\tidc_hArg\t: this.#idc.gethArg(),\n\t});\n\toverride playback(hLay: any, aPrm: Promise[]): void {\n\t\tsuper.playback(hLay, aPrm);\n\t\tif (hLay.sBkFn === '' && hLay.sBkFace === '') {\n\t\t\tthis.#sBkFn\t\t= hLay.sBkFn;\n\t\t\tthis.#sBkFace\t= hLay.sBkFace;\n\t\t\tthis.#idc.sethArg(hLay.idc_hArg);\n\t\t\treturn;\n\t\t}\n\n\t\taPrm.push(new Promise(re=> this.#laySub(\n\t\t\t{fn: hLay.sBkFn, face: hLay.sBkFace, left: hLay.x, top: hLay.y, alpha: hLay.alpha, blendmode: Layer.getNum2Blendmode(hLay.blendMode), rotation: hLay.rotation, scale_x: hLay.scale_x, scale_y: hLay.scale_y},\n\t\t\t_isStop=> {this.spLay.position.set(hLay.x, hLay.y); re()},\n\t\t\t\t// Layer.setXY()の後に再度移動\n\t\t)));\n\t}\n\n\toverride makeDesignCast(gdc: IMakeDesignCast) {\n\t\tif (! this.spLay.visible) return;\n\t\tgdc(this.#idc);\n\t}\n\t//makeDesignCastChildren(_gdc: IMakeDesignCast) {}\n\n\toverride cvsResize() {super.cvsResize()}\n\n\toverride showDesignCast() {this.#idc.visible = true}\n\t//showDesignCastChildren() {}\n\n\toverride readonly dump = ()=> super.dump() +`, \"pic\":\"${this.#csvFn}\"`;\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2024-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {argChk_Boolean, argChk_Num} from './CmnLib';\nimport {HArg} from './Grammar';\n\nimport {Rectangle} from 'pixi.js';\n\nexport interface IChRect {\n\tch\t\t: string;\n\trect\t: Rectangle;\n\telm\t\t: HTMLElement;\n}\n\nconst def行頭禁則\t= '、。,.)]}〉」』】〕”〟ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮヵヶ!?!?‼⁉・ーゝゞヽヾ々';\nconst def行末禁則\t= '[({〈「『【〔“〝';\nconst def分割禁止\t= '─‥…';\nconst defぶら下げ\t= def行頭禁則;\n\nconst defReg行頭禁則\t= new RegExp(`[${def行頭禁則}]`);\nconst defReg行末禁則\t= new RegExp(`[${def行末禁則}]`);\nconst defReg分割禁止\t= new RegExp(`[${def分割禁止}]`);\nconst defRegぶら下げ\t= defReg行頭禁則;\n\n\nexport class Hyphenation {\n\t#s行頭禁則\t\t= def行頭禁則;\n\t#s行末禁則\t\t= def行末禁則;\n\t#s分割禁止\t\t= def分割禁止;\n\t#sぶら下げ\t\t= defぶら下げ;\n\tget 行頭禁則() {return this.#s行頭禁則}\n\tget 行末禁則() {return this.#s行末禁則}\n\tget 分割禁止() {return this.#s分割禁止}\n\tget ぶら下げ() {return this.#sぶら下げ}\n\n\t#reg行頭禁則\t= defReg行頭禁則;\n\t#reg行末禁則\t= defReg行末禁則;\n\t#reg分割禁止\t= defReg分割禁止;\n\t#regぶら下げ\t= defRegぶら下げ;\n\n\tbreak_fixed\t\t= false;\n\tbreak_fixed_left= 0;\n\tbreak_fixed_top\t= 0;\n\tbura\t\t\t= false;\n\tlay(hArg: HArg) {\n\t\tif (hArg.kinsoku_sol) {\n\t\t\tthis.#s行頭禁則 = hArg.kinsoku_sol;\n\t\t\tthis.#reg行頭禁則 = new RegExp(`[${this.#s行頭禁則}]`);\n\t\t}\n\t\tif (hArg.kinsoku_eol) {\n\t\t\tthis.#s行末禁則 = hArg.kinsoku_eol;\n\t\t\tthis.#chk禁則の競合_ぶら行末();\n\t\t\tthis.#reg行末禁則 = new RegExp(`[${this.#s行末禁則}]`);\n\t\t}\n\t\tif (hArg.kinsoku_dns) {\n\t\t\tthis.#s分割禁止 = hArg.kinsoku_dns;\n\t\t\tthis.#chk禁則の競合_ぶら分禁();\n\t\t\tthis.#reg分割禁止 = new RegExp(`[${this.#s分割禁止}]`);\n\t\t}\n\t\tif (hArg.kinsoku_bura) {\n\t\t\tthis.#sぶら下げ = hArg.kinsoku_bura;\n\t\t\tthis.#chk禁則の競合_ぶら行末();\n\t\t\tthis.#chk禁則の競合_ぶら分禁();\n\t\t\tthis.#regぶら下げ = new RegExp(`[${this.#sぶら下げ}]`);\n\t\t}\n\t\tif ('bura' in hArg) this.bura = argChk_Boolean(hArg, 'bura', false);\n\n\t\tthis.break_fixed\t\t= argChk_Boolean(hArg, 'break_fixed', this.break_fixed);\n\t\tthis.break_fixed_left\t= argChk_Num(hArg, 'break_fixed_left', this.break_fixed_left);\n\t\tthis.break_fixed_top\t= argChk_Num(hArg, 'break_fixed_top', this.break_fixed_top);\n\t}\n\t\t// 禁則の競合(ぶら下げ と 行末禁則 の両方に含まれる文字があってはならない)\n\t\t#chk禁則の競合_ぶら行末() {\n\t\t\t// 処理速度最適化で主従を変える。長い方をネイティブにやらせる\n\t\t\tconst len行末禁則 = this.#s行末禁則.length;\n\t\t\tconst lenぶら下げ = this.#sぶら下げ.length;\n\t\t\tif (len行末禁則 < lenぶら下げ) {\n\t\t\t\tfor (let i=0; i Rectangle, tategaki: boolean, begin: number, bkHtm: string): [IChRect[], number] {\n\t\tlet a: IChRect[];\n\t\tlet len = 0;\n\t\tlet i = 2;\t\t// 本来 1 だがひと文字目の行頭禁則文字を無視したいので\n\t\tlet fncFirstChk = (len: number)=> {\n\t\t\tfncFirstChk = ()=> false;\n\n\t\t\tif (begin === len) {\t// 右クリック戻りなどで文字表示が崩れる件の対応\n\t\t\t\tif (begin > 0) htmTxt.innerHTML = bkHtm.replaceAll('class=\"sn_ch\"', 'class=\"sn_ch sn_ch_in_default\"');\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn len < 2;\n\t\t};\n//console.log(`🎴禁則処理判定ループ begin:${begin}`);\n\t\tdo {\n\t\t\ta = this.#getChRects(htmTxt, cnvRect);\n\t\t\tlen = a.length;\n\t\t\tif (fncFirstChk(len)) break;\n\n\t\t\t// 禁則処理判定ループ\n\t\t\tlet sl_xy = -Infinity;\t// 前回のxy\n//console.log(` len:${len}`);\n\t\t\tfor (; i 790)\n//console.log(`🎴 sl_xy:${sl_xy.toFixed(2)} xy:${xy.toFixed(2)} i:${i} ch:${ch}: rect:(${rect.left.toFixed(2)}, ${rect.top.toFixed(2)}, ${rect.width.toFixed(2)}, ${rect.height.toFixed(2)})`);\n\t\t\t\tif (sl_xy <= xy\t// 【 < 】では[tcy]二文字目を誤判定する\n\t\t\t\t// [r]による改行後は追い出し処理をしないように\n\t\t\t\t|| (elm.previousElementSibling?.tagName === 'SPAN'\n\t\t\t\t&&\telm.previousElementSibling?.innerHTML.includes('
'))\n\t\t\t\t// 外し\n\t\t\t\t|| (elm.parentElement?.previousElementSibling?.tagName === 'SPAN'\n\t\t\t\t&&\telm.parentElement?.previousElementSibling?.innerHTML.includes('
'))) {\n\t\t\t\t\tsl_xy = xy;\n\t\t\t\t\tif (! this.break_fixed) {\n\t\t\t\t\t\tthis.break_fixed_left = rect.x;\n\t\t\t\t\t\tthis.break_fixed_top = rect.y;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n/*\n\t// [r]などの改行はこう。TxtLayer.#tagCh_sub()により に入れられる\n\t​\n\t\t
\n\t​
​\n\n\t// 上記が下記に囲まれている場合もある。previousElementSibling 使用時は注意\n\t\n\n\n\t// 禁則処理による自動改行はこう\n\t
\n*/\n\n\t\t\t\tlet p_i = i -1;\n\t\t\t\twhile (a[p_i].elm.tagName === 'RT') --p_i;\t// ルビはスキップ\n\t\t\t\tconst {elm: p_elm, rect: p_rect, ch: p_ch} = a[p_i];\n//console.log(`🎴 === 自動改行発生! 前文字:${p_i}:${p_ch}: 今文字:${i}:${ch}:(${ch.charCodeAt(0).toString(16)})`);\n\t\t\t\tif (! this.break_fixed) {\n\t\t\t\t\tthis.break_fixed_left = p_rect.x;\n\t\t\t\t\tthis.break_fixed_top = p_rect.y;\n\t\t\t\t\tconst sty = globalThis.getComputedStyle(p_elm);\n\t\t\t\t\tconst rs = parseFloat(sty.fontSize);\n\t\t\t\t\tif (tategaki) this.break_fixed_top += rs; else this.break_fixed_left += rs;\n\t\t\t\t}\n\n\t\t\t\tsl_xy = -Infinity;\t// 自動改行発生!\n\t\t\t\tconst oldI = i;\n\t\t\t\tconst {cont, ins} = this.bura\n\t\t\t\t\t? this.hyph_alg_bura(a, p_i, p_ch, i)\n\t\t\t\t\t: this.hyph_alg(a, p_i, p_ch, i, ch);\n\t\t\t\ti = ins;\n//console.log(`🎴 -- cont:${cont} ins:${ins} :${a[i].ch}:の前に改行を挿入`);\n\t\t\t\tif (cont) continue;\n\n\t\t\t\t// 改行挿入\n\t\t\t\tconst elm2 = a[i].elm;\n\t\t\t\tconst pal = elm2.parentElement!;\n\t\t\t\tconst br = document.createElement('br');\n\t\t\t\tif (pal.classList.contains('sn_tx')) pal.insertBefore(br, elm2); else {\n\t\t\t\t\tconst ppal = pal.parentElement!;\n\t\t\t\t\tif (ppal.classList.contains('sn_ch')) {\n\t\t\t\t\t\tppal.parentElement!.insertBefore(br, ppal);\n\t\t\t\t\t}\n\t\t\t\t\telse ppal.insertBefore(br, pal);\n\t\t\t\t}\n\n\t\t\t\ti += 2;\t// 次へ行く +1 と、いま追加した
のぶん\n\t\t\t\tif (i < oldI) i = oldI;\t// 永久ループ防御\n\t\t\t\tlen = -1;\t// doループ先頭に戻る\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (len < 0);\n\n\t\treturn [a, len];\n\t}\n\n\t#getChRects(elm: Node, cnvRect :(range: Range, ch: string)=> Rectangle): IChRect[] {\t// 注意)再帰関数\n\t\tconst ret: IChRect[] = [];\n\t\tif (elm.nodeType !== elm.TEXT_NODE) return Array.from(elm.childNodes).map(v=> this.#getChRects(v, cnvRect)).flat();\n\n\t\tconst rng = elm.ownerDocument!.createRange();\n\t\trng.selectNodeContents(elm);\n\t\tlet pos = 0;\n\t\tconst end = rng.endOffset;\n\t\t// できれば一文字ずつ「after-edge - baseline」を調べたいが、暫定手段を取る\n\t\t//const styles = globalThis.getComputedStyle(this.htmTxt);\n\t\t//console.log('lh:'+ styles.lineHeight +' fs:'+ styles.fontSize);\n\t\twhile (pos < end) {\n\t\t\trng.setStart(elm, pos);\n\t\t\trng.setEnd(elm, ++pos);\n\t\t\tconst ch = rng.toString();\n\t\t\tret.push({\n\t\t\t\tch,\n\t\t\t\trect: cnvRect(rng, ch),\n\t\t\t\telm\t: rng.startContainer.parentElement!,\n\t\t\t});\n\t\t}\n\t\trng.detach();\n\n\t\treturn ret;\n\t}\n\n\t/**\n\t * 抽象化した禁則処理アルゴリズム\n\t * @method hyph_alg\n\t * @param {IChRect[]} a - 文章の抽象化配列\n\t * @param {number} p_i - 処理要素の一つ前の添字\n\t * @param {string} p_ch - 処理要素の一つ前の文字\n\t * @param {number} i - 処理要素の添字\n\t * @param {string} ch - 処理要素の文字\n\t * @return {Object} result 戻り値\n\t * @return {boolean} result.cont - true: 呼び元で改行挿入せず continue\n\t * @return {number} result.ins - 手前に改行を挿入すべき要素の添字\n\t */\n\thyph_alg(\t// テスト用にpublic\n\t\ta\t: IChRect[],\n\t\tp_i\t: number,\n\t\tp_ch: string,\n\t\ti\t: number,\t// i >= 2\n\t\tch\t: string,\n\t): {cont: boolean, ins: number} {\n\t\t// 追い出し走査\n\t\tif (this.#reg行末禁則.test(p_ch)) {}\t// 一つ前\n\t\telse if (this.#reg行頭禁則.test(ch)) {\t//(現在地 -> 前方走査)\n\t\t\twhile (i > 0) {\n\t\t\t\tconst {elm, ch} = a[--i];\t// 前方走査\n\t\t\t\tif (elm.tagName === 'RT') continue;\t// ルビはスキップ\n\t\t\t\tif (! this.#reg行頭禁則.test(ch)) break;\t// 行頭禁則はスキップ\n\t\t\t}\n\t\t}\n\t\telse if (p_ch === ch && this.#reg分割禁止.test(p_ch)) {}// 一つ前&現在地\n\t\telse return {cont: true, ins: i +1};\t// 追い出しなし\n\n\t\t// 追い出しによる新行末二次判定(一つ前 -> 前方走査)\n\t\ti = p_i;\n\t\twhile (i > 0) {\n\t\t\tconst {elm, ch} = a[--i];\t// 前方走査\n\t\t\tif (elm.tagName === 'RT') continue;\t// ルビはスキップ\n\t\t\tif (! this.#reg行末禁則.test(ch)) break;\t// 行末禁則はスキップ\n\t\t}\n\t\treturn {cont: false, ins: i +1};\n\t}\n\n\t/**\n\t * 抽象化した禁則処理アルゴリズム\n\t * @method hyph_alg\n\t * @param {IChRect[]} a - 文章の抽象化配列\n\t * @param {number} p_i - 処理要素の一つ前の添字\n\t * @param {string} p_ch - 処理要素の一つ前の文字\n\t * @param {number} i - 処理要素の添字\n\t * @return {Object} result 戻り値\n\t * @return {boolean} result.cont - true: 呼び元で改行挿入せず continue\n\t * @return {number} result.ins - 手前に改行を挿入すべき要素の添字\n\t */\n\thyph_alg_bura(\t// テスト用にpublic\n\t\ta\t: IChRect[],\n\t\tp_i\t: number,\n\t\tp_ch: string,\n\t\ti\t: number,\t// i >= 2\n\t): {cont: boolean, ins: number} {\n//console.log(`🎴 hyph_alg_bura p_ch:${p_ch}`);\n\t\tconst pp_i = i -2;\t// 分割禁止への「ルビスキップ」、オーバースペックかなと\n\t\tconst {ch: pp_ch} = a[pp_i];\n\t\t// 改行前二個目に「ぶら下げ」があるパターン\n\t\tif (this.#regぶら下げ.test(pp_ch) ||\n\t\t\tthis.#reg行頭禁則.test(pp_ch)\n\t\t) {\n\t\t\tlet ins = pp_i +1;\n\t\t\t// 改行前にも「ぶら下げ」があるパターン\n\t\t\tif (this.#regぶら下げ.test(p_ch)\n\t\t\t||\tthis.#reg行頭禁則.test(p_ch)) ins = p_i +1;\n\n\t\t\t// ぶら下げ後……追い出し走査\n\t\t\tconst {ch: last_ch} = a[ins -1];\t// 行末\n\t\t\tconst {ch: head_ch} = a[ins];\t\t// 行頭\n\t\t\t// 分割禁止\n\t\t\tif (last_ch === head_ch && this.#reg分割禁止.test(head_ch)) return {cont: false, ins: ins -1};\n\n\t\t\tif (! this.#reg行末禁則.test(last_ch)) return {cont: false, ins};\n\t\t\t// 行末禁則\n\t\t\ti = ins -1;\n\t\t\twhile (i > 0) {\n\t\t\t\tconst {elm, ch} = a[--i];\t// 前方走査\n\t\t\t\tif (elm.tagName === 'RT') continue;\t// ルビはスキップ\n\t\t\t\tif (! this.#reg行末禁則.test(ch)) break;\t// 行禁はスキップ\n\t\t\t}\n\t\t\treturn {cont: false, ins: i +1};\t// 行末禁則\n\t\t}\n\n\t\t// 改行前二個目に「ぶら下げ」がないパターン\n\t\tconst ppp_i = i -3;\n\t\tif (i >= 3) {\n\t\t\tconst {ch: ppp_ch} = a[ppp_i];\n\t\t\t// 改行前二個目に「分割禁止」パターン\n\t\t\tif (this.#reg分割禁止.test(pp_ch)) {\t// 分割禁止\n\t\t\t\tif (ppp_ch === pp_ch) return {cont: false, ins: ppp_i};\n\t\t\t}\n\t\t\t// 改行前三個目に「行末禁則」パターン\n\t\t\tif (this.#reg行末禁則.test(ppp_ch)) {\t// 行末禁則\n\t\t\t\ti = ppp_i;\n\t\t\t\twhile (--i > 0) {\n\t\t\t\t\tconst {elm, ch} = a[i];\t// 前方走査\n\t\t\t\t\tif (elm.tagName === 'RT') continue;\t// ルビはスキップ\n\t\t\t\t\tif (! this.#reg行末禁則.test(ch)) break;\t// 行禁はスキップ\n\t\t\t\t}\n\t\t\t\treturn {cont: false, ins: i +1};\t// 行末禁則\n\t\t\t}\n\t\t}\n\n\t\treturn {cont: false, ins: i -2};\n\t}\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2019-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {CmnLib, IEvtMng, argChk_Boolean, argChk_Num} from './CmnLib';\nimport {HArg} from './Grammar';\nimport {Config} from './Config';\nimport {CmnTween} from './CmnTween';\nimport {SpritesMng} from './SpritesMng';\nimport {DebugMng} from './DebugMng';\nimport {IMakeDesignCast} from './LayerMng';\nimport {TxtLayDesignCast, TxtLayPadDesignCast} from './DesignCast';\nimport {SysBase} from './SysBase';\nimport {Hyphenation, IChRect} from './Hyphenation';\nimport {ScriptIterator} from './ScriptIterator';\nimport {ReadState} from './ReadState';\n\nimport {Container, Texture, Sprite, Graphics, Rectangle, Renderer, Application} from 'pixi.js';\nimport {Tween} from '@tweenjs/tween.js'\n\ninterface IInfTxLay {\n\tfontsize\t: number;\n\t$width\t\t: number;\t// レイヤサイズであり、背景色(画像)サイズ\n\t$height\t\t: number;\n\tpad_left\t: number;\t// paddingLeft(レイヤサイズの内側のスペーサー)\n\tpad_right\t: number;\t// paddingRight\n\tpad_top\t\t: number;\t// paddingTop\n\tpad_bottom\t: number;\t// paddingBottom\n};\n\ninterface ISpTw {\n\tsp\t: Container;\n\ttw\t: Tween | undefined;\n};\n\n\nexport class TxtStage extends Container {\n\tstatic\t#cfg\t: Config;\n\tstatic\t#appPixi: Application;\n\tstatic\tinit(cfg: Config, appPixi: Application): void {\n\t\tTxtStage.#cfg = cfg;\n\t\tTxtStage.#appPixi = appPixi;\n\t}\n\tstatic\t#evtMng\t: IEvtMng;\n\tstatic\t#scrItr\t: ScriptIterator;\n\tstatic\tsetEvtMng(evtMng: IEvtMng, scrItr: ScriptIterator) {\n\t\tTxtStage.#evtMng = evtMng;\n\t\tTxtStage.#scrItr = scrItr;\n\t}\n\n\tstatic\tdestroy() {\n\t\tTxtStage.#hChInStyle\t= Object.create(null);\n\t\tTxtStage.#hChOutStyle\t= Object.create(null);\n\n\t\tTxtStage.delBreak();\n\t}\n\n\n\t\t\t\t#htmTxt\t= document.createElement('span');\t// サンプリング元\n\treadonly\t#cntTxt\t\t\t= new Container;\t\t\t// サンプリング先\n\treadonly\t#grpDbgMasume\t= new Graphics;\n\tstatic\treadonly\t#hWarnStyle = {\n\t\t'background-color'\t\t: 0,\n\t\t'border-bottom-width'\t: 0,\n\t\t'border-left-width'\t\t: 0,\n\t\t'border-right-width'\t: 0,\n\t\t'border-top-width'\t\t: 0,\n\t\t'margin-bottom'\t: 0,\n\t\t'margin-left'\t: 0,\n\t\t'margin-right'\t: 0,\n\t\t'margin-top'\t: 0,\n\t};\n\n\n\t#hyph\t= new Hyphenation;\n\tnoticeCompTxt\t= ()=> {};\n\tconstructor(private readonly spLay: Sprite, private readonly canFocus: ()=> boolean, private readonly sys: SysBase) {\n\t\tsuper();\n\n\t\tthis.#htmTxt.classList.add('sn_tx');\n\t\tthis.#htmTxt.style.position = 'absolute';\n\t\tTxtStage.#appPixi.view.parentElement!.appendChild(this.#htmTxt);\n\n\t\tthis.addChild(this.#cntTxt);\n\n\t\tthis.addChild(this.#grpDbgMasume);\n\t\tthis.#grpDbgMasume.name = 'grpDbgMasume';\n\n\t\tthis.#idc = new TxtLayDesignCast(this.spLay, this);\n\t\tthis.#idc.adopt(this.#idcCh);\n\n\t\tthis.noticeCompTxt = sys.isApp && TxtStage.#cfg.oCfg.debug.dumpHtm\n\t\t? ()=> {\n\t\t\tReadState.noticeCompTxt();\n\n\t\t\tconst htm = this.#htmTxt.innerHTML;\n\t\t\tif (htm === '') return;\n\t\t\tconst {fn, ln} = TxtStage.#scrItr.nowScrFnLn();\n\t\t\tconst id = `dumpHtm ${\n\t\t\t\tthis.spLay.name.slice(0, -7)\t// 末尾「 page=B」削り\n\t\t\t\t.replaceAll(':', '=')\t\t\t// ファイル名で困る文字\n\t\t\t}(fn=${fn} line=${ln})`;\n\t\t\tsys.outputFile(\n\t\t\t\tsys.path_downloads + id +'.htm',\n`${id}\n

${id}

${\n\thtm\t// outerHTML からのレイヤ再現などしたいとこだがオーバースペック\n\t.replaceAll(/(<\\/?ruby>)/g, '\\n$1\\n')\n\t.replaceAll(/<(br|\\/span)>/g, '<$1>\\n')\n}`,\n\t\t\t);\n\t\t}\n\t\t: ()=> ReadState.noticeCompTxt();\n\t}\n\n\treadonly\t#idc\t:TxtLayDesignCast;\n\treadonly\t#idcCh\t= new TxtLayPadDesignCast(this);\n\t#infTL :IInfTxLay = {\n\t\tfontsize\t: 24,\n\t\t$width\t\t: 0,\t// レイヤサイズであり、背景色(画像)サイズ\n\t\t$height\t\t: 0,\n\t\tpad_left\t: 0,\t// paddingLeft(レイヤサイズの内側のスペーサー)\n\t\tpad_right\t: 0,\t// paddingRight\n\t\tpad_top\t\t: 0,\t// paddingTop\n\t\tpad_bottom\t: 0,\t// paddingBottom\n\t}\n\n\tlay(hArg: HArg) {\n\t\tconst s = this.#htmTxt.style;\n\t\tif ('style' in hArg) {\n\t\t\tif (hArg.style) {\n\t\t\t\tconst cln = document.createElement('span');\n\t\t\t\tcln.style.cssText = hArg.style;\n\t\t\t\tconst len = cln.style.length;\n\t\t\t\tfor (let i=0; i 0) {\n\t\t\tconst aSpan = [\n\t\t\t\tthis.#htmTxt.innerHTML.replaceAll(/(animation-delay: )\\d+ms/g, '$10ms'),\n\t\t\t\t``,\n\t\t\t];\n\t\t\tthis.#clearText();\t// 消去\n\t\t\tthis.goTxt(aSpan, true);\t// 高速 goTxt()\n\t\t}\n\t}\n\t#lh_half\t= 0;\t// 「g」などで下が欠ける問題対策\n\t#lay_sub() {\n\t\tconst s = this.#htmTxt.style;\n\t\tconst fs = parseFloat(s.fontSize || '0');\n\t\tthis.#infTL.fontsize = fs;\n\n\t\tthis.#infTL.pad_left = parseFloat(s.paddingLeft || '0');\n\t\tthis.#infTL.pad_right = parseFloat(s.paddingRight || '0');\n\t\tthis.#infTL.pad_top = parseFloat(s.paddingTop || '0');\n\t\tthis.#infTL.pad_bottom = parseFloat(s.paddingBottom || '0');\n\t\tthis.#infTL.$width = parseFloat(s.width || '0');\n\t\tthis.#infTL.$height = parseFloat(s.height || '0');\n\t\tthis.position.set(this.#infTL.pad_left, this.#infTL.pad_top);\n\n\t\tthis.#isTategaki = (s.writingMode === 'vertical-rl');\n\n\t\tthis.#padTx4x = 0;\n\t\tthis.#padTx4y = 0;\n\n\t\tconst lh = s.lineHeight ?? '0';\n\t\tthis.#lh_half = this.#isTategaki\n\t\t\t? 0\n\t\t\t: (\t(lh.slice(-2) === 'px')\n\t\t\t\t? parseFloat(lh)\n\t\t\t\t: (fs *parseFloat(lh) -fs)) /2;\n\t\t\t// globalThis.getComputedStyle(this.htmTxt)がチョイチョイ値を返さないので\n\t}\n\tcvsResize() {\n\t\tconst s = this.#htmTxt.style;\n\t\tconst cvsScale = this.sys.cvsScale;\n\t\ts.left = `${this.sys.ofsLeft4elm +this.#left *cvsScale}px`;\n\t\ts.top = `${this.sys.ofsTop4elm +this.spLay.position.y *cvsScale}px`;\n\t\ts.transform = `rotate(${this.spLay.angle}deg) scale(${this.spLay.scale.x *cvsScale}, ${this.spLay.scale.y *cvsScale})`;\n\n\t\tthis.#idc.cvsResize();\n\t\tthis.#idcCh.cvsResize();\n\t}\n\t#left = 0;\n\t#isTategaki = false;\n\tget tategaki() {return this.#isTategaki}\n\t#padTx4x = 0;\n\t#padTx4y = 0;\n\n\tget\tinfTL(): IInfTxLay {return this.#infTL}\n\tget\tgetWidth() {return this.#infTL.$width}\n\tget\tgetHeight() {return this.#infTL.$height}\n\n\tsetSize(width: number, height: number) {\n\t\tthis.#infTL.$width = width;\n\t\tthis.#infTL.$height = height;\n\t\tthis.#htmTxt.style.width = this.#infTL.$width +'px';\n\t\tthis.#htmTxt.style.height = this.#infTL.$height +'px';\n\t}\n\n\n\t#htm2tx(fnc: (tx2: any)=> void, hidden = true) {\n\t\t// tsayen/dom-to-image: Generates an image from a DOM node using HTML5 canvas https://github.com/tsayen/dom-to-image\n\n/*---*/\n\t\tconst util = {\n\t\t\tescape: (str: string)=> str.replaceAll(/([.*+?^${}()|\\[\\]\\/\\\\])/g, '\\\\$1'),\n\t\t\tmimeType: (url: any)=> {\n\t\t\t\tconst extension = parseExtension(url).toLowerCase();\n\t\t\t\treturn mimes()[extension] || '';\n\t\t\t},\n\t\t\tdataAsUrl: dataAsUrl,\n\t\t\tisDataUrl: isDataUrl,\n\t\t\tresolveUrl: resolveUrl,\n\t\t\tgetAndEncode: getAndEncode,\n\t\t\tasArray: (arrayLike: StyleSheetList)=> {\n\t\t\t\tconst a: StyleSheet[] = [];\n\t\t\t\tconst len = arrayLike.length;\n\t\t\t\tfor (let i=0; i {\n\t\t\t\tconst styleNode = document.createElement('style');\n\t\t\t\tnode.appendChild(styleNode);\n\t\t\t\tstyleNode.appendChild(document.createTextNode(cssText));\n\t\t\t//console.log('cssText:%s:', cssText);\t//------------\n\t\t\t\treturn node;\n\t\t\t});\n\t\t}\n\n\n\t\t\tfunction parseExtension(url: any) {\n\t\t\t\tconst match = /\\.([^\\.\\/]*?)$/g.exec(url);\n\t\t\t\treturn match?.[1] ?? '';\n\t\t\t}\n\n\t\t\tfunction isDataUrl(url: any) {\n\t\t\t\treturn url.search(/^(data:)/) !== -1;\n\t\t\t}\n\n\t\t\tfunction resolveUrl(url: any, baseUrl: any) {\n\t\t\t\tconst doc = document.implementation.createHTMLDocument();\n\t\t\t\tconst base = doc.createElement('base');\n\t\t\t\tdoc.head.appendChild(base);\n\t\t\t\tconst a = doc.createElement('a');\n\t\t\t\tdoc.body.appendChild(a);\n\t\t\t\tbase.href = baseUrl;\n\t\t\t\ta.href = url;\n\t\t\t\treturn a.href;\n\t\t\t}\n\n\t\t\tfunction getAndEncode(url: any) {\n\t\t\t\tlet TIMEOUT = 30000;\n\t\t\t\t//if(domtoimage.impl.options.cacheBust) {\n\t\t\t\t\t// Cache bypass so we dont have CORS issues with cached images\n\t\t\t\t\t// Source: https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache\n\t\t\t\t//\turl += ((/\\?/).test(url) ? \"&\" : \"?\") + (new Date()).getTime();\n\t\t\t\t//}\n\n\t\t\t\treturn new Promise(function (resolve) {\n\t\t\t\t\tconst request = new XMLHttpRequest();\n\n\t\t\t\t\trequest.onreadystatechange = done;\n\t\t\t\t\trequest.ontimeout = timeout;\n\t\t\t\t\trequest.responseType = 'blob';\n\t\t\t\t\trequest.timeout = TIMEOUT;\n\t\t\t\t\trequest.open('GET', url, true);\n\t\t\t\t\trequest.send();\n\n\t\t\t\t\t//let placeholder;\n\t\t\t\t\t//if(domtoimage.impl.options.imagePlaceholder) {\n\t\t\t\t\t//\tlet split = domtoimage.impl.options.imagePlaceholder.split(/,/);\n\t\t\t\t\t//\tif(split && split[1]) {\n\t\t\t\t\t//\t\tplaceholder = split[1];\n\t\t\t\t\t//\t}\n\t\t\t\t\t//}\n\n\t\t\t\t\tfunction done() {\n\t\t\t\t\t\tif (request.readyState !== 4) return;\n\n\t\t\t\t\t\tif (request.status !== 200) {\n\t\t\t\t\t\t//\tif(placeholder) {\n\t\t\t\t\t\t//\t\tresolve(placeholder);\n\t\t\t\t\t\t//\t} else {\n\t\t\t\t\t\t\t\tfail('cannot fetch resource: ' + url + ', status: ' + request.status);\n\t\t\t\t\t\t//\t}\n\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst encoder = new FileReader();\n\t\t\t\t\t\tencoder.onloadend = function () {\n\t\t\t\t\t\t\tconst content = encoder.result!.toString().split(/,/)[1];\n\t\t\t\t\t\t\tresolve(content);\n\t\t\t\t\t\t};\n\t\t\t\t\t\tencoder.readAsDataURL(request.response);\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction timeout() {\n\t\t\t\t\t//\tif(placeholder) {\n\t\t\t\t\t//\t\tresolve(placeholder);\n\t\t\t\t\t//\t} else {\n\t\t\t\t\t\t\tfail('timeout of ' + TIMEOUT + 'ms occured while fetching resource: ' + url);\n\t\t\t\t\t//\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction fail(message: any) {\n\t\t\t\t\t\tconsole.error(message);\n\t\t\t\t\t\tresolve('');\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfunction dataAsUrl(content: any, type: any) {\n\t\t\t\treturn 'data:' + type + ';base64,' + content;\n\t\t\t}\n\n\n\t\tfunction newInliner() {\n\t\t\tconst URL_REGEX = /url\\(['\"]?([^'\"]+?)['\"]?\\)/g;\n\n\t\t\treturn {\n\t\t\t\tinlineAll: inlineAll,\n\t\t\t\tshouldProcess: shouldProcess,\n\t\t\t};\n\n\t\t\tfunction shouldProcess(str: any) {\n\t\t\t\treturn str.search(URL_REGEX) !== -1;\n\t\t\t}\n\n\t\t\tfunction readUrls(str: any) {\n\t\t\t\tconst result: string[] = [];\n\t\t\t\tlet match: RegExpExecArray | null;\n\t\t\t\twhile ((match = URL_REGEX.exec(str))) {\n\t\t\t\t\tresult.push(match[1]);\n\t\t\t\t}\n\t\t\t\treturn result.filter(function (url) {\n\t\t\t\t\treturn !util.isDataUrl(url);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfunction inline(str: any, url: any, baseUrl: any, get: any) {\n\t\t\t\treturn Promise.resolve(url)\n\t\t\t\t\t.then(url=> baseUrl ? util.resolveUrl(url, baseUrl) : url)\n\t\t\t\t\t.then(get || util.getAndEncode)\n\t\t\t\t\t.then(data=> util.dataAsUrl(data, util.mimeType(url)))\n\t\t\t\t\t.then(dataUrl=> str.replace(urlAsRegex(url), '$1' + dataUrl + '$3'));\n\n\t\t\t\tfunction urlAsRegex(url: any) {\n\t\t\t\t\treturn new RegExp('(url\\\\([\\'\"]?)(' + util.escape(url) + ')([\\'\"]?\\\\))', 'g');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction inlineAll(str: any, baseUrl: any, get?: any) {\n\t\t\t\tif (nothingToInline()) return Promise.resolve(str);\n\n\t\t\t\treturn Promise.resolve(str)\n\t\t\t\t\t.then(readUrls)\n\t\t\t\t\t.then(urls=> {\n\t\t\t\t\t\tlet done = Promise.resolve(str);\n\t\t\t\t\t\tfor (const url of urls) done = done.then(string=> inline(string, url, baseUrl, get));\n\t\t\t\t\t\treturn done;\n\t\t\t\t\t});\n\n\t\t\t\tfunction nothingToInline() {\n\t\t\t\t\treturn !shouldProcess(str);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction newFontFaces() {\n\t\t\treturn {\n\t\t\t\tresolveAll: resolveAll,\n\t\t\t\timpl: {readAll: readAll}\n\t\t\t};\n\n\t\t\tfunction resolveAll() {\n\t\t\t\treturn readAll()\n\t\t\t\t.then(webFonts=> Promise.allSettled(\n\t\t\t\t\twebFonts.map((webFont: any)=> webFont.resolve())\n\t\t\t\t))\n\t\t\t\t.then(cssStrings=> cssStrings.join('\\n'));\n\t\t\t}\n\n\t\t\tfunction readAll() {\n\t\t\t\treturn Promise.resolve(util.asArray(document.styleSheets))\n\t\t\t\t\t.then(getCssRules)\n\t\t\t\t\t.then(selectWebFontRules)\n\t\t\t\t\t.then(rules=> rules.map(newWebFont));\n\t\t\t\t\t\t// console.log('map:%o:', rules) ||\n\n\t\t\t\tfunction selectWebFontRules(cssRules: any) {\n\t\t\t\t\treturn cssRules\n\t\t\t\t\t.filter((rule: any)=> rule.type === CSSRule.FONT_FACE_RULE)\n\t\t\t\t\t.filter((rule: any)=> inliner.shouldProcess(rule.style.getPropertyValue('src')));\n\t\t\t\t}\n\n\t\t\t\tfunction getCssRules(styleSheets: any) {\n\t\t\t\t\tconst cssRules: any = [];\n\t\t\t\t\tfor (const sheet of styleSheets) {\n\t\t\t\t\t//console.log('1:%o', sheet);\t//-------\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif (sheet.href) continue;\n\t\t\t\t\t\t//console.log(sheet.cssRules);\n\t\t\t\t\t\t\tutil.asArray(sheet.cssRules || []).forEach(cssRules.push.bind(cssRules));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\tconsole.error('Error while reading CSS rules from ' + sheet.href, e.toString());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn cssRules;\n\t\t\t\t}\n\n\t\t\t\tfunction newWebFont(webFontRule: any) {\n\t\t\t\t\t//console.log('newWebFont:%o:', webFontRule);\t//-------\n\t\t\t\t\treturn {\n\t\t\t\t\t\tresolve: function resolve() {\n\t\t\t\t\t\t\tconst baseUrl = (webFontRule.parentStyleSheet || {}).href;\n\t\t\t\t\t\t\treturn inliner.inlineAll(webFontRule.cssText, baseUrl);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsrc: function () {\n\t\t\t\t\t\t\treturn webFontRule.style.getPropertyValue('src');\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n/*\n\t\tfetch('http://localhost:8080/prj/mat/my_himajihoso.woff2')\n\t\t.then(response=> {\n\t\t\tif (response.ok) return response.blob();\n\t\t\tthrow new Error('Network response was not ok.');\n\t\t})\n\t\t.then(blob=> new Promise((resolve, reject)=> {\n\t\t\tconst reader = new FileReader();\n\t\t\treader.onloadend = ()=> resolve(reader.result);\n\t\t\treader.onerror = reject;\n\t\t\treader.readAsDataURL(blob);\n\t\t}))\n\t\t.then(dataUrl => {\n\t\t\t// data:application/font-woff2;base64,d09GMk9U\n\t\t\tconst css =\n\t\t\t'body { margin: 0px; padding: 0px; overflow: hidden; }\\n'+\n\t\t\t'body { line-height: 36px; }\\n'+\n\n\t\t\t`@font-face { font-family: my_himajihoso; src: url(\"${\n\t\t\t\t'data:application/font-woff;base64,'+\n\t\t\t\tString(dataUrl)\n\t\t\t\t.split(/,/)[1]\n\t\t//\t\t.replace(/([.*+?^${}()|\\[\\]\\/\\\\])/g, '\\\\$1')\n\t\t\t}\"); }`;\n\n\t\tconsole.log('css:'+ css);\n\t\tconsole.log('@font-face { font-family: my_himajihoso; src: url(\"data:application/font-woff;base64,d09GMk9UVE8AAA...bhUAAA==\"); }\\n');\n\t\t\tthis.styleHtmTxt.appendChild(document.createTextNode(css));\n*/\n\n\t\tPromise.resolve(this.#htmTxt)\n\t\t.then(node=> {\t//console.log(`🍇 toSvg`);\n\t\t\tconst cln = node.cloneNode(true) as HTMLSpanElement;\n\t\t\tcln.style.padding = '0px';\t\t// ややこしいのでシンプルに\n\t\t\tcln.style.paddingRight = this.#padTx4x +'px';\n\t\t\tcln.style.paddingTop = this.#padTx4y +'px';\n\t\t\tcln.style.left = '0px';\n\t\t\tcln.style.top = '0px';\n\t\t\tcln.style.width = (this.#infTL.$width -this.#infTL.pad_left -this.#infTL.pad_right) +'px';\n\t\t\tcln.style.height = (this.#infTL.$height -this.#infTL.pad_top -this.#infTL.pad_bottom) +'px';\n\t\t\t//console.log(cln.style.cssText);\n\t\t\tthis.#htmTxt.hidden = hidden;\n\t\t\treturn cln;\n\t\t})\n\t\t.then(embedFonts)\n\t\t.then(node=> {\t//console.log(`🍈 makeSvgDataUri`);\n\t\t\tnode.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');\n\t\t\tconst img = new Image;\n\t\t\t//img.crossOrigin = 'Anonymous';\t//--いまのとこ不要\n\t\t\timg.src = `data:image/svg+xml;charset=utf-8,${\n\t\t\t\tnew XMLSerializer().serializeToString(node)\n\t\t\t\t.replaceAll('#', '%23').replaceAll('\\n', '%0A')\n\t\t\t}` // ? + new Date().getTime();\n\t\t\treturn new Promise(resolve=> img.onload = ()=> resolve(img));\n\t\t})\n\t\t.then(img=> new Promise(resolve=> setTimeout(()=> resolve(img) , 100)))\n\t\t\t// 無くすとSafariでテクスチャ取れない場合があった\n\t\t\t// clearTimeout()不要と判断\n\t\t.then((img: any)=> {\t//console.log(`🍉 toPng`);\n\t\t\tconst canvas = document.createElement('canvas');\n\t\t\tcanvas.width = this.#infTL.$width;\n\t\t\tcanvas.height = this.#infTL.$height;\n\t\t\tcanvas.getContext('2d')!.drawImage(img, 0, 0);\n\t\t\tcanvas.toBlob(blob=> {\n\t\t\t\tif (! blob) return;\n\t\t\t\tconst url = URL.createObjectURL(blob);\n\t\t\t\tTexture.from(url).once('update', tx2=> {\n\t\t\t\t\tfnc(tx2);\n\t\t\t\t\tURL.revokeObjectURL(url);\n\t\t\t\t});\n\t\t\t});\n\t\t})\n\t\t.catch(err=> DebugMng.myTrace(`goTxt() = ${err}`));\n\t}\n\n\t#ch_filter\t: any[] | undefined = undefined;\t// 文字にかけるフィルター\n\t#aSpTw\t\t: ISpTw[]\t= [];\n\n\n\t#aRect\t\t: IChRect[]\t= [];\n\t#lenHtmTxt = 0;\n\tstatic\treadonly\t#SPAN_LAST = ``;\n\tgoTxt(aSpan: string[], instant: boolean) {\n//console.log(`fn:TxtStage.ts goTxt`);\n\t\tTxtStage.#cntBreak.visible = false;\n\n\t\tlet begin = this.#aRect.length;\n\t\tlet bkHtm = '';\n\t\tif (begin === 0) {\t// 初回\n\t\t\tif (TxtStage.#cfg.oCfg.debug.masume) {\n\t\t\t\tif (CmnLib.debugLog) console.log(`🍌 masume ${\n\t\t\t\t\tthis.name} v:${this.visible} l:${this.x} t:${this.y\n\t\t\t\t\t} a:${this.alpha} pl:${this.#infTL.pad_left\n\t\t\t\t\t} pr:${this.#infTL.pad_right\n\t\t\t\t\t} pt:${this.#infTL.pad_top} pb:${this.#infTL.pad_bottom\n\t\t\t\t\t} w:${this.#infTL.$width} h:${this.#infTL.$height}`);\n\n\t\t\t\tthis.#grpDbgMasume.clear()\n\t\t\t\t.beginFill(0x33FF00, 0.2)\t// 文字レイヤ\n\t\t\t\t.lineStyle(1, 0x33FF00, 1)\n\t\t\t\t.drawRect(-this.#infTL.pad_left, -this.#infTL.pad_top, this.#infTL.$width, this.#infTL.$height)\n\t\t\t\t\t// 親の親の cntInsidePadding が padding ぶん水平移動してるので引く。\n\t\t\t\t.endFill()\n\n\t\t\t\t.beginFill(0x0033FF, 0.2)\t// cntInsidePadding\n\t\t\t\t.lineStyle(2, 0x0033FF, 1)\n\t\t\t\t.drawRect(0, 0,\n\t\t\t\tthis.#infTL.$width -this.#infTL.pad_left -this.#infTL.pad_right,\n\t\t\t\tthis.#infTL.$height -this.#infTL.pad_top -this.#infTL.pad_bottom)\n\t\t\t\t.endFill();\n\t\t\t}\n\n\t\t\tthis.#htmTxt.innerHTML = [...aSpan].join('').replaceAll(/[\\n\\t]/g, '') +TxtStage.#SPAN_LAST;\t// 末尾改行削除挙動対策\n\n\t\t\tif (! this.#hyph.break_fixed) {\n\t\t\t\tconst sty = globalThis.getComputedStyle(this.#htmTxt);\n\t\t\t\tconst rs = parseFloat(sty.fontSize);\n\t\t\t\tif (this.#isTategaki) {\n\t\t\t\t\tthis.#hyph.break_fixed_left = (this.#infTL.$width -this.#infTL.pad_left -this.#infTL.pad_right -rs *1.5) *this.sys.cvsScale;\n\t\t\t\t\tthis.#hyph.break_fixed_top = 0;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.#hyph.break_fixed_left = 0;\n\t\t\t\t\tthis.#hyph.break_fixed_top = rs /2 *this.sys.cvsScale;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tbkHtm = this.#htmTxt.innerHTML;\n\t\t\t// 末尾改行削除挙動対策\n\t\t\t--begin;\n//console.log(`fn:TxtStage.ts begin:${begin} bkHtm=${bkHtm}=`);\n\t\t\tthis.#htmTxt.querySelector('.sn_ch_last')?.remove();\n\t\t\t\t// 前回の末尾を削除\n\n\t\t\tthis.#htmTxt.querySelectorAll(':scope > br').forEach(e=> e.remove());\t// 前回の禁則処理を一度削除\n\t\t\t\t// :scope - CSS: カスケーディングスタイルシート | MDN https://developer.mozilla.org/ja/docs/Web/CSS/:scope\n\t\t\tthis.#htmTxt.insertAdjacentHTML(\n\t\t\t\t'beforeend',\n\t\t\t\taSpan.slice(this.#lenHtmTxt).join('').replaceAll(/[\\n\\t]/g, '')\n\t\t\t\t+TxtStage.#SPAN_LAST\t// 末尾改行削除挙動対策\n\t\t\t);\n\t\t}\n\t\t\t// 後の禁則処理判定で誤判定するので、innerHTML 時にムダな改行やタブは削除\n\t\t\t// [r]は後述コメントのHTMLタグになってるので問題なし\n\n\t\t// ルビ付き文字に背景指定(style='background:')がある場合、「文字」と「ルビ」と「その二つを含んだ領域」の三つが個別に塗られるが、三つめは背景指定を削除する\n\t\tthis.#htmTxt.querySelectorAll('.sn_ch:has(> ruby)').forEach((v: HTMLSpanElement)=> v.style.background = '');\t// :has直前に空白厳禁\n\n\t\tthis.#lenHtmTxt = aSpan.length;\n//console.log(`fn:TxtStage.ts === ==${this.#htmTxt.innerHTML.slice(360)}==`);\n\n\t\t// this.#getChRects()使用準備\n\t\tconst cvsScale = this.sys.cvsScale;\n\t\tconst bcr = this.#htmTxt.getBoundingClientRect();\n\t\tconst sx = bcr.left +this.#infTL.pad_left;\n\t\tconst sy = bcr.top +this.#infTL.pad_top;\n\t\tlet cnvRect :(rng: Range, ch: string)=> Rectangle;\n\t\tif (cvsScale === 1) cnvRect = (rng, ch)=> {\n\t\t\tconst r = rng.getBoundingClientRect();\n\t\t\treturn new Rectangle(\n\t\t\t\tr.left -sx,\n\t\t\t\tr.top -sy,\n\t\t\t\tr.width,\n\t\t\t\tr.height +('gjqy'.includes(ch) ?this.#lh_half :0)\n\t\t\t);\n\t\t};\n\t\telse {\n\t\t\t// Resizeを意識してDOM位置をPIXIに変換\n\t\t\t// transform scale を一時的に変更する手もあるが、ややずれるしDOM影響大\n\t\t\tconst ox = this.sys.ofsPadLeft_Dom2PIXI +bcr.left *(1- cvsScale);\n\t\t\tconst oy = this.sys.ofsPadTop_Dom2PIXI +bcr.top *(1- cvsScale);\n\t\t\tcnvRect = (rng, ch)=> {\n\t\t\t\tconst r = rng.getBoundingClientRect();\n\t\t\t\treturn new Rectangle(\n\t\t\t\t\t(r.left -ox) /cvsScale -sx,\n\t\t\t\t\t(r.top -oy) /cvsScale -sy,\n\t\t\t\t\tr.width /cvsScale,\n\t\t\t\t\t(r.height +('gjqy'.includes(ch) ?this.#lh_half :0)) /cvsScale,\n\t\t\t\t);\n\t\t\t};\n\t\t}\n\n\t\tconst [a, len] = this.#hyph.hyph(this.#htmTxt, cnvRect, this.#isTategaki, begin, bkHtm);\n\t\tthis.#aRect = a;\n\n\n\t\tconst fncMasumeLog = CmnLib.debugLog\n\t\t\t? ({ch}: IChRect, {x, y, width, height}: Rectangle)=> console.log(`🍌 masume ch:${ch} x:${x} y:${y} w:${width} h:${height}`)\n\t\t\t: ()=> {};\n\t\tconst fncMasume = TxtStage.#cfg.oCfg.debug.masume\n\t\t\t? (v: IChRect, rct: Rectangle)=> {\n\t\t\t\tfncMasumeLog(v, rct);\n\t\t\t\tthis.#grpDbgMasume\n\t\t\t\t.beginFill(0x66CCFF, 0.5)\n\t\t\t\t.lineStyle(2, 0xFF3300, 1)\n\t\t\t\t.drawRect(rct.x, rct.y, rct.width, rct.height)\n\t\t\t\t.endFill();\n\t\t\t}\n\t\t\t: ()=> {};\n\t\tconst ease = CmnTween.ease(this.#fi_easing);\n\n\t\tfor (let i=begin; i {\n\t\t\t\t\tthis.#spWork(cnt, arg, add, rct, ease, cis ?? {});\n\t\t\t\t\tif (! cnt.parent) cnt.removeChild(sp);\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (c.elm.dataset.lnk) {\n\t\t\t\tconst eCh = c.elm.parentElement!.closest('[data-arg]')! as HTMLElement;\n\t\t\t\tconst aLnk = JSON.parse(eCh.dataset.arg ?? '{}');\n\t\t\t\taLnk.key = `lnk=[${i}] `+ this.name;\n\t\t\t\tconst sp = new Sprite;\n\t\t\t\tthis.#spWork(sp, aLnk, add, rct, ease, cis ?? {});\n\n\t\t\t\tconst st_normal = aLnk.style ?? '';\n\t\t\t\tconst st_hover = st_normal +(aLnk.style_hover ?? '');\n\t\t\t\tconst st_clicked = st_normal +(aLnk.style_clicked ?? '');\n\t\t\t\tconst st_r_normal = aLnk.r_style ?? '';\n\t\t\t\tconst st_r_hover = st_r_normal +(aLnk.r_style_hover ?? '');\n\t\t\t\tconst st_r_clicked = st_r_normal +(aLnk.r_style_clicked ?? '');\n\n\t\t\t\tconst nlRt = [...eCh.getElementsByTagName('rt')];\n\t\t\t\tnlRt.forEach(e=> e.dataset.st_r_bk = e.style.cssText);\n\t\t\t\tconst st_bk = eCh.style.cssText;\n\t\t\t\tconst fncStyle = (st: string, st_r: string)=> {\n\t\t\t\t\teCh.style.cssText = st_bk + st;\n\t\t\t\t\tnlRt.forEach(e=> e.style.cssText = e.dataset.st_r_bk + st_r);\n\t\t\t\t};\n\n\t\t\t\tconst enabled = argChk_Boolean(aLnk, 'enabled', true);\n\t\t\t\tif (enabled) TxtStage.#evtMng.button(aLnk, sp,\n\t\t\t\t\t()=> fncStyle(st_normal, st_r_normal),\n\t\t\t\t\t()=> {\n\t\t\t\t\t\tif (! this.canFocus()) return false;\n\t\t\t\t\t\tfncStyle(st_hover, st_r_hover);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\t()=> fncStyle(st_clicked, st_r_clicked)\n\t\t\t\t);\n\t\t\t\telse fncStyle(\n\t\t\t\t\tst_normal +(aLnk.style_disable ?? 'color: gray;'),\n\t\t\t\t\tst_r_normal +(aLnk.r_style_disable ?? 'color: gray;')\n\t\t\t\t);\n\t\t\t\tthis.#cntTxt.addChild(sp);\n\t\t\t}\n\t\t}\n\n\t\t// 文字出現演出・開始〜終了\n\t\tconst chs = [...this.#htmTxt.getElementsByClassName('sn_ch')];\n\t\tthis.#fncEndChIn = ()=> {\n\t\t\tthis.#fncEndChIn = ()=> false;\n\t\t\tchs.forEach(v=> v.className = v.className.replaceAll(/ go_ch_in_[^\\s\"]+/g, ''));\n\t\t\tTxtStage.#cntBreak.position.set(\n\t\t\t\tthis.#hyph.break_fixed_left,\n\t\t\t\tthis.#hyph.break_fixed_top,\n\t\t\t);\n\t\t\tTxtStage.#cntBreak.visible = true;\n//console.log(`fn:TxtStage.ts // #fncEndChIn`);\n\t\t\t/*\n\t\t\t\t- これらはセットで確認すること。兼ね合いにより、いずれかが破綻する場合がある\n\t\t\t\t\t- 末尾文字表示でカーソルが次行先頭に来てしまうことのないよう\n\t\t\t\t\t- 改行→クリック待ち、の後で改行が消えないよう\n\t\t\t\t\t- 冒頭クリック待ち+改行での表示確認\n\t\t\t*/\n\n\t\t\tthis.noticeCompTxt();\n\t\t\treturn true;\n\t\t};\n\n\t\tchs.forEach(v=> v.className = v.className.replaceAll(/sn_ch_in_([^\\s\"]+)/g, 'go_ch_in_$1'));\n\t\tif (begin > 0) ++begin;\t// 末尾改行削除挙動対策\n\n\t\t// 文字表示に時間をかける最後の文字を探す。末尾はダミー(#SPAN_LAST)\n\t\tlet lastElm: HTMLElement | undefined = undefined;\n\t\tfor (let i=len -2; i>=0; --i) {\t\t// 末尾の手前から\n\t\t\tconst {elm} = this.#aRect[i];\n\t\t\tif (elm.tagName !== 'SPAN') continue;\t// ルビ以外\n\n//console.log(`fn:TxtStage.ts txt:${elm.textContent}: i:${i} begin:${begin} len:${len} elm:%o`, elm);\n\t\t\tlastElm = (elm.parentElement?.tagName === 'RUBY')\n\t\t\t\t? elm.parentElement.parentElement ?? elm\t// [tcy]も[graph]も\n\t\t\t\t: elm;\n\t\t\tbreak;\n\t\t}\n\t\tif (! lastElm || instant || begin === len) {this.#fncEndChIn(); return}\n\t\t\t// 「animation-duration: 0ms;」だと animationend が発生しないので\n\t\t\t// === は右クリック戻りで起こる\n\n\t\tlastElm.addEventListener('animationend', ()=> this.#fncEndChIn(), {once: true, passive: true});\t// クリックキャンセル時は発生しない\n\t\t\t// 差し替えるので「()=> 」形式のままにすること\n\t}\n\t#fncEndChIn: ()=> boolean\t= ()=> false;\n\t#spWork(sp: Container, arg: any, add: any, rct: Rectangle, ease: (k: number)=> number, cis: any) {\n\t\tsp.alpha = 0;\n\t\tif (arg.x) rct.x = (arg.x.at(0) === '=')\n\t\t\t? rct.x +parseInt(arg.x.slice(1))\n\t\t\t: parseInt(arg.x);\n\t\tif (arg.y) rct.y = (arg.y.at(0) === '=')\n\t\t\t? rct.y +parseInt(arg.y.slice(1))\n\t\t\t: parseInt(arg.y);\n\t\tif (arg.width) rct.width = parseInt(arg.width);\n\t\tif (arg.height) rct.height = parseInt(arg.height);\n\t\tif (arg.wait) cis.wait = parseInt(arg.wait);\n\t\tsp.width = rct.width;\n\t\tsp.height = rct.height;\n\t\tif (cis.x) sp.position.set(\n\t\t\t(cis.x.at(0) === '=') ?rct.x +sp.width *cis.nx :cis.nx,\n\t\t\t(cis.y.at(0) === '=') ?rct.y +sp.height *cis.ny :cis.ny\n\t\t);\n\t\telse sp.position.set(rct.x, rct.y,);\n\t\tconst st: ISpTw = {\n\t\t\tsp,\n\t\t\ttw: new Tween(sp)\n\t\t\t\t.to({ alpha: 1, x: rct.x, y: rct.y, width: rct.width, height: rct.height, angle: 0 }, cis.wait ?? 0)\n\t\t\t\t.easing(ease)\n\t\t\t\t.delay((add.wait ?? 0) +(arg.delay ?? 0))\n\t\t\t\t.onComplete(()=> {\n\t\t\t\t\tst.tw = undefined;\n\t\t\t\t\t//(略)\tif (rct.width === 0 || rct.height === 0) return;\n\t\t\t\t\t//if (sp instanceof Sprite) sp.cacheAsBitmap = true;\n\t\t\t\t\t// これを有効にすると[snapshot]で文字が出ない\n\t\t\t\t})\n\t\t\t\t.start(),\n\t\t};\n\t\tthis.#aSpTw.push(st);\n\t}\n\n\tskipChIn(): boolean {\t// true: 文字出現中だったので、停止する\n\t\tlet wasChInIng = this.#fncEndChIn();\n\t\tfor (const st of this.#aSpTw) {\t// Text Skip。stop() と end() は別!\n\t\t\tif (st.tw) {st.tw.stop().end(); wasChInIng = true}\n\t\t}\n\t\tthis.#aSpTw = [];\n\t\treturn wasChInIng;\n\t}\n\n\tstatic\t#hChInStyle\t= Object.create(null);\n\tstatic\treadonly\t#REG_NG_CHSTYLE_NAME_CHR\t= /[\\s\\.,]/;\n\tstatic\tinitChStyle() {\n\t\tTxtStage.#hChInStyle = Object.create(null);\n\t\tTxtStage.#hChOutStyle = Object.create(null);\n\t}\n\tstatic\tgetChInStyle(name: string) {return TxtStage.#hChInStyle[name]}\n\tstatic\tch_in_style(hArg: HArg): any {\n\t\tconst {name} = hArg;\n\t\tif (! name) throw 'nameは必須です';\n\t\tif (TxtStage.#REG_NG_CHSTYLE_NAME_CHR.test(name)) throw `name【${name}】に使えない文字が含まれます`;\n\t\tif (name in TxtStage.#hChInStyle) throw `name【${name}】はすでにあります`;\n\n\t\tconst x = String(hArg.x ?? '=0');\n\t\tconst y = String(hArg.y ?? '=0');\n\t\treturn TxtStage.#hChInStyle[name] = {\n\t\t\twait\t: argChk_Num(hArg, 'wait', 500),\t// アニメ・FI時間\n\t\t\talpha\t: argChk_Num(hArg, 'alpha', 0),\n\t\t\tx\t\t: x,\t// 初期x値\n\t\t\ty\t\t: y,\t// [tsy]と同様に絶対・相対指定可能\n\t\t\t// {x:500}\t\t\tX位置を500に\n\t\t\t// {x:'=500'}\t\t現在のX位置に+500加算した位置\n\t\t\t// {x:'=-500'}\t\t現在のX位置に-500加算した位置\n\t\t\t// {x:'250,500'}\t+250から+500までの間でランダムな値をX位置に\n\t\t\t// {x:'=250,500'}\t+250から+500までの間でランダムな値を現在のX位置に加算\n\t\t\tnx\t\t: parseFloat((x.at(0) === '=') ? x.slice(1) : x),\n\t\t\tny\t\t: parseFloat((y.at(0) === '=') ? y.slice(1) : y),\n\t\t\tscale_x\t: argChk_Num(hArg, 'scale_x', 1),\n\t\t\tscale_y\t: argChk_Num(hArg, 'scale_y', 1),\n\t\t\trotate\t: argChk_Num(hArg, 'rotate', 0),\n\t\t\tjoin\t: argChk_Boolean(hArg, 'join', true),\n\t\t\t\t\t\t// 文字を順番に出すか(true)同時か(false)\n\t\t\tease\t: hArg.ease ?? 'ease-out',\n\t\t};\n\t}\n\n\tstatic\t#hChOutStyle: {[nm: string]: {\n\t\twait\t: number;\n\t\talpha\t: number;\n\t\tx\t\t: string;\n\t\ty\t\t: string;\n\t\tnx\t\t: number;\n\t\tny\t\t: number;\n\t\tscale_x\t: number;\n\t\tscale_y\t: number;\n\t\trotate\t: number;\n\t\tjoin\t: boolean;\n\t\tease\t: string;\n\t}}\t= Object.create(null);\n\tstatic\tgetChOutStyle(name: string) {return TxtStage.#hChOutStyle[name]}\n\tstatic\tch_out_style(hArg: HArg): any {\n\t\tconst {name} = hArg;\n\t\tif (! name) throw 'nameは必須です';\n\t\tif (TxtStage.#REG_NG_CHSTYLE_NAME_CHR.test(name)) throw `name【${name}】に使えない文字が含まれます`;\n\t\tif (name in TxtStage.#hChOutStyle) throw `name【${name}】はすでにあります`;\n\n\t\tconst x = String(hArg.x ?? '=0');\n\t\tconst y = String(hArg.y ?? '=0');\n\t\treturn TxtStage.#hChOutStyle[name] = {\n\t\t\twait\t: argChk_Num(hArg, 'wait', 500),\t// アニメ・FI時間\n\t\t\talpha\t: argChk_Num(hArg, 'alpha', 0),\n\t\t\tx\t\t: x,\t// 初期x値\n\t\t\ty\t\t: y,\t// [tsy]と同様に絶対・相対指定可能\n\t\t\t// {x:500}\t\t\tX位置を500に\n\t\t\t// {x:'=500'}\t\t現在のX位置に+500加算した位置\n\t\t\t// {x:'=-500'}\t\t現在のX位置に-500加算した位置\n\t\t\t// {x:'250,500'}\t+250から+500までの間でランダムな値をX位置に\n\t\t\t// {x:'=250,500'}\t+250から+500までの間でランダムな値を現在のX位置に加算\n\t\t\tnx\t\t: parseFloat((x.at(0) === '=') ? x.slice(1) : x),\n\t\t\tny\t\t: parseFloat((y.at(0) === '=') ? y.slice(1) : y),\n\t\t\tscale_x\t: argChk_Num(hArg, 'scale_x', 1),\n\t\t\tscale_y\t: argChk_Num(hArg, 'scale_y', 1),\n\t\t\trotate\t: argChk_Num(hArg, 'rotate', 0),\n\t\t\tjoin\t: argChk_Boolean(hArg, 'join', false),\n\t\t\t\t\t\t// 文字を順番に出すか(true)同時か(false)\n\t\t\tease\t: hArg.ease ?? 'ease-out',\n\t\t};\n\t}\n\n\tstatic\treadonly\t#cntBreak\t= new Container;\n\tstatic\t\t\t\t#spsBreak\t= new SpritesMng;\n\tdispBreak(o: HArg) {\n\t\tTxtStage.delBreak();\n\n\t\tconst cnt = TxtStage.#cntBreak;\n\t\tcnt.visible = false;\n\t\tthis.addChild(cnt);\t// 次のcsv2Spritesが即終わる場合もあるので先に行なう\n\t\tTxtStage.#spsBreak.destroy();\n\t\tTxtStage.#spsBreak = new SpritesMng(o.pic, cnt, sp=> {\n\t\t\tif (cnt.parent) {\n\t\t\t\tsp.x = argChk_Num(o, 'x', 0);\n\t\t\t\tsp.y = argChk_Num(o, 'y', 0);\n\t\t\t\tsp.width = argChk_Num(o, 'width', this.#infTL.fontsize);\n\t\t\t\tsp.height = argChk_Num(o, 'height', this.#infTL.fontsize);\n\t\t\t}\n\t\t\telse cnt.removeChild(sp);\n\t\t});\n\t}\n\tstatic\tdelBreak() {\n\t\tconst cnt = TxtStage.#cntBreak;\n\t\tcnt.parent?.removeChild(cnt);\t// 複数メッセージウインドウを想定\n\t\tTxtStage.#spsBreak.destroy();\n\t}\n\n\t#fi_easing\t= 'Quadratic.Out';\n\t#fo_easing\t= 'Quadratic.Out';\n\t#clearText() {\n\t\tthis.#grpDbgMasume.clear();\n\t\tthis.#aRect = [];\n\t\tthis.#lenHtmTxt = 0;\n\n\t\t//utils.clearTextureCache();\t// 改ページと思われるこのタイミングで\n\t\tthis.skipChIn();\n\t\tconst n = this.#htmTxt.cloneNode(true) as HTMLSpanElement;\n\t\t//this.htmTxt.innerHTML = '';\t\t以下の方が早いらしい\n\t\tn.textContent = '';\n\t\tconst old = this.#htmTxt;\n\t\told.parentElement!.insertBefore(n, old);\n\n\t\tlet sum_wait = 0;\n\t\told.querySelectorAll('span.sn_ch').forEach(elm=> {\n\t\t\tconst add = JSON.parse(\n\t\t\t\telm?.dataset.add ??\t\t\t\t// 通常文字\n\t\t\t\telm?.children[0]?.getAttribute('data-add') ??\t// ルビ\n\t\t\t\telm?.children[0]?.children[0]\n\t\t\t\t\t?.getAttribute('data-add') ?? '{}'\t\t// 縦中横\n\t\t\t);\n\t\t\tif (! add.ch_out_style) return;\n\n\t\t\tconst cos = TxtStage.#hChOutStyle[add.ch_out_style];\n\t\t\tif (! cos) return;\n\t\t\tif (cos.wait === 0) {elm.style.display = 'none'; return}\n\n\t\t\tsum_wait += cos.wait;\n\t\t\tif (! cos.join) elm.style.animationDelay = '0ms';\n\t\t\telm.classList.add(`go_ch_out_${add.ch_out_style}`);\n\t\t});\n\n\t\tconst end = ()=> {\n\t\t\told.parentElement!.removeChild(old);\n\t\t\tfor (const c of this.#cntTxt.removeChildren()) {\n\t\t\t\tif (c instanceof Container) TxtStage.#evtMng.unButton(c);\n\t\t\t\tc.destroy();\n\t\t\t}\n\t\t};\n\t\tif (sum_wait === 0) {this.#htmTxt.textContent = ''; end()}\n\t\telse old.lastElementChild?.addEventListener('animationend', end, {once: true, passive: true});\n\n\t\tthis.#htmTxt = n;\n\n\t\t//this.#hyph.clear();\t// クリアはしない\n\t}\n\treNew(): TxtStage {\n\t\tthis.#clearText();\n\n\t\tconst to = new TxtStage(this.spLay, ()=> this.canFocus(), this.sys);\n\t\tto.#infTL = this.#infTL;\n\t\tto.#htmTxt.style.cssText = this.#htmTxt.style.cssText;\n\t\tto.#left = this.#left;\n\t\tto.name = this.name;\n\t\tto.#lay_sub();\n\t\tto.#idc.sethArg(this.#idc.gethArg());\n\n\t\tto.#ch_filter = this.#ch_filter;\n\t\tto.#fi_easing = this.#fi_easing;\n\t\tto.#fo_easing = this.#fo_easing;\n\n\t\tthis.#hyph.reNew(to.#hyph);\n\n\t\tthis.destroy();\n\n\t\treturn to;\n\t}\n\n\n\trecord() {return {\n\t\tinfTL\t\t: this.#infTL,\n\n\t\tcssText\t\t: this.#htmTxt.style.cssText,\n\t\tleft\t\t: this.#left,\n\t\tidc_hArg\t: this.#idc.gethArg(),\n\n\t\tch_filter\t: this.#ch_filter,\n\t\tfi_easing\t: this.#fi_easing,\n\t\tfo_easing\t: this.#fo_easing,\n\n\t\thyph\t\t: this.#hyph.record(),\n\t}};\n\tplayback(hLay: any) {\n\t\tthis.#infTL = hLay.infTL;\n\t\tthis.position.set(this.#infTL.pad_left, this.#infTL.pad_top);\n\n\t\tthis.#htmTxt.style.cssText = hLay.cssText;\n\t\tthis.#left = hLay.left;\n\t\tthis.#lay_sub();\n\t\tthis.#idc.sethArg(hLay.idc_hArg);\n\n\t\tthis.#ch_filter\t= hLay.ch_filter;\n\t\tthis.#fi_easing\t= hLay.fi_easing;\n\t\tthis.#fo_easing\t= hLay.fo_easing;\n\n\t\tthis.#hyph.playback(hLay.hyph);\n\t}\n\n\t#sss :Sprite | undefined = undefined;\n\tsnapshot(rnd: Renderer, re: ()=> void) {\n\t\tthis.#htm2tx(tx=> {\n\t\t\tthis.#sss = new Sprite(tx);\t// Safariだけ文字影が映らない\n\t\t\tif (this.#isTategaki) {\n\t\t\t\tthis.#sss.x += CmnLib.stageW -(this.#left +this.#infTL.$width)\n\t\t\t\t//- ((CmnLib.isSafari && !CmnLib.isMobile)\t// 無効化 2022/02/09\n\t\t\t\t//\t? 0\n\t\t\t\t//\t: this.#infTL.pad_left +this.#infTL.pad_right);\n\t\t\t}\n\t\t\tthis.#sss.y -= this.#padTx4y;\n\t\t\tthis.#sss.texture.frame = new Rectangle(\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\tMath.min(this.#sss.width, this.#infTL.$width -this.#left),\n\t\t\t\tMath.min(this.#sss.height, this.#infTL.$height),\n\t\t\t);\t// これがないと画面サイズを超える\n\t\t\tthis.#cntTxt.addChild(this.#sss);\n\t\t\trnd.render(this.#sss, {clear: false});\n\t\t\tre();\n\t\t}, false);\n\t}\n\tsnapshot_end() {\n\t\tif (this.#sss) {this.#cntTxt.removeChild(this.#sss); this.#sss = undefined}\n\t}\n\n\tmakeDesignCast(gdc: IMakeDesignCast) {\n\t\tgdc(this.#idc);\n\n\t\tconst o = this.#idc.gethArg();\n\t\tthis.#idcCh.sethArg({...o, ':id_dc': o[':id_tag'] +'_pad'});\n\t\tgdc(this.#idcCh);\n\t}\n\tshowDesignCast() {this.#idc.visible = true; this.#idcCh.visible = true}\n\n\tdump(): string {\n\t\tconst aStyle: string[] = [];\n\t\tconst s = this.#htmTxt.style;\n\t\tconst len = s.length;\n\t\tfor (let i=0; i {};\n\tinit(putCh: IPutCh) {this.#putCh = putCh}\n\n/*\n\t\t★Unicodeで「漢字」の正規表現 – ものかの http://tama-san.com/kanji-regex/\n\t\t2E80..2FDF CJK部首補助+康熙部首\n\t\t3005 々(漢字の踊り字)\n\t\t3007 〇(漢数字のゼロ)\n\t\t303B 〻(漢字の踊り字)\n\t\t3400..4DBF CJK統合漢字拡張A\n\t\t4E00..9FFF CJK統合漢字\n\t\tF900..FAFF CJK互換漢字\n\t\t20000..2FFFF CJK統合漢字拡張B〜F+CJK互換漢字追加+念のためU+2FFFFまで\n\n\t\t[\\x{2E80}-\\x{2FDF}々〇〻\\x{3400}-\\x{4DBF}\\x{4E00}-\\x{9FFF}\\x{F900}-\\x{FAFF}\\x{20000}-\\x{2FFFF}]\n\t\t[\\u2E80-\\u2FDF々〇〻\\u3400-\\u4DBF\\u4E00-\\u9FFF\\uF900-\\uFAFF\\u20000-\\u2FFFF]\n\t\t[⺀-⿟々〇〻㐀-䶿一-鿿豈-﫿\\u20000-\\u2FFFF]\t\t// 含まれない文字がある\n\t\t[⺀-⿟々〇〻㐀-鿿豈-﫿\\u20000-\\u2FFFF]\t\t\t// ヽ--30FD が変に引っかかる。多分\\u2000-\\u2FFF解釈\n\t\t\\\\u{20000}-\\\\u{2FFFF}\t// 五桁だとエラー\n\n\t\t【2022/10/03】ruby正規表現のUnicode プロパティ(とPOSIX文字クラス) - Qiita https://qiita.com/Takayuki_Nakano/items/8d38beaddb84b488d683\n\t\t\t> このHiraganaプロパティ、長音記号は含まれていません。\n\t\t\t> \\p{Han}…簡体字や繁体字、韓国語の漢字…ベトナム語の漢字にもマッチ\n\t\t\n\t\t・Unicode文字一覧表 - instant tools https://tools.m-bsys.com/ex/unicode_table.php\n*/\n\tstatic\t#REG_RUBY\t: RegExp;\n\tstatic\tsetEscape(ce: string) {\n\t\t// 830 match 11293 step(1.7ms) PCRE2 https://regex101.com/r/BBrQtC/1\n\t\t/*\n(?\\\\\\S)\n|\t|(?[^《\\n]+)《(?[^》\\n]+)》\n|\t(?: (?[⺀-⿟々〇〻㐀-鿿豈-﫿]+ [ぁ-ヿ]* | [^ |《》\\n])\n\t\t《(?[^》\\n]+)》)\n|\t(?\n\t[\\xD800-\\xDBFF][\\xDC00-\\xDFFF]\n|\t[^|《》]+?\n|\t.)\n\t\t*/\n\t\tRubySpliter.#REG_RUBY = new RegExp(\n\t\t\t`${ce ?`(?\\\\${ce}\\\\S)|` :''}`+\n\t\t\t`|(?[^《\\\\n]+)《(?[^》\\\\n]+)》`+\n\t\t\t`|(?:(?[⺀-⿟々〇〻㐀-鿿豈-﫿]+[ぁ-ヿ]*|[^ |《》\\\\n])`+\n\t\t\t`《(?[^》\\\\n]+)》)`+\n\t\t\t`|(?`+\n\t\t\t`[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]`+\t// 上位 + 下位サロゲート\n\t\t\t`|[^|《》]+?`+\t\t// 不要だが細切れにしないほうが後々効率で有利\n\t\t\t`|.)`,\n\t\t\t'gs'\n\t\t);\n\t}\n\n\tputTxt(text: string) {\n\t\tfor (const {groups} of text.matchAll(RubySpliter.#REG_RUBY)) {\n\t\t\tconst {ruby, kan_ruby, kan, ce, txt='', str} = groups!;\n\t\t\tif (ruby) {this.putTxtRb(decodeURIComponent(str), ruby); continue}\n\n\t\t\tif (kan_ruby) {this.putTxtRb(kan, kan_ruby); continue}\n\t\t\tif (ce) {this.#putCh(ce.slice(1), ''); continue}\n\n\t\t\tfor (const v of Array.from(txt)) this.#putCh(v, '');\n\t\t\t\t// txt.split('')や [...txt] はサロゲートペアで問題\n\t\t}\n\t}\n\n\tputTxtRb(text: string, ruby: string) {\t// テスト用にpublic\n\t\t// 自動区切りを行わない(内部的 json文法)\n\t\tif (/^\\w+|{\"/.test(ruby)) {this.#putCh(text, ruby); return}\n\n\t\tconst a: string[] = Array.from(text);\n\t\tconst len = a.length;\n\t\tif (/^\\*.?$/.test(ruby)) {\t// 傍点文法\n\t\t\tconst rb_ses = 'center|'+ (ruby === '*' ?RubySpliter.#sesame :ruby.charAt(1));\n\t\t\tfor (let i=0; i len) ?lenR :len;\n\t\tfor (let i=0; i {};\n\tstatic\t#procMasume4pic = (_me: Button, _sp: Sprite, _w3: number, _h: number)=> {};\n\tstatic\tinit(cfg: Config) {\n\t\tif (! cfg.oCfg.debug.masume) return;\n\n\t\tButton.#procMasume4txt = (me, txt)=> me.addChild(\n\t\t\t(new Graphics)\n\t\t\t.beginFill(0x883388, 0.2)\n\t\t\t.lineStyle(1, 0x883388, 1)\n\t\t\t.drawRect(txt.x, txt.y, txt.width, txt.height)\n\t\t\t.endFill()\n\t\t);\n\t\tButton.#procMasume4pic = (me, sp, w3, h)=> me.addChild(\n\t\t\t(new Graphics)\n\t\t\t.beginFill(0x883388, 0.2)\n\t\t\t.lineStyle(1, 0x883388, 1)\n\t\t\t.drawRect(sp.x, sp.y, w3, h)\n\t\t\t.endFill()\n\t\t);\n\t}\n\n\tsetText(_text: string) {}\n\tgetBtnBounds = ()=> this.#rctBtnTxt;\n\t\t// 文字ボタンは背景画像を含まない位置指定なので、その当たり判定用\n\t#rctBtnTxt\t= new Rectangle;\n\n\t#sps\t\t= new SpritesMng;\n\n\t#idc\t\t: DesignCast;\n\treadonly\t#o\t: {\n\t\ttype\t: 'pic'|'text';\n\t\tenabled\t: boolean;\n\t\tx\t\t: number;\n\t\ty\t\t: number;\n\t\trotation: number;\n\t\t\t// flash : rotation is in degrees.\n\t\t\t// pixijs: rotation is in radians, angle is in degrees.\n\t\tpivot_x\t: number;\n\t\tpivot_y\t: number;\n\t\tscale_x\t: number;\n\t\tscale_y\t: number;\n\t\talpha\t: number;\n\t\ttext\t: string;\n\t\tb_pic\t: string;\n\t\twidth\t: number;\n\t\theight\t: number;\n\t};\n\n\tconstructor(private readonly hArg: HArg, readonly evtMng: IEvtMng, readonly resolve: ()=> void, private readonly canFocus: ()=> boolean) {\n\t\tsuper();\n\n\t\tif (CmnLib.isDbg) {\n\t\t\tthis.makeDesignCast = gdc=> gdc(this.#idc);\n\t\t\tthis.cvsResize = ()=> this.#idc.cvsResize();\n\t\t}\n\n\t\tthis.#o = {\n\t\t\ttype\t: 'pic',\n\t\t\tenabled\t: argChk_Boolean(hArg, 'enabled', true),\n\t\t\tx\t\t: this.x = uint(hArg.left ?? 0),\n\t\t\ty\t\t: this.y = uint(hArg.top ?? 0),\n\t\t\trotation: this.angle = argChk_Num(hArg, 'rotation', this.angle),\n\t\t\t\t// flash : rotation is in degrees.\n\t\t\t\t// pixijs: rotation is in radians, angle is in degrees.\n\t\t\tpivot_x\t: this.pivot.x = argChk_Num(hArg, 'pivot_x', this.pivot.x),\n\t\t\tpivot_y\t: this.pivot.y = argChk_Num(hArg, 'pivot_y', this.pivot.y),\n\t\t\tscale_x\t: this.scale.x = argChk_Num(hArg, 'scale_x', this.scale.x),\n\t\t\tscale_y\t: this.scale.y = argChk_Num(hArg, 'scale_y', this.scale.y),\n\t\t\talpha\t: 1,\n\t\t\ttext\t: '',\n\t\t\tb_pic\t: '',\n\t\t\twidth\t: 0,\n\t\t\theight\t: 0,\n\t\t};\n\t\tthis.getBtnBounds = ()=> {\n\t\t\tthis.#rctBtnTxt.x = this.#o.x;\n\t\t\tthis.#rctBtnTxt.y = this.#o.y;\n\t\t\treturn this.#rctBtnTxt;\n\t\t};\n\n\t\tif (this.#o.enabled) evtMng.button(this.hArg, this, ()=> this.normal(), ()=> this.#hover(), ()=> this.#clicked());\t// あとで差し替えるのでアロー必須\n\n\t\t// == 画像から生成\n\t\tif (hArg.pic) {\n\t\t\tthis.#o.type = 'pic';\t// dump用\n\t\t\tthis.#idc = new PicBtnDesignCast(this, hArg);\n\n\t\t\tthis.#sps = new SpritesMng(\n\t\t\t\thArg.pic,\n\t\t\t\tthis,\n\t\t\t\tsp=> {\n\t\t\t\t\tthis.#loaded_pic(sp);\n\t\t\t\t\tthis.#rctBtnTxt.width = sp.width * this.#o.scale_x;\n\t\t\t\t\tthis.#rctBtnTxt.height = sp.height * this.#o.scale_y;\n\t\t\t\t},\n\t\t\t\t_isStop=> resolve,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tif (! hArg.text) throw 'textまたはpic属性は必須です';\n\n\t\t// == 文字列から生成\n\t\tconst height = argChk_Num(hArg, 'height', 30);\n\t\tconst style = new TextStyle({\n\t\t\talign\t\t: 'center',\n\t\t\tdropShadow\t: true,\n\t\t\tdropShadowAlpha\t: 0.7,\n\t\t\tdropShadowColor\t: 'white',\n\t\t\tdropShadowBlur\t: 7,\n\t\t\tdropShadowDistance\t: 0,\n\t\t\tfill\t\t: this.#o.enabled ?'black' :'gray',\n\t\t\tfontFamily\t: Button.fontFamily,\n\t\t\tfontSize\t: height,\n\t\t\tpadding\t\t: 5,\n\t\t});\n\t\tif (hArg.style) try {\n\t\t\tconst o = JSON.parse(hArg.style);\n\t\t\tfor (const [nm, v] of Object.entries(o)) (style as any)[nm] = v;\n\t\t//\tstyle = {...style, ...JSON.parse(hArg.style)};\t// 上手くいかない\n\t\t} catch (e) {\n\t\t\tthrow new Error(mesErrJSON(hArg, 'style', e.message));\n\t\t}\n\n\t\tconst txt = new Text(hArg.text ?? '', style);\n\t\ttxt.alpha = argChk_Num(hArg, 'alpha', txt.alpha);\t// 上にまとめない\n\t\ttxt.width = argChk_Num(hArg, 'width', 100);\n\t\ttxt.height = hArg.height = height;\n\t\tthis.setText = text=> txt.text = text;\n\n\t\tthis.#o.type = 'text';\t// dump用\n\t\tthis.#o = {...this.#o, ...style};\n\t\tthis.#o.alpha = txt.alpha;\n\t\tthis.#o.text = txt.text;\n\t\tthis.#o.width = txt.width;\n\t\tthis.#o.height = txt.height;\n\t\tthis.#idc = new TxtBtnDesignCast(this, hArg, txt);\n\n\t\tlet isStop = false;\n\t\tthis.#o.width = this.width;\n\t\tthis.#o.height = this.height;\n\t\tif (hArg.b_pic) {\n\t\t\tthis.#o.b_pic = hArg.b_pic;\n\t\t\tthis.#sps = new SpritesMng(\n\t\t\t\thArg.b_pic,\n\t\t\t\tthis,\n\t\t\t\tsp=> {\n\t\t\t\t\tthis.#loaded_b_pic(sp, txt);\n\t\t\t\t\tthis.#o.width = this.width;\n\t\t\t\t\tthis.#o.height = this.height;\n\t\t\t\t},\n\t\t\t\tisStop=> {\n\t\t\t\t\tLayer.setBlendmode(this, hArg);\n\t\t\t\t\tif (isStop) resolve();\n\t\t\t\t},\n\t\t\t);\n\t\t\tisStop = this.#sps.ret;\n\t\t}\n\t\ttxt.name = JSON.stringify(this.#o);\n\n\t\tthis.addChild(txt);\n\t\tthis.#rctBtnTxt.width = txt.width;\t// addChild()後に取得すること\n\t\tthis.#rctBtnTxt.height = txt.height;\n\t//x\tthis.#rctBtnTxt = txt.getBounds();\t// 上手くいかない\n\n\t\tif (! hArg.b_pic) Layer.setBlendmode(this, hArg);\t// 重なり順でここ\n\t\tButton.#procMasume4txt(this, txt);\n\t\tif (! this.#o.enabled) {if (! isStop) resolve(); return}\n\n\t\tconst style_hover = style.clone();\n\t\tif (hArg.style_hover) try {\n\t\t\tconst o = JSON.parse(hArg.style_hover);\n\t\t\tfor (const [nm, v] of Object.entries(o)) (style_hover as any)[nm] = v;\n\t\t} catch (e) {\n\t\t\tthrow new Error(mesErrJSON(hArg, 'style_hover', e.message));\n\t\t}\n\t\telse style_hover.fill = 'white';\n\n\t\tconst style_clicked = style_hover.clone();\n\t\tif (hArg.style_clicked) try {\n\t\t\tconst o = JSON.parse(hArg.style_clicked);\n\t\t\tfor (const [nm, v] of Object.entries(o)) (style_clicked as any)[nm] = v;\n\t\t} catch (e) {\n\t\t\tthrow new Error(mesErrJSON(hArg, 'style_clicked', e.message));\n\t\t}\n\t\telse style_clicked.dropShadow = false;\n\n\t\tthis.normal = ()=> txt.style = style;\n\t\tthis.#hover = ()=> {\n\t\t\tif (! canFocus()) return false;\n\t\t\ttxt.style = style_hover;\n\t\t\treturn true;\n\t\t};\n\t\tthis.#clicked = ()=> txt.style = style_clicked;\n\n\t\tif (! isStop) resolve();\n\t}\n\n\toverride\tdestroy(_options?: IDestroyOptions | boolean): void {\n\t\tthis.evtMng.unButton(this);\n\t\tthis.#sps.destroy();\n\t\tsuper.destroy();\n\t}\n\n\tmakeDesignCast(_gdc: IMakeDesignCast) {}\n\tshowDesignCast() {this.#idc.visible = true}\n\tcvsResize() {}\n\n\t#loaded_b_pic(sp: Sprite, txt: Text) {\n\t\tthis.setChildIndex(sp, 0);\n\t\tsp.alpha = txt.alpha;\n\t\tsp.setTransform(\n\t\t\ttxt.x, txt.y,\n\t\t\t1, 1, txt.rotation, 0, 0,\n\t\t\t(sp.width -txt.width) /2,\n\t\t\t(sp.height -txt.height) /2,\n\t\t);\n\n\t\tsp.name = txt.name;\n\t}\n\n\tnormal\t\t: ()=> void\t\t= ()=> {};\n\t#hover\t\t: ()=> boolean\t= ()=> false;\n\t#clicked\t: ()=> void\t\t= ()=> {};\n\t#loaded_pic(sp: Sprite) {\n\t\tthis.#o.alpha = sp.alpha = argChk_Num(this.hArg, 'alpha', sp.alpha);\n\t\t(this.#idc).setSp(sp);\n\n\t\tconst w_3 = sp.width /3;\n\t\tconst w = this.#o.enabled ?w_3 :sp.width;\n\t\tconst h = sp.height;\n\t\tconst tx = sp.texture.baseTexture;\n\t\tconst txNormal = new Texture(tx, new Rectangle(0, 0, w_3, h));\n\t\tconst txClicked = new Texture(tx, new Rectangle(w_3, 0, w_3, h));\n\t\tconst txHover = new Texture(tx, new Rectangle(w_3 *2, 0, w_3, h));\n\t\tconst normal = ()=> sp.texture = txNormal;\n\t\tif (this.#o.enabled) normal();\n\n\t\tthis.normal\t= normal;\n\t\tthis.#hover\t\t= ()=> {\n\t\t\tif (! this.canFocus()) return false;\n\t\t\tsp.texture = txHover;\n\t\t\treturn true;\n\t\t};\n\t\tthis.#clicked\t= ()=> sp.texture = txClicked;\n\n\t\tif ('width' in this.hArg) {\n\t\t\tthis.#o.width = uint(this.hArg.width);\n\t\t\tthis.scale.x *= this.#o.width /w;\n\t\t}\n\t\telse this.#o.width = w;\n\t\tif ('height' in this.hArg) {\n\t\t\tthis.#o.height = uint(this.hArg.height);\n\t\t\tthis.scale.y *= this.#o.height /h;\n\t\t}\n\t\telse this.#o.height = h;\n\t\tsp.name = JSON.stringify(this.#o);\t// dump用\n\n\t\tButton.#procMasume4pic(this, sp, w, h);\n\t}\n\n}\n","/* ***** BEGIN LICENSE BLOCK *****\n\tCopyright (c) 2018-2024 Famibee (famibee.blog38.fc2.com)\n\n\tThis software is released under the MIT License.\n\thttp://opensource.org/licenses/mit-license.php\n** ***** END LICENSE BLOCK ***** */\n\nimport {Layer} from './Layer';\nimport {uint, CmnLib, IEvtMng, argChk_Boolean, argChk_Num, initStyle, addStyle, argChk_Color} from './CmnLib';\nimport {IHTag, HArg} from './Grammar';\nimport {IVariable, IPutCh, IRecorder} from './CmnInterface';\nimport {TxtStage} from './TxtStage';\nimport {Config} from './Config';\nimport {RubySpliter} from './RubySpliter';\nimport {SpritesMng} from './SpritesMng';\nimport {Button} from './Button';\nimport {LayerMng, IMakeDesignCast} from './LayerMng';\nimport {SysBase} from './SysBase';\nimport {DebugMng} from './DebugMng';\nimport {SEARCH_PATH_ARG_EXT} from './ConfigBase';\nimport {enableEvent, disableEvent} from './ReadState';\nimport {ScriptIterator} from './ScriptIterator';\n\nimport {Sprite, DisplayObject, Graphics, Container, Renderer, Application} from 'pixi.js';\n\n\nexport class TxtLayer extends Layer {\n\tstatic\t#cfg\t\t: Config;\n\tstatic\t#val\t\t: IVariable;\n\tstatic\t#isPageFore\t: (me: TxtLayer)=> boolean;\n\tstatic\t#recorder\t: IRecorder;\n\tstatic\tinit(cfg: Config, hTag: IHTag, val: IVariable, recorder: IRecorder, isPageFore: (me: TxtLayer)=> boolean, appPixi: Application): void {\n\t\tTxtLayer.#cfg = cfg;\n\t\tTxtStage.init(cfg, appPixi);\n\t\tTxtLayer.#val = val;\n\t\tTxtLayer.#recorder = recorder;\n\t\tTxtLayer.#isPageFore = isPageFore;\n\n\t\tval.setDoRecProc(TxtLayer.chgDoRec);\n\n\t\thTag.autowc\t\t\t= o=> TxtLayer.#autowc(o);\t// 文字を追加する\n\t\thTag.autowc({enabled: false, text: '', time: 0});\n\t\thTag.ch_in_style\t= o=> TxtLayer.#ch_in_style(o);\t// 文字出現演出\n\t\thTag.ch_out_style\t= o=> TxtLayer.#ch_out_style(o);\t// 文字消去演出\n\n\t\t// ギャラリーリロード用初期化\n\t\tTxtStage.initChStyle();\n\t\tinitStyle();\n\n\t\taddStyle(\n\t\t\tcfg.matchPath('.+', SEARCH_PATH_ARG_EXT.FONT)\n\t\t\t.flatMap(o=> Object.values(o).map(v=> `\n@font-face {\n\tfont-family: '${v}';\n\tsrc: url('${this.#cfg.searchPath(v, SEARCH_PATH_ARG_EXT.FONT)}');\n}\n`)).join('')\n\n\t\t\t// 文字出現演出関係\n\t\t\t+`\n.sn_tx {\n\tpointer-events: none;\n\tuser-select: none;\n\t-webkit-touch-callout: none;\n\tbox-sizing: border-box;\n}\n.sn_ch {\n\tposition: relative;\n\tdisplay: inline-block;\n}\n`\t// 「sn_ch」と「sn_ch_in_〜」の中身が重複しているが、これは必須\n\t\t);\n\n\t\tTxtLayer.#ch_in_style({\n\t\t\tname\t: 'default',\n\t\t\twait\t: 500,\n\t\t\talpha\t: 0,\n\t\t\tx\t\t: '=0.3',\n\t\t\ty\t\t: '=0',\n\t\t\tscale_x\t: 1,\n\t\t\tscale_y\t: 1,\n\t\t\trotate\t: 0,\n\t\t\tjoin\t: true,\n\t\t\tease\t: 'ease-out',\n\t\t});\n\t\tTxtLayer.#ch_out_style({\n\t\t\tname\t: 'default',\n\t\t\twait\t: 0,\n\t\t\talpha\t: 0,\n\t\t\tx\t\t: '=0',\n\t\t\ty\t\t: '=0',\n\t\t\tscale_x\t: 1,\n\t\t\tscale_y\t: 1,\n\t\t\trotate\t: 0,\n\t\t\tjoin\t: false,\n\t\t\tease\t: 'ease-out',\n\t\t});\n\t}\n\n\t// 文字出現演出\n\tstatic\t#ch_in_style(hArg: HArg) {\n\t\tconst o = TxtStage.ch_in_style(hArg);\n\t\tconst x = (o.x.at(0) === '=') ?`${o.nx *100}%` :`${o.nx}px`;\n\t\tconst y = (o.y.at(0) === '=') ?`${o.ny *100}%` :`${o.ny}px`;\n\t\tconst {name} = hArg;\n\t\taddStyle(`\n.sn_ch_in_${name} {\n\tposition: relative;\n\tdisplay: inline-block;\n}\n.go_ch_in_${name} {\n\topacity: ${o.alpha};\n\tposition: relative;\n\tdisplay: inline-block;\n\tanimation: sn_ch_in_${name} ${o.wait}ms ${o.ease} 0s both;\n}\n@keyframes sn_ch_in_${name} {\n\tfrom {transform: rotate(${o.rotate}deg) scale(${o.scale_x}, ${o.scale_y}) translate(${x}, ${y})}\n\tto {opacity: 1; transform: none;}\n}\n`);\n\n\t\treturn false;\n\t}\n\t// 文字消去演出\n\tstatic\t#ch_out_style(hArg: HArg) {\n\t\tconst o = TxtStage.ch_out_style(hArg);\n\t\tconst x = (o.x.at(0) === '=') ?`${o.nx *100}%` :`${o.nx}px`;\n\t\tconst y = (o.y.at(0) === '=') ?`${o.ny *100}%` :`${o.ny}px`;\n\t\tconst {name} = hArg;\n\t\taddStyle(`\n.go_ch_out_${name} {\n\tposition: relative;\n\tdisplay: inline-block;\n\tanimation: go_ch_out_${name} ${o.wait}ms ${o.ease} 0s both;\n}\n@keyframes go_ch_out_${name} {\n\tto {\n\t\topacity: ${o.alpha};\n\t\ttransform: rotate(${o.rotate}deg) scale(${o.scale_x}, ${o.scale_y}) translate(${x}, ${y});\n\t}\n`);\n\n\t\treturn false;\n\t}\n\n\n\tstatic\t#evtMng\t: IEvtMng;\n\tstatic\t#sys\t: SysBase;\n\tstatic setEvtMng(evtMng: IEvtMng, sys: SysBase, scrItr: ScriptIterator) {\n\t\tTxtLayer.#evtMng = evtMng;\n\t\tTxtLayer.#sys = sys;\n\t\tTxtStage.setEvtMng(evtMng, scrItr);\n\t}\n\n\t// 文字ごとのウェイト\n\tstatic #doAutoWc\t= false;\n\tstatic #hAutoWc\t: {[ch: string]: number}\t= {};\n\tstatic #autowc(hArg: HArg) {\n\t\tTxtLayer.#doAutoWc = argChk_Boolean(hArg, 'enabled', TxtLayer.#doAutoWc);\n\t\tTxtLayer.#val.setVal_Nochk('save', 'const.sn.autowc.enabled', TxtLayer.#doAutoWc);\n\n\t\tconst {text} = hArg;\n\t\tif (('text' in hArg) !== ('time' in hArg)) throw '[autowc] textとtimeは同時指定必須です';\n\t\tTxtLayer.#val.setVal_Nochk('save', 'const.sn.autowc.text', text);\n\t\tif (! text) {\n\t\t\tTxtLayer.#val.setVal_Nochk('save', 'const.sn.autowc.time', '');\n\t\t\treturn false;\n\t\t}\n\n\t\tconst len = text.length;\n\t\tif (TxtLayer.#doAutoWc && len === 0) throw '[autowc] enabled === false かつ text === \"\" は許されません';\n\n\t\tconst a = String(hArg.time).split(',');\n\t\tif (a.length !== len) throw '[autowc] text文字数とtimeに記述された待ち時間(コンマ区切り)は同数にして下さい';\n\t\tTxtLayer.#hAutoWc = {};\t// 毎回クリアを仕様とする\n\t\ta.forEach((v, i)=> TxtLayer.#hAutoWc[text[i]] = uint(v));\n\t\tTxtLayer.#val.setVal_Nochk('save', 'const.sn.autowc.time', hArg.time);\n\n\t\treturn false;\n\t}\n\n\n\t// バック\n\t#b_color\t\t\t= 0x000000;\n\t#b_alpha\t\t\t= 0;\n\t#b_alpha_isfixed\t= false;\n\t#b_do\t\t\t: DisplayObject | undefined\t= undefined;\n\t#b_pic\t\t\t= '';\t// 背景画像無し(=単色塗り)\n\n\t// 文字表示\n\t#txs\t= new TxtStage(this.spLay, ()=> this.canFocus(), TxtLayer.#sys);\n\n\treadonly\t#rbSpl\t= new RubySpliter;\n\treadonly\t#htmRb\t= document.createElement('span');// cssチェック・保存用\n\tstatic\treadonly\t#hWarnR_Style = {\n\t\t'text-align'\t\t: 0,\n\t\t'text-align-last'\t: 0,\n\t\t'height'\t: 0,\n\t\t'width'\t\t: 0,\n\t\t'padding-left'\t\t: 0,\n\t\t'padding-right'\t\t: 0,\n\t\t'padding-top'\t\t: 0,\n\t\t'padding-bottom'\t: 0,\n\t};\n\n\treadonly\t#cntBtn: Container