/*! * PixiJS - v8.12.0 * Compiled Tue, 05 Aug 2025 08:52:10 UTC * * PixiJS is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license */const iv={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var r;return(r=document.baseURI)!=null?r:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let Fc=iv;const I={get(){return Fc},set(r){Fc=r}};var LD=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Wn(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function ND(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function $D(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function XD(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function s(){return this instanceof s?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(s){var i=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:function(){return r[s]}})}),e}var Yn={},ee={},re={};function nv(r,t,e){if(e===void 0&&(e=Array.prototype),r&&typeof e.find=="function")return e.find.call(r,t);for(var s=0;s=0&&r=0){for(var i=t.length-1;s0},lookupPrefix:function(r){for(var t=this;t;){var e=t._nsMap;if(e){for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]===r)return s}t=t.nodeType==Ve?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(r){for(var t=this;t;){var e=t._nsMap;if(e&&Object.prototype.hasOwnProperty.call(e,r))return e[r];t=t.nodeType==Ve?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(r){var t=this.lookupPrefix(r);return t==null}};function Qc(r){return r=="<"&&"<"||r==">"&&">"||r=="&"&&"&"||r=='"'&&"""||"&#"+r.charCodeAt()+";"}kr(xt,V),kr(xt,V.prototype);function Lr(r,t){if(t(r))return!0;if(r=r.firstChild)do if(Lr(r,t))return!0;while(r=r.nextSibling)}function Nr(){this.ownerDocument=this}function pv(r,t,e){r&&r._inc++;var s=e.namespaceURI;s===Ur.XMLNS&&(t._nsMap[e.prefix?e.localName:""]=e.value)}function Jc(r,t,e,s){r&&r._inc++;var i=e.namespaceURI;i===Ur.XMLNS&&delete t._nsMap[e.prefix?e.localName:""]}function Zn(r,t,e){if(r&&r._inc){r._inc++;var s=t.childNodes;if(e)s[s.length++]=e;else{for(var i=t.firstChild,n=0;i;)s[n++]=i,i=i.nextSibling;s.length=n,delete s[s.length]}}}function th(r,t){var e=t.previousSibling,s=t.nextSibling;return e?e.nextSibling=s:r.firstChild=s,s?s.previousSibling=e:r.lastChild=e,t.parentNode=null,t.previousSibling=null,t.nextSibling=null,Zn(r.ownerDocument,r),t}function fv(r){return r&&(r.nodeType===V.DOCUMENT_NODE||r.nodeType===V.DOCUMENT_FRAGMENT_NODE||r.nodeType===V.ELEMENT_NODE)}function mv(r){return r&&(Wt(r)||Qn(r)||ne(r)||r.nodeType===V.DOCUMENT_FRAGMENT_NODE||r.nodeType===V.COMMENT_NODE||r.nodeType===V.PROCESSING_INSTRUCTION_NODE)}function ne(r){return r&&r.nodeType===V.DOCUMENT_TYPE_NODE}function Wt(r){return r&&r.nodeType===V.ELEMENT_NODE}function Qn(r){return r&&r.nodeType===V.TEXT_NODE}function eh(r,t){var e=r.childNodes||[];if(Vt(e,Wt)||ne(t))return!1;var s=Vt(e,ne);return!(t&&s&&e.indexOf(s)>e.indexOf(t))}function rh(r,t){var e=r.childNodes||[];function s(n){return Wt(n)&&n!==t}if(Vt(e,s))return!1;var i=Vt(e,ne);return!(t&&i&&e.indexOf(i)>e.indexOf(t))}function gv(r,t,e){if(!fv(r))throw new rt(bt,"Unexpected parent node type "+r.nodeType);if(e&&e.parentNode!==r)throw new rt(Vc,"child not in parent");if(!mv(t)||ne(t)&&r.nodeType!==V.DOCUMENT_NODE)throw new rt(bt,"Unexpected node type "+t.nodeType+" for parent node type "+r.nodeType)}function _v(r,t,e){var s=r.childNodes||[],i=t.childNodes||[];if(t.nodeType===V.DOCUMENT_FRAGMENT_NODE){var n=i.filter(Wt);if(n.length>1||Vt(i,Qn))throw new rt(bt,"More than one element or text in fragment");if(n.length===1&&!eh(r,e))throw new rt(bt,"Element in fragment can not be inserted before doctype")}if(Wt(t)&&!eh(r,e))throw new rt(bt,"Only one element can be added and only after doctype");if(ne(t)){if(Vt(s,ne))throw new rt(bt,"Only one doctype is allowed");var o=Vt(s,Wt);if(e&&s.indexOf(o)1||Vt(i,Qn))throw new rt(bt,"More than one element or text in fragment");if(n.length===1&&!rh(r,e))throw new rt(bt,"Element in fragment can not be inserted before doctype")}if(Wt(t)&&!rh(r,e))throw new rt(bt,"Only one element can be added and only after doctype");if(ne(t)){if(Vt(s,function(u){return ne(u)&&u!==e}))throw new rt(bt,"Only one doctype is allowed");var o=Vt(s,Wt);if(e&&s.indexOf(o)0&&Lr(e.documentElement,function(i){if(i!==e&&i.nodeType===$t){var n=i.getAttribute("class");if(n){var o=r===n;if(!o){var a=Lc(n);o=t.every(cv(a))}o&&s.push(i)}}}),s})},createElement:function(r){var t=new Re;t.ownerDocument=this,t.nodeName=r,t.tagName=r,t.localName=r,t.childNodes=new ie;var e=t.attributes=new Hs;return e._ownerElement=t,t},createDocumentFragment:function(){var r=new Ws;return r.ownerDocument=this,r.childNodes=new ie,r},createTextNode:function(r){var t=new Jn;return t.ownerDocument=this,t.appendData(r),t},createComment:function(r){var t=new to;return t.ownerDocument=this,t.appendData(r),t},createCDATASection:function(r){var t=new eo;return t.ownerDocument=this,t.appendData(r),t},createProcessingInstruction:function(r,t){var e=new so;return e.ownerDocument=this,e.tagName=e.nodeName=e.target=r,e.nodeValue=e.data=t,e},createAttribute:function(r){var t=new zs;return t.ownerDocument=this,t.name=r,t.nodeName=r,t.localName=r,t.specified=!0,t},createEntityReference:function(r){var t=new ro;return t.ownerDocument=this,t.nodeName=r,t},createElementNS:function(r,t){var e=new Re,s=t.split(":"),i=e.attributes=new Hs;return e.childNodes=new ie,e.ownerDocument=this,e.nodeName=t,e.tagName=t,e.namespaceURI=r,s.length==2?(e.prefix=s[0],e.localName=s[1]):e.localName=t,i._ownerElement=e,e},createAttributeNS:function(r,t){var e=new zs,s=t.split(":");return e.ownerDocument=this,e.nodeName=t,e.name=t,e.namespaceURI=r,e.specified=!0,s.length==2?(e.prefix=s[0],e.localName=s[1]):e.localName=t,e}},_t(Nr,V);function Re(){this._nsMap={}}Re.prototype={nodeType:$t,hasAttribute:function(r){return this.getAttributeNode(r)!=null},getAttribute:function(r){var t=this.getAttributeNode(r);return t&&t.value||""},getAttributeNode:function(r){return this.attributes.getNamedItem(r)},setAttribute:function(r,t){var e=this.ownerDocument.createAttribute(r);e.value=e.nodeValue=""+t,this.setAttributeNode(e)},removeAttribute:function(r){var t=this.getAttributeNode(r);t&&this.removeAttributeNode(t)},appendChild:function(r){return r.nodeType===se?this.insertBefore(r,null):xv(this,r)},setAttributeNode:function(r){return this.attributes.setNamedItem(r)},setAttributeNodeNS:function(r){return this.attributes.setNamedItemNS(r)},removeAttributeNode:function(r){return this.attributes.removeNamedItem(r.nodeName)},removeAttributeNS:function(r,t){var e=this.getAttributeNodeNS(r,t);e&&this.removeAttributeNode(e)},hasAttributeNS:function(r,t){return this.getAttributeNodeNS(r,t)!=null},getAttributeNS:function(r,t){var e=this.getAttributeNodeNS(r,t);return e&&e.value||""},setAttributeNS:function(r,t,e){var s=this.ownerDocument.createAttributeNS(r,t);s.value=s.nodeValue=""+e,this.setAttributeNode(s)},getAttributeNodeNS:function(r,t){return this.attributes.getNamedItemNS(r,t)},getElementsByTagName:function(r){return new We(this,function(t){var e=[];return Lr(t,function(s){s!==t&&s.nodeType==$t&&(r==="*"||s.tagName==r)&&e.push(s)}),e})},getElementsByTagNameNS:function(r,t){return new We(this,function(e){var s=[];return Lr(e,function(i){i!==e&&i.nodeType===$t&&(r==="*"||i.namespaceURI===r)&&(t==="*"||i.localName==t)&&s.push(i)}),s})}},Nr.prototype.getElementsByTagName=Re.prototype.getElementsByTagName,Nr.prototype.getElementsByTagNameNS=Re.prototype.getElementsByTagNameNS,_t(Re,V);function zs(){}zs.prototype.nodeType=Ve,_t(zs,V);function $r(){}$r.prototype={data:"",substringData:function(r,t){return this.data.substring(r,r+t)},appendData:function(r){r=this.data+r,this.nodeValue=this.data=r,this.length=r.length},insertData:function(r,t){this.replaceData(r,0,t)},appendChild:function(r){throw new Error(at[bt])},deleteData:function(r,t){this.replaceData(r,t,"")},replaceData:function(r,t,e){var s=this.data.substring(0,r),i=this.data.substring(r+t);e=s+e+i,this.nodeValue=this.data=e,this.length=e.length}},_t($r,V);function Jn(){}Jn.prototype={nodeName:"#text",nodeType:Xs,splitText:function(r){var t=this.data,e=t.substring(r);t=t.substring(0,r),this.data=this.nodeValue=t,this.length=t.length;var s=this.ownerDocument.createTextNode(e);return this.parentNode&&this.parentNode.insertBefore(s,this.nextSibling),s}},_t(Jn,$r);function to(){}to.prototype={nodeName:"#comment",nodeType:Hc},_t(to,$r);function eo(){}eo.prototype={nodeName:"#cdata-section",nodeType:Nc},_t(eo,$r);function Vs(){}Vs.prototype.nodeType=zc,_t(Vs,V);function ih(){}ih.prototype.nodeType=dv,_t(ih,V);function nh(){}nh.prototype.nodeType=hv,_t(nh,V);function ro(){}ro.prototype.nodeType=$c,_t(ro,V);function Ws(){}Ws.prototype.nodeName="#document-fragment",Ws.prototype.nodeType=se,_t(Ws,V);function so(){}so.prototype.nodeType=Xc,_t(so,V);function oh(){}oh.prototype.serializeToString=function(r,t,e){return ah.call(r,t,e)},V.prototype.toString=ah;function ah(r,t){var e=[],s=this.nodeType==9&&this.documentElement||this,i=s.prefix,n=s.namespaceURI;if(n&&i==null){var i=s.lookupPrefix(n);if(i==null)var o=[{namespace:n,prefix:null}]}return Ye(this,e,r,t,o),e.join("")}function uh(r,t,e){var s=r.prefix||"",i=r.namespaceURI;if(!i||s==="xml"&&i===Ur.XML||i===Ur.XMLNS)return!1;for(var n=e.length;n--;){var o=e[n];if(o.prefix===s)return o.namespace!==i}return!0}function io(r,t,e){r.push(" ",t,'="',e.replace(/[<>&"\t\n\r]/g,Qc),'"')}function Ye(r,t,e,s,i){if(i||(i=[]),s)if(r=s(r),r){if(typeof r=="string"){t.push(r);return}}else return;switch(r.nodeType){case $t:var n=r.attributes,o=n.length,_=r.firstChild,a=r.tagName;e=Ur.isHTML(r.namespaceURI)||e;var u=a;if(!e&&!r.prefix&&r.namespaceURI){for(var l,c=0;c=0;h--){var d=i[h];if(d.prefix===""&&d.namespace===r.namespaceURI){l=d.namespace;break}}if(l!==r.namespaceURI)for(var h=i.length-1;h>=0;h--){var d=i[h];if(d.namespace===r.namespaceURI){d.prefix&&(u=d.prefix+":"+a);break}}}t.push("<",u);for(var p=0;p"),e&&/^script$/i.test(a))for(;_;)_.data?t.push(_.data):Ye(_,t,e,s,i.slice()),_=_.nextSibling;else for(;_;)Ye(_,t,e,s,i.slice()),_=_.nextSibling;t.push("")}else t.push("/>");return;case jc:case se:for(var _=r.firstChild;_;)Ye(_,t,e,s,i.slice()),_=_.nextSibling;return;case Ve:return io(t,r.name,r.value);case Xs:return t.push(r.data.replace(/[<&>]/g,Qc));case Nc:return t.push("");case Hc:return t.push("");case zc:var b=r.publicId,x=r.systemId;if(t.push("");else if(x&&x!=".")t.push(" SYSTEM ",x,">");else{var y=r.internalSubset;y&&t.push(" [",y,"]"),t.push(">")}return;case Xc:return t.push("");case $c:return t.push("&",r.nodeName,";");default:t.push("??",r.nodeName)}}function lh(r,t,e){var s;switch(t.nodeType){case $t:s=t.cloneNode(!1),s.ownerDocument=r;case se:break;case Ve:e=!0;break}if(s||(s=t.cloneNode(!1)),s.ownerDocument=r,s.parentNode=null,e)for(var i=t.firstChild;i;)s.appendChild(lh(r,i,e)),i=i.nextSibling;return s}function no(r,t,e){var s=new t.constructor;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var n=t[i];typeof n!="object"&&n!=s[i]&&(s[i]=n)}switch(t.childNodes&&(s.childNodes=new ie),s.ownerDocument=r,s.nodeType){case $t:var o=t.attributes,a=s.attributes=new Hs,u=o.length;a._ownerElement=s;for(var l=0;l",lt:"<",quot:'"'}),r.HTML_ENTITIES=t({Aacute:"\xC1",aacute:"\xE1",Abreve:"\u0102",abreve:"\u0103",ac:"\u223E",acd:"\u223F",acE:"\u223E\u0333",Acirc:"\xC2",acirc:"\xE2",acute:"\xB4",Acy:"\u0410",acy:"\u0430",AElig:"\xC6",aelig:"\xE6",af:"\u2061",Afr:"\u{1D504}",afr:"\u{1D51E}",Agrave:"\xC0",agrave:"\xE0",alefsym:"\u2135",aleph:"\u2135",Alpha:"\u0391",alpha:"\u03B1",Amacr:"\u0100",amacr:"\u0101",amalg:"\u2A3F",AMP:"&",amp:"&",And:"\u2A53",and:"\u2227",andand:"\u2A55",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsd:"\u2221",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",Aogon:"\u0104",aogon:"\u0105",Aopf:"\u{1D538}",aopf:"\u{1D552}",ap:"\u2248",apacir:"\u2A6F",apE:"\u2A70",ape:"\u224A",apid:"\u224B",apos:"'",ApplyFunction:"\u2061",approx:"\u2248",approxeq:"\u224A",Aring:"\xC5",aring:"\xE5",Ascr:"\u{1D49C}",ascr:"\u{1D4B6}",Assign:"\u2254",ast:"*",asymp:"\u2248",asympeq:"\u224D",Atilde:"\xC3",atilde:"\xE3",Auml:"\xC4",auml:"\xE4",awconint:"\u2233",awint:"\u2A11",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",Backslash:"\u2216",Barv:"\u2AE7",barvee:"\u22BD",Barwed:"\u2306",barwed:"\u2305",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",Bcy:"\u0411",bcy:"\u0431",bdquo:"\u201E",becaus:"\u2235",Because:"\u2235",because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",Bernoullis:"\u212C",Beta:"\u0392",beta:"\u03B2",beth:"\u2136",between:"\u226C",Bfr:"\u{1D505}",bfr:"\u{1D51F}",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bNot:"\u2AED",bnot:"\u2310",Bopf:"\u{1D539}",bopf:"\u{1D553}",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxbox:"\u29C9",boxDL:"\u2557",boxDl:"\u2556",boxdL:"\u2555",boxdl:"\u2510",boxDR:"\u2554",boxDr:"\u2553",boxdR:"\u2552",boxdr:"\u250C",boxH:"\u2550",boxh:"\u2500",boxHD:"\u2566",boxHd:"\u2564",boxhD:"\u2565",boxhd:"\u252C",boxHU:"\u2569",boxHu:"\u2567",boxhU:"\u2568",boxhu:"\u2534",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxUL:"\u255D",boxUl:"\u255C",boxuL:"\u255B",boxul:"\u2518",boxUR:"\u255A",boxUr:"\u2559",boxuR:"\u2558",boxur:"\u2514",boxV:"\u2551",boxv:"\u2502",boxVH:"\u256C",boxVh:"\u256B",boxvH:"\u256A",boxvh:"\u253C",boxVL:"\u2563",boxVl:"\u2562",boxvL:"\u2561",boxvl:"\u2524",boxVR:"\u2560",boxVr:"\u255F",boxvR:"\u255E",boxvr:"\u251C",bprime:"\u2035",Breve:"\u02D8",breve:"\u02D8",brvbar:"\xA6",Bscr:"\u212C",bscr:"\u{1D4B7}",bsemi:"\u204F",bsim:"\u223D",bsime:"\u22CD",bsol:"\\",bsolb:"\u29C5",bsolhsub:"\u27C8",bull:"\u2022",bullet:"\u2022",bump:"\u224E",bumpE:"\u2AAE",bumpe:"\u224F",Bumpeq:"\u224E",bumpeq:"\u224F",Cacute:"\u0106",cacute:"\u0107",Cap:"\u22D2",cap:"\u2229",capand:"\u2A44",capbrcup:"\u2A49",capcap:"\u2A4B",capcup:"\u2A47",capdot:"\u2A40",CapitalDifferentialD:"\u2145",caps:"\u2229\uFE00",caret:"\u2041",caron:"\u02C7",Cayleys:"\u212D",ccaps:"\u2A4D",Ccaron:"\u010C",ccaron:"\u010D",Ccedil:"\xC7",ccedil:"\xE7",Ccirc:"\u0108",ccirc:"\u0109",Cconint:"\u2230",ccups:"\u2A4C",ccupssm:"\u2A50",Cdot:"\u010A",cdot:"\u010B",cedil:"\xB8",Cedilla:"\xB8",cemptyv:"\u29B2",cent:"\xA2",CenterDot:"\xB7",centerdot:"\xB7",Cfr:"\u212D",cfr:"\u{1D520}",CHcy:"\u0427",chcy:"\u0447",check:"\u2713",checkmark:"\u2713",Chi:"\u03A7",chi:"\u03C7",cir:"\u25CB",circ:"\u02C6",circeq:"\u2257",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",circledast:"\u229B",circledcirc:"\u229A",circleddash:"\u229D",CircleDot:"\u2299",circledR:"\xAE",circledS:"\u24C8",CircleMinus:"\u2296",CirclePlus:"\u2295",CircleTimes:"\u2297",cirE:"\u29C3",cire:"\u2257",cirfnint:"\u2A10",cirmid:"\u2AEF",cirscir:"\u29C2",ClockwiseContourIntegral:"\u2232",CloseCurlyDoubleQuote:"\u201D",CloseCurlyQuote:"\u2019",clubs:"\u2663",clubsuit:"\u2663",Colon:"\u2237",colon:":",Colone:"\u2A74",colone:"\u2254",coloneq:"\u2254",comma:",",commat:"@",comp:"\u2201",compfn:"\u2218",complement:"\u2201",complexes:"\u2102",cong:"\u2245",congdot:"\u2A6D",Congruent:"\u2261",Conint:"\u222F",conint:"\u222E",ContourIntegral:"\u222E",Copf:"\u2102",copf:"\u{1D554}",coprod:"\u2210",Coproduct:"\u2210",COPY:"\xA9",copy:"\xA9",copysr:"\u2117",CounterClockwiseContourIntegral:"\u2233",crarr:"\u21B5",Cross:"\u2A2F",cross:"\u2717",Cscr:"\u{1D49E}",cscr:"\u{1D4B8}",csub:"\u2ACF",csube:"\u2AD1",csup:"\u2AD0",csupe:"\u2AD2",ctdot:"\u22EF",cudarrl:"\u2938",cudarrr:"\u2935",cuepr:"\u22DE",cuesc:"\u22DF",cularr:"\u21B6",cularrp:"\u293D",Cup:"\u22D3",cup:"\u222A",cupbrcap:"\u2A48",CupCap:"\u224D",cupcap:"\u2A46",cupcup:"\u2A4A",cupdot:"\u228D",cupor:"\u2A45",cups:"\u222A\uFE00",curarr:"\u21B7",curarrm:"\u293C",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",curlyvee:"\u22CE",curlywedge:"\u22CF",curren:"\xA4",curvearrowleft:"\u21B6",curvearrowright:"\u21B7",cuvee:"\u22CE",cuwed:"\u22CF",cwconint:"\u2232",cwint:"\u2231",cylcty:"\u232D",Dagger:"\u2021",dagger:"\u2020",daleth:"\u2138",Darr:"\u21A1",dArr:"\u21D3",darr:"\u2193",dash:"\u2010",Dashv:"\u2AE4",dashv:"\u22A3",dbkarow:"\u290F",dblac:"\u02DD",Dcaron:"\u010E",dcaron:"\u010F",Dcy:"\u0414",dcy:"\u0434",DD:"\u2145",dd:"\u2146",ddagger:"\u2021",ddarr:"\u21CA",DDotrahd:"\u2911",ddotseq:"\u2A77",deg:"\xB0",Del:"\u2207",Delta:"\u0394",delta:"\u03B4",demptyv:"\u29B1",dfisht:"\u297F",Dfr:"\u{1D507}",dfr:"\u{1D521}",dHar:"\u2965",dharl:"\u21C3",dharr:"\u21C2",DiacriticalAcute:"\xB4",DiacriticalDot:"\u02D9",DiacriticalDoubleAcute:"\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\u02DC",diam:"\u22C4",Diamond:"\u22C4",diamond:"\u22C4",diamondsuit:"\u2666",diams:"\u2666",die:"\xA8",DifferentialD:"\u2146",digamma:"\u03DD",disin:"\u22F2",div:"\xF7",divide:"\xF7",divideontimes:"\u22C7",divonx:"\u22C7",DJcy:"\u0402",djcy:"\u0452",dlcorn:"\u231E",dlcrop:"\u230D",dollar:"$",Dopf:"\u{1D53B}",dopf:"\u{1D555}",Dot:"\xA8",dot:"\u02D9",DotDot:"\u20DC",doteq:"\u2250",doteqdot:"\u2251",DotEqual:"\u2250",dotminus:"\u2238",dotplus:"\u2214",dotsquare:"\u22A1",doublebarwedge:"\u2306",DoubleContourIntegral:"\u222F",DoubleDot:"\xA8",DoubleDownArrow:"\u21D3",DoubleLeftArrow:"\u21D0",DoubleLeftRightArrow:"\u21D4",DoubleLeftTee:"\u2AE4",DoubleLongLeftArrow:"\u27F8",DoubleLongLeftRightArrow:"\u27FA",DoubleLongRightArrow:"\u27F9",DoubleRightArrow:"\u21D2",DoubleRightTee:"\u22A8",DoubleUpArrow:"\u21D1",DoubleUpDownArrow:"\u21D5",DoubleVerticalBar:"\u2225",DownArrow:"\u2193",Downarrow:"\u21D3",downarrow:"\u2193",DownArrowBar:"\u2913",DownArrowUpArrow:"\u21F5",DownBreve:"\u0311",downdownarrows:"\u21CA",downharpoonleft:"\u21C3",downharpoonright:"\u21C2",DownLeftRightVector:"\u2950",DownLeftTeeVector:"\u295E",DownLeftVector:"\u21BD",DownLeftVectorBar:"\u2956",DownRightTeeVector:"\u295F",DownRightVector:"\u21C1",DownRightVectorBar:"\u2957",DownTee:"\u22A4",DownTeeArrow:"\u21A7",drbkarow:"\u2910",drcorn:"\u231F",drcrop:"\u230C",Dscr:"\u{1D49F}",dscr:"\u{1D4B9}",DScy:"\u0405",dscy:"\u0455",dsol:"\u29F6",Dstrok:"\u0110",dstrok:"\u0111",dtdot:"\u22F1",dtri:"\u25BF",dtrif:"\u25BE",duarr:"\u21F5",duhar:"\u296F",dwangle:"\u29A6",DZcy:"\u040F",dzcy:"\u045F",dzigrarr:"\u27FF",Eacute:"\xC9",eacute:"\xE9",easter:"\u2A6E",Ecaron:"\u011A",ecaron:"\u011B",ecir:"\u2256",Ecirc:"\xCA",ecirc:"\xEA",ecolon:"\u2255",Ecy:"\u042D",ecy:"\u044D",eDDot:"\u2A77",Edot:"\u0116",eDot:"\u2251",edot:"\u0117",ee:"\u2147",efDot:"\u2252",Efr:"\u{1D508}",efr:"\u{1D522}",eg:"\u2A9A",Egrave:"\xC8",egrave:"\xE8",egs:"\u2A96",egsdot:"\u2A98",el:"\u2A99",Element:"\u2208",elinters:"\u23E7",ell:"\u2113",els:"\u2A95",elsdot:"\u2A97",Emacr:"\u0112",emacr:"\u0113",empty:"\u2205",emptyset:"\u2205",EmptySmallSquare:"\u25FB",emptyv:"\u2205",EmptyVerySmallSquare:"\u25AB",emsp:"\u2003",emsp13:"\u2004",emsp14:"\u2005",ENG:"\u014A",eng:"\u014B",ensp:"\u2002",Eogon:"\u0118",eogon:"\u0119",Eopf:"\u{1D53C}",eopf:"\u{1D556}",epar:"\u22D5",eparsl:"\u29E3",eplus:"\u2A71",epsi:"\u03B5",Epsilon:"\u0395",epsilon:"\u03B5",epsiv:"\u03F5",eqcirc:"\u2256",eqcolon:"\u2255",eqsim:"\u2242",eqslantgtr:"\u2A96",eqslantless:"\u2A95",Equal:"\u2A75",equals:"=",EqualTilde:"\u2242",equest:"\u225F",Equilibrium:"\u21CC",equiv:"\u2261",equivDD:"\u2A78",eqvparsl:"\u29E5",erarr:"\u2971",erDot:"\u2253",Escr:"\u2130",escr:"\u212F",esdot:"\u2250",Esim:"\u2A73",esim:"\u2242",Eta:"\u0397",eta:"\u03B7",ETH:"\xD0",eth:"\xF0",Euml:"\xCB",euml:"\xEB",euro:"\u20AC",excl:"!",exist:"\u2203",Exists:"\u2203",expectation:"\u2130",ExponentialE:"\u2147",exponentiale:"\u2147",fallingdotseq:"\u2252",Fcy:"\u0424",fcy:"\u0444",female:"\u2640",ffilig:"\uFB03",fflig:"\uFB00",ffllig:"\uFB04",Ffr:"\u{1D509}",ffr:"\u{1D523}",filig:"\uFB01",FilledSmallSquare:"\u25FC",FilledVerySmallSquare:"\u25AA",fjlig:"fj",flat:"\u266D",fllig:"\uFB02",fltns:"\u25B1",fnof:"\u0192",Fopf:"\u{1D53D}",fopf:"\u{1D557}",ForAll:"\u2200",forall:"\u2200",fork:"\u22D4",forkv:"\u2AD9",Fouriertrf:"\u2131",fpartint:"\u2A0D",frac12:"\xBD",frac13:"\u2153",frac14:"\xBC",frac15:"\u2155",frac16:"\u2159",frac18:"\u215B",frac23:"\u2154",frac25:"\u2156",frac34:"\xBE",frac35:"\u2157",frac38:"\u215C",frac45:"\u2158",frac56:"\u215A",frac58:"\u215D",frac78:"\u215E",frasl:"\u2044",frown:"\u2322",Fscr:"\u2131",fscr:"\u{1D4BB}",gacute:"\u01F5",Gamma:"\u0393",gamma:"\u03B3",Gammad:"\u03DC",gammad:"\u03DD",gap:"\u2A86",Gbreve:"\u011E",gbreve:"\u011F",Gcedil:"\u0122",Gcirc:"\u011C",gcirc:"\u011D",Gcy:"\u0413",gcy:"\u0433",Gdot:"\u0120",gdot:"\u0121",gE:"\u2267",ge:"\u2265",gEl:"\u2A8C",gel:"\u22DB",geq:"\u2265",geqq:"\u2267",geqslant:"\u2A7E",ges:"\u2A7E",gescc:"\u2AA9",gesdot:"\u2A80",gesdoto:"\u2A82",gesdotol:"\u2A84",gesl:"\u22DB\uFE00",gesles:"\u2A94",Gfr:"\u{1D50A}",gfr:"\u{1D524}",Gg:"\u22D9",gg:"\u226B",ggg:"\u22D9",gimel:"\u2137",GJcy:"\u0403",gjcy:"\u0453",gl:"\u2277",gla:"\u2AA5",glE:"\u2A92",glj:"\u2AA4",gnap:"\u2A8A",gnapprox:"\u2A8A",gnE:"\u2269",gne:"\u2A88",gneq:"\u2A88",gneqq:"\u2269",gnsim:"\u22E7",Gopf:"\u{1D53E}",gopf:"\u{1D558}",grave:"`",GreaterEqual:"\u2265",GreaterEqualLess:"\u22DB",GreaterFullEqual:"\u2267",GreaterGreater:"\u2AA2",GreaterLess:"\u2277",GreaterSlantEqual:"\u2A7E",GreaterTilde:"\u2273",Gscr:"\u{1D4A2}",gscr:"\u210A",gsim:"\u2273",gsime:"\u2A8E",gsiml:"\u2A90",Gt:"\u226B",GT:">",gt:">",gtcc:"\u2AA7",gtcir:"\u2A7A",gtdot:"\u22D7",gtlPar:"\u2995",gtquest:"\u2A7C",gtrapprox:"\u2A86",gtrarr:"\u2978",gtrdot:"\u22D7",gtreqless:"\u22DB",gtreqqless:"\u2A8C",gtrless:"\u2277",gtrsim:"\u2273",gvertneqq:"\u2269\uFE00",gvnE:"\u2269\uFE00",Hacek:"\u02C7",hairsp:"\u200A",half:"\xBD",hamilt:"\u210B",HARDcy:"\u042A",hardcy:"\u044A",hArr:"\u21D4",harr:"\u2194",harrcir:"\u2948",harrw:"\u21AD",Hat:"^",hbar:"\u210F",Hcirc:"\u0124",hcirc:"\u0125",hearts:"\u2665",heartsuit:"\u2665",hellip:"\u2026",hercon:"\u22B9",Hfr:"\u210C",hfr:"\u{1D525}",HilbertSpace:"\u210B",hksearow:"\u2925",hkswarow:"\u2926",hoarr:"\u21FF",homtht:"\u223B",hookleftarrow:"\u21A9",hookrightarrow:"\u21AA",Hopf:"\u210D",hopf:"\u{1D559}",horbar:"\u2015",HorizontalLine:"\u2500",Hscr:"\u210B",hscr:"\u{1D4BD}",hslash:"\u210F",Hstrok:"\u0126",hstrok:"\u0127",HumpDownHump:"\u224E",HumpEqual:"\u224F",hybull:"\u2043",hyphen:"\u2010",Iacute:"\xCD",iacute:"\xED",ic:"\u2063",Icirc:"\xCE",icirc:"\xEE",Icy:"\u0418",icy:"\u0438",Idot:"\u0130",IEcy:"\u0415",iecy:"\u0435",iexcl:"\xA1",iff:"\u21D4",Ifr:"\u2111",ifr:"\u{1D526}",Igrave:"\xCC",igrave:"\xEC",ii:"\u2148",iiiint:"\u2A0C",iiint:"\u222D",iinfin:"\u29DC",iiota:"\u2129",IJlig:"\u0132",ijlig:"\u0133",Im:"\u2111",Imacr:"\u012A",imacr:"\u012B",image:"\u2111",ImaginaryI:"\u2148",imagline:"\u2110",imagpart:"\u2111",imath:"\u0131",imof:"\u22B7",imped:"\u01B5",Implies:"\u21D2",in:"\u2208",incare:"\u2105",infin:"\u221E",infintie:"\u29DD",inodot:"\u0131",Int:"\u222C",int:"\u222B",intcal:"\u22BA",integers:"\u2124",Integral:"\u222B",intercal:"\u22BA",Intersection:"\u22C2",intlarhk:"\u2A17",intprod:"\u2A3C",InvisibleComma:"\u2063",InvisibleTimes:"\u2062",IOcy:"\u0401",iocy:"\u0451",Iogon:"\u012E",iogon:"\u012F",Iopf:"\u{1D540}",iopf:"\u{1D55A}",Iota:"\u0399",iota:"\u03B9",iprod:"\u2A3C",iquest:"\xBF",Iscr:"\u2110",iscr:"\u{1D4BE}",isin:"\u2208",isindot:"\u22F5",isinE:"\u22F9",isins:"\u22F4",isinsv:"\u22F3",isinv:"\u2208",it:"\u2062",Itilde:"\u0128",itilde:"\u0129",Iukcy:"\u0406",iukcy:"\u0456",Iuml:"\xCF",iuml:"\xEF",Jcirc:"\u0134",jcirc:"\u0135",Jcy:"\u0419",jcy:"\u0439",Jfr:"\u{1D50D}",jfr:"\u{1D527}",jmath:"\u0237",Jopf:"\u{1D541}",jopf:"\u{1D55B}",Jscr:"\u{1D4A5}",jscr:"\u{1D4BF}",Jsercy:"\u0408",jsercy:"\u0458",Jukcy:"\u0404",jukcy:"\u0454",Kappa:"\u039A",kappa:"\u03BA",kappav:"\u03F0",Kcedil:"\u0136",kcedil:"\u0137",Kcy:"\u041A",kcy:"\u043A",Kfr:"\u{1D50E}",kfr:"\u{1D528}",kgreen:"\u0138",KHcy:"\u0425",khcy:"\u0445",KJcy:"\u040C",kjcy:"\u045C",Kopf:"\u{1D542}",kopf:"\u{1D55C}",Kscr:"\u{1D4A6}",kscr:"\u{1D4C0}",lAarr:"\u21DA",Lacute:"\u0139",lacute:"\u013A",laemptyv:"\u29B4",lagran:"\u2112",Lambda:"\u039B",lambda:"\u03BB",Lang:"\u27EA",lang:"\u27E8",langd:"\u2991",langle:"\u27E8",lap:"\u2A85",Laplacetrf:"\u2112",laquo:"\xAB",Larr:"\u219E",lArr:"\u21D0",larr:"\u2190",larrb:"\u21E4",larrbfs:"\u291F",larrfs:"\u291D",larrhk:"\u21A9",larrlp:"\u21AB",larrpl:"\u2939",larrsim:"\u2973",larrtl:"\u21A2",lat:"\u2AAB",lAtail:"\u291B",latail:"\u2919",late:"\u2AAD",lates:"\u2AAD\uFE00",lBarr:"\u290E",lbarr:"\u290C",lbbrk:"\u2772",lbrace:"{",lbrack:"[",lbrke:"\u298B",lbrksld:"\u298F",lbrkslu:"\u298D",Lcaron:"\u013D",lcaron:"\u013E",Lcedil:"\u013B",lcedil:"\u013C",lceil:"\u2308",lcub:"{",Lcy:"\u041B",lcy:"\u043B",ldca:"\u2936",ldquo:"\u201C",ldquor:"\u201E",ldrdhar:"\u2967",ldrushar:"\u294B",ldsh:"\u21B2",lE:"\u2266",le:"\u2264",LeftAngleBracket:"\u27E8",LeftArrow:"\u2190",Leftarrow:"\u21D0",leftarrow:"\u2190",LeftArrowBar:"\u21E4",LeftArrowRightArrow:"\u21C6",leftarrowtail:"\u21A2",LeftCeiling:"\u2308",LeftDoubleBracket:"\u27E6",LeftDownTeeVector:"\u2961",LeftDownVector:"\u21C3",LeftDownVectorBar:"\u2959",LeftFloor:"\u230A",leftharpoondown:"\u21BD",leftharpoonup:"\u21BC",leftleftarrows:"\u21C7",LeftRightArrow:"\u2194",Leftrightarrow:"\u21D4",leftrightarrow:"\u2194",leftrightarrows:"\u21C6",leftrightharpoons:"\u21CB",leftrightsquigarrow:"\u21AD",LeftRightVector:"\u294E",LeftTee:"\u22A3",LeftTeeArrow:"\u21A4",LeftTeeVector:"\u295A",leftthreetimes:"\u22CB",LeftTriangle:"\u22B2",LeftTriangleBar:"\u29CF",LeftTriangleEqual:"\u22B4",LeftUpDownVector:"\u2951",LeftUpTeeVector:"\u2960",LeftUpVector:"\u21BF",LeftUpVectorBar:"\u2958",LeftVector:"\u21BC",LeftVectorBar:"\u2952",lEg:"\u2A8B",leg:"\u22DA",leq:"\u2264",leqq:"\u2266",leqslant:"\u2A7D",les:"\u2A7D",lescc:"\u2AA8",lesdot:"\u2A7F",lesdoto:"\u2A81",lesdotor:"\u2A83",lesg:"\u22DA\uFE00",lesges:"\u2A93",lessapprox:"\u2A85",lessdot:"\u22D6",lesseqgtr:"\u22DA",lesseqqgtr:"\u2A8B",LessEqualGreater:"\u22DA",LessFullEqual:"\u2266",LessGreater:"\u2276",lessgtr:"\u2276",LessLess:"\u2AA1",lesssim:"\u2272",LessSlantEqual:"\u2A7D",LessTilde:"\u2272",lfisht:"\u297C",lfloor:"\u230A",Lfr:"\u{1D50F}",lfr:"\u{1D529}",lg:"\u2276",lgE:"\u2A91",lHar:"\u2962",lhard:"\u21BD",lharu:"\u21BC",lharul:"\u296A",lhblk:"\u2584",LJcy:"\u0409",ljcy:"\u0459",Ll:"\u22D8",ll:"\u226A",llarr:"\u21C7",llcorner:"\u231E",Lleftarrow:"\u21DA",llhard:"\u296B",lltri:"\u25FA",Lmidot:"\u013F",lmidot:"\u0140",lmoust:"\u23B0",lmoustache:"\u23B0",lnap:"\u2A89",lnapprox:"\u2A89",lnE:"\u2268",lne:"\u2A87",lneq:"\u2A87",lneqq:"\u2268",lnsim:"\u22E6",loang:"\u27EC",loarr:"\u21FD",lobrk:"\u27E6",LongLeftArrow:"\u27F5",Longleftarrow:"\u27F8",longleftarrow:"\u27F5",LongLeftRightArrow:"\u27F7",Longleftrightarrow:"\u27FA",longleftrightarrow:"\u27F7",longmapsto:"\u27FC",LongRightArrow:"\u27F6",Longrightarrow:"\u27F9",longrightarrow:"\u27F6",looparrowleft:"\u21AB",looparrowright:"\u21AC",lopar:"\u2985",Lopf:"\u{1D543}",lopf:"\u{1D55D}",loplus:"\u2A2D",lotimes:"\u2A34",lowast:"\u2217",lowbar:"_",LowerLeftArrow:"\u2199",LowerRightArrow:"\u2198",loz:"\u25CA",lozenge:"\u25CA",lozf:"\u29EB",lpar:"(",lparlt:"\u2993",lrarr:"\u21C6",lrcorner:"\u231F",lrhar:"\u21CB",lrhard:"\u296D",lrm:"\u200E",lrtri:"\u22BF",lsaquo:"\u2039",Lscr:"\u2112",lscr:"\u{1D4C1}",Lsh:"\u21B0",lsh:"\u21B0",lsim:"\u2272",lsime:"\u2A8D",lsimg:"\u2A8F",lsqb:"[",lsquo:"\u2018",lsquor:"\u201A",Lstrok:"\u0141",lstrok:"\u0142",Lt:"\u226A",LT:"<",lt:"<",ltcc:"\u2AA6",ltcir:"\u2A79",ltdot:"\u22D6",lthree:"\u22CB",ltimes:"\u22C9",ltlarr:"\u2976",ltquest:"\u2A7B",ltri:"\u25C3",ltrie:"\u22B4",ltrif:"\u25C2",ltrPar:"\u2996",lurdshar:"\u294A",luruhar:"\u2966",lvertneqq:"\u2268\uFE00",lvnE:"\u2268\uFE00",macr:"\xAF",male:"\u2642",malt:"\u2720",maltese:"\u2720",Map:"\u2905",map:"\u21A6",mapsto:"\u21A6",mapstodown:"\u21A7",mapstoleft:"\u21A4",mapstoup:"\u21A5",marker:"\u25AE",mcomma:"\u2A29",Mcy:"\u041C",mcy:"\u043C",mdash:"\u2014",mDDot:"\u223A",measuredangle:"\u2221",MediumSpace:"\u205F",Mellintrf:"\u2133",Mfr:"\u{1D510}",mfr:"\u{1D52A}",mho:"\u2127",micro:"\xB5",mid:"\u2223",midast:"*",midcir:"\u2AF0",middot:"\xB7",minus:"\u2212",minusb:"\u229F",minusd:"\u2238",minusdu:"\u2A2A",MinusPlus:"\u2213",mlcp:"\u2ADB",mldr:"\u2026",mnplus:"\u2213",models:"\u22A7",Mopf:"\u{1D544}",mopf:"\u{1D55E}",mp:"\u2213",Mscr:"\u2133",mscr:"\u{1D4C2}",mstpos:"\u223E",Mu:"\u039C",mu:"\u03BC",multimap:"\u22B8",mumap:"\u22B8",nabla:"\u2207",Nacute:"\u0143",nacute:"\u0144",nang:"\u2220\u20D2",nap:"\u2249",napE:"\u2A70\u0338",napid:"\u224B\u0338",napos:"\u0149",napprox:"\u2249",natur:"\u266E",natural:"\u266E",naturals:"\u2115",nbsp:"\xA0",nbump:"\u224E\u0338",nbumpe:"\u224F\u0338",ncap:"\u2A43",Ncaron:"\u0147",ncaron:"\u0148",Ncedil:"\u0145",ncedil:"\u0146",ncong:"\u2247",ncongdot:"\u2A6D\u0338",ncup:"\u2A42",Ncy:"\u041D",ncy:"\u043D",ndash:"\u2013",ne:"\u2260",nearhk:"\u2924",neArr:"\u21D7",nearr:"\u2197",nearrow:"\u2197",nedot:"\u2250\u0338",NegativeMediumSpace:"\u200B",NegativeThickSpace:"\u200B",NegativeThinSpace:"\u200B",NegativeVeryThinSpace:"\u200B",nequiv:"\u2262",nesear:"\u2928",nesim:"\u2242\u0338",NestedGreaterGreater:"\u226B",NestedLessLess:"\u226A",NewLine:` `,nexist:"\u2204",nexists:"\u2204",Nfr:"\u{1D511}",nfr:"\u{1D52B}",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",nGt:"\u226B\u20D2",ngt:"\u226F",ngtr:"\u226F",nGtv:"\u226B\u0338",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",NJcy:"\u040A",njcy:"\u045A",nlArr:"\u21CD",nlarr:"\u219A",nldr:"\u2025",nlE:"\u2266\u0338",nle:"\u2270",nLeftarrow:"\u21CD",nleftarrow:"\u219A",nLeftrightarrow:"\u21CE",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nLt:"\u226A\u20D2",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",nopf:"\u{1D55F}",Not:"\u2AEC",not:"\xAC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nRightarrow:"\u21CF",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",Nscr:"\u{1D4A9}",nscr:"\u{1D4C3}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",Ntilde:"\xD1",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",Nu:"\u039D",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nVDash:"\u22AF",nVdash:"\u22AE",nvDash:"\u22AD",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwArr:"\u21D6",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",Oacute:"\xD3",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",Ocirc:"\xD4",ocirc:"\xF4",Ocy:"\u041E",ocy:"\u043E",odash:"\u229D",Odblac:"\u0150",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",OElig:"\u0152",oelig:"\u0153",ofcir:"\u29BF",Ofr:"\u{1D512}",ofr:"\u{1D52C}",ogon:"\u02DB",Ograve:"\xD2",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",Omacr:"\u014C",omacr:"\u014D",Omega:"\u03A9",omega:"\u03C9",Omicron:"\u039F",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",Oopf:"\u{1D546}",oopf:"\u{1D560}",opar:"\u29B7",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",operp:"\u29B9",oplus:"\u2295",Or:"\u2A54",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oS:"\u24C8",Oscr:"\u{1D4AA}",oscr:"\u2134",Oslash:"\xD8",oslash:"\xF8",osol:"\u2298",Otilde:"\xD5",otilde:"\xF5",Otimes:"\u2A37",otimes:"\u2297",otimesas:"\u2A36",Ouml:"\xD6",ouml:"\xF6",ovbar:"\u233D",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4",OverParenthesis:"\u23DC",par:"\u2225",para:"\xB6",parallel:"\u2225",parsim:"\u2AF3",parsl:"\u2AFD",part:"\u2202",PartialD:"\u2202",Pcy:"\u041F",pcy:"\u043F",percnt:"%",period:".",permil:"\u2030",perp:"\u22A5",pertenk:"\u2031",Pfr:"\u{1D513}",pfr:"\u{1D52D}",Phi:"\u03A6",phi:"\u03C6",phiv:"\u03D5",phmmat:"\u2133",phone:"\u260E",Pi:"\u03A0",pi:"\u03C0",pitchfork:"\u22D4",piv:"\u03D6",planck:"\u210F",planckh:"\u210E",plankv:"\u210F",plus:"+",plusacir:"\u2A23",plusb:"\u229E",pluscir:"\u2A22",plusdo:"\u2214",plusdu:"\u2A25",pluse:"\u2A72",PlusMinus:"\xB1",plusmn:"\xB1",plussim:"\u2A26",plustwo:"\u2A27",pm:"\xB1",Poincareplane:"\u210C",pointint:"\u2A15",Popf:"\u2119",popf:"\u{1D561}",pound:"\xA3",Pr:"\u2ABB",pr:"\u227A",prap:"\u2AB7",prcue:"\u227C",prE:"\u2AB3",pre:"\u2AAF",prec:"\u227A",precapprox:"\u2AB7",preccurlyeq:"\u227C",Precedes:"\u227A",PrecedesEqual:"\u2AAF",PrecedesSlantEqual:"\u227C",PrecedesTilde:"\u227E",preceq:"\u2AAF",precnapprox:"\u2AB9",precneqq:"\u2AB5",precnsim:"\u22E8",precsim:"\u227E",Prime:"\u2033",prime:"\u2032",primes:"\u2119",prnap:"\u2AB9",prnE:"\u2AB5",prnsim:"\u22E8",prod:"\u220F",Product:"\u220F",profalar:"\u232E",profline:"\u2312",profsurf:"\u2313",prop:"\u221D",Proportion:"\u2237",Proportional:"\u221D",propto:"\u221D",prsim:"\u227E",prurel:"\u22B0",Pscr:"\u{1D4AB}",pscr:"\u{1D4C5}",Psi:"\u03A8",psi:"\u03C8",puncsp:"\u2008",Qfr:"\u{1D514}",qfr:"\u{1D52E}",qint:"\u2A0C",Qopf:"\u211A",qopf:"\u{1D562}",qprime:"\u2057",Qscr:"\u{1D4AC}",qscr:"\u{1D4C6}",quaternions:"\u210D",quatint:"\u2A16",quest:"?",questeq:"\u225F",QUOT:'"',quot:'"',rAarr:"\u21DB",race:"\u223D\u0331",Racute:"\u0154",racute:"\u0155",radic:"\u221A",raemptyv:"\u29B3",Rang:"\u27EB",rang:"\u27E9",rangd:"\u2992",range:"\u29A5",rangle:"\u27E9",raquo:"\xBB",Rarr:"\u21A0",rArr:"\u21D2",rarr:"\u2192",rarrap:"\u2975",rarrb:"\u21E5",rarrbfs:"\u2920",rarrc:"\u2933",rarrfs:"\u291E",rarrhk:"\u21AA",rarrlp:"\u21AC",rarrpl:"\u2945",rarrsim:"\u2974",Rarrtl:"\u2916",rarrtl:"\u21A3",rarrw:"\u219D",rAtail:"\u291C",ratail:"\u291A",ratio:"\u2236",rationals:"\u211A",RBarr:"\u2910",rBarr:"\u290F",rbarr:"\u290D",rbbrk:"\u2773",rbrace:"}",rbrack:"]",rbrke:"\u298C",rbrksld:"\u298E",rbrkslu:"\u2990",Rcaron:"\u0158",rcaron:"\u0159",Rcedil:"\u0156",rcedil:"\u0157",rceil:"\u2309",rcub:"}",Rcy:"\u0420",rcy:"\u0440",rdca:"\u2937",rdldhar:"\u2969",rdquo:"\u201D",rdquor:"\u201D",rdsh:"\u21B3",Re:"\u211C",real:"\u211C",realine:"\u211B",realpart:"\u211C",reals:"\u211D",rect:"\u25AD",REG:"\xAE",reg:"\xAE",ReverseElement:"\u220B",ReverseEquilibrium:"\u21CB",ReverseUpEquilibrium:"\u296F",rfisht:"\u297D",rfloor:"\u230B",Rfr:"\u211C",rfr:"\u{1D52F}",rHar:"\u2964",rhard:"\u21C1",rharu:"\u21C0",rharul:"\u296C",Rho:"\u03A1",rho:"\u03C1",rhov:"\u03F1",RightAngleBracket:"\u27E9",RightArrow:"\u2192",Rightarrow:"\u21D2",rightarrow:"\u2192",RightArrowBar:"\u21E5",RightArrowLeftArrow:"\u21C4",rightarrowtail:"\u21A3",RightCeiling:"\u2309",RightDoubleBracket:"\u27E7",RightDownTeeVector:"\u295D",RightDownVector:"\u21C2",RightDownVectorBar:"\u2955",RightFloor:"\u230B",rightharpoondown:"\u21C1",rightharpoonup:"\u21C0",rightleftarrows:"\u21C4",rightleftharpoons:"\u21CC",rightrightarrows:"\u21C9",rightsquigarrow:"\u219D",RightTee:"\u22A2",RightTeeArrow:"\u21A6",RightTeeVector:"\u295B",rightthreetimes:"\u22CC",RightTriangle:"\u22B3",RightTriangleBar:"\u29D0",RightTriangleEqual:"\u22B5",RightUpDownVector:"\u294F",RightUpTeeVector:"\u295C",RightUpVector:"\u21BE",RightUpVectorBar:"\u2954",RightVector:"\u21C0",RightVectorBar:"\u2953",ring:"\u02DA",risingdotseq:"\u2253",rlarr:"\u21C4",rlhar:"\u21CC",rlm:"\u200F",rmoust:"\u23B1",rmoustache:"\u23B1",rnmid:"\u2AEE",roang:"\u27ED",roarr:"\u21FE",robrk:"\u27E7",ropar:"\u2986",Ropf:"\u211D",ropf:"\u{1D563}",roplus:"\u2A2E",rotimes:"\u2A35",RoundImplies:"\u2970",rpar:")",rpargt:"\u2994",rppolint:"\u2A12",rrarr:"\u21C9",Rrightarrow:"\u21DB",rsaquo:"\u203A",Rscr:"\u211B",rscr:"\u{1D4C7}",Rsh:"\u21B1",rsh:"\u21B1",rsqb:"]",rsquo:"\u2019",rsquor:"\u2019",rthree:"\u22CC",rtimes:"\u22CA",rtri:"\u25B9",rtrie:"\u22B5",rtrif:"\u25B8",rtriltri:"\u29CE",RuleDelayed:"\u29F4",ruluhar:"\u2968",rx:"\u211E",Sacute:"\u015A",sacute:"\u015B",sbquo:"\u201A",Sc:"\u2ABC",sc:"\u227B",scap:"\u2AB8",Scaron:"\u0160",scaron:"\u0161",sccue:"\u227D",scE:"\u2AB4",sce:"\u2AB0",Scedil:"\u015E",scedil:"\u015F",Scirc:"\u015C",scirc:"\u015D",scnap:"\u2ABA",scnE:"\u2AB6",scnsim:"\u22E9",scpolint:"\u2A13",scsim:"\u227F",Scy:"\u0421",scy:"\u0441",sdot:"\u22C5",sdotb:"\u22A1",sdote:"\u2A66",searhk:"\u2925",seArr:"\u21D8",searr:"\u2198",searrow:"\u2198",sect:"\xA7",semi:";",seswar:"\u2929",setminus:"\u2216",setmn:"\u2216",sext:"\u2736",Sfr:"\u{1D516}",sfr:"\u{1D530}",sfrown:"\u2322",sharp:"\u266F",SHCHcy:"\u0429",shchcy:"\u0449",SHcy:"\u0428",shcy:"\u0448",ShortDownArrow:"\u2193",ShortLeftArrow:"\u2190",shortmid:"\u2223",shortparallel:"\u2225",ShortRightArrow:"\u2192",ShortUpArrow:"\u2191",shy:"\xAD",Sigma:"\u03A3",sigma:"\u03C3",sigmaf:"\u03C2",sigmav:"\u03C2",sim:"\u223C",simdot:"\u2A6A",sime:"\u2243",simeq:"\u2243",simg:"\u2A9E",simgE:"\u2AA0",siml:"\u2A9D",simlE:"\u2A9F",simne:"\u2246",simplus:"\u2A24",simrarr:"\u2972",slarr:"\u2190",SmallCircle:"\u2218",smallsetminus:"\u2216",smashp:"\u2A33",smeparsl:"\u29E4",smid:"\u2223",smile:"\u2323",smt:"\u2AAA",smte:"\u2AAC",smtes:"\u2AAC\uFE00",SOFTcy:"\u042C",softcy:"\u044C",sol:"/",solb:"\u29C4",solbar:"\u233F",Sopf:"\u{1D54A}",sopf:"\u{1D564}",spades:"\u2660",spadesuit:"\u2660",spar:"\u2225",sqcap:"\u2293",sqcaps:"\u2293\uFE00",sqcup:"\u2294",sqcups:"\u2294\uFE00",Sqrt:"\u221A",sqsub:"\u228F",sqsube:"\u2291",sqsubset:"\u228F",sqsubseteq:"\u2291",sqsup:"\u2290",sqsupe:"\u2292",sqsupset:"\u2290",sqsupseteq:"\u2292",squ:"\u25A1",Square:"\u25A1",square:"\u25A1",SquareIntersection:"\u2293",SquareSubset:"\u228F",SquareSubsetEqual:"\u2291",SquareSuperset:"\u2290",SquareSupersetEqual:"\u2292",SquareUnion:"\u2294",squarf:"\u25AA",squf:"\u25AA",srarr:"\u2192",Sscr:"\u{1D4AE}",sscr:"\u{1D4C8}",ssetmn:"\u2216",ssmile:"\u2323",sstarf:"\u22C6",Star:"\u22C6",star:"\u2606",starf:"\u2605",straightepsilon:"\u03F5",straightphi:"\u03D5",strns:"\xAF",Sub:"\u22D0",sub:"\u2282",subdot:"\u2ABD",subE:"\u2AC5",sube:"\u2286",subedot:"\u2AC3",submult:"\u2AC1",subnE:"\u2ACB",subne:"\u228A",subplus:"\u2ABF",subrarr:"\u2979",Subset:"\u22D0",subset:"\u2282",subseteq:"\u2286",subseteqq:"\u2AC5",SubsetEqual:"\u2286",subsetneq:"\u228A",subsetneqq:"\u2ACB",subsim:"\u2AC7",subsub:"\u2AD5",subsup:"\u2AD3",succ:"\u227B",succapprox:"\u2AB8",succcurlyeq:"\u227D",Succeeds:"\u227B",SucceedsEqual:"\u2AB0",SucceedsSlantEqual:"\u227D",SucceedsTilde:"\u227F",succeq:"\u2AB0",succnapprox:"\u2ABA",succneqq:"\u2AB6",succnsim:"\u22E9",succsim:"\u227F",SuchThat:"\u220B",Sum:"\u2211",sum:"\u2211",sung:"\u266A",Sup:"\u22D1",sup:"\u2283",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",supdot:"\u2ABE",supdsub:"\u2AD8",supE:"\u2AC6",supe:"\u2287",supedot:"\u2AC4",Superset:"\u2283",SupersetEqual:"\u2287",suphsol:"\u27C9",suphsub:"\u2AD7",suplarr:"\u297B",supmult:"\u2AC2",supnE:"\u2ACC",supne:"\u228B",supplus:"\u2AC0",Supset:"\u22D1",supset:"\u2283",supseteq:"\u2287",supseteqq:"\u2AC6",supsetneq:"\u228B",supsetneqq:"\u2ACC",supsim:"\u2AC8",supsub:"\u2AD4",supsup:"\u2AD6",swarhk:"\u2926",swArr:"\u21D9",swarr:"\u2199",swarrow:"\u2199",swnwar:"\u292A",szlig:"\xDF",Tab:" ",target:"\u2316",Tau:"\u03A4",tau:"\u03C4",tbrk:"\u23B4",Tcaron:"\u0164",tcaron:"\u0165",Tcedil:"\u0162",tcedil:"\u0163",Tcy:"\u0422",tcy:"\u0442",tdot:"\u20DB",telrec:"\u2315",Tfr:"\u{1D517}",tfr:"\u{1D531}",there4:"\u2234",Therefore:"\u2234",therefore:"\u2234",Theta:"\u0398",theta:"\u03B8",thetasym:"\u03D1",thetav:"\u03D1",thickapprox:"\u2248",thicksim:"\u223C",ThickSpace:"\u205F\u200A",thinsp:"\u2009",ThinSpace:"\u2009",thkap:"\u2248",thksim:"\u223C",THORN:"\xDE",thorn:"\xFE",Tilde:"\u223C",tilde:"\u02DC",TildeEqual:"\u2243",TildeFullEqual:"\u2245",TildeTilde:"\u2248",times:"\xD7",timesb:"\u22A0",timesbar:"\u2A31",timesd:"\u2A30",tint:"\u222D",toea:"\u2928",top:"\u22A4",topbot:"\u2336",topcir:"\u2AF1",Topf:"\u{1D54B}",topf:"\u{1D565}",topfork:"\u2ADA",tosa:"\u2929",tprime:"\u2034",TRADE:"\u2122",trade:"\u2122",triangle:"\u25B5",triangledown:"\u25BF",triangleleft:"\u25C3",trianglelefteq:"\u22B4",triangleq:"\u225C",triangleright:"\u25B9",trianglerighteq:"\u22B5",tridot:"\u25EC",trie:"\u225C",triminus:"\u2A3A",TripleDot:"\u20DB",triplus:"\u2A39",trisb:"\u29CD",tritime:"\u2A3B",trpezium:"\u23E2",Tscr:"\u{1D4AF}",tscr:"\u{1D4C9}",TScy:"\u0426",tscy:"\u0446",TSHcy:"\u040B",tshcy:"\u045B",Tstrok:"\u0166",tstrok:"\u0167",twixt:"\u226C",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",Uacute:"\xDA",uacute:"\xFA",Uarr:"\u219F",uArr:"\u21D1",uarr:"\u2191",Uarrocir:"\u2949",Ubrcy:"\u040E",ubrcy:"\u045E",Ubreve:"\u016C",ubreve:"\u016D",Ucirc:"\xDB",ucirc:"\xFB",Ucy:"\u0423",ucy:"\u0443",udarr:"\u21C5",Udblac:"\u0170",udblac:"\u0171",udhar:"\u296E",ufisht:"\u297E",Ufr:"\u{1D518}",ufr:"\u{1D532}",Ugrave:"\xD9",ugrave:"\xF9",uHar:"\u2963",uharl:"\u21BF",uharr:"\u21BE",uhblk:"\u2580",ulcorn:"\u231C",ulcorner:"\u231C",ulcrop:"\u230F",ultri:"\u25F8",Umacr:"\u016A",umacr:"\u016B",uml:"\xA8",UnderBar:"_",UnderBrace:"\u23DF",UnderBracket:"\u23B5",UnderParenthesis:"\u23DD",Union:"\u22C3",UnionPlus:"\u228E",Uogon:"\u0172",uogon:"\u0173",Uopf:"\u{1D54C}",uopf:"\u{1D566}",UpArrow:"\u2191",Uparrow:"\u21D1",uparrow:"\u2191",UpArrowBar:"\u2912",UpArrowDownArrow:"\u21C5",UpDownArrow:"\u2195",Updownarrow:"\u21D5",updownarrow:"\u2195",UpEquilibrium:"\u296E",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",uplus:"\u228E",UpperLeftArrow:"\u2196",UpperRightArrow:"\u2197",Upsi:"\u03D2",upsi:"\u03C5",upsih:"\u03D2",Upsilon:"\u03A5",upsilon:"\u03C5",UpTee:"\u22A5",UpTeeArrow:"\u21A5",upuparrows:"\u21C8",urcorn:"\u231D",urcorner:"\u231D",urcrop:"\u230E",Uring:"\u016E",uring:"\u016F",urtri:"\u25F9",Uscr:"\u{1D4B0}",uscr:"\u{1D4CA}",utdot:"\u22F0",Utilde:"\u0168",utilde:"\u0169",utri:"\u25B5",utrif:"\u25B4",uuarr:"\u21C8",Uuml:"\xDC",uuml:"\xFC",uwangle:"\u29A7",vangrt:"\u299C",varepsilon:"\u03F5",varkappa:"\u03F0",varnothing:"\u2205",varphi:"\u03D5",varpi:"\u03D6",varpropto:"\u221D",vArr:"\u21D5",varr:"\u2195",varrho:"\u03F1",varsigma:"\u03C2",varsubsetneq:"\u228A\uFE00",varsubsetneqq:"\u2ACB\uFE00",varsupsetneq:"\u228B\uFE00",varsupsetneqq:"\u2ACC\uFE00",vartheta:"\u03D1",vartriangleleft:"\u22B2",vartriangleright:"\u22B3",Vbar:"\u2AEB",vBar:"\u2AE8",vBarv:"\u2AE9",Vcy:"\u0412",vcy:"\u0432",VDash:"\u22AB",Vdash:"\u22A9",vDash:"\u22A8",vdash:"\u22A2",Vdashl:"\u2AE6",Vee:"\u22C1",vee:"\u2228",veebar:"\u22BB",veeeq:"\u225A",vellip:"\u22EE",Verbar:"\u2016",verbar:"|",Vert:"\u2016",vert:"|",VerticalBar:"\u2223",VerticalLine:"|",VerticalSeparator:"\u2758",VerticalTilde:"\u2240",VeryThinSpace:"\u200A",Vfr:"\u{1D519}",vfr:"\u{1D533}",vltri:"\u22B2",vnsub:"\u2282\u20D2",vnsup:"\u2283\u20D2",Vopf:"\u{1D54D}",vopf:"\u{1D567}",vprop:"\u221D",vrtri:"\u22B3",Vscr:"\u{1D4B1}",vscr:"\u{1D4CB}",vsubnE:"\u2ACB\uFE00",vsubne:"\u228A\uFE00",vsupnE:"\u2ACC\uFE00",vsupne:"\u228B\uFE00",Vvdash:"\u22AA",vzigzag:"\u299A",Wcirc:"\u0174",wcirc:"\u0175",wedbar:"\u2A5F",Wedge:"\u22C0",wedge:"\u2227",wedgeq:"\u2259",weierp:"\u2118",Wfr:"\u{1D51A}",wfr:"\u{1D534}",Wopf:"\u{1D54E}",wopf:"\u{1D568}",wp:"\u2118",wr:"\u2240",wreath:"\u2240",Wscr:"\u{1D4B2}",wscr:"\u{1D4CC}",xcap:"\u22C2",xcirc:"\u25EF",xcup:"\u22C3",xdtri:"\u25BD",Xfr:"\u{1D51B}",xfr:"\u{1D535}",xhArr:"\u27FA",xharr:"\u27F7",Xi:"\u039E",xi:"\u03BE",xlArr:"\u27F8",xlarr:"\u27F5",xmap:"\u27FC",xnis:"\u22FB",xodot:"\u2A00",Xopf:"\u{1D54F}",xopf:"\u{1D569}",xoplus:"\u2A01",xotime:"\u2A02",xrArr:"\u27F9",xrarr:"\u27F6",Xscr:"\u{1D4B3}",xscr:"\u{1D4CD}",xsqcup:"\u2A06",xuplus:"\u2A04",xutri:"\u25B3",xvee:"\u22C1",xwedge:"\u22C0",Yacute:"\xDD",yacute:"\xFD",YAcy:"\u042F",yacy:"\u044F",Ycirc:"\u0176",ycirc:"\u0177",Ycy:"\u042B",ycy:"\u044B",yen:"\xA5",Yfr:"\u{1D51C}",yfr:"\u{1D536}",YIcy:"\u0407",yicy:"\u0457",Yopf:"\u{1D550}",yopf:"\u{1D56A}",Yscr:"\u{1D4B4}",yscr:"\u{1D4CE}",YUcy:"\u042E",yucy:"\u044E",Yuml:"\u0178",yuml:"\xFF",Zacute:"\u0179",zacute:"\u017A",Zcaron:"\u017D",zcaron:"\u017E",Zcy:"\u0417",zcy:"\u0437",Zdot:"\u017B",zdot:"\u017C",zeetrf:"\u2128",ZeroWidthSpace:"\u200B",Zeta:"\u0396",zeta:"\u03B6",Zfr:"\u2128",zfr:"\u{1D537}",ZHcy:"\u0416",zhcy:"\u0436",zigrarr:"\u21DD",Zopf:"\u2124",zopf:"\u{1D56B}",Zscr:"\u{1D4B5}",zscr:"\u{1D4CF}",zwj:"\u200D",zwnj:"\u200C"}),r.entityMap=r.HTML_ENTITIES})(oo);var pM=Wn(oo),ao={},Xr=re.NAMESPACE,uo=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,hh=new RegExp("[\\-\\.0-9"+uo.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),dh=new RegExp("^"+uo.source+hh.source+"*(?::"+uo.source+hh.source+"*)?$"),Hr=0,me=1,qe=2,jr=3,Ke=4,Ze=5,zr=6,qs=7;function Qe(r,t){this.message=r,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,Qe)}Qe.prototype=new Error,Qe.prototype.name=Qe.name;function ph(){}ph.prototype={parse:function(r,t,e){var s=this.domBuilder;s.startDocument(),gh(t,t={}),bv(r,t,e,s,this.errorHandler),s.endDocument()}};function bv(r,t,e,s,i){function n(P){if(P>65535){P-=65536;var O=55296+(P>>10),ze=56320+(P&1023);return String.fromCharCode(O,ze)}else return String.fromCharCode(P)}function o(P){var O=P.slice(1,-1);return Object.hasOwnProperty.call(e,O)?e[O]:O.charAt(0)==="#"?n(parseInt(O.substr(1).replace("x","0x"))):(i.error("entity not found:"+P),P)}function a(P){if(P>g){var O=r.substring(g,P).replace(/&#?\w+;/g,o);d&&u(g),s.characters(O,0,P-g),g=P}}function u(P,O){for(;P>=c&&(O=h.exec(r));)l=O.index,c=l+O[0].length,d.lineNumber++;d.columnNumber=P-l+1}for(var l=0,c=0,h=/.*(?:\r\n?|\n)|.*$/g,d=s.locator,p=[{currentNSMap:t}],f={},g=0;;){try{var m=r.indexOf("<",g);if(m<0){if(!r.substr(g).match(/^\s*$/)){var _=s.doc,b=_.createTextNode(r.substr(g));_.appendChild(b),s.currentElement=b}return}switch(m>g&&a(m),r.charAt(m+1)){case"/":var E=r.indexOf(">",m+3),x=r.substring(m+2,E).replace(/[ \t\n\r]+$/g,""),y=p.pop();E<0?(x=r.substring(m+2).replace(/[\s<].*/,""),i.error("end tag name: "+x+" is not complete:"+y.tagName),E=m+1+x.length):x.match(/\sg?g=E:a(Math.max(m,g)+1)}}function fh(r,t){return t.lineNumber=r.lineNumber,t.columnNumber=r.columnNumber,t}function yv(r,t,e,s,i,n){function o(p,f,g){e.attributeNames.hasOwnProperty(p)&&n.fatalError("Attribute "+p+" redefined"),e.addValue(p,f.replace(/[\t\n\r]/g," ").replace(/&#?\w+;/g,i),g)}for(var a,u,l=++t,c=Hr;;){var h=r.charAt(l);switch(h){case"=":if(c===me)a=r.slice(t,l),c=jr;else if(c===qe)c=jr;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(c===jr||c===me)if(c===me&&(n.warning('attribute value must after "="'),a=r.slice(t,l)),t=l+1,l=r.indexOf(h,t),l>0)u=r.slice(t,l),o(a,u,t-1),c=Ze;else throw new Error("attribute value no end '"+h+"' match");else if(c==Ke)u=r.slice(t,l),o(a,u,t),n.warning('attribute "'+a+'" missed start quot('+h+")!!"),t=l+1,c=Ze;else throw new Error('attribute value must after "="');break;case"/":switch(c){case Hr:e.setTagName(r.slice(t,l));case Ze:case zr:case qs:c=qs,e.closed=!0;case Ke:case me:break;case qe:e.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return n.error("unexpected end of input"),c==Hr&&e.setTagName(r.slice(t,l)),l;case">":switch(c){case Hr:e.setTagName(r.slice(t,l));case Ze:case zr:case qs:break;case Ke:case me:u=r.slice(t,l),u.slice(-1)==="/"&&(e.closed=!0,u=u.slice(0,-1));case qe:c===qe&&(u=a),c==Ke?(n.warning('attribute "'+u+'" missed quot(")!'),o(a,u,t)):((!Xr.isHTML(s[""])||!u.match(/^(?:disabled|checked|selected)$/i))&&n.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),o(u,u,t));break;case jr:throw new Error("attribute value missed!!")}return l;case"\x80":h=" ";default:if(h<=" ")switch(c){case Hr:e.setTagName(r.slice(t,l)),c=zr;break;case me:a=r.slice(t,l),c=qe;break;case Ke:var u=r.slice(t,l);n.warning('attribute "'+u+'" missed quot(")!!'),o(a,u,t);case Ze:c=zr;break}else switch(c){case qe:var d=e.tagName;(!Xr.isHTML(s[""])||!a.match(/^(?:disabled|checked|selected)$/i))&&n.warning('attribute "'+a+'" missed value!! "'+a+'" instead2!!'),o(a,a,t),t=l,c=me;break;case Ze:n.warning('attribute space is required"'+a+'"!!');case zr:c=me,t=l;break;case jr:c=Ke,t=l;break;case qs:throw new Error("elements closed character '/' and '>' must be connected to")}}l++}}function mh(r,t,e){for(var s=r.tagName,i=null,h=r.length;h--;){var n=r[h],o=n.qName,a=n.value,d=o.indexOf(":");if(d>0)var u=n.prefix=o.slice(0,d),l=o.slice(d+1),c=u==="xmlns"&&l;else l=o,u=null,c=o==="xmlns"&&"";n.localName=l,c!==!1&&(i==null&&(i={},gh(e,e={})),e[c]=i[c]=a,n.uri=Xr.XMLNS,t.startPrefixMapping(c,a))}for(var h=r.length;h--;){n=r[h];var u=n.prefix;u&&(u==="xml"&&(n.uri=Xr.XML),u!=="xmlns"&&(n.uri=e[u||""]))}var d=s.indexOf(":");d>0?(u=r.prefix=s.slice(0,d),l=r.localName=s.slice(d+1)):(u=null,l=r.localName=s);var p=r.uri=e[u||""];if(t.startElement(p,l,s,r),r.closed){if(t.endElement(p,l,s),i)for(u in i)Object.prototype.hasOwnProperty.call(i,u)&&t.endPrefixMapping(u)}else return r.currentNSMap=e,r.localNSMap=i,!0}function vv(r,t,e,s,i){if(/^(?:script|textarea)$/i.test(e)){var n=r.indexOf("",t),o=r.substring(t+1,n);if(/[&<]/.test(o))return/^script$/i.test(e)?(i.characters(o,0,o.length),n):(o=o.replace(/&#?\w+;/g,s),i.characters(o,0,o.length),n)}return t+1}function Tv(r,t,e,s){var i=s[e];return i==null&&(i=r.lastIndexOf(""),i",t+4);return n>t?(e.comment(r,t+4,n-t-4),n+3):(s.error("Unclosed comment"),-1)}else return-1;default:if(r.substr(t+3,6)=="CDATA["){var n=r.indexOf("]]>",t+9);return e.startCDATA(),e.characters(r,t+9,n-t-9),e.endCDATA(),n+3}var o=Ev(r,t),a=o.length;if(a>1&&/!doctype/i.test(o[0][0])){var u=o[1][0],l=!1,c=!1;a>3&&(/^public$/i.test(o[2][0])?(l=o[3][0],c=a>4&&o[4][0]):/^system$/i.test(o[2][0])&&(c=o[3][0]));var h=o[a-1];return e.startDTD(u,l,c),e.endDTD(),h.index+h[0].length}}return-1}function Sv(r,t,e){var s=r.indexOf("?>",t);if(s){var i=r.substring(t,s).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(i){var n=i[0].length;return e.processingInstruction(i[1],i[2]),s+2}else return-1}return-1}function _h(){this.attributeNames={}}_h.prototype={setTagName:function(r){if(!dh.test(r))throw new Error("invalid tagName:"+r);this.tagName=r},addValue:function(r,t,e){if(!dh.test(r))throw new Error("invalid attribute:"+r);this.attributeNames[r]=this.length,this[this.length++]={qName:r,value:t,offset:e}},length:0,getLocalName:function(r){return this[r].localName},getLocator:function(r){return this[r].locator},getQName:function(r){return this[r].qName},getURI:function(r){return this[r].uri},getValue:function(r){return this[r].value}};function Ev(r,t){var e,s=[],i=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;for(i.lastIndex=t,i.exec(r);e=i.exec(r);)if(s.push(e),e[1])return s}var fM=ao.XMLReader=ph,mM=ao.ParseError=Qe,wv=re,Cv=ee,xh=oo,bh=ao,Rv=Cv.DOMImplementation,yh=wv.NAMESPACE,Pv=bh.ParseError,Dv=bh.XMLReader;function vh(r){return r.replace(/\r[\n\u0085]/g,` `).replace(/[\r\u0085\u2028]/g,` `)}function Th(r){this.options=r||{locator:{}}}Th.prototype.parseFromString=function(r,t){var e=this.options,s=new Dv,i=e.domBuilder||new Vr,n=e.errorHandler,o=e.locator,a=e.xmlns||{},u=/\/x?html?$/.test(t),l=u?xh.HTML_ENTITIES:xh.XML_ENTITIES;o&&i.setDocumentLocator(o),s.errorHandler=Mv(n,i,o),s.domBuilder=e.domBuilder||i,u&&(a[""]=yh.HTML),a.xml=a.xml||yh.XML;var c=e.normalizeLineEndings||vh;return r&&typeof r=="string"?s.parse(c(r),a,l):s.errorHandler.error("invalid doc source"),i.doc};function Mv(r,t,e){if(!r){if(t instanceof Vr)return t;r=t}var s={},i=r instanceof Function;e=e||{};function n(o){var a=r[o];!a&&i&&(a=r.length==2?function(u){r(o,u)}:r),s[o]=a&&function(u){a("[xmldom "+o+"] "+u+lo(e))}||function(){}}return n("warning"),n("error"),n("fatalError"),s}function Vr(){this.cdata=!1}function Je(r,t){t.lineNumber=r.lineNumber,t.columnNumber=r.columnNumber}Vr.prototype={startDocument:function(){this.doc=new Rv().createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(r,t,e,s){var i=this.doc,n=i.createElementNS(r,e||t),o=s.length;Ks(this,n),this.currentElement=n,this.locator&&Je(this.locator,n);for(var a=0;a=t+e||t?new java.lang.String(r,t,e)+"":r}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(r){Vr.prototype[r]=function(){return null}});function Ks(r,t){r.currentElement?r.currentElement.appendChild(t):r.doc.appendChild(t)}var gM=Ys.__DOMHandler=Vr,_M=Ys.normalizeLineEndings=vh,xM=Ys.DOMParser=Th,Sh=ee,bM=Yn.DOMImplementation=Sh.DOMImplementation,yM=Yn.XMLSerializer=Sh.XMLSerializer,Ov=Yn.DOMParser=Ys.DOMParser;const Eh={createCanvas:(r,t)=>new OffscreenCanvas(r!=null?r:0,t!=null?t:0),createImage:()=>new Image,getCanvasRenderingContext2D:()=>OffscreenCanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>globalThis.location.href,getFontFaceSet:()=>globalThis.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new Ov().parseFromString(r,"text/xml")};var Bv=Object.defineProperty,Gv=Object.defineProperties,Fv=Object.getOwnPropertyDescriptors,wh=Object.getOwnPropertySymbols,Iv=Object.prototype.hasOwnProperty,Uv=Object.prototype.propertyIsEnumerable,Ch=(r,t,e)=>t in r?Bv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Rh=(r,t)=>{for(var e in t||(t={}))Iv.call(t,e)&&Ch(r,e,t[e]);if(wh)for(var e of wh(t))Uv.call(t,e)&&Ch(r,e,t[e]);return r},kv=(r,t)=>Gv(r,Fv(t)),v=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(v||{});const co=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=kv(Rh({},t),{ref:r})}if(typeof r=="object")r=Rh({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},Wr=(r,t)=>{var e;return(e=co(r).priority)!=null?e:t},U={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(co).forEach(t=>{t.type.forEach(e=>{var s,i;return(i=(s=this._removeHandlers)[e])==null?void 0:i.call(s,t)})}),this},add(...r){return r.map(co).forEach(t=>{t.type.forEach(e=>{var s,i;const n=this._addHandlers,o=this._queue;n[e]?(i=n[e])==null||i.call(n,t):(o[e]=o[e]||[],(s=o[e])==null||s.push(t))})}),this},handle(r,t,e){var s;const i=this._addHandlers,n=this._removeHandlers;i[r]=t,n[r]=e;const o=this._queue;return o[r]&&((s=o[r])==null||s.forEach(a=>t(a)),delete o[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(r,t,e=-1){return this.handle(r,s=>{t.findIndex(i=>i.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((i,n)=>Wr(n.value,e)-Wr(i.value,e)))},s=>{const i=t.findIndex(n=>n.name===s.name);i!==-1&&t.splice(i,1)})},handleByList(r,t,e=-1){return this.handle(r,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((i,n)=>Wr(n,e)-Wr(i,e)))},s=>{const i=t.indexOf(s.ref);i!==-1&&t.splice(i,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}};class ho{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,s;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,s=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:n}=this._resizeTo;e=i,s=n}this.renderer.resize(e,s),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}ho.extension=v.Application;var ge=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(ge||{});class Zs{constructor(t,e=null,s=0,i=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=i}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Ph=class Gt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Zs(null,null,1/0),this.deltaMS=1/Gt.targetFPMS,this.elapsedMS=1/Gt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=ge.NORMAL){return this._addListener(new Zs(t,e,s))}addOnce(t,e,s=ge.NORMAL){return this._addListener(new Zs(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?ft.shared:new ft,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}po.extension=v.Application,U.add(ho),U.add(po);var Ct=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Ct||{});function Xt(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function Yr(r){return r.split("?")[0].split("#")[0]}function Lv(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Nv(r,t,e){return r.replace(new RegExp(Lv(t),"g"),e)}function $v(r,t){let e="",s=0,i=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a2){const u=e.lastIndexOf("/");if(u!==e.length-1){u===-1?(e="",s=0):(e=e.slice(0,u),s=e.length-1-e.lastIndexOf("/")),i=a,n=0;continue}}else if(e.length===2||e.length===1){e="",s=0,i=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",s=2)}else e.length>0?e+=`/${r.slice(i+1,a)}`:e=r.slice(i+1,a),s=a-i-1;i=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const yt={toPosix(r){return Nv(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){Xt(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(Xt(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const s=Yr(this.toPosix(t!=null?t:I.get().getBaseUrl())),i=Yr(this.toPosix(e!=null?e:this.rootname(s)));return r=this.toPosix(r),r.startsWith("/")?yt.join(i,r.slice(1)):this.isAbsolute(r)?r:this.join(s,r)},normalize(r){if(Xt(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const s=r.endsWith("/");return r=$v(r,!1),r.length>0&&s&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Xt(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){var t;if(r.length===0)return".";let e;for(let s=0;s0)if(e===void 0)e=i;else{const n=(t=r[s-1])!=null?t:"";this.joinExtensions.includes(this.extname(n).toLowerCase())?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(Xt(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let s=-1,i=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!i){s=a;break}}else i=!1;return s===-1?e?"/":this.isUrl(o)?n+r:n:e&&s===1?"//":n+r.slice(0,s)},rootname(r){Xt(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){Xt(r),t&&Xt(t),r=Yr(this.toPosix(r));let e=0,s=-1,i=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const u=r.charCodeAt(n);if(u===47){if(!i){e=n+1;break}}else a===-1&&(i=!1,a=n+1),o>=0&&(u===t.charCodeAt(o)?--o===-1&&(s=n):(o=-1,s=a))}return e===s?s=a:s===-1&&(s=r.length),r.slice(e,s)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!i){e=n+1;break}}else s===-1&&(i=!1,s=n+1);return s===-1?"":r.slice(e,s)},extname(r){Xt(r),r=Yr(this.toPosix(r));let t=-1,e=0,s=-1,i=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!i){e=o+1;break}continue}s===-1&&(i=!1,s=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||s===-1||n===0||n===1&&t===s-1&&t===e+1?"":r.slice(t,s)},parse(r){Xt(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=Yr(this.toPosix(r));let e=r.charCodeAt(0);const s=this.isAbsolute(r);let i;const n="";t.root=this.rootname(r),s||this.hasProtocol(r)?i=1:i=0;let o=-1,a=0,u=-1,l=!0,c=r.length-1,h=0;for(;c>=i;--c){if(e=r.charCodeAt(c),e===47){if(!l){a=c+1;break}continue}u===-1&&(l=!1,u=c+1),e===46?o===-1?o=c:h!==1&&(h=1):o!==-1&&(h=-1)}return o===-1||u===-1||h===0||h===1&&o===u-1&&o===a+1?u!==-1&&(a===0&&s?t.base=t.name=r.slice(1,u):t.base=t.name=r.slice(a,u)):(a===0&&s?(t.name=r.slice(1,o),t.base=r.slice(1,u)):(t.name=r.slice(a,o),t.base=r.slice(a,u)),t.ext=r.slice(o,u)),t.dir=this.dirname(r),n&&(t.dir=n+t.dir),t},sep:"/",delimiter:":",joinExtensions:[".html"]},Ut=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(s=>typeof s=="string"||e?t(s):s):r);function Dh(r,t,e,s,i){const n=t[e];for(let o=0;o{const o=n.substring(1,n.length-1).split(",");i.push(o)}),Dh(r,i,0,e,s)}else s.push(r);return s}const qr=r=>!Array.isArray(r);var Xv=Object.defineProperty,Hv=Object.defineProperties,jv=Object.getOwnPropertyDescriptors,Oh=Object.getOwnPropertySymbols,zv=Object.prototype.hasOwnProperty,Vv=Object.prototype.propertyIsEnumerable,Bh=(r,t,e)=>t in r?Xv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,tr=(r,t)=>{for(var e in t||(t={}))zv.call(t,e)&&Bh(r,e,t[e]);if(Oh)for(var e of Oh(t))Vv.call(t,e)&&Bh(r,e,t[e]);return r},Wv=(r,t)=>Hv(r,jv(t));class _e{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){var e,s,i;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(s=t.createBundleAssetId)!=null?s:this._createBundleAssetId,this._extractAssetIdFromBundle=(i=t.extractAssetIdFromBundle)!=null?i:this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return Ut(e||s,i=>typeof i=="string"?i:Array.isArray(i)?i.map(n=>{var o;return(o=n==null?void 0:n.src)!=null?o:n}):i!=null&&i.src?i.src:i,!0)}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let i=e;Array.isArray(e)||(i=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:tr({alias:n},o))),i.forEach(n=>{const o=n.src,a=n.alias;let u;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);s.push(l),u=[a,l]}else{const l=a.map(c=>this._createBundleAssetId(t,c));s.push(...l),u=[...a,...l]}this.add(Wv(tr({},n),{alias:u,src:o}))}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;Ut(e).forEach(i=>{const{src:n}=i;let{data:o,format:a,loadParser:u,parser:l}=i;const c=Ut(n).map(p=>typeof p=="string"?Mh(p):Array.isArray(p)?p:[p]),h=this.getAlias(i),d=[];c.forEach(p=>{p.forEach(f=>{var g,m,_,b;let x={};if(typeof f!="object"){x.src=f;for(let y=0;y{this._assetMap[p]=d})})}resolveBundle(t){const e=qr(t);t=Ut(t);const s={};return t.forEach(i=>{const n=this._bundles[i];if(n){const o=this.resolve(n),a={};for(const u in o){const l=o[u];a[this._extractAssetIdFromBundle(i,u)]=l}s[i]=a}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const i in e)s[i]=e[i].src;return s}return e.src}resolve(t){const e=qr(t);t=Ut(t);const s={};return t.forEach(i=>{if(!this._resolverHash[i])if(this._assetMap[i]){let n=this._assetMap[i];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(u=>{const l=n.filter(c=>c[a]?c[a]===u:!1);l.length&&(n=l)})}),this._resolverHash[i]=n[0]}else this._resolverHash[i]=this._buildResolvedAsset({alias:[i],src:i},{});s[i]=this._resolverHash[i]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;en.params.format.includes(s.format));if(i)return i}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var s,i;const{aliases:n,data:o,loadParser:a,parser:u,format:l}=e;return(this._basePath||this._rootPath)&&(t.src=yt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(s=n!=null?n:t.alias)!=null?s:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=tr(tr({},o||{}),t.data),t.loadParser=a!=null?a:t.loadParser,t.parser=u!=null?u:t.parser,t.format=(i=l!=null?l:t.format)!=null?i:Gh(t.src),t}}_e.RETINA_PREFIX=/@([0-9\.]+)x/;function Gh(r){return r.split(".").pop().split("?").shift().split("#").shift()}const Qs=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};var fo={exports:{}},vM=fo.exports;(function(r){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function i(u,l,c){this.fn=u,this.context=l,this.once=c||!1}function n(u,l,c,h,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var p=new i(c,h||u,d),f=e?e+l:l;return u._events[f]?u._events[f].fn?u._events[f]=[u._events[f],p]:u._events[f].push(p):(u._events[f]=p,u._eventsCount++),u}function o(u,l){--u._eventsCount===0?u._events=new s:delete u._events[l]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,h;if(this._eventsCount===0)return l;for(h in c=this._events)t.call(c,h)&&l.push(e?h.slice(1):h);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var d=0,p=h.length,f=new Array(p);dPe[r],uY:r=>De[r],vX:r=>Me[r],vY:r=>Oe[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>go[r][t],sub:(r,t)=>go[r][k.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?k.S:k.N:Math.abs(t)*2<=Math.abs(r)?r>0?k.E:k.W:t>0?r>0?k.SE:k.SW:r>0?k.NE:k.NW,matrixAppendRotationInv:(r,t,e=0,s=0)=>{const i=kh[k.inv(t)];i.tx=e,i.ty=s,r.append(i)},transformRectCoords:(r,t,e,s)=>{const{x:i,y:n,width:o,height:a}=r,{x:u,y:l,width:c,height:h}=t;return e===k.E?(s.set(i+u,n+l,o,a),s):e===k.S?s.set(c-n-a+u,i+l,a,o):e===k.W?s.set(c-i-o+u,h-n-a+l,o,a):e===k.N?s.set(n+u,h-i-o+l,a,o):s.set(i+u,n+l,o,a)}},ti=[new nt,new nt,new nt,new nt];class j{constructor(t=0,e=0,s=0,i=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(i)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new j(0,0,0,0)}clone(){return new j(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t=this.y&&e=h&&t<=d&&e>=p&&e<=f&&!(t>g&&t_&&et.right?t.right:this.right)<=D)return!1;const R=this.yt.bottom?t.bottom:this.bottom)>R}const s=this.left,i=this.right,n=this.top,o=this.bottom;if(i<=s||o<=n)return!1;const a=ti[0].set(t.left,t.top),u=ti[1].set(t.left,t.bottom),l=ti[2].set(t.right,t.top),c=ti[3].set(t.right,t.bottom);if(l.x<=a.x||u.y<=a.y)return!1;const h=Math.sign(e.a*e.d-e.b*e.c);if(h===0||(e.apply(a,a),e.apply(u,u),e.apply(l,l),e.apply(c,c),Math.max(a.x,u.x,l.x,c.x)<=s||Math.min(a.x,u.x,l.x,c.x)>=i||Math.max(a.y,u.y,l.y,c.y)<=n||Math.min(a.y,u.y,l.y,c.y)>=o))return!1;const d=h*(u.y-a.y),p=h*(a.x-u.x),f=d*s+p*n,g=d*i+p*n,m=d*s+p*o,_=d*i+p*o;if(Math.max(f,g,m,_)<=d*a.x+p*a.y||Math.min(f,g,m,_)>=d*c.x+p*c.y)return!1;const b=h*(a.y-l.y),x=h*(l.x-a.x),y=b*s+x*n,A=b*i+x*n,T=b*s+x*o,S=b*i+x*o;return!(Math.max(y,A,T,S)<=b*a.x+x*a.y||Math.min(y,A,T,S)>=b*c.x+x*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),i=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=i,this.height=Math.max(n-i,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,i=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=i-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),i=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=i,this.height=n-i,this}getBounds(t){return t||(t=new j),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,s=t.y,i=t.x+t.width,n=t.y+t.height;return e>=this.x&&e=this.y&&s=this.x&&i=this.y&&n{};function Be(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function xo(r){return!(r&r-1)&&!!r}function Jv(r){let t=(r>65535?1:0)<<4;r>>>=t;let e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function Ht(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var t1=Object.defineProperty,Lh=Object.getOwnPropertySymbols,e1=Object.prototype.hasOwnProperty,r1=Object.prototype.propertyIsEnumerable,Nh=(r,t,e)=>t in r?t1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$h=(r,t)=>{for(var e in t||(t={}))e1.call(t,e)&&Nh(r,e,t[e]);if(Lh)for(var e of Lh(t))r1.call(t,e)&&Nh(r,e,t[e]);return r};const Xh=Object.create(null);function s1(r){const t=Xh[r];return t===void 0&&(Xh[r]=Y("resource")),t}const Hh=class wy extends Rt{constructor(t={}){var e,s,i,n,o,a,u;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=$h($h({},wy.defaultOptions),t),this.addressMode=t.addressMode,this.addressModeU=(e=t.addressModeU)!=null?e:this.addressModeU,this.addressModeV=(s=t.addressModeV)!=null?s:this.addressModeV,this.addressModeW=(i=t.addressModeW)!=null?i:this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=(n=t.magFilter)!=null?n:this.magFilter,this.minFilter=(o=t.minFilter)!=null?o:this.minFilter,this.mipmapFilter=(a=t.mipmapFilter)!=null?a:this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=(u=t.maxAnisotropy)!=null?u:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=s1(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Hh.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Pt=Hh;var i1=Object.defineProperty,jh=Object.getOwnPropertySymbols,n1=Object.prototype.hasOwnProperty,o1=Object.prototype.propertyIsEnumerable,zh=(r,t,e)=>t in r?i1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vh=(r,t)=>{for(var e in t||(t={}))n1.call(t,e)&&zh(r,e,t[e]);if(jh)for(var e of jh(t))o1.call(t,e)&&zh(r,e,t[e]);return r};const Wh=class Cy extends Rt{constructor(t={}){var e,s,i;super(),this.options=t,this.uid=Y("textureSource"),this._resourceType="textureSource",this._resourceId=Y("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t=Vh(Vh({},Cy.defaultOptions),t),this.label=(e=t.label)!=null?e:"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&(s=this.resourceWidth)!=null?s:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&(i=this.resourceHeight)!=null?i:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new Pt(Ht(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=Y("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s||(s=this._resolution),t||(t=this.width),e||(e=this.height);const i=Math.round(t*s),n=Math.round(e*s);return this.width=i/s,this.height=n/s,this._resolution=s,this.pixelWidth===i&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=i,this.pixelHeight=n,this.emit("resize",this),this._resourceId=Y("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=xo(this.pixelWidth)&&xo(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Wh.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let K=Wh;var a1=Object.defineProperty,u1=Object.defineProperties,l1=Object.getOwnPropertyDescriptors,Yh=Object.getOwnPropertySymbols,c1=Object.prototype.hasOwnProperty,h1=Object.prototype.propertyIsEnumerable,qh=(r,t,e)=>t in r?a1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,d1=(r,t)=>{for(var e in t||(t={}))c1.call(t,e)&&qh(r,e,t[e]);if(Yh)for(var e of Yh(t))h1.call(t,e)&&qh(r,e,t[e]);return r},p1=(r,t)=>u1(r,l1(t));class ei extends K{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super(p1(d1({},t),{resource:e,format:s})),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}ei.extension=v.TextureSource;const Kh=new M;class bo{constructor(t,e){this.mapCoord=new M,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e=="undefined"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let i=0;i{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Is.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=Is.BATCH_SIZE;for(;e-t{this._batchIndex*Is.BATCH_SIZE{s[i]=t}),Object.keys(t.textures).forEach(i=>{s[`${t.cachePrefix}${i}`]=t.textures[i]}),!e){const i=yt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=Qh([`${i}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const Jh={extension:v.Asset,cache:{test:r=>r instanceof yo,getCacheableAssets:(r,t)=>Qh(r,t,!1)},resolver:{extension:{type:v.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),s=t.pop();return e==="json"&&f1.includes(s)},parse:r=>{var t,e;const s=r.split(".");return{resolution:parseFloat((e=(t=_e.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s[s.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:v.LoadParser,priority:Ct.Normal,name:"spritesheetLoader"},async testParse(r,t){return yt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var s,i,n;const{texture:o,imageFilename:a,textureOptions:u,cachePrefix:l}=(s=t==null?void 0:t.data)!=null?s:{};let c=yt.dirname(t.src);c&&c.lastIndexOf("/")!==c.length-1&&(c+="/");let h;if(o instanceof C)h=o;else{const f=Qs(c+(a!=null?a:r.meta.image),t.src);h=(await e.load([{src:f,data:u}]))[f]}const d=new yo({texture:h.source,data:r,cachePrefix:l});await d.parse();const p=(i=r==null?void 0:r.meta)==null?void 0:i.related_multi_packs;if(Array.isArray(p)){const f=[];for(const m of p){if(typeof m!="string")continue;let _=c+m;(n=t.data)!=null&&n.ignoreMultiPack||(_=Qs(_,t.src),f.push(e.load({src:_,data:{textureOptions:u,ignoreMultiPack:!0}})))}const g=await Promise.all(f);d.linkedSheets=g,g.forEach(m=>{m.linkedSheets=[d].concat(d.linkedSheets.filter(_=>_!==m))})}return d},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};U.add(Jh);class q{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new q(t!=null?t:this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}function vo(r,t,e){const{width:s,height:i}=e.orig,n=e.trim;if(n){const o=n.width,a=n.height;r.minX=n.x-t._x*s,r.maxX=r.minX+o,r.minY=n.y-t._y*i,r.maxY=r.minY+a}else r.minX=-t._x*s,r.maxX=r.minX+s,r.minY=-t._y*i,r.maxY=r.minY+i}const td=new M;class ot{constructor(t=1/0,e=1/0,s=-1/0,i=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=td,this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new j);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=td,this}set(t,e,s,i){this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}addFrame(t,e,s,i,n){n||(n=this.matrix);const o=n.a,a=n.b,u=n.c,l=n.d,c=n.tx,h=n.ty;let d=this.minX,p=this.minY,f=this.maxX,g=this.maxY,m=o*t+u*e+c,_=a*t+l*e+h;mf&&(f=m),_>g&&(g=_),m=o*s+u*e+c,_=a*s+l*e+h,mf&&(f=m),_>g&&(g=_),m=o*t+u*i+c,_=a*t+l*i+h,mf&&(f=m),_>g&&(g=_),m=o*s+u*i+c,_=a*s+l*i+h,mf&&(f=m),_>g&&(g=_),this.minX=d,this.minY=p,this.maxX=f,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxXthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*e+u*n+c,p=a*e+l*n+h,this.minX=dthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*i+u*n+c,p=a*i+l*n+h,this.minX=dthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,i){return this.minXe&&(this.maxX=e),this.minYi&&(this.maxY=i),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new ot(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,s,i){let n=this.minX,o=this.minY,a=this.maxX,u=this.maxY;i||(i=this.matrix);const l=i.a,c=i.b,h=i.c,d=i.d,p=i.tx,f=i.ty;for(let g=e;ga?b:a,u=x>u?x:u}this.minX=n,this.minY=o,this.maxX=a,this.maxY=u}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var m1={grad:.9,turn:360,rad:360/(2*Math.PI)},oe=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},ut=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},kt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},ed=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},rd=function(r){return{r:kt(r.r,0,255),g:kt(r.g,0,255),b:kt(r.b,0,255),a:kt(r.a)}},To=function(r){return{r:ut(r.r),g:ut(r.g),b:ut(r.b),a:ut(r.a,3)}},g1=/^#([0-9a-f]{3,8})$/i,ri=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},sd=function(r){var t=r.r,e=r.g,s=r.b,i=r.a,n=Math.max(t,e,s),o=n-Math.min(t,e,s),a=o?n===t?(e-s)/o:n===e?2+(s-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:i}},id=function(r){var t=r.h,e=r.s,s=r.v,i=r.a;t=t/360*6,e/=100,s/=100;var n=Math.floor(t),o=s*(1-e),a=s*(1-(t-n)*e),u=s*(1-(1-t+n)*e),l=n%6;return{r:255*[s,a,o,o,u,s][l],g:255*[u,s,s,a,o,o][l],b:255*[o,o,u,s,s,a][l],a:i}},nd=function(r){return{h:ed(r.h),s:kt(r.s,0,100),l:kt(r.l,0,100),a:kt(r.a)}},od=function(r){return{h:ut(r.h),s:ut(r.s),l:ut(r.l),a:ut(r.a,3)}},ad=function(r){return id((e=(t=r).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},Zr=function(r){return{h:(t=sd(r)).h,s:(i=(200-(e=t.s))*(s=t.v)/100)>0&&i<200?e*s/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,e,s,i},_1=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,x1=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,b1=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y1=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ao={string:[[function(r){var t=g1.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?ut(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?ut(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=b1.exec(r)||y1.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:rd({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=_1.exec(r)||x1.exec(r);if(!t)return null;var e,s,i=nd({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(m1[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return ad(i)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,s=r.b,i=r.a,n=i===void 0?1:i;return oe(t)&&oe(e)&&oe(s)?rd({r:Number(t),g:Number(e),b:Number(s),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,s=r.l,i=r.a,n=i===void 0?1:i;if(!oe(t)||!oe(e)||!oe(s))return null;var o=nd({h:Number(t),s:Number(e),l:Number(s),a:Number(n)});return ad(o)},"hsl"],[function(r){var t=r.h,e=r.s,s=r.v,i=r.a,n=i===void 0?1:i;if(!oe(t)||!oe(e)||!oe(s))return null;var o=function(a){return{h:ed(a.h),s:kt(a.s,0,100),v:kt(a.v,0,100),a:kt(a.a)}}({h:Number(t),s:Number(e),v:Number(s),a:Number(n)});return id(o)},"hsv"]]},ud=function(r,t){for(var e=0;e=.5},r.prototype.toHex=function(){return t=To(this.rgba),e=t.r,s=t.g,i=t.b,o=(n=t.a)<1?ri(ut(255*n)):"","#"+ri(e)+ri(s)+ri(i)+o;var t,e,s,i,n,o},r.prototype.toRgb=function(){return To(this.rgba)},r.prototype.toRgbString=function(){return t=To(this.rgba),e=t.r,s=t.g,i=t.b,(n=t.a)<1?"rgba("+e+", "+s+", "+i+", "+n+")":"rgb("+e+", "+s+", "+i+")";var t,e,s,i,n},r.prototype.toHsl=function(){return od(Zr(this.rgba))},r.prototype.toHslString=function(){return t=od(Zr(this.rgba)),e=t.h,s=t.s,i=t.l,(n=t.a)<1?"hsla("+e+", "+s+"%, "+i+"%, "+n+")":"hsl("+e+", "+s+"%, "+i+"%)";var t,e,s,i,n},r.prototype.toHsv=function(){return t=sd(this.rgba),{h:ut(t.h),s:ut(t.s),v:ut(t.v),a:ut(t.a,3)};var t},r.prototype.invert=function(){return Yt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),Yt(So(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),Yt(So(this.rgba,-t))},r.prototype.grayscale=function(){return Yt(So(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),Yt(cd(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),Yt(cd(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?Yt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):ut(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=Zr(this.rgba);return typeof t=="number"?Yt({h:t,s:e.s,l:e.l,a:e.a}):ut(e.h)},r.prototype.isEqual=function(t){return this.toHex()===Yt(t).toHex()},r}(),Yt=function(r){return r instanceof si?r:new si(r)},hd=[],v1=function(r){r.forEach(function(t){hd.indexOf(t)<0&&(t(si,Ao),hd.push(t))})},AM=function(){return new si({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function T1(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var i in e)s[e[i]]=i;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,u,l=s[this.toHex()];if(l)return l;if(o!=null&&o.closest){var c=this.toRgb(),h=1/0,d="black";if(!n.length)for(var p in e)n[p]=new r(e[p]).toRgb();for(var f in e){var g=(a=c,u=n[f],Math.pow(a.r-u.r,2)+Math.pow(a.g-u.g,2)+Math.pow(a.b-u.b,2));gt in r?A1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,w1=(r,t)=>{for(var e in t||(t={}))S1.call(t,e)&&pd(r,e,t[e]);if(dd)for(var e of dd(t))E1.call(t,e)&&pd(r,e,t[e]);return r};v1([T1]);const er=class Us{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof Us)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?w1({},t):t}_isSourceEqual(t,e){const s=typeof t;if(s!==typeof e)return!1;if(s==="number"||s==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((i,n)=>i===e[n]);if(t!==null&&e!==null){const i=Object.keys(t),n=Object.keys(e);return i.length!==n.length?!1:i.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,s,i]=this._components;return{r:t,g:e,b:s,a:i}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,i]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(i*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,s,i,n]=this._components;return t[0]=e,t[1]=s,t[2]=i,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,s,i]=this._components;return t[0]=e,t[1]=s,t[2]=i,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,i,n]=Us._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=i,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,i=this._int>>8&255,n=this._int&255;return e&&(s=s*t+.5|0,i=i*t+.5|0,n=n*t+.5|0),(t*255<<24)+(s<<16)+(i<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,s,i,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,s=(o>>8&255)/255,i=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,i,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,i,n=255]=t,e/=255,s/=255,i/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Us.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Yt(t);o.isValid()&&({r:e,g:s,b:i,a:n}=o.rgba,e/=255,s/=255,i/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=i,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((i,n)=>{t[n]=Math.min(Math.max(i,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Us||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};er.shared=new er,er._temp=new er,er.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let X=er;const fd={cullArea:null,cullable:!1,cullableChildren:!0};class ii{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e0?s=this._pool[--this._index]:s=new this._classType,(e=s.init)==null||e.call(s,t),s}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}class md{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new ii(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const lt=new md,gd={get isCachedAsTexture(){var r;return!!((r=this.renderGroup)!=null&&r.isCachedAsTexture)},cacheAsTexture(r){typeof r=="boolean"&&r===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(r===!0?{}:r))},updateCacheTexture(){var r;(r=this.renderGroup)==null||r.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(r){this.cacheAsTexture(r)}};function _d(r,t,e){const s=r.length;let i;if(t>=s||e===0)return;e=t+e>s?s-t:e;const n=s-e;for(i=t;i0&&i<=s){for(let a=s-1;a>=r;a--){const u=this.children[a];u&&(n.push(u),u.parent=null)}_d(this.children,r,s);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(n);for(let a=0;a0&&this._didViewChangeTick++,n}else if(i===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const t=this.getChildAt(r);return this.removeChild(t)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,t)},getChildIndex(r){const t=this.children.indexOf(r);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(r,t){const{children:e}=this;if(t<0||t>e.length)throw new Error(`${r}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(r.parent){const i=r.parent.children.indexOf(r);if(r.parent===this&&i===t)return r;i!==-1&&r.parent.children.splice(i,1)}t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(r),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",r,this,t),r.emit("added",this),r},swapChildren(r,t){if(r===t)return;const e=this.getChildIndex(r),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=r;const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(t=>this.reparentChildAt(t,this.children.length)),r[0])},reparentChildAt(r,t){if(r.parent===this)return this.setChildIndex(r,t),r;const e=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),r.setFromMatrix(e),r},replaceChild(r,t){r.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(r)),t.setFromMatrix(r.localTransform),t.updateLocalTransform(),this.removeChild(r)}},bd={collectRenderables(r,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,t,e))},collectRenderablesSimple(r,t,e){const s=this.children,i=s.length;for(let n=0;n=0;i--){const n=this.effects[i];s[n.pipe].pop(n,this,r)}}};class Qr{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;et in r?C1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ad=(r,t)=>{for(var e in t||(t={}))R1.call(t,e)&&Td(r,e,t[e]);if(vd)for(var e of vd(t))P1.call(t,e)&&Td(r,e,t[e]);return r};const Sd={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0)},addEffect(r){this.effects.indexOf(r)===-1&&(this.effects.push(r),this.effects.sort((t,e)=>t.priority-e.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){const t=this.effects.indexOf(r);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){const t=this._maskEffect;(t==null?void 0:t.mask)!==r&&(t&&(this.removeEffect(t),ni.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=ni.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions=Ad(Ad({},this._maskOptions),r),r.mask&&(this.mask=r.mask),this._markStructureAsChanged()},set filters(r){var t;!Array.isArray(r)&&r&&(r=[r]);const e=this._filterEffect||(this._filterEffect=new Qr);r=r;const s=(r==null?void 0:r.length)>0,i=((t=e.filters)==null?void 0:t.length)>0,n=s!==i;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),n&&(s?this.addEffect(e):(this.removeEffect(e),e.filters=r!=null?r:null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new Qr),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},Ed={label:null,get name(){return this.label},set name(r){this.label=r},getChildByName(r,t=!1){return this.getChildByLabel(r,t)},getChildByLabel(r,t=!1){const e=this.children;for(let s=0;s>16&255,s=r>>8&255,i=r&255,n=t>>16&255,o=t>>8&255,a=t&255,u=e*n/255|0,l=s*o/255|0,c=i*a/255|0;return(u<<16)+(l<<8)+c}const Rd=16777215;function ts(r,t){return r===Rd?t:t===Rd?r:wo(r,t)}function rr(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const Pd={getGlobalAlpha(r){if(r)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(r=new M,t){if(t)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const e=oi(this,dt.get().identity());return r.appendFrom(this.localTransform,e),dt.return(e),r},getGlobalTint(r){if(r)return this.renderGroup?rr(this.renderGroup.worldColor):this.parentRenderGroup?rr(ts(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=ts(t,e.localColor),e=e.parent;return rr(t)}};function ai(r,t,e){return t.clear(),e||(e=M.IDENTITY),Dd(r,t,e,r,!0),t.isValid||t.set(0,0,0,0),t}function Dd(r,t,e,s,i){var n,o;let a;if(i)a=dt.get(),a=e.copyTo(a);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const c=r.localTransform;a=dt.get(),a.appendFrom(c,e)}const u=t,l=!!r.effects.length;if(l&&(t=qt.get().clear()),r.boundsArea)t.addRect(r.boundsArea,a);else{r.renderPipeId&&(t.matrix=a,t.addBounds(r.bounds));const c=r.children;for(let h=0;ht in r?B1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,k1=(r,t)=>{for(var e in t||(t={}))I1.call(t,e)&&Id(r,e,t[e]);if(Fd)for(var e of Fd(t))U1.call(t,e)&&Id(r,e,t[e]);return r},L1=(r,t)=>G1(r,F1(t));let N1=0;class Ud{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new Pt(this.textureOptions)}createTexture(t,e,s){const i=new K(L1(k1({},this.textureOptions),{width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!1}));return new C({source:i,label:`texturePool_${N1++}`})}getOptimalTexture(t,e,s=1,i){let n=Math.ceil(t*s-1e-6),o=Math.ceil(e*s-1e-6);n=Be(n),o=Be(o);const a=(n<<17)+(o<<1)+(i?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let u=this._texturePool[a].pop();return u||(u=this.createTexture(n,o,i)),u.source._resolution=s,u.source.width=n/s,u.source.height=o/s,u.source.pixelWidth=n,u.source.pixelHeight=o,u.frame.x=0,u.frame.y=0,u.frame.width=t,u.frame.height=e,u.updateUvs(),this._poolKeyHash[u.uid]=a,u}getSameSizeTexture(t,e=!1){const s=t.source;return this.getOptimalTexture(t.width,t.height,s._resolution,e)}returnTexture(t,e=!1){const s=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[s].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const s=this._texturePool[e];if(s)for(let i=0;i-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;ethis.addChild(i)),(s=t.parent)==null||s.addChild(this)}static mixin(t){U.mixin(et,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(t.length>1){for(let i=0;i1){for(let i=0;i-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,s),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=lt.get(kd,this),this.groupTransform=M.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),lt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new M),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*Ih}set angle(t){this.rotation=t*Uh}get pivot(){return this._pivot===Do&&(this._pivot=new q(this,0,0)),this._pivot}set pivot(t){this._pivot===Do&&(this._pivot=new q(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Po&&(this._skew=new q(this,0,0)),this._skew}set skew(t){this._skew===Po&&(this._skew=new q(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Mo&&(this._scale=new q(this,1,1)),this._scale}set scale(t){this._scale===Mo&&(this._scale=new q(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===Oo&&(this._origin=new q(this,0,0)),this._origin}set origin(t){this._origin===Oo&&(this._origin=new q(this,0,0)),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){var s;const i=this.getLocalBounds();typeof t=="object"?(e=(s=t.height)!=null?s:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,i=this._pivot,n=this._origin,o=this._position,a=s._x,u=s._y,l=i._x,c=i._y,h=-n._x,d=-n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*u,e.d=this._sy*u,e.tx=o._x-(l*e.a+c*e.c)+(h*e.a+d*e.c)-h,e.ty=o._y-(l*e.b+c*e.d)+(h*e.b+d*e.d)-d}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=es,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=X.shared.setValue(t!=null?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=es,this._onUpdate())}get tint(){return rr(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=li,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=sr,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=sr,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=sr,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var e;if(this.destroyed)return;this.destroyed=!0;let s;if(this.children.length&&(s=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&s)for(let i=0;i=e.minX&&s<=e.maxX&&i>=e.minY&&i<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){var e,s;super.destroy(t),this._bounds=null;for(const i in this._gpuData)(s=(e=this._gpuData[i]).destroy)==null||s.call(e);this._gpuData=null}collectRenderablesSimple(t,e,s){const{renderPipes:i}=e;i.blendMode.setBlendMode(this,this.groupBlendMode,t),i[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=!1;const n=this.children,o=n.length;for(let a=0;at in r?X1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,H1=(r,t)=>{for(var e in t||(t={}))Ld.call(t,e)&&$d(r,e,t[e]);if(ci)for(var e of ci(t))Nd.call(t,e)&&$d(r,e,t[e]);return r},j1=(r,t)=>{var e={};for(var s in r)Ld.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&ci)for(var s of ci(r))t.indexOf(s)<0&&Nd.call(r,s)&&(e[s]=r[s]);return e};class zt extends ae{constructor(t=C.EMPTY){t instanceof C&&(t={texture:t});const e=t,{texture:s=C.EMPTY,anchor:i,roundPixels:n,width:o,height:a}=e,u=j1(e,["texture","anchor","roundPixels","width","height"]);super(H1({label:"Sprite"},u)),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new q({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:s.defaultAnchor&&(this.anchor=s.defaultAnchor),this.texture=s,this.allowChildren=!1,this.roundPixels=n!=null?n:!1,o!==void 0&&(this.width=o),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof C?new zt(t):new zt(C.from(t,e))}set texture(t){t||(t=C.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return vo(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,s=this._bounds,{width:i,height:n}=e.orig;s.minX=-t._x*i,s.maxX=s.minX+i,s.minY=-t._y*n,s.maxY=s.minY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null,this._gpuData=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){var s;typeof t=="object"?(e=(s=t.height)!=null?s:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const z1=new ot;function hi(r,t,e){const s=z1;r.measurable=!0,Jr(r,e,s),t.addBoundsMask(s),r.measurable=!1}function di(r,t,e){const s=qt.get();r.measurable=!0;const i=dt.get().identity(),n=Xd(r,e,i);ai(r,s,n),r.measurable=!1,t.addBoundsMask(s),dt.return(i),qt.return(s)}function Xd(r,t,e){return r&&r!==t&&(Xd(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class Bo{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof zt),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){this.inverse||hi(this.mask,t,e)}addLocalBounds(t,e){di(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof zt}}Bo.extension=v.MaskEffect;class Go{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}Go.extension=v.MaskEffect;class Fo{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){hi(this.mask,t,e)}addLocalBounds(t,e){di(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof et}}Fo.extension=v.MaskEffect;class Kt extends K{constructor(t){t.resource||(t.resource=I.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,s=this._resolution){const i=super.resize(t,e,s);return i&&this.resizeCanvas(),i}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Kt.extension=v.TextureSource;class xe extends K{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}xe.extension=v.TextureSource;let Io;async function Uo(){return Io!=null||(Io=(async()=>{var r;const t=I.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!e)return"premultiply-alpha-on-upload";const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(i),t.deleteTexture(s),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Io}var V1=Object.defineProperty,W1=Object.defineProperties,Y1=Object.getOwnPropertyDescriptors,Hd=Object.getOwnPropertySymbols,q1=Object.prototype.hasOwnProperty,K1=Object.prototype.propertyIsEnumerable,jd=(r,t,e)=>t in r?V1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ko=(r,t)=>{for(var e in t||(t={}))q1.call(t,e)&&jd(r,e,t[e]);if(Hd)for(var e of Hd(t))K1.call(t,e)&&jd(r,e,t[e]);return r},Z1=(r,t)=>W1(r,Y1(t));const pi=class Ry extends K{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=ko(ko({},Ry.defaultOptions),t),this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=(e=t.alphaMode)!=null?e:"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=ft.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await Uo(),this._load=new Promise((s,i)=>{this.isValid?s(this):(this._resolve=s,this._reject=i,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(ft.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(ft.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ft.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};pi.extension=v.TextureSource,pi.defaultOptions=Z1(ko({},K.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),pi.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let ir=pi,Q1=class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){return this._cache.get(t)}set(t,e){const s=Ut(t);let i;for(let u=0;u{n.set(u,e)});const o=[...n.keys()],a={cacheKeys:o,keys:s};s.forEach(u=>{this._cacheMap.set(u,a)}),o.forEach(u=>{const l=i?i[u]:e;this._cache.has(u)&&this._cache.get(u),this._cache.set(u,n.get(u))})}remove(t){if(!this._cacheMap.has(t))return;const e=this._cacheMap.get(t);e.cacheKeys.forEach(s=>{this._cache.delete(s)}),e.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}};const z=new Q1,Lo=[];U.handleByList(v.TextureSource,Lo);function J1(r={}){return No(r)}function No(r={}){const t=r&&r.resource,e=t?r.resource:r,s=t?r:{resource:r};for(let i=0;i{z.has(s)&&z.remove(s)}),t||z.set(s,n),n}function Vd(r,t=!1){return typeof r=="string"?z.get(r):r instanceof K?new C({source:r}):zd(r,t)}C.from=Vd,K.from=No,U.add(Bo,Go,Fo,ir,xe,Kt,ei);class Zt{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const i=t[s];this.setResource(i,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){var s,i;const n=this.resources[e];t!==n&&(n&&((s=t.off)==null||s.call(t,"change",this.onResourceChange,this)),(i=t.on)==null||i.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const s in e)e[s]._touched=t}destroy(){var t;const e=this.resources;for(const s in e){const i=e[s];(t=i.off)==null||t.call(i,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const s in e)e[s]===t&&(e[s]=null)}else this._updateKey()}}const Wd={};function fi(r,t,e){let s=2166136261;for(let i=0;i>>=0;return Wd[s]||tT(r,t,s,e)}function tT(r,t,e,s){const i={};let n=0;for(let a=0;a0){const n=new Uint8Array(r,e*8,i);new Uint8Array(t,e*8,i).set(n)}}const Kd={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var J=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",r[r.NONE=5]="NONE",r))(J||{});function nr(r,t){return t.alphaMode==="no-premultiply-alpha"&&Kd[r]||r}let rs;function $o(){return(!rs||rs!=null&&rs.isContextLost())&&(rs=I.get().createCanvas().getContext("webgl",{})),rs}const sT=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` `);function iT(r){let t="";for(let e=0;e0&&(t+=` else `),et in r?nT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ep=(r,t)=>{for(var e in t||(t={}))oT.call(t,e)&&tp(r,e,t[e]);if(Jd)for(var e of Jd(t))aT.call(t,e)&&tp(r,e,t[e]);return r};class rp{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Qd,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const sp=[];let Ho=0;function ip(){return Ho>0?sp[--Ho]:new rp}function np(r){sp[Ho++]=r}let ss=0;const op=class Py{constructor(t){this.uid=Y("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t=ep(ep({},Py.defaultOptions),t),t.maxTextures||(qd("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=Zd());const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:i}=t;this.attributeBuffer=new Ge(s*4),this.indexBuffer=new Uint16Array(i),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;tthis.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const u=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,c=this.indexBuffer;let h=this._batchIndexSize,d=this._batchIndexStart,p="startBatch";const f=this.maxTextures;for(let g=this.elementStart;g=f||x)&&(this._finishBatch(s,d,h-d,i,o,a,t,p),p="renderBatch",d=h,o=b,a=m.topology,s=ip(),i=s.textures,i.clear(),++ss),m._textureId=_._textureBindLocation=i.count,i.ids[_.uid]=i.count,i.textures[i.count++]=_,m._batch=s,h+=m.indexSize,m.packAsQuad?(this.packQuadAttributes(m,u,l,m._attributeStart,m._textureId),this.packQuadIndex(c,m._indexStart,m._attributeStart/this.vertexSize)):(this.packAttributes(m,u,l,m._attributeStart,m._textureId),this.packIndex(m,c,m._indexStart,m._attributeStart/this.vertexSize))}i.count>0&&(this._finishBatch(s,d,h-d,i,o,a,t,p),d=h,++ss),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=h}_finishBatch(t,e,s,i,n,o,a,u){t.gpuBindGroup=null,t.bindGroup=null,t.action=u,t.batcher=this,t.textures=i,t.blendMode=n,t.topology=o,t.start=e,t.size=s,++ss,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new Ge(e);mi(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const i=s>65535?new Uint32Array(s):new Uint16Array(s);if(i.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n(r[r.MAP_READ=1]="MAP_READ",r[r.MAP_WRITE=2]="MAP_WRITE",r[r.COPY_SRC=4]="COPY_SRC",r[r.COPY_DST=8]="COPY_DST",r[r.INDEX=16]="INDEX",r[r.VERTEX=32]="VERTEX",r[r.UNIFORM=64]="UNIFORM",r[r.STORAGE=128]="STORAGE",r[r.INDIRECT=256]="INDIRECT",r[r.QUERY_RESOLVE=512]="QUERY_RESOLVE",r[r.STATIC=1024]="STATIC",r))($||{});class vt extends Rt{constructor(t){let{data:e,size:s}=t;const{usage:i,label:n,shrinkToFit:o}=t;super(),this.uid=Y("buffer"),this._resourceType="buffer",this._resourceId=Y("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s!=null||(s=e==null?void 0:e.byteLength);const a=!!e;this.descriptor={size:s,usage:i,mappedAtCreation:a,label:n},this.shrinkToFit=o!=null?o:!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&$.STATIC)}set static(t){t?this.descriptor.usage|=$.STATIC:this.descriptor.usage&=~$.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const i=this._data;if(this._data=t,this._dataInt32=null,!i||i.length!==t.length){!this.shrinkToFit&&i&&t.byteLengtha&&(a=p),f>u&&(u=f),pe.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const lT=new Float32Array(1),cT=new Uint32Array(1);class lp extends Fe{constructor(){const t=new vt({data:lT,label:"attribute-batch-buffer",usage:$.VERTEX|$.COPY_DST,shrinkToFit:!1}),e=new vt({data:cT,label:"index-batch-buffer",usage:$.INDEX|$.COPY_DST,shrinkToFit:!1}),s=6*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:s,offset:0},aUV:{buffer:t,format:"float32x2",stride:s,offset:2*4},aColor:{buffer:t,format:"unorm8x4",stride:s,offset:4*4},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:s,offset:5*4}},indexBuffer:e})}}const zo=Object.create(null),cp=Object.create(null);function ar(r,t){let e=cp[r];return e===void 0&&(zo[t]===void 0&&(zo[t]=1),cp[r]=e=zo[t]++),e}let gi;function hp(){if(!gi){gi="mediump";const r=$o();r&&r.getShaderPrecisionFormat&&(gi=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return gi}function dp(r,t,e){return t?r:e?(r=r.replace("out vec4 finalColor;",""),` #ifdef GL_ES // This checks if it is WebGL1 #define in varying #define finalColor gl_FragColor #define texture texture2D #endif ${r} `):` #ifdef GL_ES // This checks if it is WebGL1 #define in attribute #define out varying #endif ${r} `}function pp(r,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let i=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return i==="highp"&&s!=="highp"&&(i="mediump"),`precision ${i} float; ${r}`}else if(s!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function fp(r,t){return t?`#version 300 es ${r}`:r}const hT={},dT={};function mp(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?hT:dT;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`} ${r}`}function gp(r,t){return t?r.replace("#version 300 es",""):r}var pT=Object.defineProperty,_p=Object.getOwnPropertySymbols,fT=Object.prototype.hasOwnProperty,mT=Object.prototype.propertyIsEnumerable,xp=(r,t,e)=>t in r?pT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bp=(r,t)=>{for(var e in t||(t={}))fT.call(t,e)&&xp(r,e,t[e]);if(_p)for(var e of _p(t))mT.call(t,e)&&xp(r,e,t[e]);return r};const Vo={stripVersion:gp,ensurePrecision:pp,addProgramDefines:dp,setProgramName:mp,insertVersion:fp},Wo=Object.create(null),yp=class Tc{constructor(t){t=bp(bp({},Tc.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:hp()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let i=t.fragment,n=t.vertex;Object.keys(Vo).forEach(o=>{const a=s[o];i=Vo[o](i,a,!0),n=Vo[o](n,a,!1)}),this.fragment=i,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=ar(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Wo[e]||(Wo[e]=new Tc(t)),Wo[e]}};yp.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Dt=yp;const vp={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function ue(r){var t;return(t=vp[r])!=null?t:vp.float32}const gT={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"};function Tp({source:r,entryPoint:t}){var e;const s={},i=r.indexOf(`fn ${t}`);if(i!==-1){const n=r.indexOf("->",i);if(n!==-1){const o=r.substring(i,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let u;for(;(u=a.exec(o))!==null;){const l=(e=gT[u[3]])!=null?e:"float32";s[u[2]]={location:parseInt(u[1],10),format:l,stride:ue(l).stride,offset:0,instance:!1,start:0}}}}return s}function _i(r){var t,e,s;const i=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,o=/@binding\((\d+)\)/,a=/var(<[^>]+>)? (\w+)/,u=/:\s*(\w+)/,l=/struct\s+(\w+)\s*{([^}]+)}/g,c=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,d=(t=r.match(i))==null?void 0:t.map(f=>({group:parseInt(f.match(n)[1],10),binding:parseInt(f.match(o)[1],10),name:f.match(a)[2],isUniform:f.match(a)[1]==="",type:f.match(u)[1]}));if(!d)return{groups:[],structs:[]};const p=(s=(e=r.match(l))==null?void 0:e.map(f=>{const g=f.match(h)[1],m=f.match(c).reduce((_,b)=>{const[x,y]=b.split(":");return _[x.trim()]=y.trim(),_},{});return m?{name:g,members:m}:null}).filter(({name:f})=>d.some(g=>g.type===f)))!=null?s:[];return{groups:d,structs:p}}var ur=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(ur||{});function Ap({groups:r}){const t=[];for(let e=0;ee.has(o.name)?!1:(e.add(o.name),!0)),n=[...r.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return s.has(a)?!1:(s.add(a),!0)});return{structs:i,groups:n}}const Yo=Object.create(null);class wt{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;var e,s;const{fragment:i,vertex:n,layout:o,gpuLayout:a,name:u}=t;if(this.name=u,this.fragment=i,this.vertex=n,i.source===n.source){const l=_i(i.source);this.structsAndGroups=l}else{const l=_i(n.source),c=_i(i.source);this.structsAndGroups=Ep(l,c)}this.layout=o!=null?o:Sp(this.structsAndGroups),this.gpuLayout=a!=null?a:Ap(this.structsAndGroups),this.autoAssignGlobalUniforms=((e=this.layout[0])==null?void 0:e.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((s=this.layout[1])==null?void 0:s.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=ar(s,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=Tp(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Yo[e]||(Yo[e]=new wt(t)),Yo[e]}}function qo(r,t,e){if(r)for(const s in r){const i=s.toLocaleLowerCase(),n=t[i];if(n){let o=r[s];s==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}}}const _T=/\{\{(.*?)\}\}/g;function Ko(r){var t,e;const s={};return((e=(t=r.match(_T))==null?void 0:t.map(i=>i.replace(/[{()}]/g,"")))!=null?e:[]).forEach(i=>{s[i]=[]}),s}function wp(r,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function Zo(r,t,e=!1){const s=[];wp(t,s),r.forEach(a=>{a.header&&wp(a.header,s)});const i=s;e&&i.sort();const n=i.map((a,u)=>` @location(${u}) ${a},`).join(` `);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",` ${n} `),o}function Cp(r,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function xT(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function bT(r){const t=/@.*?\s+/g;return r.replace(t,"")}function Rp(r,t){const e=[];Cp(t,e),r.forEach(u=>{u.header&&Cp(u.header,e)});let s=0;const i=e.sort().map(u=>u.indexOf("builtin")>-1?u:`@location(${s++}) ${u}`).join(`, `),n=e.sort().map(u=>` var ${bT(u)};`).join(` `),o=`return VSOutput( ${e.sort().map(u=>` ${xT(u)}`).join(`, `)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",` ${i} `),a=a.replace("{{start}}",` ${n} `),a=a.replace("{{return}}",` ${o} `),a}function Qo(r,t){let e=r;for(const s in t){const i=t[s];i.join(` `).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----// ${i.join(` `)} //----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const Ie=Object.create(null),Jo=new Map;let yT=0;function Pp({template:r,bits:t}){const e=Mp(r,t);if(Ie[e])return Ie[e];const{vertex:s,fragment:i}=vT(r,t);return Ie[e]=Op(s,i,t),Ie[e]}function Dp({template:r,bits:t}){const e=Mp(r,t);return Ie[e]||(Ie[e]=Op(r.vertex,r.fragment,t)),Ie[e]}function vT(r,t){const e=t.map(o=>o.vertex).filter(o=>!!o),s=t.map(o=>o.fragment).filter(o=>!!o);let i=Zo(e,r.vertex,!0);i=Rp(e,i);const n=Zo(s,r.fragment,!0);return{vertex:i,fragment:n}}function Mp(r,t){return t.map(e=>(Jo.has(e)||Jo.set(e,yT++),Jo.get(e))).sort((e,s)=>e-s).join("-")+r.vertex+r.fragment}function Op(r,t,e){const s=Ko(r),i=Ko(t);return e.forEach(n=>{qo(n.vertex,s,n.name),qo(n.fragment,i,n.name)}),{vertex:Qo(r,s),fragment:Qo(t,i)}}const Bp=` @in aPosition: vec2; @in aUV: vec2; @out @builtin(position) vPosition: vec4; @out vUV : vec2; @out vColor : vec4; {{header}} struct VSOutput { {{struct}} }; @vertex fn main( {{in}} ) -> VSOutput { var worldTransformMatrix = globalUniforms.uWorldTransformMatrix; var modelMatrix = mat3x3( 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ); var position = aPosition; var uv = aUV; {{start}} vColor = vec4(1., 1., 1., 1.); {{main}} vUV = uv; var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix; vPosition = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); vColor *= globalUniforms.uWorldColorAlpha; {{end}} {{return}} }; `,Gp=` @in vUV : vec2; @in vColor : vec4; {{header}} @fragment fn main( {{in}} ) -> @location(0) vec4 { {{start}} var outColor:vec4; {{main}} var finalColor:vec4 = outColor * vColor; {{end}} return finalColor; }; `,Fp=` in vec2 aPosition; in vec2 aUV; out vec4 vColor; out vec2 vUV; {{header}} void main(void){ mat3 worldTransformMatrix = uWorldTransformMatrix; mat3 modelMatrix = mat3( 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ); vec2 position = aPosition; vec2 uv = aUV; {{start}} vColor = vec4(1.); {{main}} vUV = uv; mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix; gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); vColor *= uWorldColorAlpha; {{end}} } `,Ip=` in vec4 vColor; in vec2 vUV; out vec4 finalColor; {{header}} void main(void) { {{start}} vec4 outColor; {{main}} finalColor = outColor * vColor; {{end}} } `,Up={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, uWorldColorAlpha: vec4, uResolution: vec2, } @group(0) @binding(0) var globalUniforms : GlobalUniforms; `}},TT={name:"global-uniforms-ubo-bit",vertex:{header:` uniform globalUniforms { mat3 uProjectionMatrix; mat3 uWorldTransformMatrix; vec4 uWorldColorAlpha; vec2 uResolution; }; `}},kp={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; `}};var AT=Object.defineProperty,Lp=Object.getOwnPropertySymbols,ST=Object.prototype.hasOwnProperty,ET=Object.prototype.propertyIsEnumerable,Np=(r,t,e)=>t in r?AT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wT=(r,t)=>{for(var e in t||(t={}))ST.call(t,e)&&Np(r,e,t[e]);if(Lp)for(var e of Lp(t))ET.call(t,e)&&Np(r,e,t[e]);return r};function lr({bits:r,name:t}){const e=Pp({template:{fragment:Gp,vertex:Bp},bits:[Up,...r]});return wt.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function cr({bits:r,name:t}){return new Dt(wT({name:t},Dp({template:{vertex:Fp,fragment:Ip},bits:[kp,...r]})))}const xi={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},bi={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},ta={};function CT(r){const t=[];if(r===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(` `)}function RT(r){const t=[];if(r===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e; @out @interpolate(flat) vTextureId : u32; `,main:` vTextureId = aTextureIdAndRound.y; `,end:` if(aTextureIdAndRound.x == 1) { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } `},fragment:{header:` @in @interpolate(flat) vTextureId: u32; ${CT(r)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); ${RT(r)} `}}),ta[r]}const ea={};function PT(r){const t=[];for(let e=0;e0&&t.push("else"),e, targetSize: vec2) -> vec2 { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } `}},dr={name:"round-pixels-bit",vertex:{header:` vec2 roundPixels(vec2 position, vec2 targetSize) { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } `}},ra=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4","vec2","vec3","vec4"],$p=ra.reduce((r,t)=>(r[t]=!0,r),{});function Xp(r,t){switch(r){case"f32":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"mat2x2":return new Float32Array([1,0,0,1]);case"mat3x3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var DT=Object.defineProperty,Hp=Object.getOwnPropertySymbols,MT=Object.prototype.hasOwnProperty,OT=Object.prototype.propertyIsEnumerable,jp=(r,t,e)=>t in r?DT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,zp=(r,t)=>{for(var e in t||(t={}))MT.call(t,e)&&jp(r,e,t[e]);if(Hp)for(var e of Hp(t))OT.call(t,e)&&jp(r,e,t[e]);return r};const Vp=class Dy{constructor(t,e){this._touched=0,this.uid=Y("uniform"),this._resourceType="uniformGroup",this._resourceId=Y("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1;var s,i;e=zp(zp({},Dy.defaultOptions),e),this.uniformStructures=t;const n={};for(const o in t){const a=t[o];if(a.name=o,a.size=(s=a.size)!=null?s:1,!$p[a.type])throw new Error(`Uniform type ${a.type} is not supported. Supported uniform types are: ${ra.join(", ")}`);(i=a.value)!=null||(a.value=Xp(a.type,a.size)),n[o]=a.value}this.uniforms=n,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=ar(Object.keys(n).map(o=>`${o}-${t[o].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Vp.defaultOptions={ubo:!1,isStatic:!1};let it=Vp;const Wp={};function Ti(r){let t=Wp[r];if(t)return t;const e=new Int32Array(r);for(let s=0;s(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.BOTH=3]="BOTH",r))(Tt||{}),BT=Object.defineProperty,Ai=Object.getOwnPropertySymbols,Yp=Object.prototype.hasOwnProperty,qp=Object.prototype.propertyIsEnumerable,Kp=(r,t,e)=>t in r?BT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,GT=(r,t)=>{for(var e in t||(t={}))Yp.call(t,e)&&Kp(r,e,t[e]);if(Ai)for(var e of Ai(t))qp.call(t,e)&&Kp(r,e,t[e]);return r},FT=(r,t)=>{var e={};for(var s in r)Yp.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ai)for(var s of Ai(r))t.indexOf(s)<0&&qp.call(r,s)&&(e[s]=r[s]);return e};class Ft extends Rt{constructor(t){super(),this.uid=Y("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:s,groups:i,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=s,o===void 0&&(o=0,e&&(o|=Tt.WEBGPU),s&&(o|=Tt.WEBGL)),this.compatibleRenderers=o;const u={};if(!n&&!i&&(n={}),n&&i)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&i&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&i&&a)for(const l in a)for(const c in a[l]){const h=a[l][c];u[h]={group:l,binding:c,name:h}}else if(e&&i&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,u[c.name]=c})}else if(n){i={},a={},e&&e.structsAndGroups.groups.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,u[c.name]=c});let l=0;for(const c in n)u[c]||(i[99]||(i[99]=new Zt,this._ownedBindGroups.push(i[99])),u[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in n){const h=c;let d=n[c];!d.source&&!d._resourceType&&(d=new it(d));const p=u[h];p&&(i[p.group]||(i[p.group]=new Zt,this._ownedBindGroups.push(i[p.group])),i[p.group].setResource(d,p.binding))}}this.groups=i,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(i,u)}addResource(t,e,s){var i,n;(i=this._uniformBindMap)[e]||(i[e]={}),(n=this._uniformBindMap[e])[s]||(n[s]=t),this.groups[e]||(this.groups[e]=new Zt,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const i in e){const n=e[i];Object.defineProperty(s,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return s}destroy(t=!1){var e,s;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(i=>{i.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const e=t,{gpu:s,gl:i}=e,n=FT(e,["gpu","gl"]);let o,a;return s&&(o=wt.from(s)),i&&(a=Dt.from(i)),new Ft(GT({gpuProgram:o,glProgram:a},n))}}class Zp extends Ft{constructor(t){const e=cr({name:"batch",bits:[bi,vi(t),dr]}),s=lr({name:"batch",bits:[xi,yi(t),hr]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:Ti(t)}})}}let sa=null;const Qp=class My extends ap{constructor(t){super(t),this.geometry=new lp,this.name=My.extension.name,this.vertexSize=6,sa!=null||(sa=new Zp(t.maxTextures)),this.shader=sa}packAttributes(t,e,s,i,n){const o=n<<16|t.roundPixels&65535,a=t.transform,u=a.a,l=a.b,c=a.c,h=a.d,d=a.tx,p=a.ty,{positions:f,uvs:g}=t,m=t.color,_=t.attributeOffset,b=_+t.attributeSize;for(let x=_;x>16|t&65280|(t&255)<<16,s=this.renderable;return s?wo(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||IT}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}}var UT=Object.defineProperty,kT=Object.defineProperties,LT=Object.getOwnPropertyDescriptors,ef=Object.getOwnPropertySymbols,NT=Object.prototype.hasOwnProperty,$T=Object.prototype.propertyIsEnumerable,rf=(r,t,e)=>t in r?UT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wi=(r,t)=>{for(var e in t||(t={}))NT.call(t,e)&&rf(r,e,t[e]);if(ef)for(var e of ef(t))$T.call(t,e)&&rf(r,e,t[e]);return r},Ci=(r,t)=>kT(r,LT(t));const pr={extension:{type:v.ShapeBuilder,name:"circle"},build(r,t){let e,s,i,n,o,a;if(r.type==="circle"){const y=r;if(o=a=y.radius,o<=0)return!1;e=y.x,s=y.y,i=n=0}else if(r.type==="ellipse"){const y=r;if(o=y.halfWidth,a=y.halfHeight,o<=0||a<=0)return!1;e=y.x,s=y.y,i=n=0}else{const y=r,A=y.width/2,T=y.height/2;e=y.x+A,s=y.y+T,o=a=Math.max(0,Math.min(y.radius,Math.min(A,T))),i=A-o,n=T-a}if(i<0||n<0)return!1;const u=Math.ceil(2.3*Math.sqrt(o+a)),l=u*8+(i?4:0)+(n?4:0);if(l===0)return!1;if(u===0)return t[0]=t[6]=e+i,t[1]=t[3]=s+n,t[2]=t[4]=e-i,t[5]=t[7]=s-n,!0;let c=0,h=u*4+(i?2:0)+2,d=h,p=l,f=i+o,g=n,m=e+f,_=e-f,b=s+g;if(t[c++]=m,t[c++]=b,t[--h]=b,t[--h]=_,n){const y=s-g;t[d++]=_,t[d++]=y,t[--p]=y,t[--p]=m}for(let y=1;y0&&(i[n++]=u,i[n++]=l,i[n++]=u-1),u++;i[n++]=l+1,i[n++]=l,i[n++]=u-1}},sf=Ci(wi({},pr),{extension:Ci(wi({},pr.extension),{name:"ellipse"})}),nf=Ci(wi({},pr),{extension:Ci(wi({},pr.extension),{name:"roundedRectangle"})}),na=1e-4,oa=1e-4;function of(r){const t=r.length;if(t<6)return 1;let e=0;for(let s=0,i=r[t-2],n=r[t-1];sh&&(h+=Math.PI*2);let d=c;const p=h-c,f=Math.abs(p),g=Math.sqrt(u*u+l*l),m=(15*f*Math.sqrt(g)/Math.PI>>0)+1,_=p/m;if(d+=_,a){o.push(r,t),o.push(e,s);for(let b=1,x=d;b=0&&(a.join==="round"?g+=Ue(T,S,T-w*P,S-E*P,T-G*P,S-L*P,p,!1)+4:g+=2,p.push(T-G*O,S-L*O),p.push(T+G*P,S+L*P));continue}const Oc=(-w+y)*(-E+S)-(-w+T)*(-E+A),Bc=(-G+D)*(-L+S)-(-G+T)*(-L+R),Ns=(fe*Bc-Gr*Oc)/Ls,$s=(Fr*Oc-Br*Bc)/Ls,Vn=(Ns-T)*(Ns-T)+($s-S)*($s-S),Se=T+(Ns-T)*P,Ee=S+($s-S)*P,we=T-(Ns-T)*O,Ce=S-($s-S)*O,rv=Math.min(fe*fe+Br*Br,Gr*Gr+Fr*Fr),Gc=Ir?P:O,sv=rv+Gc*Gc*b;Vn<=sv?a.join==="bevel"||Vn/b>x?(Ir?(p.push(Se,Ee),p.push(T+w*O,S+E*O),p.push(Se,Ee),p.push(T+G*O,S+L*O)):(p.push(T-w*P,S-E*P),p.push(we,Ce),p.push(T-G*P,S-L*P),p.push(we,Ce)),g+=2):a.join==="round"?Ir?(p.push(Se,Ee),p.push(T+w*O,S+E*O),g+=Ue(T,S,T+w*O,S+E*O,T+G*O,S+L*O,p,!0)+4,p.push(Se,Ee),p.push(T+G*O,S+L*O)):(p.push(T-w*P,S-E*P),p.push(we,Ce),g+=Ue(T,S,T-w*P,S-E*P,T-G*P,S-L*P,p,!1)+4,p.push(T-G*P,S-L*P),p.push(we,Ce)):(p.push(Se,Ee),p.push(we,Ce)):(p.push(T-w*P,S-E*P),p.push(T+w*O,S+E*O),a.join==="round"?Ir?g+=Ue(T,S,T+w*O,S+E*O,T+G*O,S+L*O,p,!0)+2:g+=Ue(T,S,T-w*P,S-E*P,T-G*P,S-L*P,p,!1)+2:a.join==="miter"&&Vn/b<=x&&(Ir?(p.push(we,Ce),p.push(we,Ce)):(p.push(Se,Ee),p.push(Se,Ee)),g+=2),p.push(T-G*P,S-L*P),p.push(T+G*O,S+L*O),g+=2)}y=r[(f-2)*2],A=r[(f-2)*2+1],T=r[(f-1)*2],S=r[(f-1)*2+1],w=-(A-S),E=y-T,N=Math.sqrt(w*w+E*E),w/=N,E/=N,w*=_,E*=_,p.push(T-w*P,S-E*P),p.push(T+w*O,S+E*O),h||(a.cap==="round"?g+=Ue(T-w*(P-O)*.5,S-E*(P-O)*.5,T-w*P,S-E*P,T+w*O,S+E*O,p,!1)+2:a.cap==="square"&&(g+=af(T,S,w,E,P,O,!1,p)));const ze=oa*oa;for(let W=m;W80*e){a=r[0],u=r[1];let c=a,h=u;for(let d=e;dc&&(c=p),f>h&&(h=f)}l=Math.max(c-a,h-u),l=l!==0?32767/l:0}return is(n,o,e,a,u,l,0),o}function hf(r,t,e,s,i){let n;if(i===la(r,t,e,s)>0)for(let o=t;o=t;o-=s)n=mf(o/s|0,r[o],r[o+1],n);return n&&fr(n,n.next)&&(as(n),n=n.next),n}function ke(r,t){if(!r)return r;t||(t=r);let e=r,s;do if(s=!1,!e.steiner&&(fr(e,e.next)||Z(e.prev,e,e.next)===0)){if(as(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function is(r,t,e,s,i,n,o){if(!r)return;!o&&n&&ZT(r,s,i,n);let a=r;for(;r.prev!==r.next;){const u=r.prev,l=r.next;if(n?HT(r,s,i,n):XT(r)){t.push(u.i,r.i,l.i),as(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=jT(ke(r),t),is(r,t,e,s,i,n,2)):o===2&&zT(r,t,e,s,i,n):is(ke(r),t,e,s,i,n,1);break}}}function XT(r){const t=r.prev,e=r,s=r.next;if(Z(t,e,s)>=0)return!1;const i=t.x,n=e.x,o=s.x,a=t.y,u=e.y,l=s.y,c=Math.min(i,n,o),h=Math.min(a,u,l),d=Math.max(i,n,o),p=Math.max(a,u,l);let f=s.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=h&&f.y<=p&&ns(i,a,n,u,o,l,f.x,f.y)&&Z(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function HT(r,t,e,s){const i=r.prev,n=r,o=r.next;if(Z(i,n,o)>=0)return!1;const a=i.x,u=n.x,l=o.x,c=i.y,h=n.y,d=o.y,p=Math.min(a,u,l),f=Math.min(c,h,d),g=Math.max(a,u,l),m=Math.max(c,h,d),_=aa(p,f,t,e,s),b=aa(g,m,t,e,s);let x=r.prevZ,y=r.nextZ;for(;x&&x.z>=_&&y&&y.z<=b;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==i&&x!==o&&ns(a,c,u,h,l,d,x.x,x.y)&&Z(x.prev,x,x.next)>=0||(x=x.prevZ,y.x>=p&&y.x<=g&&y.y>=f&&y.y<=m&&y!==i&&y!==o&&ns(a,c,u,h,l,d,y.x,y.y)&&Z(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;x&&x.z>=_;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==i&&x!==o&&ns(a,c,u,h,l,d,x.x,x.y)&&Z(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;y&&y.z<=b;){if(y.x>=p&&y.x<=g&&y.y>=f&&y.y<=m&&y!==i&&y!==o&&ns(a,c,u,h,l,d,y.x,y.y)&&Z(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function jT(r,t){let e=r;do{const s=e.prev,i=e.next.next;!fr(s,i)&&pf(s,e,e.next,i)&&os(s,i)&&os(i,s)&&(t.push(s.i,e.i,i.i),as(e),as(e.next),e=r=i),e=e.next}while(e!==r);return ke(e)}function zT(r,t,e,s,i,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&tA(o,a)){let u=ff(o,a);o=ke(o,o.next),u=ke(u,u.next),is(o,t,e,s,i,n,0),is(u,t,e,s,i,n,0);return}a=a.next}o=o.next}while(o!==r)}function VT(r,t,e,s){const i=[];for(let n=0,o=t.length;n=e.next.y&&e.next.y!==e.y){const h=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=s&&h>n&&(n=h,o=e.x=e.x&&e.x>=u&&s!==e.x&&df(io.x||e.x===o.x&&KT(o,e)))&&(o=e,c=h)}e=e.next}while(e!==a);return o}function KT(r,t){return Z(r.prev,r,t.prev)<0&&Z(t.next,r,r.next)<0}function ZT(r,t,e,s){let i=r;do i.z===0&&(i.z=aa(i.x,i.y,t,e,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,QT(i)}function QT(r){let t,e=1;do{let s=r,i;r=null;let n=null;for(t=0;s;){t++;let o=s,a=0;for(let l=0;l0||u>0&&o;)a!==0&&(u===0||!o||s.z<=o.z)?(i=s,s=s.nextZ,a--):(i=o,o=o.nextZ,u--),n?n.nextZ=i:r=i,i.prevZ=n,n=i;s=o}n.nextZ=null,e*=2}while(t>1);return r}function aa(r,t,e,s,i){return r=(r-e)*i|0,t=(t-s)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function JT(r){let t=r,e=r;do(t.x=(r-o)*(n-a)&&(r-o)*(s-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(i-o)*(s-a)}function ns(r,t,e,s,i,n,o,a){return!(r===o&&t===a)&&df(r,t,e,s,i,n,o,a)}function tA(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!eA(r,t)&&(os(r,t)&&os(t,r)&&rA(r,t)&&(Z(r.prev,r,t.prev)||Z(r,t.prev,t))||fr(r,t)&&Z(r.prev,r,r.next)>0&&Z(t.prev,t,t.next)>0)}function Z(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function fr(r,t){return r.x===t.x&&r.y===t.y}function pf(r,t,e,s){const i=Pi(Z(r,t,e)),n=Pi(Z(r,t,s)),o=Pi(Z(e,s,r)),a=Pi(Z(e,s,t));return!!(i!==n&&o!==a||i===0&&Ri(r,e,t)||n===0&&Ri(r,s,t)||o===0&&Ri(e,r,s)||a===0&&Ri(e,t,s))}function Ri(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Pi(r){return r>0?1:r<0?-1:0}function eA(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&pf(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function os(r,t){return Z(r.prev,r,r.next)<0?Z(r,t,r.next)>=0&&Z(r,r.prev,t)>=0:Z(r,t,r.prev)<0||Z(r,r.next,t)<0}function rA(r,t){let e=r,s=!1;const i=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&i<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==r);return s}function ff(r,t){const e=ua(r.i,r.x,r.y),s=ua(t.i,t.x,t.y),i=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,s.next=e,e.prev=s,n.next=s,s.prev=n,s}function mf(r,t,e,s){const i=ua(r,t,e);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function as(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function ua(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function EM(r,t,e,s){const i=t&&t.length,n=i?t[0]*e:r.length;let o=Math.abs(la(r,0,n,e));if(i)for(let u=0,l=t.length;u0&&o>0?(t[0]=s,t[1]=i,t[2]=s+n,t[3]=i,t[4]=s+n,t[5]=i+o,t[6]=s,t[7]=i+o,!0):!1},triangulate(r,t,e,s,i,n){let o=0;s*=e,t[s+o]=r[0],t[s+o+1]=r[1],o+=e,t[s+o]=r[2],t[s+o+1]=r[3],o+=e,t[s+o]=r[6],t[s+o+1]=r[7],o+=e,t[s+o]=r[4],t[s+o+1]=r[5],o+=e;const a=s/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2,i[n++]=a+1,i[n++]=a+3,i[n++]=a+2}},bf={extension:{type:v.ShapeBuilder,name:"triangle"},build(r,t){return t[0]=r.x,t[1]=r.y,t[2]=r.x2,t[3]=r.y2,t[4]=r.x3,t[5]=r.y3,!0},triangulate(r,t,e,s,i,n){let o=0;s*=e,t[s+o]=r[0],t[s+o+1]=r[1],o+=e,t[s+o]=r[2],t[s+o+1]=r[3],o+=e,t[s+o]=r[4],t[s+o+1]=r[5];const a=s/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2}};var iA=Object.defineProperty,yf=Object.getOwnPropertySymbols,nA=Object.prototype.hasOwnProperty,oA=Object.prototype.propertyIsEnumerable,vf=(r,t,e)=>t in r?iA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Tf=(r,t)=>{for(var e in t||(t={}))nA.call(t,e)&&vf(r,e,t[e]);if(yf)for(var e of yf(t))oA.call(t,e)&&vf(r,e,t[e]);return r};const Af=[{offset:0,color:"white"},{offset:1,color:"black"}],ha=class Ac{constructor(...t){this.uid=Y("fillGradient"),this.type="linear",this.colorStops=[];var e;let s=aA(t);const i=s.type==="radial"?Ac.defaultRadialOptions:Ac.defaultLinearOptions;s=Tf(Tf({},i),Ht(s)),this._textureSize=s.textureSize,this._wrapMode=s.wrapMode,s.type==="radial"?(this.center=s.center,this.outerCenter=(e=s.outerCenter)!=null?e:this.center,this.innerRadius=s.innerRadius,this.outerRadius=s.outerRadius,this.scale=s.scale,this.rotation=s.rotation):(this.start=s.start,this.end=s.end),this.textureSpace=s.textureSpace,this.type=s.type,s.colorStops.forEach(n=>{this.addColorStop(n.offset,n.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:X.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:s,y:i}=this.end,n=s-t,o=i-e;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const m=t;t=s,s=m,n*=-1}if(o<0){const m=e;e=i,i=m,o*=-1}}const u=this.colorStops.length?this.colorStops:Af,l=this._textureSize,{canvas:c,context:h}=Ef(l,1),d=a?h.createLinearGradient(this._textureSize,0,0,0):h.createLinearGradient(0,0,this._textureSize,0);Sf(d,u),h.fillStyle=d,h.fillRect(0,0,l,1),this.texture=new C({source:new xe({resource:c,addressMode:this._wrapMode})});const p=Math.sqrt(n*n+o*o),f=Math.atan2(o,n),g=new M;g.scale(p/l,1),g.rotate(f),g.translate(t,e),this.textureSpace==="local"&&g.scale(l,l),this.transform=g}buildGradient(){this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Af,e=this._textureSize,{canvas:s,context:i}=Ef(e,e),{x:n,y:o}=this.center,{x:a,y:u}=this.outerCenter,l=this.innerRadius,c=this.outerRadius,h=a-c,d=u-c,p=e/(c*2),f=(n-h)*p,g=(o-d)*p,m=i.createRadialGradient(f,g,l*p,(a-h)*p,(u-d)*p,c*p);Sf(m,t),i.fillStyle=t[t.length-1].color,i.fillRect(0,0,e,e),i.fillStyle=m,i.translate(f,g),i.rotate(this.rotation),i.scale(1,this.scale),i.translate(-f,-g),i.fillRect(0,0,e,e),this.texture=new C({source:new xe({resource:s,addressMode:this._wrapMode})});const _=new M;_.scale(1/p,1/p),_.translate(h,d),this.textureSpace==="local"&&_.scale(e,e),this.transform=_}get styleKey(){return this.uid}destroy(){var t;(t=this.texture)==null||t.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}};ha.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},ha.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Qt=ha;function Sf(r,t){for(let e=0;e{var h;const d=[],p=us[u.type];if(!p.build(u,d))return;const f=a.length,g=n.length/2;let m="triangle-list";if(l&&ia(d,l),e){const y=(h=u.closePath)!=null?h:!0,A=t;A.pixelLine?(lf(d,y,n,a),m="line-list"):uf(d,A,!1,y,n,a)}else if(c){const y=[],A=d.slice();pA(c).forEach(T=>{y.push(A.length/2),A.push(...T)}),ca(A,y,n,2,g,a,f)}else p.triangulate(d,n,2,g,a,f);const _=o.length/2,b=t.texture;if(b!==C.WHITE){const y=wf(hA,t,u,l);Jp(n,2,g,o,_,2,n.length/2-g,y)}else tf(o,_,2,n.length/2-g);const x=lt.get(Ei);x.indexOffset=f,x.indexSize=a.length-f,x.attributeOffset=g,x.attributeSize=n.length/2-g,x.baseColor=t.color,x.alpha=t.alpha,x.texture=b,x.geometryData=i,x.topology=m,s.push(x)})}function pA(r){const t=[];for(let e=0;e{lt.return(s)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};da.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"graphicsContext"},da.defaultOptions={bezierSmoothness:.5};let Di=da;const fA={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},pa=0,fa=1,ma=2,ga=3,_a=4,xa=5,ba=class Oy{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<>16&255)/255,e[s++]=(r>>8&255)/255,e[s++]=(r&255)/255,e[s++]=t}function mr(r,t,e){const s=(r>>24&255)/255;t[e++]=(r&255)/255*s,t[e++]=(r>>8&255)/255*s,t[e++]=(r>>16&255)/255*s,t[e++]=s}class Mf{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{lt.return(t)}),this.batches.length=0}}class ya{constructor(t,e){this.state=Mt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this)}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,s=!!t._gpuData,i=this.renderer.graphicsContext.updateGpuContext(e);return!!(i.isBatchable||s!==i.isBatchable)}addRenderable(t,e){const s=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),s.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._getGpuDataForRenderable(t).batches;for(let s=0;s{const a=lt.get(Ei);return o.copyTo(a),a.renderable=t,a.roundPixels=n,a})}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}ya.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"graphics"},U.add(ya),U.add(Di);class Mi{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(t){this._topology=t}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(t){this.texture!==t&&(this.texture=t,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),e=t.data;let s=e;const i=this.texture.textureMatrix;return i.isSimple||(s=this._transformedUvs,(this._textureMatrixUpdateId!==i._updateID||this._uvUpdateId!==t._updateID)&&((!s||s.length"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Zt({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),s=e.batched,i=t.batched;if(e.batched=i,s!==i)return!0;if(i){const n=t._geometry;if(n.indices.length!==e.indexSize||n.positions.length!==e.vertexSize)return e.indexSize=n.indices.length,e.vertexSize=n.positions.length,!0;const o=this._getBatchableMesh(t);return o.texture.uid!==t._texture.uid&&(o._textureMatrixUpdateId=-1),!o._batcher.checkAndUpdateTexture(o,t._texture)}return!1}addRenderable(t,e){var s,i;const n=this.renderer.renderPipes.batch,o=this._getMeshData(t);if(t.didViewUpdate&&(o.indexSize=(s=t._geometry.indices)==null?void 0:s.length,o.vertexSize=(i=t._geometry.positions)==null?void 0:i.length),o.batched){const a=this._getBatchableMesh(t);a.setTexture(t._texture),a.geometry=t._geometry,n.addToBatch(a,e)}else n.break(e),e.add(t)}updateRenderable(t){if(t.batched){const e=this._getBatchableMesh(t);e.setTexture(t._texture),e.geometry=t._geometry,e._batcher.updateElement(e)}}execute(t){if(!t.isRenderable)return;t.state.blendMode=nr(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),mr(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){var e,s;return(e=t._gpuData)[s=this.renderer.uid]||(e[s]=new va),t._gpuData[this.renderer.uid].meshData||this._initMeshData(t)}_initMeshData(t){return t._gpuData[this.renderer.uid].meshData={batched:t.batched,indexSize:0,vertexSize:0},t._gpuData[this.renderer.uid].meshData}_getBatchableMesh(t){var e,s;return(e=t._gpuData)[s=this.renderer.uid]||(e[s]=new va),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new Mi;return e.renderable=t,e.setTexture(t._texture),e.transform=t.groupTransform,e.roundPixels=this.renderer._roundPixels|t._roundPixels,t._gpuData[this.renderer.uid].batchableMesh=e,e}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}Ta.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"mesh"},U.add(Ta);class Of{execute(t,e){const s=t.state,i=t.renderer,n=e.shader||t.defaultShader;n.resources.uTexture=e.texture._source,n.resources.uniforms=t.localUniforms;const o=i.gl,a=t.getBuffers(e);i.shader.bind(n),i.state.set(s),i.geometry.bind(a.geometry,n.glProgram);const u=a.geometry.indexBuffer.data.BYTES_PER_ELEMENT===2?o.UNSIGNED_SHORT:o.UNSIGNED_INT;o.drawElements(o.TRIANGLES,e.particleChildren.length*6,u,0)}}function Aa(r,t=null){const e=r*6;if(e>65535?t||(t=new Uint32Array(e)):t||(t=new Uint16Array(e)),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let s=0,i=0;sthis._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new Ge(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new Ge(this._size*this._dynamicStride*4*4),this.indexBuffer=Aa(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const s=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,s.float32View,s.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){const i=this.staticAttributeBuffer;this._staticUpload(t,i.float32View,i.uint32View),this._staticBuffer.setDataWithSize(i.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}function gA(r){const t=[];for(const e in r){const s=r[e];t.push(e,s.code,s.dynamic?"d":"s")}return t.join("_")}var If=`varying vec2 vUV; varying vec4 vColor; uniform sampler2D uTexture; void main(void){ vec4 color = texture2D(uTexture, vUV) * vColor; gl_FragColor = color; }`,Uf=`attribute vec2 aVertex; attribute vec2 aUV; attribute vec4 aColor; attribute vec2 aPosition; attribute float aRotation; uniform mat3 uTranslationMatrix; uniform float uRound; uniform vec2 uResolution; uniform vec4 uColor; varying vec2 vUV; varying vec4 vColor; vec2 roundPixels(vec2 position, vec2 targetSize) { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } void main(void){ float cosRotation = cos(aRotation); float sinRotation = sin(aRotation); float x = aVertex.x * cosRotation - aVertex.y * sinRotation; float y = aVertex.x * sinRotation + aVertex.y * cosRotation; vec2 v = vec2(x, y); v = v + aPosition; gl_Position = vec4((uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0); if(uRound == 1.0) { gl_Position.xy = roundPixels(gl_Position.xy, uResolution); } vUV = aUV; vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor; } `,Sa=` struct ParticleUniforms { uProjectionMatrix:mat3x3, uColor:vec4, uResolution:vec2, uRoundPixels:f32, }; @group(0) @binding(0) var uniforms: ParticleUniforms; @group(1) @binding(0) var uTexture: texture_2d; @group(1) @binding(1) var uSampler : sampler; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2, @location(1) color : vec4, }; @vertex fn mainVertex( @location(0) aVertex: vec2, @location(1) aPosition: vec2, @location(2) aUV: vec2, @location(3) aColor: vec4, @location(4) aRotation: f32, ) -> VSOutput { let v = vec2( aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation), aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation) ) + aPosition; let position = vec4((uniforms.uProjectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0); let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor; return VSOutput( position, aUV, vColor, ); } @fragment fn mainFragment( @location(0) uv: vec2, @location(1) color: vec4, @builtin(position) position: vec4, ) -> @location(0) vec4 { var sample = textureSample(uTexture, uSampler, uv) * color; return sample; }`;class kf extends Ft{constructor(){const t=Dt.from({vertex:Uf,fragment:If}),e=wt.from({fragment:{source:Sa,entryPoint:"mainFragment"},vertex:{source:Sa,entryPoint:"mainVertex"}});super({glProgram:t,gpuProgram:e,resources:{uTexture:C.WHITE.source,uSampler:new Pt({}),uniforms:{uTranslationMatrix:{value:new M,type:"mat3x3"},uColor:{value:new X(16777215),type:"vec4"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2"}}}})}}class Ea{constructor(t,e){this.state=Mt.for2d(),this.localUniforms=new it({uTranslationMatrix:{value:new M,type:"mat3x3"},uColor:{value:new Float32Array(4),type:"vec4"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new kf,this.state=Mt.for2d()}validateRenderable(t){return!1}addRenderable(t,e){this.renderer.renderPipes.batch.break(e),e.add(t)}getBuffers(t){return t._gpuData[this.renderer.uid]||this._initBuffer(t)}_initBuffer(t){return t._gpuData[this.renderer.uid]=new Ff({size:t.particleChildren.length,properties:t._properties}),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(e.length===0)return;const s=this.renderer,i=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const n=this.state;i.update(e,t._childrenDirty),t._childrenDirty=!1,n.blendMode=nr(t.blendMode,t.texture._source);const o=this.localUniforms.uniforms,a=o.uTranslationMatrix;t.worldTransform.copyTo(a),a.prepend(s.globalUniforms.globalUniformData.projectionMatrix),o.uResolution=s.globalUniforms.globalUniformData.resolution,o.uRound=s._roundPixels|t._roundPixels,mr(t.groupColorAlpha,o.uColor,0),this.adaptor.execute(this,t)}destroy(){this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}class wa extends Ea{constructor(t){super(t,new Of)}}wa.extension={type:[v.WebGLPipes],name:"particle"};class Lf{execute(t,e){const s=t.renderer,i=e.shader||t.defaultShader;i.groups[0]=s.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),i.groups[1]=s.texture.getTextureBindGroup(e.texture);const n=t.state,o=t.getBuffers(e);s.encoder.draw({geometry:o.geometry,shader:e.shader||t.defaultShader,state:n,size:e.particleChildren.length*6})}}class Ca extends Ea{constructor(t){super(t,new Lf)}}Ca.extension={type:[v.WebGPUPipes],name:"particle"},U.add(wa),U.add(Ca);function Oi(r,t){const{texture:e,bounds:s}=r,i=t._style._getFinalPadding();vo(s,t._anchor,e);const n=t._anchor._x*i*2,o=t._anchor._y*i*2;s.minX-=i-n,s.minY-=i-o,s.maxX-=i-n,s.maxY-=i-o}class ls{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){}}class Nf extends ls{constructor(t){super(),this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){this._renderer.canvasText.returnTexture(this.texture),this._renderer=null}}class Ra{constructor(t){this._renderer=t}validateRenderable(t){return t._didTextUpdate}addRenderable(t,e){const s=this._getGpuText(t);t._didTextUpdate&&(this._updateGpuText(t),t._didTextUpdate=!1),this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.returnTexture(e.texture),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getTexture(t),Oi(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Nf(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Ra.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"text"};const $f={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class cs{constructor(t,e){this.uid=Y("fillPattern"),this.transform=new M,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=$f[e].addressModeU,t.source.style.addressModeV=$f[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._styleKey=null}get styleKey(){return this._styleKey?this._styleKey:(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`,this._styleKey)}destroy(){this.texture.destroy(!0),this.texture=null,this._styleKey=null}}var _A=bA,Pa={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},xA=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function bA(r){var t=[];return r.replace(xA,function(e,s,i){var n=s.toLowerCase();for(i=vA(i),n=="m"&&i.length>2&&(t.push([s].concat(i.splice(0,2))),n="l",s=s=="m"?"l":"L");;){if(i.length==Pa[n])return i.unshift(s),t.push(i);if(i.length0&&(i=s.pop(),i?(n=i.startX,o=i.startY):(n=0,o=0)),i=null;break;default:}l!=="Z"&&l!=="z"&&i===null&&(i={startX:n,startY:o},s.push(i))}return t}class $n{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new $n(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let i=this.x-t,n=this.y-e;return i*=i,n*=n,i+n<=s}strokeContains(t,e,s,i=.5){if(this.radius===0)return!1;const n=this.x-t,o=this.y-e,a=this.radius,u=(1-i)*s,l=Math.sqrt(n*n+o*o);return l<=a+u&&l>a-(s-u)}getBounds(t){return t||(t=new j),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}}class Xn{constructor(t=0,e=0,s=0,i=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=i}clone(){return new Xn(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,i=(e-this.y)/this.halfHeight;return s*=s,i*=i,s+i<=1}strokeContains(t,e,s,i=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=s*(1-i),u=s-a,l=n-u,c=o-u,h=n+a,d=o+a,p=t-this.x,f=e-this.y,g=p*p/(l*l)+f*f/(c*c),m=p*p/(h*h)+f*f/(d*d);return g>1&&m<=1}getBounds(t){return t||(t=new j),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}}function hs(r,t,e,s,i,n){const o=r-e,a=t-s,u=i-e,l=n-s,c=o*u+a*l,h=u*u+l*l;let d=-1;h!==0&&(d=c/h);let p,f;d<0?(p=e,f=s):d>1?(p=i,f=n):(p=e+d*u,f=s+d*l);const g=r-p,m=t-f;return g*g+m*m}let AA,SA;class Mr{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let i=0,n=e.length;ie!=c>e&&t<(l-a)*((e-u)/(c-u))+a&&(s=!s)}return s}strokeContains(t,e,s,i=.5){const n=s*s,o=n*(1-i),a=n-o,{points:u}=this,l=u.length-(this.closePath?0:2);for(let c=0;ci?l:i,n=co?c:o}return t.x=s,t.width=i-s,t.y=n,t.height=o-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const Bi=(r,t,e,s,i,n,o)=>{const a=r-e,u=t-s,l=Math.sqrt(a*a+u*u);return l>=i-n&&l<=i+o};class Hn{constructor(t=0,e=0,s=0,i=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=i,this.radius=n}getBounds(t){return t||(t=new j),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Hn(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let i=t-(this.x+s),n=e-(this.y+s);const o=s*s;if(i*i+n*n<=o||(i=t-(this.x+this.width-s),i*i+n*n<=o)||(n=e-(this.y+this.height-s),i*i+n*n<=o)||(i=t-(this.x+s),i*i+n*n<=o))return!0}return!1}strokeContains(t,e,s,i=.5){const{x:n,y:o,width:a,height:u,radius:l}=this,c=s*(1-i),h=s-c,d=n+l,p=o+l,f=a-l*2,g=u-l*2,m=n+a,_=o+u;return(t>=n-c&&t<=n+h||t>=m-h&&t<=m+c)&&e>=p&&e<=p+g||(e>=o-c&&e<=o+h||e>=_-h&&e<=_+c)&&t>=d&&t<=d+f?!0:tm-l&&em-l&&e>_-l&&Bi(t,e,m-l,_-l,l,h,c)||t_-l&&Bi(t,e,d,_-l,l,h,c)}}const EA=8,Gi=11920929e-14,wA=1,Da=.01,gr=0,Le=0;function Ma(r,t,e,s,i,n,o,a,u,l){const c=Math.min(.99,Math.max(0,l!=null?l:Di.defaultOptions.bezierSmoothness));let h=(wA-c)/1;return h*=h,CA(t,e,s,i,n,o,a,u,r,h),r}function CA(r,t,e,s,i,n,o,a,u,l){Oa(r,t,e,s,i,n,o,a,u,l,0),u.push(o,a)}function Oa(r,t,e,s,i,n,o,a,u,l,c){if(c>EA)return;const h=Math.PI,d=(r+e)/2,p=(t+s)/2,f=(e+i)/2,g=(s+n)/2,m=(i+o)/2,_=(n+a)/2,b=(d+f)/2,x=(p+g)/2,y=(f+m)/2,A=(g+_)/2,T=(b+y)/2,S=(x+A)/2;if(c>0){let D=o-r,R=a-t;const w=Math.abs((e-o)*R-(s-a)*D),E=Math.abs((i-o)*R-(n-a)*D);let G,L;if(w>Gi&&E>Gi){if((w+E)*(w+E)<=l*(D*D+R*R)){if(gr=h&&(G=2*h-G),L>=h&&(L=2*h-L),G+LLe){u.push(e,s);return}if(L>Le){u.push(i,n);return}}}}else if(w>Gi){if(w*w<=l*(D*D+R*R)){if(gr=h&&(G=2*h-G),GLe){u.push(e,s);return}}}else if(E>Gi){if(E*E<=l*(D*D+R*R)){if(gr=h&&(G=2*h-G),GLe){u.push(i,n);return}}}else if(D=T-(r+o)/2,R=S-(t+a)/2,D*D+R*R<=l){u.push(T,S);return}}Oa(r,t,d,p,b,x,T,S,u,l,c+1),Oa(T,S,y,A,m,_,o,a,u,l,c+1)}const RA=8,PA=11920929e-14,DA=1,MA=.01,Hf=0;function jf(r,t,e,s,i,n,o,a){const u=Math.min(.99,Math.max(0,a!=null?a:Di.defaultOptions.bezierSmoothness));let l=(DA-u)/1;return l*=l,OA(t,e,s,i,n,o,r,l),r}function OA(r,t,e,s,i,n,o,a){Ba(o,r,t,e,s,i,n,a,0),o.push(i,n)}function Ba(r,t,e,s,i,n,o,a,u){if(u>RA)return;const l=Math.PI,c=(t+s)/2,h=(e+i)/2,d=(s+n)/2,p=(i+o)/2,f=(c+d)/2,g=(h+p)/2;let m=n-t,_=o-e;const b=Math.abs((s-n)*_-(i-o)*m);if(b>PA){if(b*b<=a*(m*m+_*_)){if(Hf=l&&(x=2*l-x),xn||o&&n>i)&&(u=2*Math.PI-u),a||(a=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(u/Math.PI)))),a=Math.max(a,3);let l=u/a,c=i;l*=o?-1:1;for(let h=0;hc*a)}const ds=Math.PI*2,Fa={centerX:0,centerY:0,ang1:0,ang2:0},Ia=({x:r,y:t},e,s,i,n,o,a,u)=>{r*=e,t*=s;const l=i*r-n*t,c=n*r+i*t;return u.x=l+o,u.y=c+a,u};function BA(r,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,i=Math.cos(r),n=Math.sin(r),o=Math.cos(r+t),a=Math.sin(r+t);return[{x:i-n*s,y:n+i*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}const Vf=(r,t,e,s)=>{const i=r*s-t*e<0?-1:1;let n=r*e+t*s;return n>1&&(n=1),n<-1&&(n=-1),i*Math.acos(n)},GA=(r,t,e,s,i,n,o,a,u,l,c,h,d)=>{const p=Math.pow(i,2),f=Math.pow(n,2),g=Math.pow(c,2),m=Math.pow(h,2);let _=p*f-p*m-f*g;_<0&&(_=0),_/=p*m+f*g,_=Math.sqrt(_)*(o===a?-1:1);const b=_*i/n*h,x=_*-n/i*c,y=l*b-u*x+(r+e)/2,A=u*b+l*x+(t+s)/2,T=(c-b)/i,S=(h-x)/n,D=(-c-b)/i,R=(-h-x)/n,w=Vf(1,0,T,S);let E=Vf(T,S,D,R);a===0&&E>0&&(E-=ds),a===1&&E<0&&(E+=ds),d.centerX=y,d.centerY=A,d.ang1=w,d.ang2=E};function Wf(r,t,e,s,i,n,o,a=0,u=0,l=0){if(n===0||o===0)return;const c=Math.sin(a*ds/360),h=Math.cos(a*ds/360),d=h*(t-s)/2+c*(e-i)/2,p=-c*(t-s)/2+h*(e-i)/2;if(d===0&&p===0)return;n=Math.abs(n),o=Math.abs(o);const f=Math.pow(d,2)/Math.pow(n,2)+Math.pow(p,2)/Math.pow(o,2);f>1&&(n*=Math.sqrt(f),o*=Math.sqrt(f)),GA(t,e,s,i,n,o,u,l,c,h,d,p,Fa);let{ang1:g,ang2:m}=Fa;const{centerX:_,centerY:b}=Fa;let x=Math.abs(m)/(ds/4);Math.abs(1-x)<1e-7&&(x=1);const y=Math.max(Math.ceil(x),1);m/=y;let A=r[r.length-2],T=r[r.length-1];const S={x:0,y:0};for(let D=0;D{const l=u.x-a.x,c=u.y-a.y,h=Math.sqrt(l*l+c*c),d=l/h,p=c/h;return{len:h,nx:d,ny:p}},n=(a,u)=>{a===0?r.moveTo(u.x,u.y):r.lineTo(u.x,u.y)};let o=t[t.length-1];for(let a=0;a0&&(f=-1,g=!0);const m=p/2;let _,b=Math.abs(Math.cos(m)*l/Math.sin(m));b>Math.min(h.len/2,d.len/2)?(b=Math.min(h.len/2,d.len/2),_=Math.abs(b*Math.sin(m)/Math.cos(m))):_=l;const x=u.x+d.nx*b+-d.ny*_*f,y=u.y+d.ny*b+d.nx*_*f,A=Math.atan2(h.ny,h.nx)+Math.PI/2*f,T=Math.atan2(d.ny,d.nx)-Math.PI/2*f;a===0&&r.moveTo(x+Math.cos(A)*_,y+Math.sin(A)*_),r.arc(x,y,_,A,T,g),o=u}}function qf(r,t,e,s){var i;const n=(u,l)=>Math.sqrt((u.x-l.x)**2+(u.y-l.y)**2),o=(u,l,c)=>({x:u.x+(l.x-u.x)*c,y:u.y+(l.y-u.y)*c}),a=t.length;for(let u=0;u1){let n=null;for(let o=i;o=2;h-=2)c[h]===c[h-2]&&c[h-1]===c[h-3]&&c.splice(h-1,2);return this.poly(c,!0,o)}ellipse(t,e,s,i,n){return this.drawShape(new Xn(t,e,s,i),n),this}roundRect(t,e,s,i,n,o){return this.drawShape(new Hn(t,e,s,i,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new Mr,s.points.push(t,e),this._currentPoly=s,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new Mr,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,i=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=s;s=n.a*s+n.c*i+n.tx,i=n.b*o+n.d*i+n.ty}this._currentPoly.points.push(s,i)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;et in r?kA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fi=(r,t)=>{for(var e in t||(t={}))LA.call(t,e)&&em(r,e,t[e]);if(tm)for(var e of tm(t))NA.call(t,e)&&em(r,e,t[e]);return r};function rm(r,t){if(typeof r=="string"){const o=document.createElement("div");o.innerHTML=r.trim(),r=o.querySelector("svg")}const e={context:t,defs:{},path:new je};Qf(r,e);const s=r.children,{fillStyle:i,strokeStyle:n}=Na(r,e);for(let o=0;oparseInt(R,10)),t.context.poly(x,!0),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"polyline":y=r.getAttribute("points"),x=y.match(/\d+/g).map(R=>parseInt(R,10)),t.context.poly(x,!1),s&&t.context.stroke(s);break;case"g":case"svg":break;default:{Lt(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}a&&(e=null);for(let R=0;Rt in r?$A(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jt=(r,t)=>{for(var e in t||(t={}))im.call(t,e)&&om(r,e,t[e]);if(Ii)for(var e of Ii(t))nm.call(t,e)&&om(r,e,t[e]);return r},XA=(r,t)=>{var e={};for(var s in r)im.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ii)for(var s of Ii(r))t.indexOf(s)<0&&nm.call(r,s)&&(e[s]=r[s]);return e};function HA(r){return X.isColorLike(r)}function am(r){return r instanceof cs}function um(r){return r instanceof Qt}function jA(r){return r instanceof C}function zA(r,t,e){const s=X.shared.setValue(t!=null?t:0);return r.color=s.toNumber(),r.alpha=s.alpha===1?e.alpha:s.alpha,r.texture=C.WHITE,jt(jt({},e),r)}function VA(r,t,e){return r.texture=t,jt(jt({},e),r)}function lm(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,jt(jt({},e),r)}function cm(r,t,e){return t.buildGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,jt(jt({},e),r)}function WA(r,t){const e=jt(jt({},t),r),s=X.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e}function be(r,t){if(r==null)return null;const e={},s=r;return HA(r)?zA(e,r,t):jA(r)?VA(e,r,t):am(r)?lm(e,r,t):um(r)?cm(e,r,t):s.fill&&am(s.fill)?lm(s,s.fill,t):s.fill&&um(s.fill)?cm(s,s.fill,t):WA(s,t)}function fs(r,t){const e=t,{width:s,alignment:i,miterLimit:n,cap:o,join:a,pixelLine:u}=e,l=XA(e,["width","alignment","miterLimit","cap","join","pixelLine"]),c=be(r,l);return c?jt({width:s,alignment:i,miterLimit:n,cap:o,join:a,pixelLine:u},c):null}var YA=Object.defineProperty,hm=Object.getOwnPropertySymbols,qA=Object.prototype.hasOwnProperty,KA=Object.prototype.propertyIsEnumerable,dm=(r,t,e)=>t in r?YA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_r=(r,t)=>{for(var e in t||(t={}))qA.call(t,e)&&dm(r,e,t[e]);if(hm)for(var e of hm(t))KA.call(t,e)&&dm(r,e,t[e]);return r};const ZA=new nt,pm=new M,$a=class te extends Rt{constructor(){super(...arguments),this.uid=Y("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new je,this._transform=new M,this._fillStyle=_r({},te.defaultFillStyle),this._strokeStyle=_r({},te.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new ot,this._boundsDirty=!0}clone(){const t=new te;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=_r({},this._fillStyle),t._strokeStyle=_r({},this._strokeStyle),t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=be(t,te.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=fs(t,te.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=be(t,te.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=be(t,te.defaultStrokeStyle),this}texture(t,e,s,i,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:i||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?X.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new je,this}fill(t,e){let s;const i=this.instructions[this.instructions.length-1];return this._tick===0&&i&&i.action==="stroke"?s=i.data.path:s=this._activePath.clone(),s?(t!=null&&(e!==void 0&&typeof t=="number"&&(t={color:t,alpha:e}),this._fillStyle=be(t,te.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(nt.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const s=this.instructions[this.instructions.length-1];return this._tick===0&&s&&s.action==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=fs(t,te.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],s=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(s);else{e.data.hole=s;break}}return this._initNextPathLocation(),this}arc(t,e,s,i,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,s,i,n,o),this}arcTo(t,e,s,i,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*i+o.tx,o.b*s+o.d*i+o.ty,n),this}arcToSvg(t,e,s,i,n,o,a){this._tick++;const u=this._transform;return this._activePath.arcToSvg(t,e,s,i,n,u.a*o+u.c*a+u.tx,u.b*o+u.d*a+u.ty),this}bezierCurveTo(t,e,s,i,n,o,a){this._tick++;const u=this._transform;return this._activePath.bezierCurveTo(u.a*t+u.c*e+u.tx,u.b*t+u.d*e+u.ty,u.a*s+u.c*i+u.tx,u.b*s+u.d*i+u.ty,u.a*n+u.c*o+u.tx,u.b*n+u.d*o+u.ty,a),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,s,i){return this._tick++,this._activePath.ellipse(t,e,s,i,this._transform.clone()),this}circle(t,e,s){return this._tick++,this._activePath.circle(t,e,s,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty),this}moveTo(t,e){this._tick++;const s=this._transform,i=this._activePath.instructions,n=s.a*t+s.c*e+s.tx,o=s.b*t+s.d*e+s.ty;return i.length===1&&i[0].action==="moveTo"?(i[0].data[0]=n,i[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,s,i,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*i+o.tx,o.b*s+o.d*i+o.ty,n),this}rect(t,e,s,i){return this._tick++,this._activePath.rect(t,e,s,i,this._transform.clone()),this}roundRect(t,e,s,i,n){return this._tick++,this._activePath.roundRect(t,e,s,i,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,s,i,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,s,i,n,o),this}roundPoly(t,e,s,i,n,o){return this._tick++,this._activePath.roundPoly(t,e,s,i,n,o),this}roundShape(t,e,s,i){return this._tick++,this._activePath.roundShape(t,e,s,i),this}filletRect(t,e,s,i,n){return this._tick++,this._activePath.filletRect(t,e,s,i,n),this}chamferRect(t,e,s,i,n,o){return this._tick++,this._activePath.chamferRect(t,e,s,i,n,o),this}star(t,e,s,i,n=0,o=0){return this._tick++,this._activePath.star(t,e,s,i,n,o,this._transform.clone()),this}svg(t){return this._tick++,rm(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:_r({},this._fillStyle),strokeStyle:_r({},this._strokeStyle)}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,s,i,n,o){return t instanceof M?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,s,i,n,o),this)}transform(t,e,s,i,n,o){return t instanceof M?(this._transform.append(t),this):(pm.set(t,e,s,i,n,o),this._transform.append(pm),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const t=this._bounds;t.clear();for(let e=0;et in r?eS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ot=(r,t)=>{for(var e in t||(t={}))iS.call(t,e)&&xm(r,e,t[e]);if(_m)for(var e of _m(t))nS.call(t,e)&&xm(r,e,t[e]);return r},oS=(r,t)=>rS(r,sS(t));const Xa=class Dr extends Rt{constructor(t={}){super(),aS(t);const e=Ot(Ot({},Dr.defaultTextStyle),t);for(const s in e){const i=s;this[i]=e[s]}this.update()}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(t){t!==null&&typeof t=="object"?this._dropShadow=this._createProxy(Ot(Ot({},Dr.defaultDropShadow),t)):this._dropShadow=t?this._createProxy(Ot({},Dr.defaultDropShadow)):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily=t,this.update()}get fontSize(){return this._fontSize}set fontSize(t){typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t.toLowerCase(),this.update()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this.update()}get leading(){return this._leading}set leading(t){this._leading=t,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing=t,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight=t,this.update()}get padding(){return this._padding}set padding(t){this._padding=t,this.update()}get filters(){return this._filters}set filters(t){this._filters=t,this.update()}get trim(){return this._trim}set trim(t){this._trim=t,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace=t,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap=t,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth=t,this.update()}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy(Ot(Ot({},mt.defaultFillStyle),t),()=>{this._fill=be(Ot({},this._originalFill),mt.defaultFillStyle)})),this._fill=be(t===0?"black":t,mt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(Ot(Ot({},mt.defaultStrokeStyle),t),()=>{this._stroke=fs(Ot({},this._originalStroke),mt.defaultStrokeStyle)})),this._stroke=fs(t,mt.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=mm(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=Dr.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new Dr({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?Ot({},this._dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e(s[i]=n,e==null||e(i,n),this.update(),!0)})}_isFillStyle(t){return(t!=null?t:null)!==null&&!(X.isColorLike(t)||t instanceof Qt||t instanceof cs)}};Xa.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},Xa.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Bt=Xa;function aS(r){var t,e,s,i,n;const o=r;if(typeof o.dropShadow=="boolean"&&o.dropShadow){const a=Bt.defaultDropShadow;r.dropShadow={alpha:(t=o.dropShadowAlpha)!=null?t:a.alpha,angle:(e=o.dropShadowAngle)!=null?e:a.angle,blur:(s=o.dropShadowBlur)!=null?s:a.blur,color:(i=o.dropShadowColor)!=null?i:a.color,distance:(n=o.dropShadowDistance)!=null?n:a.distance}}if(o.strokeThickness!==void 0){const a=o.stroke;let u={};if(X.isColorLike(a))u.color=a;else if(a instanceof Qt||a instanceof cs)u.fill=a;else if(Object.hasOwnProperty.call(a,"color")||Object.hasOwnProperty.call(a,"fill"))u=a;else throw new Error("Invalid stroke value.");r.stroke=oS(Ot({},u),{width:o.strokeThickness})}if(Array.isArray(o.fillGradientStops)){if(!Array.isArray(o.fill)||o.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");o.fill.length,o.fillGradientStops.length;const a=new Qt({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),u=o.fillGradientStops.slice(),l=o.fill.map(c=>X.shared.setValue(c).toNumber());u.forEach((c,h)=>{a.addColorStop(c,l[h])}),r.fill={fill:a}}}const uS=new ot;function Ha(r,t,e,s){const i=uS;i.minX=0,i.minY=0,i.maxX=r.width/s|0,i.maxY=r.height/s|0;const n=st.getOptimalTexture(i.width,i.height,s,!1);return n.source.uploadMethodId="image",n.source.resource=r,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=t/s,n.frame.height=e/s,n.source.emit("update",n.source),n.updateUvs(),n}class bm{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=I.get().createCanvas();s.width=t,s.height=e;const i=s.getContext("2d");return{canvas:s,context:i}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=Be(t),e=Be(e);const i=(t<<17)+(e<<1);this._canvasPool[i]||(this._canvasPool[i]=[]);let n=this._canvasPool[i].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:i}=e,n=(s<<17)+(i<<1);t.context.resetTransform(),t.context.clearRect(0,0,s,i),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const le=new bm;let Ne=null,ce=null;function lS(r,t){Ne||(Ne=I.get().createCanvas(256,128),ce=Ne.getContext("2d",{willReadFrequently:!0}),ce.globalCompositeOperation="copy",ce.globalAlpha=1),(Ne.width=0;s--){let i=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(i)&&!cS.includes(i)&&(i=`"${i}"`),e[s]=i}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const ja={willReadFrequently:!0},Jt=class B{static get experimentalLetterSpacingSupported(){let t=B._experimentalLetterSpacingSupported;if(t===void 0){const e=I.get().getCanvasRenderingContext2D().prototype;t=B._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,i,n,o,a,u,l){this.text=t,this.style=e,this.width=s,this.height=i,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=u,this.fontProperties=l}static measureText(t=" ",e,s=B._canvas,i=e.wordWrap){var n;const o=ms(e),a=B.measureFont(o);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);const u=B.__context;u.font=o;const l=(i?B._wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),c=new Array(l.length);let h=0;for(let m=0;m0)if(i)o-=e,u-=e;else{const l=(B.graphemeSegmenter(t).length-1)*e;o+=l,u+=l}return Math.max(o,u)}static _wordWrap(t,e,s=B._canvas){const i=s.getContext("2d",ja);let n=0,o="",a="";const u=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,h=B._collapseSpaces(c),d=B._collapseNewlines(c);let p=!h;const f=e.wordWrapWidth+l,g=B._tokenize(t);for(let m=0;mf)if(o!==""&&(a+=B._addLine(o),o="",n=0),B.canBreakWords(_,e.breakWords)){const x=B.wordWrapSplit(_);for(let y=0;yf&&(a+=B._addLine(o),p=!1,o="",n=0),o+=A,n+=D}}else{o.length>0&&(a+=B._addLine(o),o="",n=0);const x=m===g.length-1;a+=B._addLine(_,!x),p=!1,o="",n=0}else b+n>f&&(p=!1,a+=B._addLine(o),o="",n=0),(o.length>0||!B.isBreakingSpace(_)||p)&&(o+=_,n+=b)}return a+=B._addLine(o,!1),a}static _addLine(t,e=!0){return t=B._trimRight(t),t=e?`${t} `:t,t}static _getFromCache(t,e,s,i){let n=s[t];return typeof n!="number"&&(n=B._measureText(t,e,i)+e,s[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const s=t[e];if(!B.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:B._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:B._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let i=0;i{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>{const e=r.segment(t),s=[];let i=0;for(const n of e)s[i++]=n.segment;return s}}return r=>[...r]})(),Jt.experimentalLetterSpacing=!1,Jt._fonts={},Jt._newlines=[10,13],Jt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let pt=Jt;const Am=1e5;function gs(r,t,e,s=0){var i;if(r.texture===C.WHITE&&!r.fill)return X.shared.setValue(r.color).setAlpha((i=r.alpha)!=null?i:1).toHexa();if(r.fill){if(r.fill instanceof cs){const n=r.fill,o=t.createPattern(n.texture.source.resource,"repeat"),a=n.transform.copyTo(M.shared);return a.scale(n.texture.frame.width,n.texture.frame.height),o.setTransform(a),o}else if(r.fill instanceof Qt){const n=r.fill,o=n.type==="linear",a=n.textureSpace==="local";let u=1,l=1;a&&e&&(u=e.width+s,l=e.height+s);let c,h=!1;if(o){const{start:d,end:p}=n;c=t.createLinearGradient(d.x*u,d.y*l,p.x*u,p.y*l),h=Math.abs(p.x-d.x){const m=f+g.offset*d;c.addColorStop(Math.floor(m*Am)/Am,X.shared.setValue(g.color).toHex())})}}else n.colorStops.forEach(d=>{c.addColorStop(d.offset,X.shared.setValue(d.color).toHex())});return c}}else{const n=t.createPattern(r.texture.source.resource,"repeat"),o=r.matrix.copyTo(M.shared);return o.scale(r.texture.frame.width,r.texture.frame.height),n.setTransform(o),n}return"red"}const Sm=new j;let hS=class{getCanvasAndContext(t){const{text:e,style:s,resolution:i=1}=t,n=s._getFinalPadding(),o=pt.measureText(e||" ",s),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*i),u=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*i),l=le.getOptimalCanvasAndContext(a,u);this._renderTextToCanvas(e,s,n,i,l);const c=s.trim?Tm({canvas:l.canvas,width:a,height:u,resolution:1,output:Sm}):Sm.set(0,0,a,u);return{canvasAndContext:l,frame:c}}returnCanvasAndContext(t){le.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,s,i,n){var o,a,u,l,c;const{canvas:h,context:d}=n,p=ms(e),f=pt.measureText(t||" ",e),g=f.lines,m=f.lineHeight,_=f.lineWidths,b=f.maxLineWidth,x=f.fontProperties,y=h.height;if(d.resetTransform(),d.scale(i,i),d.textBaseline=e.textBaseline,(o=e._stroke)!=null&&o.width){const D=e._stroke;d.lineWidth=D.width,d.miterLimit=D.miterLimit,d.lineJoin=D.join,d.lineCap=D.cap}d.font=p;let A,T;const S=e.dropShadow?2:1;for(let D=0;Dt in r?dS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pS=(r,t)=>{for(var e in t||(t={}))Em.call(t,e)&&Cm(r,e,t[e]);if(Ui)for(var e of Ui(t))wm.call(t,e)&&Cm(r,e,t[e]);return r},fS=(r,t)=>{var e={};for(var s in r)Em.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ui)for(var s of Ui(r))t.indexOf(s)<0&&wm.call(r,s)&&(e[s]=r[s]);return e};class Or extends ae{constructor(t){t instanceof mt&&(t={context:t});const e=t||{},{context:s,roundPixels:i}=e,n=fS(e,["context","roundPixels"]);super(pS({label:"Graphics"},n)),this.renderPipeId="graphics",s?this._context=s:this._context=this._ownedContext=new mt,this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=i!=null?i:!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new Or(this._context.clone()):(this._ownedContext=null,new Or(this._context))}lineStyle(t,e,s){const i={};return t&&(i.width=t),e&&(i.color=e),s&&(i.alpha=s),this.context.strokeStyle=i,this}beginFill(t,e){const s={};return t!==void 0&&(s.color=t),e!==void 0&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){this.context.fill();const t=this.context.strokeStyle;return(t.width!==mt.defaultStrokeStyle.width||t.color!==mt.defaultStrokeStyle.color||t.alpha!==mt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return this._callContextMethod("circle",t)}drawEllipse(...t){return this._callContextMethod("ellipse",t)}drawPolygon(...t){return this._callContextMethod("poly",t)}drawRect(...t){return this._callContextMethod("rect",t)}drawRoundedRect(...t){return this._callContextMethod("roundRect",t)}drawStar(...t){return this._callContextMethod("star",t)}}const Rm={name:"local-uniform-msdf-bit",vertex:{header:` struct LocalUniforms { uColor:vec4, uTransformMatrix:mat3x3, uDistance: f32, uRound:f32, } @group(2) @binding(0) var localUniforms : LocalUniforms; `,main:` vColor *= localUniforms.uColor; modelMatrix *= localUniforms.uTransformMatrix; `,end:` if(localUniforms.uRound == 1) { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } `},fragment:{header:` struct LocalUniforms { uColor:vec4, uTransformMatrix:mat3x3, uDistance: f32 } @group(2) @binding(0) var localUniforms : LocalUniforms; `,main:` outColor = vec4(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance)); `}},Pm={name:"local-uniform-msdf-bit",vertex:{header:` uniform mat3 uTransformMatrix; uniform vec4 uColor; uniform float uRound; `,main:` vColor *= uColor; modelMatrix *= uTransformMatrix; `,end:` if(uRound == 1.) { gl_Position.xy = roundPixels(gl_Position.xy, uResolution); } `},fragment:{header:` uniform float uDistance; `,main:` outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance)); `}},Dm={name:"msdf-bit",fragment:{header:` fn calculateMSDFAlpha(msdfColor:vec4, shapeColor:vec4, distance:f32) -> f32 { // MSDF var median = msdfColor.r + msdfColor.g + msdfColor.b - min(msdfColor.r, min(msdfColor.g, msdfColor.b)) - max(msdfColor.r, max(msdfColor.g, msdfColor.b)); // SDF median = min(median, msdfColor.a); var screenPxDistance = distance * (median - 0.5); var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0); if (median < 0.01) { alpha = 0.0; } else if (median > 0.99) { alpha = 1.0; } // Gamma correction for coverage-like alpha var luma: f32 = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114)); var gamma: f32 = mix(1.0, 1.0 / 2.2, luma); var coverage: f32 = pow(shapeColor.a * alpha, gamma); return coverage; } `}},Mm={name:"msdf-bit",fragment:{header:` float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) { // MSDF float median = msdfColor.r + msdfColor.g + msdfColor.b - min(msdfColor.r, min(msdfColor.g, msdfColor.b)) - max(msdfColor.r, max(msdfColor.g, msdfColor.b)); // SDF median = min(median, msdfColor.a); float screenPxDistance = distance * (median - 0.5); float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0); if (median < 0.01) { alpha = 0.0; } else if (median > 0.99) { alpha = 1.0; } // Gamma correction for coverage-like alpha float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114)); float gamma = mix(1.0, 1.0 / 2.2, luma); float coverage = pow(shapeColor.a * alpha, gamma); return coverage; } `}};let Va,Wa;class Om extends Ft{constructor(t){const e=new it({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new M,type:"mat3x3"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});Va!=null||(Va=lr({name:"sdf-shader",bits:[xi,yi(t),Rm,Dm,hr]})),Wa!=null||(Wa=cr({name:"sdf-shader",bits:[bi,vi(t),Pm,Mm,dr]})),super({glProgram:Wa,gpuProgram:Va,resources:{localUniforms:e,batchSamplers:Ti(t)}})}}class Ya extends Rt{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return this.fontFamily}get pageTextures(){return this.pages}get size(){return this.fontMetrics.fontSize}get distanceFieldRange(){return this.distanceField.range}get distanceFieldType(){return this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const s in this.chars)(e=this.chars[s].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(s=>s.texture.destroy(!0)),this.pages=null)}}var mS=Object.defineProperty,Bm=Object.getOwnPropertySymbols,gS=Object.prototype.hasOwnProperty,_S=Object.prototype.propertyIsEnumerable,Gm=(r,t,e)=>t in r?mS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fm=(r,t)=>{for(var e in t||(t={}))gS.call(t,e)&&Gm(r,e,t[e]);if(Bm)for(var e of Bm(t))_S.call(t,e)&&Gm(r,e,t[e]);return r};const Im=class By extends Ya{constructor(t){var e,s,i;super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;const n=Fm(Fm({},By.defaultOptions),t);this._textureSize=n.textureSize,this._mipmap=n.mipmap;const o=n.style.clone();n.overrideFill&&(o._fill.color=16777215,o._fill.alpha=1,o._fill.texture=C.WHITE,o._fill.fill=null),this.applyFillAsTint=n.overrideFill;const a=o.fontSize;o.fontSize=this.baseMeasurementFontSize;const u=ms(o);n.overrideSize?o._stroke&&(o._stroke.width*=this.baseRenderedFontSize/a):o.fontSize=this.baseRenderedFontSize=a,this._style=o,this._skipKerning=(e=n.skipKerning)!=null?e:!1,this.resolution=(s=n.resolution)!=null?s:1,this._padding=(i=n.padding)!=null?i:4,n.textureStyle&&(this._textureStyle=n.textureStyle instanceof Pt?n.textureStyle:new Pt(n.textureStyle)),this.fontMetrics=pt.measureFont(u),this.lineHeight=o.lineHeight||this.fontMetrics.fontSize||o.fontSize}ensureCharacters(t){var e,s,i,n;const o=pt.graphemeSegmenter(t).filter(y=>!this._currentChars.includes(y)).filter((y,A,T)=>T.indexOf(y)===A);if(!o.length)return;this._currentChars=[...this._currentChars,...o];let a;this._currentPageIndex===-1?a=this._nextPage():a=this.pages[this._currentPageIndex];let{canvas:u,context:l}=a.canvasAndContext,c=a.texture.source;const h=this._style;let d=this._currentX,p=this._currentY,f=this._currentMaxCharHeight;const g=this.baseRenderedFontSize/this.baseMeasurementFontSize,m=this._padding*g;let _=!1;const b=u.width/this.resolution,x=u.height/this.resolution;for(let y=0;yb&&(p+=f,f=E,d=0,p+f>x)){c.update();const L=this._nextPage();u=L.canvasAndContext.canvas,l=L.canvasAndContext.context,c=L.texture.source,d=0,p=0,f=0}const G=S/g-((s=(e=h.dropShadow)==null?void 0:e.distance)!=null?s:0)-((n=(i=h._stroke)==null?void 0:i.width)!=null?n:0);if(this.chars[A]={id:A.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:G,kerning:{}},_){this._drawGlyph(l,T,d+m,p+m,g,h);const L=c.width*g,N=c.height*g,It=new j(d/L*c.width,p/N*c.height,w/L*c.width,E/N*c.height);this.chars[A].texture=new C({source:c,frame:It}),d+=Math.ceil(w)}}c.update(),this._currentX=d,this._currentY=p,this._currentMaxCharHeight=f,this._skipKerning&&this._applyKerning(o,l)}get pageTextures(){return this.pages}_applyKerning(t,e){const s=this._measureCache;for(let i=0;i{const b=n.width;for(let x=0;x{let _=n.chars.length-1;if(s){let b=n.chars[_];for(;b===" ";)n.width-=e.chars[b].xAdvance,b=n.chars[--_]}i.width=Math.max(i.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,i.lines.push(n),i.height+=d},m=_=>_-c>h;for(let _=0;_t in r?vS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ka=(r,t)=>{for(var e in t||(t={}))TS.call(t,e)&&Lm(r,e,t[e]);if(km)for(var e of km(t))AS.call(t,e)&&Lm(r,e,t[e]);return r};let Li=0,SS=class{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1,textureStyle:null}}getFont(t,e){var s;let i=`${e.fontFamily}-bitmap`,n=!0;if(e._fill.fill&&!e._stroke)i+=e._fill.fill.styleKey,n=!1;else if(e._stroke||e.dropShadow){let a=e.styleKey;a=a.substring(0,a.lastIndexOf("-")),i=`${a}-bitmap`,n=!1}if(!z.has(i)){const a=Object.create(e);a.lineHeight=0;const u=new qa(Ka({style:a,overrideFill:n,overrideSize:!0},this.defaultOptions));Li++,Li>50&&Lt("BitmapText",`You have dynamically created ${Li} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),u.once("destroy",()=>{Li--,z.remove(i)}),z.set(i,u)}const o=z.get(i);return(s=o.ensureCharacters)==null||s.call(o,t),o}getLayout(t,e,s=!0){const i=this.getFont(t,e),n=pt.graphemeSegmenter(t);return ki(n,e,i,s)}measureText(t,e,s=!0){return this.getLayout(t,e,s)}install(...t){var e,s,i,n,o;let a=t[0];typeof a=="string"&&(a={name:a,style:t[1],chars:(e=t[2])==null?void 0:e.chars,resolution:(s=t[2])==null?void 0:s.resolution,padding:(i=t[2])==null?void 0:i.padding,skipKerning:(n=t[2])==null?void 0:n.skipKerning});const u=a==null?void 0:a.name;if(!u)throw new Error("[BitmapFontManager] Property `name` is required.");a=Ka(Ka({},this.defaultOptions),a);const l=a.style,c=l instanceof Bt?l:new Bt(l),h=(o=a.dynamicFill)!=null?o:this._canUseTintForStyle(c),d=new qa({style:c,overrideFill:h,skipKerning:a.skipKerning,padding:a.padding,resolution:a.resolution,overrideSize:!1,textureStyle:a.textureStyle}),p=Um(a.chars);return d.ensureCharacters(p.join("")),z.set(`${u}-bitmap`,d),d.once("destroy",()=>z.remove(`${u}-bitmap`)),d}uninstall(t){const e=`${t}-bitmap`,s=z.get(e);s&&s.destroy()}_canUseTintForStyle(t){return!t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}};const br=new SS;class Nm extends Or{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class Za{constructor(t){this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBitmapText")}validateRenderable(t){const e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const s=this._getGpuBitmapText(t);$m(t,s),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,s)),this._renderer.renderPipes.graphics.addRenderable(s,e),s.context.customShader&&this._updateDistanceField(t)}updateRenderable(t){const e=this._getGpuBitmapText(t);$m(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:s}=e,i=br.getFont(t.text,t._style);s.clear(),i.distanceField.type!=="none"&&(s.customShader||(s.customShader=new Om(this._renderer.limits.maxBatchableTextures)));const n=pt.graphemeSegmenter(t.text),o=t._style;let a=i.baseLineOffset;const u=ki(n,o,i,!0),l=o.padding,c=u.scale;let h=u.width,d=u.height+u.offsetY;o._stroke&&(h+=o._stroke.width/c,d+=o._stroke.width/c),s.translate(-t._anchor._x*h-l,-t._anchor._y*d-l).scale(c,c);const p=i.applyFillAsTint?o._fill.color:16777215;let f=i.fontMetrics.fontSize,g=i.lineHeight;o.lineHeight&&(f=o.fontSize/c,g=o.lineHeight/c);let m=(g-f)/2;m-i.baseLineOffset<0&&(m=0);for(let _=0;_{console.error(i)}),t._didTextUpdate=!1,Oi(s,t)),this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}async _updateGpuText(t){t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;e.texturePromise&&(this._renderer.htmlText.returnTexturePromise(e.texturePromise),e.texturePromise=null),e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const s=this._renderer.htmlText.getTexturePromise(t);e.texturePromise=s,e.texture=await s;const i=t.renderGroup||t.parentRenderGroup;i&&(i.structureDidChange=!0),e.generatingTexture=!1,Oi(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Xm(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.texture=C.EMPTY,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Qa.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"htmlText"};function Hm(){const{userAgent:r}=I.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}const jm="http://www.w3.org/2000/svg",zm="http://www.w3.org/1999/xhtml";class Ja{constructor(){this.svgRoot=document.createElementNS(jm,"svg"),this.foreignObject=document.createElementNS(jm,"foreignObject"),this.domElement=document.createElementNS(zm,"div"),this.styleElement=document.createElementNS(zm,"style");const{foreignObject:t,svgRoot:e,styleElement:s,domElement:i}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(s),t.appendChild(i),this.image=I.get().createImage()}}function Vm(r,t){const e=t.fontFamily,s=[],i={},n=/font-family:([^;"\s]+)/g,o=r.match(n);function a(u){i[u]||(s.push(u),i[u]=!0)}if(Array.isArray(e))for(let u=0;u{const l=u.split(":")[1].trim();a(l)});for(const u in t.tagStyles){const l=t.tagStyles[u].fontFamily;a(l)}return s}async function Wm(r){const t=await(await I.get().fetch(r)).blob(),e=new FileReader;return await new Promise((s,i)=>{e.onloadend=()=>s(e.result),e.onerror=i,e.readAsDataURL(t)})}async function Ym(r,t){const e=await Wm(t);return`@font-face { font-family: "${r.fontFamily}"; font-weight: ${r.fontWeight}; font-style: ${r.fontStyle}; src: url('${e}'); }`}const Ni=new Map;async function qm(r){const t=r.filter(e=>z.has(`${e}-and-url`)).map(e=>{if(!Ni.has(e)){const{entries:s}=z.get(`${e}-and-url`),i=[];s.forEach(n=>{const o=n.url,a=n.faces.map(u=>({weight:u.weight,style:u.style}));i.push(...a.map(u=>Ym({fontWeight:u.weight,fontStyle:u.style,fontFamily:e},o)))}),Ni.set(e,Promise.all(i).then(n=>n.join(` `)))}return Ni.get(e)});return(await Promise.all(t)).join(` `)}function Km(r,t,e,s,i){const{domElement:n,styleElement:o,svgRoot:a}=i;n.innerHTML=`
${r}
`,n.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),o.textContent=s;const{width:u,height:l}=i.image;return a.setAttribute("width",u.toString()),a.setAttribute("height",l.toString()),new XMLSerializer().serializeToString(a)}function Zm(r,t){const e=le.getOptimalCanvasAndContext(r.width,r.height,t),{context:s}=e;return s.clearRect(0,0,r.width,r.height),s.drawImage(r,0,0),e}function Qm(r,t,e){return new Promise(async s=>{e&&await new Promise(i=>setTimeout(i,100)),r.onload=()=>{s()},r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,r.crossOrigin="anonymous"})}let Jm;function tu(r,t,e,s){s||(s=Jm||(Jm=new Ja));const{domElement:i,styleElement:n,svgRoot:o}=s;i.innerHTML=`
${r}
`,i.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(n.textContent=e),document.body.appendChild(o);const a=i.getBoundingClientRect();o.remove();const u=t.padding*2;return{width:a.width-u,height:a.height-u}}class eu{constructor(t){this._renderer=t,this._createCanvas=t.type===Tt.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:s,resolution:i,textureStyle:n}=t,o=lt.get(Ja),a=Vm(e,s),u=await qm(a),l=tu(e,s,u,o),c=Math.ceil(Math.ceil(Math.max(1,l.width)+s.padding*2)*i),h=Math.ceil(Math.ceil(Math.max(1,l.height)+s.padding*2)*i),d=o.image,p=2;d.width=(c|0)+p,d.height=(h|0)+p;const f=Km(e,s,i,u,o);await Qm(d,f,Hm()&&a.length>0);const g=d;let m;this._createCanvas&&(m=Zm(d,i));const _=Ha(m?m.canvas:g,d.width-p,d.height-p,i);return n&&(_.source.style=n),this._createCanvas&&(this._renderer.texture.initSource(_.source),le.returnCanvasAndContext(m)),lt.return(o),_}returnTexturePromise(t){t.then(e=>{this._cleanUp(e)}).catch(()=>{})}_cleanUp(t){st.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null}}eu.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"htmlText"},U.add(eu),U.add(Qa);var ES=Object.defineProperty,tg=Object.getOwnPropertySymbols,wS=Object.prototype.hasOwnProperty,CS=Object.prototype.propertyIsEnumerable,eg=(r,t,e)=>t in r?ES(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rg=(r,t)=>{for(var e in t||(t={}))wS.call(t,e)&&eg(r,e,t[e]);if(tg)for(var e of tg(t))CS.call(t,e)&&eg(r,e,t[e]);return r};const sg=class Gy extends Fe{constructor(...t){var e;let s=(e=t[0])!=null?e:{};s instanceof Float32Array&&(s={positions:s,uvs:t[1],indices:t[2]}),s=rg(rg({},Gy.defaultOptions),s);const i=s.positions||new Float32Array([0,0,1,0,1,1,0,1]);let n=s.uvs;n||(s.positions?n=new Float32Array(i.length):n=new Float32Array([0,0,1,0,1,1,0,1]));const o=s.indices||new Uint32Array([0,1,2,0,2,3]),a=s.shrinkBuffersToFit,u=new vt({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:$.VERTEX|$.COPY_DST}),l=new vt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:$.VERTEX|$.COPY_DST}),c=new vt({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:$.INDEX|$.COPY_DST});super({attributes:{aPosition:{buffer:u,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:l,format:"float32x2",stride:2*4,offset:0}},indexBuffer:c,topology:s.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};sg.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let $e=sg;var RS=Object.defineProperty,PS=Object.defineProperties,DS=Object.getOwnPropertyDescriptors,ig=Object.getOwnPropertySymbols,MS=Object.prototype.hasOwnProperty,OS=Object.prototype.propertyIsEnumerable,ng=(r,t,e)=>t in r?RS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,og=(r,t)=>{for(var e in t||(t={}))MS.call(t,e)&&ng(r,e,t[e]);if(ig)for(var e of ig(t))OS.call(t,e)&&ng(r,e,t[e]);return r},ag=(r,t)=>PS(r,DS(t));const yr={name:"local-uniform-bit",vertex:{header:` struct LocalUniforms { uTransformMatrix:mat3x3, uColor:vec4, uRound:f32, } @group(1) @binding(0) var localUniforms : LocalUniforms; `,main:` vColor *= localUniforms.uColor; modelMatrix *= localUniforms.uTransformMatrix; `,end:` if(localUniforms.uRound == 1) { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } `}},ug=ag(og({},yr),{vertex:ag(og({},yr.vertex),{header:yr.vertex.header.replace("group(1)","group(2)")})}),$i={name:"local-uniform-bit",vertex:{header:` uniform mat3 uTransformMatrix; uniform vec4 uColor; uniform float uRound; `,main:` vColor *= uColor; modelMatrix = uTransformMatrix; `,end:` if(uRound == 1.) { gl_Position.xy = roundPixels(gl_Position.xy, uResolution); } `}},lg={name:"tiling-bit",vertex:{header:` struct TilingUniforms { uMapCoord:mat3x3, uClampFrame:vec4, uClampOffset:vec2, uTextureTransform:mat3x3, uSizeAnchor:vec4 }; @group(2) @binding(0) var tilingUniforms: TilingUniforms; @group(2) @binding(1) var uTexture: texture_2d; @group(2) @binding(2) var uSampler: sampler; `,main:` uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy; position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy; `},fragment:{header:` struct TilingUniforms { uMapCoord:mat3x3, uClampFrame:vec4, uClampOffset:vec2, uTextureTransform:mat3x3, uSizeAnchor:vec4 }; @group(2) @binding(0) var tilingUniforms: TilingUniforms; @group(2) @binding(1) var uTexture: texture_2d; @group(2) @binding(2) var uSampler: sampler; `,main:` var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV); coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy; var unclamped = coord; coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw); var bias = 0.; if(unclamped.x == coord.x && unclamped.y == coord.y) { bias = -32.; } outColor = textureSampleBias(uTexture, uSampler, coord, bias); `}},cg={name:"tiling-bit",vertex:{header:` uniform mat3 uTextureTransform; uniform vec4 uSizeAnchor; `,main:` uv = (uTextureTransform * vec3(aUV, 1.0)).xy; position = (position - uSizeAnchor.zw) * uSizeAnchor.xy; `},fragment:{header:` uniform sampler2D uTexture; uniform mat3 uMapCoord; uniform vec4 uClampFrame; uniform vec2 uClampOffset; `,main:` vec2 coord = vUV + ceil(uClampOffset - vUV); coord = (uMapCoord * vec3(coord, 1.0)).xy; vec2 unclamped = coord; coord = clamp(coord, uClampFrame.xy, uClampFrame.zw); outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0 `}};let ru,su;class hg extends Ft{constructor(){ru!=null||(ru=lr({name:"tiling-sprite-shader",bits:[yr,lg,hr]})),su!=null||(su=cr({name:"tiling-sprite-shader",bits:[$i,cg,dr]}));const t=new it({uMapCoord:{value:new M,type:"mat3x3"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2"},uTextureTransform:{value:new M,type:"mat3x3"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4"}});super({glProgram:su,gpuProgram:ru,resources:{localUniforms:new it({uTransformMatrix:{value:new M,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:C.EMPTY.source,uSampler:C.EMPTY.source.style}})}updateUniforms(t,e,s,i,n,o){const a=this.resources.tilingUniforms,u=o.width,l=o.height,c=o.textureMatrix,h=a.uniforms.uTextureTransform;h.set(s.a*u/t,s.b*u/e,s.c*l/t,s.d*l/e,s.tx/t,s.ty/e),h.invert(),a.uniforms.uMapCoord=c.mapCoord,a.uniforms.uClampFrame=c.uClampFrame,a.uniforms.uClampOffset=c.uClampOffset,a.uniforms.uTextureTransform=h,a.uniforms.uSizeAnchor[0]=t,a.uniforms.uSizeAnchor[1]=e,a.uniforms.uSizeAnchor[2]=i,a.uniforms.uSizeAnchor[3]=n,o&&(this.resources.uTexture=o.source,this.resources.uSampler=o.source.style)}}class dg extends $e{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}function pg(r,t){const e=r.anchor.x,s=r.anchor.y;t[0]=-e*r.width,t[1]=-s*r.height,t[2]=(1-e)*r.width,t[3]=-s*r.height,t[4]=(1-e)*r.width,t[5]=(1-s)*r.height,t[6]=-e*r.width,t[7]=(1-s)*r.height}function fg(r,t,e,s){let i=0;const n=r.length/(t||2),o=s.a,a=s.b,u=s.c,l=s.d,c=s.tx,h=s.ty;for(e*=t;it in r?BS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bg=(r,t)=>{for(var e in t||(t={}))GS.call(t,e)&&xg(r,e,t[e]);if(_g)for(var e of _g(t))FS.call(t,e)&&xg(r,e,t[e]);return r};const yg=class Fy extends $e{constructor(...t){var e;super({});let s=(e=t[0])!=null?e:{};typeof s=="number"&&(s={width:s,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(s)}build(t){var e,s,i,n;t=bg(bg({},Fy.defaultOptions),t),this.verticesX=(e=this.verticesX)!=null?e:t.verticesX,this.verticesY=(s=this.verticesY)!=null?s:t.verticesY,this.width=(i=this.width)!=null?i:t.width,this.height=(n=this.height)!=null?n:t.height;const o=this.verticesX*this.verticesY,a=[],u=[],l=[],c=this.verticesX-1,h=this.verticesY-1,d=this.width/c,p=this.height/h;for(let g=0;gt in r?IS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ag=(r,t)=>{for(var e in t||(t={}))US.call(t,e)&&Tg(r,e,t[e]);if(vg)for(var e of vg(t))kS.call(t,e)&&Tg(r,e,t[e]);return r};const Sg=class Iy extends Hi{constructor(t={}){t=Ag(Ag({},Iy.defaultOptions),t),super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){var e,s,i,n,o,a,u,l,c,h;this.width=(e=t.width)!=null?e:this.width,this.height=(s=t.height)!=null?s:this.height,this._originalWidth=(i=t.originalWidth)!=null?i:this._originalWidth,this._originalHeight=(n=t.originalHeight)!=null?n:this._originalHeight,this._leftWidth=(o=t.leftWidth)!=null?o:this._leftWidth,this._rightWidth=(a=t.rightWidth)!=null?a:this._rightWidth,this._topHeight=(u=t.topHeight)!=null?u:this._topHeight,this._bottomHeight=(l=t.bottomHeight)!=null?l:this._bottomHeight,this._anchorX=(c=t.anchor)==null?void 0:c.x,this._anchorY=(h=t.anchor)==null?void 0:h.y,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:s,_leftWidth:i,_rightWidth:n,_topHeight:o,_bottomHeight:a,_anchorX:u,_anchorY:l}=this,c=i+n,h=e>c?1:e/c,d=o+a,p=s>d?1:s/d,f=Math.min(h,p),g=u*e,m=l*s;t[0]=t[8]=t[16]=t[24]=-g,t[2]=t[10]=t[18]=t[26]=i*f-g,t[4]=t[12]=t[20]=t[28]=e-n*f-g,t[6]=t[14]=t[22]=t[30]=e-g,t[1]=t[3]=t[5]=t[7]=-m,t[9]=t[11]=t[13]=t[15]=o*f-m,t[17]=t[19]=t[21]=t[23]=s-a*f-m,t[25]=t[27]=t[29]=t[31]=s-m,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,s=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=s*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-s*this._bottomHeight,this.getBuffer("aUV").update()}};Sg.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let ye=Sg;class Eg extends Mi{constructor(){super(),this.geometry=new ye}destroy(){this.geometry.destroy()}}class nu{constructor(t){this._renderer=t}addRenderable(t,e){const s=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,s),this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture)}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=t._gpuData[this._renderer.uid]=new Eg,s=e;return s.renderable=t,s.transform=t.groupTransform,s.texture=t._texture,s.roundPixels=this._renderer._roundPixels|t._roundPixels,t.didViewUpdate||this._updateBatchableSprite(t,s),e}destroy(){this._renderer=null}}nu.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"nineSliceSprite"},U.add(nu);class ou{constructor(t){this._renderer=t}push(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}ou.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"filter"};function wg(r,t){t.clear();const e=t.matrix;for(let s=0;s"},uInputPixel:{value:new Float32Array(4),type:"vec4"},uInputClamp:{value:new Float32Array(4),type:"vec4"},uOutputFrame:{value:new Float32Array(4),type:"vec4"},uGlobalFrame:{value:new Float32Array(4),type:"vec4"},uOutputTexture:{value:new Float32Array(4),type:"vec4"}}),this._globalFilterBindGroup=new Zt({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){const e=this.renderer,s=t.filterEffect.filters,i=this._pushFilterData();i.skip=!1,i.filters=s,i.container=t.container,i.outputRenderSurface=e.renderTarget.renderSurface;const n=e.renderTarget.renderTarget.colorTexture.source,o=n.resolution,a=n.antialias;if(s.length===0){i.skip=!0;return}const u=i.bounds;if(this._calculateFilterArea(t,u),this._calculateFilterBounds(i,e.renderTarget.rootViewPort,a,o,1),i.skip)return;const l=this._getPreviousFilterData(),c=this._findFilterResolution(o);let h=0,d=0;l&&(h=l.bounds.minX,d=l.bounds.minY),this._calculateGlobalFrame(i,h,d,c,n.width,n.height),this._setupFilterTextures(i,u,e,l)}generateFilteredTexture({texture:t,filters:e}){const s=this._pushFilterData();this._activeFilterData=s,s.skip=!1,s.filters=e;const i=t.source,n=i.resolution,o=i.antialias;if(e.length===0)return s.skip=!0,t;const a=s.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(s,a.rectangle,o,n,0),s.skip)return t;const u=n,l=0,c=0;this._calculateGlobalFrame(s,l,c,u,i.width,i.height),s.outputRenderSurface=st.getOptimalTexture(a.width,a.height,s.resolution,s.antialias),s.backTexture=C.EMPTY,s.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(s,!0);const h=s.outputRenderSurface;return h.source.alphaMode="premultiplied-alpha",h}pop(){const t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&st.returnTexture(e.backTexture),st.returnTexture(e.inputTexture))}getBackTexture(t,e,s){const i=t.colorTexture.source._resolution,n=st.getOptimalTexture(e.width,e.height,i,!1);let o=e.minX,a=e.minY;s&&(o-=s.minX,a-=s.minY),o=Math.floor(o*i),a=Math.floor(a*i);const u=Math.ceil(e.width*i),l=Math.ceil(e.height*i);return this.renderer.renderTarget.copyToTexture(t,n,{x:o,y:a},{width:u,height:l},{x:0,y:0}),n}applyFilter(t,e,s,i){const n=this.renderer,o=this._activeFilterData,a=o.outputRenderSurface===s,u=n.renderTarget.rootRenderTarget.colorTexture.source._resolution,l=this._findFilterResolution(u);let c=0,h=0;if(a){const d=this._findPreviousFilterOffset();c=d.x,h=d.y}this._updateFilterUniforms(e,s,o,c,h,l,a,i),this._setupBindGroupsAndRender(t,e,n)}calculateSpriteMatrix(t,e){const s=this._activeFilterData,i=t.set(s.inputTexture._source.width,0,0,s.inputTexture._source.height,s.bounds.minX,s.bounds.minY),n=e.worldTransform.copyTo(M.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),i.prepend(n),i.scale(1/e.texture.orig.width,1/e.texture.orig.height),i.translate(e.anchor.x,e.anchor.y),i}destroy(){}_setupBindGroupsAndRender(t,e,s){if(s.renderPipes.uniformBatch){const i=s.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(i,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,s.encoder.draw({geometry:LS,shader:t,state:t._state,topology:"triangle-list"}),s.type===Tt.WEBGL&&s.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,s,i){if(t.backTexture=C.EMPTY,t.blendRequired){s.renderTarget.finishRenderPass();const n=s.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(n,e,i==null?void 0:i.bounds)}t.inputTexture=st.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),s.renderTarget.bind(t.inputTexture,!0),s.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,s,i,n,o){const a=t.globalFrame;a.x=e*i,a.y=s*i,a.width=n*i,a.height=o*i}_updateFilterUniforms(t,e,s,i,n,o,a,u){const l=this._filterGlobalUniforms.uniforms,c=l.uOutputFrame,h=l.uInputSize,d=l.uInputPixel,p=l.uInputClamp,f=l.uGlobalFrame,g=l.uOutputTexture;a?(c[0]=s.bounds.minX-i,c[1]=s.bounds.minY-n):(c[0]=0,c[1]=0),c[2]=t.frame.width,c[3]=t.frame.height,h[0]=t.source.width,h[1]=t.source.height,h[2]=1/h[0],h[3]=1/h[1],d[0]=t.source.pixelWidth,d[1]=t.source.pixelHeight,d[2]=1/d[0],d[3]=1/d[1],p[0]=.5*d[2],p[1]=.5*d[3],p[2]=t.frame.width*h[2]-.5*d[2],p[3]=t.frame.height*h[3]-.5*d[3];const m=this.renderer.renderTarget.rootRenderTarget.colorTexture;f[0]=i*o,f[1]=n*o,f[2]=m.source.width*o,f[3]=m.source.height*o,e instanceof C&&(e.source.resource=null);const _=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!u),e instanceof C?(g[0]=e.frame.width,g[1]=e.frame.height):(g[0]=_.width,g[1]=_.height),g[2]=_.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,s=this._filterStackIndex;for(;s>0;){s--;const i=this._filterStack[s];if(!i.skip){t=i.bounds.minX,e=i.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?wg(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const s=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;s&&e.applyMatrix(s)}}_applyFiltersToTexture(t,e){const s=t.inputTexture,i=t.bounds,n=t.filters;if(this._globalFilterBindGroup.setResource(s.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),n.length===1)n[0].apply(this,s,t.outputRenderSurface,e);else{let o=t.inputTexture;const a=st.getOptimalTexture(i.width,i.height,o.source._resolution,!1);let u=a,l=0;for(l=0;l1&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new NS),this._filterStackIndex++,t}}au.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"filter"},U.add(au),U.add(ou);var $S={__proto__:null};const uu=[];U.handleByNamedList(v.Environment,uu);async function lu(r){if(!r)for(let t=0;t(r[r.NONE=0]="NONE",r[r.COLOR=16384]="COLOR",r[r.STENCIL=1024]="STENCIL",r[r.DEPTH=256]="DEPTH",r[r.COLOR_DEPTH=16640]="COLOR_DEPTH",r[r.COLOR_STENCIL=17408]="COLOR_STENCIL",r[r.DEPTH_STENCIL=1280]="DEPTH_STENCIL",r[r.ALL=17664]="ALL",r))(At||{});class hu{constructor(t){this.items=[],this._name=t}emit(t,e,s,i,n,o,a,u){const{name:l,items:c}=this;for(let h=0,d=c.length;ht in r?HS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ji=(r,t)=>{for(var e in t||(t={}))jS.call(t,e)&&Rg(r,e,t[e]);if(Cg)for(var e of Cg(t))zS.call(t,e)&&Rg(r,e,t[e]);return r};const VS=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Pg=class Uy extends Rt{constructor(t){var e;super(),this.uid=Y("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const s=[...VS,...(e=this.config.runners)!=null?e:[]];this._addRunners(...s),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await lu(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const s in this._systemsHash){const i=this._systemsHash[s].constructor.defaultOptions;t=ji(ji({},i),t)}t=ji(ji({},Uy.defaultOptions),t),this._roundPixels=t.roundPixels?1:0;for(let s=0;s{this.runners[e]=new hu(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const i in this.runners)this.runners[i].add(s);return this}_addPipes(t,e){const s=e.reduce((i,n)=>(i[n.name]=n.value,i),{});t.forEach(i=>{const n=i.value,o=i.name,a=s[o];this.renderPipes[o]=new n(this,a?new a:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!cu())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};Pg.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let xs=Pg,du;function bs(r){return du!==void 0||(du=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:xs.defaultOptions.failIfMajorPerformanceCaveat};try{if(!I.get().getWebGLRenderingContext())return!1;let s=I.get().createCanvas().getContext("webgl",e);const i=!!((t=s==null?void 0:s.getContextAttributes())!=null&&t.stencil);if(s){const n=s.getExtension("WEBGL_lose_context");n&&n.loseContext()}return s=null,i}catch(s){return!1}})()),du}let pu;async function ys(r={}){return pu!==void 0||(pu=await(async()=>{const t=I.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch(e){return!1}})()),pu}var WS=Object.defineProperty,Dg=Object.getOwnPropertySymbols,YS=Object.prototype.hasOwnProperty,qS=Object.prototype.propertyIsEnumerable,Mg=(r,t,e)=>t in r?WS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,vs=(r,t)=>{for(var e in t||(t={}))YS.call(t,e)&&Mg(r,e,t[e]);if(Dg)for(var e of Dg(t))qS.call(t,e)&&Mg(r,e,t[e]);return r};const Og=["webgl","webgpu","canvas"];async function Bg(r){var t;let e=[];r.preference?(e.push(r.preference),Og.forEach(o=>{o!==r.preference&&e.push(o)})):e=Og.slice();let s,i={};for(let o=0;ot in r?ZS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,t3=(r,t)=>{for(var e in t||(t={}))QS.call(t,e)&&Fg(r,e,t[e]);if(Gg)for(var e of Gg(t))JS.call(t,e)&&Fg(r,e,t[e]);return r};const Ig=class Ec{constructor(...t){this.stage=new et}async init(t){t=t3({},t),this.renderer=await Bg(t),Ec._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const s=Ec._plugins.slice(0);s.reverse(),s.forEach(i=>{i.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Ig._plugins=[];let Ug=Ig;U.handleByList(v.Application,Ug._plugins),U.add(fu);class gu extends Ya{constructor(t,e){var s;super();const{textures:i,data:n}=t;Object.keys(n.pages).forEach(o=>{const a=n.pages[parseInt(o,10)],u=i[a.id];this.pages.push({texture:u})}),Object.keys(n.chars).forEach(o=>{var a;const u=n.chars[o],{frame:l,source:c,rotate:h}=i[u.page],d=k.transformRectCoords(u,l,h,new j),p=new C({frame:d,orig:new j(0,0,u.width,u.height),source:c,rotate:h});this.chars[o]={id:o.codePointAt(0),xOffset:u.xOffset,yOffset:u.yOffset,xAdvance:u.xAdvance,kerning:(a=u.kerning)!=null?a:{},texture:p}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=(s=n.distanceField)!=null?s:{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t")?_u.test(I.get().parseXML(r)):!1},parse(r){return _u.parse(I.get().parseXML(r))}},e3=[".xml",".fnt"],kg={extension:{type:v.CacheParser,name:"cacheBitmapFont"},test:r=>r instanceof gu,getCacheableAssets(r,t){const e={};return r.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Lg={extension:{type:v.LoadParser,priority:Ct.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return e3.includes(yt.extname(r).toLowerCase())},async testParse(r){return zi.test(r)||xu.test(r)},async parse(r,t,e){const s=zi.test(r)?zi.parse(r):xu.parse(r),{src:i}=t,{pages:n}=s,o=[],a=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let c=0;cu[c.src]);return new gu({data:s,textures:l},i)},async load(r,t){return await(await I.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(s=>e.unload(s.texture.source._sourceOrigin))),r.destroy()}};class Ng{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let s=0;sArray.isArray(r)&&r.every(t=>t instanceof C),getCacheableAssets:(r,t)=>{const e={};return r.forEach(s=>{t.forEach((i,n)=>{e[s+(n===0?"":n+1)]=i})}),e}};async function bu(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch(t){return!1}return!0}return!1}const Xg={extension:{type:v.DetectionParser,priority:1},test:async()=>bu("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},Hg=["png","jpg","jpeg"],jg={extension:{type:v.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Hg],remove:async r=>r.filter(t=>!Hg.includes(t))},r3="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function As(r){return r3?!1:document.createElement("video").canPlayType(r)!==""}const zg={extension:{type:v.DetectionParser,priority:0},test:async()=>As("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},Vg={extension:{type:v.DetectionParser,priority:0},test:async()=>As("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},Wg={extension:{type:v.DetectionParser,priority:0},test:async()=>As("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},Yg={extension:{type:v.DetectionParser,priority:0},test:async()=>bu("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};class qg{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var i,n;let o=null,a=null;if((e.parser||e.loadParser)&&(a=this._parserHash[e.parser||e.loadParser]),!a){for(let u=0;u({alias:[l],src:l,data:{}})),a=o.length,u=o.map(async l=>{const c=yt.toAbsolute(l.src);if(!i[l.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,l)),i[l.src]=await this.promiseCache[c].promise,e&&e(++s/a)}catch(h){throw delete this.promiseCache[c],delete i[l.src],new Error(`[Loader.load] Failed to load ${c}. ${h}`)}});return await Promise.all(u),n?i[o[0].src]:i}async unload(t){const e=Ut(t,s=>({alias:[s],src:s})).map(async s=>{var i,n;const o=yt.toAbsolute(s.src),a=this.promiseCache[o];if(a){const u=await a.promise;delete this.promiseCache[o],await((n=(i=a.parser)==null?void 0:i.unload)==null?void 0:n.call(i,u,s,this))}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(!e.name&&!e.id||t[e.name]||t[e.id],t[e.name]=e,e.id&&(t[e.id]=e),t),{})}}function Xe(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function Nt(r,t){const e=r.split("?")[0],s=yt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const s3=".json",i3="application/json",Kg={extension:{type:v.LoadParser,priority:Ct.Low},name:"loadJson",id:"json",test(r){return Xe(r,i3)||Nt(r,s3)},async load(r){return await(await I.get().fetch(r)).json()}},n3=".txt",o3="text/plain",Zg={name:"loadTxt",id:"text",extension:{type:v.LoadParser,priority:Ct.Low,name:"loadTxt"},test(r){return Xe(r,o3)||Nt(r,n3)},async load(r){return await(await I.get().fetch(r)).text()}};var a3=Object.defineProperty,u3=Object.defineProperties,l3=Object.getOwnPropertyDescriptors,Qg=Object.getOwnPropertySymbols,c3=Object.prototype.hasOwnProperty,h3=Object.prototype.propertyIsEnumerable,Jg=(r,t,e)=>t in r?a3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,d3=(r,t)=>{for(var e in t||(t={}))c3.call(t,e)&&Jg(r,e,t[e]);if(Qg)for(var e of Qg(t))h3.call(t,e)&&Jg(r,e,t[e]);return r},p3=(r,t)=>u3(r,l3(t));const f3=["normal","bold","100","200","300","400","500","600","700","800","900"],m3=[".ttf",".otf",".woff",".woff2"],g3=["font/ttf","font/otf","font/woff","font/woff2"],_3=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function t_(r){const t=yt.extname(r),e=yt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let s=e.length>0;for(const n of e)if(!n.match(_3)){s=!1;break}let i=e.join(" ");return s||(i=`"${i.replace(/[\\"]/g,"\\$&")}"`),i}const x3=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function b3(r){return x3.test(r)?r:encodeURI(r)}const e_={extension:{type:v.LoadParser,priority:Ct.Low},name:"loadWebFont",id:"web-font",test(r){return Xe(r,g3)||Nt(r,m3)},async load(r,t){var e,s,i,n,o,a;const u=I.get().getFontFaceSet();if(u){const l=[],c=(s=(e=t.data)==null?void 0:e.family)!=null?s:t_(r),h=(o=(n=(i=t.data)==null?void 0:i.weights)==null?void 0:n.filter(p=>f3.includes(p)))!=null?o:["normal"],d=(a=t.data)!=null?a:{};for(let p=0;pn.faces.some(o=>t.indexOf(o)!==-1));i.faces=i.faces.filter(n=>t.indexOf(n)===-1),i.faces.length===0&&(s.entries=s.entries.filter(n=>n!==i)),t.forEach(n=>{I.get().getFontFaceSet().delete(n)}),s.entries.length===0&&z.remove(`${e}-and-url`)}};function Vi(r,t=1){var e;const s=(e=_e.RETINA_PREFIX)==null?void 0:e.exec(r);return s?parseFloat(s[1]):t}function ve(r,t,e){r.label=e,r._sourceOrigin=e;const s=new C({source:r,label:e}),i=()=>{delete t.promiseCache[e],z.has(e)&&z.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&i()}),s.once("destroy",()=>{r.destroyed||i()}),s}var y3=Object.defineProperty,Wi=Object.getOwnPropertySymbols,r_=Object.prototype.hasOwnProperty,s_=Object.prototype.propertyIsEnumerable,i_=(r,t,e)=>t in r?y3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,v3=(r,t)=>{for(var e in t||(t={}))r_.call(t,e)&&i_(r,e,t[e]);if(Wi)for(var e of Wi(t))s_.call(t,e)&&i_(r,e,t[e]);return r},T3=(r,t)=>{var e={};for(var s in r)r_.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Wi)for(var s of Wi(r))t.indexOf(s)<0&&s_.call(r,s)&&(e[s]=r[s]);return e};const A3=".svg",S3="image/svg+xml",n_={extension:{type:v.LoadParser,priority:Ct.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return Xe(r,S3)||Nt(r,A3)},async load(r,t,e){var s,i;return((i=(s=t.data)==null?void 0:s.parseAsGraphicsContext)!=null?i:this.config.parseAsGraphicsContext)?w3(r):E3(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function E3(r,t,e,s){var i,n,o,a,u,l;const c=await(await I.get().fetch(r)).blob(),h=URL.createObjectURL(c),d=I.get().createImage();d.src=h,d.crossOrigin=s,await d.decode(),URL.revokeObjectURL(h);const p=(n=(i=t.data)==null?void 0:i.width)!=null?n:d.width,f=(a=(o=t.data)==null?void 0:o.height)!=null?a:d.height,g=((u=t.data)==null?void 0:u.resolution)||Vi(r),m=I.get().createCanvas(p*g,f*g);m.getContext("2d").drawImage(d,0,0,p*g,f*g);const _=(l=t.data)!=null?l:{},{parseAsGraphicsContext:b}=_,x=T3(_,["parseAsGraphicsContext"]),y=new xe(v3({resource:m,alphaMode:"premultiply-alpha-on-upload",resolution:g},x));return ve(y,e,r)}async function w3(r){const t=await(await I.get().fetch(r)).text(),e=new mt;return e.svg(t),e}const C3=`(function(){"use strict";const e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";async function a(){try{if(typeof createImageBitmap!="function")return!1;const A=await(await fetch(e)).blob(),t=await createImageBitmap(A);return t.width===1&&t.height===1}catch(A){return!1}}a().then(A=>{self.postMessage(A)})})(); `;let vr=null,yu=class{constructor(){vr||(vr=URL.createObjectURL(new Blob([C3],{type:"application/javascript"}))),this.worker=new Worker(vr)}};yu.revokeObjectURL=function(){vr&&(URL.revokeObjectURL(vr),vr=null)};const R3='(function(){"use strict";async function s(a,t){const e=await fetch(a);if(!e.ok)throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${a}: ${e.status} ${e.statusText}`);const i=await e.blob();return t==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}self.onmessage=async a=>{try{const t=await s(a.data.data[0],a.data.data[1]);self.postMessage({data:t,uuid:a.data.uuid,id:a.data.id},[t])}catch(t){self.postMessage({error:t,uuid:a.data.uuid,id:a.data.id})}}})();\n';let Tr=null,o_=class{constructor(){Tr||(Tr=URL.createObjectURL(new Blob([R3],{type:"application/javascript"}))),this.worker=new Worker(Tr)}};o_.revokeObjectURL=function(){Tr&&(URL.revokeObjectURL(Tr),Tr=null)};let a_=0,vu,P3=class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new yu;e.addEventListener("message",s=>{e.terminate(),yu.revokeObjectURL(),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var s;return this._run("loadImageBitmap",[t,(s=e==null?void 0:e.data)==null?void 0:s.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){vu===void 0&&(vu=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const s=new Promise((i,n)=>{this._queue.push({id:t,arguments:e,resolve:i,reject:n})});return this._next(),s}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),s=e.id;this._resolveHash[a_]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:a_++,id:s})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t==null||t(new Error("WorkerManager destroyed"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}};const Tu=new P3;var D3=Object.defineProperty,u_=Object.getOwnPropertySymbols,M3=Object.prototype.hasOwnProperty,O3=Object.prototype.propertyIsEnumerable,l_=(r,t,e)=>t in r?D3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,B3=(r,t)=>{for(var e in t||(t={}))M3.call(t,e)&&l_(r,e,t[e]);if(u_)for(var e of u_(t))O3.call(t,e)&&l_(r,e,t[e]);return r};const G3=[".jpeg",".jpg",".png",".webp",".avif"],F3=["image/jpeg","image/png","image/webp","image/avif"];async function c_(r,t){var e;const s=await I.get().fetch(r);if(!s.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${s.status} ${s.statusText}`);const i=await s.blob();return((e=t==null?void 0:t.data)==null?void 0:e.alphaMode)==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const Au={name:"loadTextures",id:"texture",extension:{type:v.LoadParser,priority:Ct.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Xe(r,F3)||Nt(r,G3)},async load(r,t,e){var s;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Tu.isImageBitmapSupported()?i=await Tu.loadImageBitmap(r,t):i=await c_(r,t):i=await new Promise((o,a)=>{i=I.get().createImage(),i.crossOrigin=this.config.crossOrigin,i.src=r,i.complete?o(i):(i.onload=()=>{o(i)},i.onerror=a)});const n=new xe(B3({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((s=t.data)==null?void 0:s.resolution)||Vi(r)},t.data));return ve(n,e,r)},unload(r){r.destroy(!0)}};var I3=Object.defineProperty,U3=Object.defineProperties,k3=Object.getOwnPropertyDescriptors,h_=Object.getOwnPropertySymbols,L3=Object.prototype.hasOwnProperty,N3=Object.prototype.propertyIsEnumerable,d_=(r,t,e)=>t in r?I3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Su=(r,t)=>{for(var e in t||(t={}))L3.call(t,e)&&d_(r,e,t[e]);if(h_)for(var e of h_(t))N3.call(t,e)&&d_(r,e,t[e]);return r},p_=(r,t)=>U3(r,k3(t));const $3=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let Eu,wu;function f_(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=g_(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function m_(r){return new Promise((t,e)=>{r.addEventListener("canplaythrough",s),r.addEventListener("error",i),r.load();function s(){n(),t()}function i(o){n(),e(o)}function n(){r.removeEventListener("canplaythrough",s),r.removeEventListener("error",i)}})}function g_(r,t=globalThis.location){if(r.startsWith("data:"))return"";t||(t=globalThis.location);const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function X3(){const r=[],t=[];for(const e of $3){const s=ir.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;As(s)&&(r.push(e),t.includes(s)||t.push(s))}return{validVideoExtensions:r,validVideoMime:t}}const __={name:"loadVideo",id:"video",extension:{type:v.LoadParser,name:"loadVideo"},test(r){if(!Eu||!wu){const{validVideoExtensions:s,validVideoMime:i}=X3();Eu=s,wu=i}const t=Xe(r,wu),e=Nt(r,Eu);return t||e},async load(r,t,e){var s,i;const n=Su(p_(Su({},ir.defaultOptions),{resolution:((s=t.data)==null?void 0:s.resolution)||Vi(r),alphaMode:((i=t.data)==null?void 0:i.alphaMode)||await Uo()}),t.data),o=document.createElement("video"),a={preload:n.autoLoad!==!1?"auto":void 0,"webkit-playsinline":n.playsinline!==!1?"":void 0,playsinline:n.playsinline!==!1?"":void 0,muted:n.muted===!0?"":void 0,loop:n.loop===!0?"":void 0,autoplay:n.autoPlay!==!1?"":void 0};Object.keys(a).forEach(c=>{const h=a[c];h!==void 0&&o.setAttribute(c,h)}),n.muted===!0&&(o.muted=!0),f_(o,r,n.crossorigin);const u=document.createElement("source");let l;if(n.mime)l=n.mime;else if(r.startsWith("data:"))l=r.slice(5,r.indexOf(";"));else if(!r.startsWith("blob:")){const c=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();l=ir.MIME_TYPES[c]||`video/${c}`}return u.src=r,l&&(u.type=l),new Promise(c=>{const h=async()=>{const d=new ir(p_(Su({},n),{resource:o}));o.removeEventListener("canplay",h),t.data.preload&&await m_(o),c(ve(d,e,r))};n.preload&&!n.autoPlay&&o.load(),o.addEventListener("canplay",h),o.appendChild(u)})},unload(r){r.destroy(!0)}},Cu={extension:{type:v.ResolveParser,name:"resolveTexture"},test:Au.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=_e.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},x_={extension:{type:v.ResolveParser,priority:-2,name:"resolveJson"},test:r=>_e.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:Cu.parse};class b_{constructor(){this._detections=[],this._initialized=!1,this.resolver=new _e,this.loader=new qg,this.cache=z,this._backgroundLoader=new Ng(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var e,s,i;if(this._initialized)return;if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let u=t.manifest;typeof u=="string"&&(u=await this.load(u)),this.resolver.addManifest(u)}const n=(s=(e=t.texturePreference)==null?void 0:e.resolution)!=null?s:1,o=typeof n=="number"?[n]:n,a=await this._detectFormats({preferredFormats:(i=t.texturePreference)==null?void 0:i.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:a,resolution:o}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=qr(t),i=Ut(t).map(a=>{if(typeof a!="string"){const u=this.resolver.getAlias(a);return u.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(u)?u[0]:u}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(i),o=await this._mapLoadToResolve(n,e);return s?o[i[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!0,t=[t]);const i=this.resolver.resolveBundle(t),n={},o=Object.keys(i);let a=0,u=0;const l=()=>{e==null||e(++a/u)},c=o.map(h=>{const d=i[h],p=Object.values(d),f=[...new Set(p.flat())];return u+=f.length,this._mapLoadToResolve(d,l).then(g=>{n[h]=g})});return await Promise.all(c),s?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return z.get(t);const e={};for(let s=0;s{const a=i[o.src],u=[o.src];o.alias&&u.push(...o.alias),u.forEach(l=>{n[l]=a}),z.set(u,a)}),n}async unload(t){this._initialized||await this.init();const e=Ut(t).map(i=>typeof i!="string"?i.src:i),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=Ut(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(i=>this._unloadFromResolved(e[i]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{z.remove(s.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const s of t.detections)t.skipDetections||await s.test()?e=await s.add(e):t.skipDetections||(e=await s.remove(e));return e=e.filter((s,i)=>e.indexOf(s)===i),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(s=>s in t).forEach(s=>{e.config[s]=t[s]})})}}const Ss=new b_;U.handleByList(v.LoadParser,Ss.loader.parsers).handleByList(v.ResolveParser,Ss.resolver.parsers).handleByList(v.CacheParser,Ss.cache.parsers).handleByList(v.DetectionParser,Ss.detections),U.add($g,jg,Xg,Yg,zg,Vg,Wg,Kg,Zg,e_,n_,Au,__,Lg,kg,Cu,x_);const y_={loader:v.LoadParser,resolver:v.ResolveParser,cache:v.CacheParser,detection:v.DetectionParser};U.handle(v.Asset,r=>{const t=r.ref;Object.entries(y_).filter(([e])=>!!t[e]).forEach(([e,s])=>{var i;return U.add(Object.assign(t[e],{extension:(i=t[e].extension)!=null?i:s}))})},r=>{const t=r.ref;Object.keys(y_).filter(e=>!!t[e]).forEach(e=>U.remove(t[e]))});const H3={extension:{type:v.DetectionParser,priority:3},test:async()=>!!(await ys()||bs()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};class Es extends K{constructor(t){super(t),this.uploadMethodId="compressed",this.resource=t.resource,this.mipLevelCount=this.resource.length}}let Yi;function Ru(){if(Yi)return Yi;const r=I.get().createCanvas(1,1).getContext("webgl");return r?(Yi=[...r.getExtension("EXT_texture_compression_bptc")?["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"]:[],...r.getExtension("WEBGL_compressed_texture_s3tc")?["bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"]:[],...r.getExtension("WEBGL_compressed_texture_s3tc_srgb")?["bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"]:[],...r.getExtension("EXT_texture_compression_rgtc")?["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"]:[],...r.getExtension("WEBGL_compressed_texture_etc")?["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","eac-r11unorm","eac-rg11unorm"]:[],...r.getExtension("WEBGL_compressed_texture_astc")?["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]:[]],Yi):[]}let qi;async function Pu(){if(qi)return qi;const r=await I.get().getNavigator().gpu.requestAdapter();return qi=[...r.features.has("texture-compression-bc")?["bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb","bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm","bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"]:[],...r.features.has("texture-compression-etc2")?["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"]:[],...r.features.has("texture-compression-astc")?["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]:[]],qi}let Du;async function Mu(){return Du!==void 0||(Du=await(async()=>{const r=await ys(),t=bs();if(r&&t){const e=await Pu(),s=Ru();return e.filter(i=>s.includes(i))}else{if(r)return await Pu();if(t)return Ru()}return[]})()),Du}const v_=["r8unorm","r8snorm","r8uint","r8sint","r16uint","r16sint","r16float","rg8unorm","rg8snorm","rg8uint","rg8sint","r32uint","r32sint","r32float","rg16uint","rg16sint","rg16float","rgba8unorm","rgba8unorm-srgb","rgba8snorm","rgba8uint","rgba8sint","bgra8unorm","bgra8unorm-srgb","rgb9e5ufloat","rgb10a2unorm","rg11b10ufloat","rg32uint","rg32sint","rg32float","rgba16uint","rgba16sint","rgba16float","rgba32uint","rgba32sint","rgba32float","stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"];let Ki;async function ws(){if(Ki!==void 0)return Ki;const r=await Mu();return Ki=[...v_,...r],Ki}const j3='(function(){"use strict";function g(r,a){const t=r.getNumImages(),s=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const m=[];for(let e=0;e{BASIS({locateFile:s=>a}).then(s=>{s.initializeBasis(),t(s.BasisFile)})})}return c}async function b(r,a){const t=await fetch(r);if(t.ok){const s=await t.arrayBuffer();return new a(new Uint8Array(s))}throw new Error(`Failed to load Basis texture: ${r}`)}const h=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function p(r){const a=await l(),t=await b(r,a),s=g(t,u);return{width:t.getImageWidth(0,0),height:t.getImageHeight(0,0),format:i,resource:s,alphaMode:"no-premultiply-alpha"}}async function y(r,a,t){r&&(n.jsUrl=r),a&&(n.wasmUrl=a),i=h.filter(s=>t.includes(s))[0],u=d(i),await l()}const U={init:async r=>{const{jsUrl:a,wasmUrl:t,supportedTextures:s}=r;await y(a,t,s)},load:async r=>{var a;try{const t=await p(r.url);return{type:"load",url:r.url,success:!0,textureOptions:t,transferables:(a=t.resource)==null?void 0:a.map(s=>s.buffer)}}catch(t){throw t}}};self.onmessage=async r=>{const a=r.data,t=await U[a.type](a);t&&self.postMessage(t,t.transferables)}})();\n';let Ar=null,T_=class{constructor(){Ar||(Ar=URL.createObjectURL(new Blob([j3],{type:"application/javascript"}))),this.worker=new Worker(Ar)}};T_.revokeObjectURL=function(){Ar&&(URL.revokeObjectURL(Ar),Ar=null)};const Zi={jsUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.js",wasmUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.wasm"};function z3(r){Object.assign(Zi,r)}let Cs;const A_={};function V3(r){return Cs||(Cs=new T_().worker,Cs.onmessage=t=>{const{success:e,url:s,textureOptions:i}=t.data;e||console.warn("Failed to load Basis texture",s),A_[s](i)},Cs.postMessage({type:"init",jsUrl:Zi.jsUrl,wasmUrl:Zi.wasmUrl,supportedTextures:r})),Cs}function S_(r,t){const e=V3(t);return new Promise(s=>{A_[r]=s,e.postMessage({type:"load",url:r})})}const W3={extension:{type:v.LoadParser,priority:Ct.High,name:"loadBasis"},name:"loadBasis",id:"basis",test(r){return Nt(r,[".basis"])},async load(r,t,e){const s=await ws(),i=await S_(r,s),n=new Es(i);return ve(n,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function Y3(r,t){const e=r.getNumImages(),s=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const i=[];for(let n=0;n(r[r.DXGI_FORMAT_UNKNOWN=0]="DXGI_FORMAT_UNKNOWN",r[r.DXGI_FORMAT_R32G32B32A32_TYPELESS=1]="DXGI_FORMAT_R32G32B32A32_TYPELESS",r[r.DXGI_FORMAT_R32G32B32A32_FLOAT=2]="DXGI_FORMAT_R32G32B32A32_FLOAT",r[r.DXGI_FORMAT_R32G32B32A32_UINT=3]="DXGI_FORMAT_R32G32B32A32_UINT",r[r.DXGI_FORMAT_R32G32B32A32_SINT=4]="DXGI_FORMAT_R32G32B32A32_SINT",r[r.DXGI_FORMAT_R32G32B32_TYPELESS=5]="DXGI_FORMAT_R32G32B32_TYPELESS",r[r.DXGI_FORMAT_R32G32B32_FLOAT=6]="DXGI_FORMAT_R32G32B32_FLOAT",r[r.DXGI_FORMAT_R32G32B32_UINT=7]="DXGI_FORMAT_R32G32B32_UINT",r[r.DXGI_FORMAT_R32G32B32_SINT=8]="DXGI_FORMAT_R32G32B32_SINT",r[r.DXGI_FORMAT_R16G16B16A16_TYPELESS=9]="DXGI_FORMAT_R16G16B16A16_TYPELESS",r[r.DXGI_FORMAT_R16G16B16A16_FLOAT=10]="DXGI_FORMAT_R16G16B16A16_FLOAT",r[r.DXGI_FORMAT_R16G16B16A16_UNORM=11]="DXGI_FORMAT_R16G16B16A16_UNORM",r[r.DXGI_FORMAT_R16G16B16A16_UINT=12]="DXGI_FORMAT_R16G16B16A16_UINT",r[r.DXGI_FORMAT_R16G16B16A16_SNORM=13]="DXGI_FORMAT_R16G16B16A16_SNORM",r[r.DXGI_FORMAT_R16G16B16A16_SINT=14]="DXGI_FORMAT_R16G16B16A16_SINT",r[r.DXGI_FORMAT_R32G32_TYPELESS=15]="DXGI_FORMAT_R32G32_TYPELESS",r[r.DXGI_FORMAT_R32G32_FLOAT=16]="DXGI_FORMAT_R32G32_FLOAT",r[r.DXGI_FORMAT_R32G32_UINT=17]="DXGI_FORMAT_R32G32_UINT",r[r.DXGI_FORMAT_R32G32_SINT=18]="DXGI_FORMAT_R32G32_SINT",r[r.DXGI_FORMAT_R32G8X24_TYPELESS=19]="DXGI_FORMAT_R32G8X24_TYPELESS",r[r.DXGI_FORMAT_D32_FLOAT_S8X24_UINT=20]="DXGI_FORMAT_D32_FLOAT_S8X24_UINT",r[r.DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS=21]="DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS",r[r.DXGI_FORMAT_X32_TYPELESS_G8X24_UINT=22]="DXGI_FORMAT_X32_TYPELESS_G8X24_UINT",r[r.DXGI_FORMAT_R10G10B10A2_TYPELESS=23]="DXGI_FORMAT_R10G10B10A2_TYPELESS",r[r.DXGI_FORMAT_R10G10B10A2_UNORM=24]="DXGI_FORMAT_R10G10B10A2_UNORM",r[r.DXGI_FORMAT_R10G10B10A2_UINT=25]="DXGI_FORMAT_R10G10B10A2_UINT",r[r.DXGI_FORMAT_R11G11B10_FLOAT=26]="DXGI_FORMAT_R11G11B10_FLOAT",r[r.DXGI_FORMAT_R8G8B8A8_TYPELESS=27]="DXGI_FORMAT_R8G8B8A8_TYPELESS",r[r.DXGI_FORMAT_R8G8B8A8_UNORM=28]="DXGI_FORMAT_R8G8B8A8_UNORM",r[r.DXGI_FORMAT_R8G8B8A8_UNORM_SRGB=29]="DXGI_FORMAT_R8G8B8A8_UNORM_SRGB",r[r.DXGI_FORMAT_R8G8B8A8_UINT=30]="DXGI_FORMAT_R8G8B8A8_UINT",r[r.DXGI_FORMAT_R8G8B8A8_SNORM=31]="DXGI_FORMAT_R8G8B8A8_SNORM",r[r.DXGI_FORMAT_R8G8B8A8_SINT=32]="DXGI_FORMAT_R8G8B8A8_SINT",r[r.DXGI_FORMAT_R16G16_TYPELESS=33]="DXGI_FORMAT_R16G16_TYPELESS",r[r.DXGI_FORMAT_R16G16_FLOAT=34]="DXGI_FORMAT_R16G16_FLOAT",r[r.DXGI_FORMAT_R16G16_UNORM=35]="DXGI_FORMAT_R16G16_UNORM",r[r.DXGI_FORMAT_R16G16_UINT=36]="DXGI_FORMAT_R16G16_UINT",r[r.DXGI_FORMAT_R16G16_SNORM=37]="DXGI_FORMAT_R16G16_SNORM",r[r.DXGI_FORMAT_R16G16_SINT=38]="DXGI_FORMAT_R16G16_SINT",r[r.DXGI_FORMAT_R32_TYPELESS=39]="DXGI_FORMAT_R32_TYPELESS",r[r.DXGI_FORMAT_D32_FLOAT=40]="DXGI_FORMAT_D32_FLOAT",r[r.DXGI_FORMAT_R32_FLOAT=41]="DXGI_FORMAT_R32_FLOAT",r[r.DXGI_FORMAT_R32_UINT=42]="DXGI_FORMAT_R32_UINT",r[r.DXGI_FORMAT_R32_SINT=43]="DXGI_FORMAT_R32_SINT",r[r.DXGI_FORMAT_R24G8_TYPELESS=44]="DXGI_FORMAT_R24G8_TYPELESS",r[r.DXGI_FORMAT_D24_UNORM_S8_UINT=45]="DXGI_FORMAT_D24_UNORM_S8_UINT",r[r.DXGI_FORMAT_R24_UNORM_X8_TYPELESS=46]="DXGI_FORMAT_R24_UNORM_X8_TYPELESS",r[r.DXGI_FORMAT_X24_TYPELESS_G8_UINT=47]="DXGI_FORMAT_X24_TYPELESS_G8_UINT",r[r.DXGI_FORMAT_R8G8_TYPELESS=48]="DXGI_FORMAT_R8G8_TYPELESS",r[r.DXGI_FORMAT_R8G8_UNORM=49]="DXGI_FORMAT_R8G8_UNORM",r[r.DXGI_FORMAT_R8G8_UINT=50]="DXGI_FORMAT_R8G8_UINT",r[r.DXGI_FORMAT_R8G8_SNORM=51]="DXGI_FORMAT_R8G8_SNORM",r[r.DXGI_FORMAT_R8G8_SINT=52]="DXGI_FORMAT_R8G8_SINT",r[r.DXGI_FORMAT_R16_TYPELESS=53]="DXGI_FORMAT_R16_TYPELESS",r[r.DXGI_FORMAT_R16_FLOAT=54]="DXGI_FORMAT_R16_FLOAT",r[r.DXGI_FORMAT_D16_UNORM=55]="DXGI_FORMAT_D16_UNORM",r[r.DXGI_FORMAT_R16_UNORM=56]="DXGI_FORMAT_R16_UNORM",r[r.DXGI_FORMAT_R16_UINT=57]="DXGI_FORMAT_R16_UINT",r[r.DXGI_FORMAT_R16_SNORM=58]="DXGI_FORMAT_R16_SNORM",r[r.DXGI_FORMAT_R16_SINT=59]="DXGI_FORMAT_R16_SINT",r[r.DXGI_FORMAT_R8_TYPELESS=60]="DXGI_FORMAT_R8_TYPELESS",r[r.DXGI_FORMAT_R8_UNORM=61]="DXGI_FORMAT_R8_UNORM",r[r.DXGI_FORMAT_R8_UINT=62]="DXGI_FORMAT_R8_UINT",r[r.DXGI_FORMAT_R8_SNORM=63]="DXGI_FORMAT_R8_SNORM",r[r.DXGI_FORMAT_R8_SINT=64]="DXGI_FORMAT_R8_SINT",r[r.DXGI_FORMAT_A8_UNORM=65]="DXGI_FORMAT_A8_UNORM",r[r.DXGI_FORMAT_R1_UNORM=66]="DXGI_FORMAT_R1_UNORM",r[r.DXGI_FORMAT_R9G9B9E5_SHAREDEXP=67]="DXGI_FORMAT_R9G9B9E5_SHAREDEXP",r[r.DXGI_FORMAT_R8G8_B8G8_UNORM=68]="DXGI_FORMAT_R8G8_B8G8_UNORM",r[r.DXGI_FORMAT_G8R8_G8B8_UNORM=69]="DXGI_FORMAT_G8R8_G8B8_UNORM",r[r.DXGI_FORMAT_BC1_TYPELESS=70]="DXGI_FORMAT_BC1_TYPELESS",r[r.DXGI_FORMAT_BC1_UNORM=71]="DXGI_FORMAT_BC1_UNORM",r[r.DXGI_FORMAT_BC1_UNORM_SRGB=72]="DXGI_FORMAT_BC1_UNORM_SRGB",r[r.DXGI_FORMAT_BC2_TYPELESS=73]="DXGI_FORMAT_BC2_TYPELESS",r[r.DXGI_FORMAT_BC2_UNORM=74]="DXGI_FORMAT_BC2_UNORM",r[r.DXGI_FORMAT_BC2_UNORM_SRGB=75]="DXGI_FORMAT_BC2_UNORM_SRGB",r[r.DXGI_FORMAT_BC3_TYPELESS=76]="DXGI_FORMAT_BC3_TYPELESS",r[r.DXGI_FORMAT_BC3_UNORM=77]="DXGI_FORMAT_BC3_UNORM",r[r.DXGI_FORMAT_BC3_UNORM_SRGB=78]="DXGI_FORMAT_BC3_UNORM_SRGB",r[r.DXGI_FORMAT_BC4_TYPELESS=79]="DXGI_FORMAT_BC4_TYPELESS",r[r.DXGI_FORMAT_BC4_UNORM=80]="DXGI_FORMAT_BC4_UNORM",r[r.DXGI_FORMAT_BC4_SNORM=81]="DXGI_FORMAT_BC4_SNORM",r[r.DXGI_FORMAT_BC5_TYPELESS=82]="DXGI_FORMAT_BC5_TYPELESS",r[r.DXGI_FORMAT_BC5_UNORM=83]="DXGI_FORMAT_BC5_UNORM",r[r.DXGI_FORMAT_BC5_SNORM=84]="DXGI_FORMAT_BC5_SNORM",r[r.DXGI_FORMAT_B5G6R5_UNORM=85]="DXGI_FORMAT_B5G6R5_UNORM",r[r.DXGI_FORMAT_B5G5R5A1_UNORM=86]="DXGI_FORMAT_B5G5R5A1_UNORM",r[r.DXGI_FORMAT_B8G8R8A8_UNORM=87]="DXGI_FORMAT_B8G8R8A8_UNORM",r[r.DXGI_FORMAT_B8G8R8X8_UNORM=88]="DXGI_FORMAT_B8G8R8X8_UNORM",r[r.DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM=89]="DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM",r[r.DXGI_FORMAT_B8G8R8A8_TYPELESS=90]="DXGI_FORMAT_B8G8R8A8_TYPELESS",r[r.DXGI_FORMAT_B8G8R8A8_UNORM_SRGB=91]="DXGI_FORMAT_B8G8R8A8_UNORM_SRGB",r[r.DXGI_FORMAT_B8G8R8X8_TYPELESS=92]="DXGI_FORMAT_B8G8R8X8_TYPELESS",r[r.DXGI_FORMAT_B8G8R8X8_UNORM_SRGB=93]="DXGI_FORMAT_B8G8R8X8_UNORM_SRGB",r[r.DXGI_FORMAT_BC6H_TYPELESS=94]="DXGI_FORMAT_BC6H_TYPELESS",r[r.DXGI_FORMAT_BC6H_UF16=95]="DXGI_FORMAT_BC6H_UF16",r[r.DXGI_FORMAT_BC6H_SF16=96]="DXGI_FORMAT_BC6H_SF16",r[r.DXGI_FORMAT_BC7_TYPELESS=97]="DXGI_FORMAT_BC7_TYPELESS",r[r.DXGI_FORMAT_BC7_UNORM=98]="DXGI_FORMAT_BC7_UNORM",r[r.DXGI_FORMAT_BC7_UNORM_SRGB=99]="DXGI_FORMAT_BC7_UNORM_SRGB",r[r.DXGI_FORMAT_AYUV=100]="DXGI_FORMAT_AYUV",r[r.DXGI_FORMAT_Y410=101]="DXGI_FORMAT_Y410",r[r.DXGI_FORMAT_Y416=102]="DXGI_FORMAT_Y416",r[r.DXGI_FORMAT_NV12=103]="DXGI_FORMAT_NV12",r[r.DXGI_FORMAT_P010=104]="DXGI_FORMAT_P010",r[r.DXGI_FORMAT_P016=105]="DXGI_FORMAT_P016",r[r.DXGI_FORMAT_420_OPAQUE=106]="DXGI_FORMAT_420_OPAQUE",r[r.DXGI_FORMAT_YUY2=107]="DXGI_FORMAT_YUY2",r[r.DXGI_FORMAT_Y210=108]="DXGI_FORMAT_Y210",r[r.DXGI_FORMAT_Y216=109]="DXGI_FORMAT_Y216",r[r.DXGI_FORMAT_NV11=110]="DXGI_FORMAT_NV11",r[r.DXGI_FORMAT_AI44=111]="DXGI_FORMAT_AI44",r[r.DXGI_FORMAT_IA44=112]="DXGI_FORMAT_IA44",r[r.DXGI_FORMAT_P8=113]="DXGI_FORMAT_P8",r[r.DXGI_FORMAT_A8P8=114]="DXGI_FORMAT_A8P8",r[r.DXGI_FORMAT_B4G4R4A4_UNORM=115]="DXGI_FORMAT_B4G4R4A4_UNORM",r[r.DXGI_FORMAT_P208=116]="DXGI_FORMAT_P208",r[r.DXGI_FORMAT_V208=117]="DXGI_FORMAT_V208",r[r.DXGI_FORMAT_V408=118]="DXGI_FORMAT_V408",r[r.DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE=119]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE",r[r.DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE=120]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE",r[r.DXGI_FORMAT_FORCE_UINT=121]="DXGI_FORMAT_FORCE_UINT",r))(Ou||{}),Bu=(r=>(r[r.DDS_DIMENSION_TEXTURE1D=2]="DDS_DIMENSION_TEXTURE1D",r[r.DDS_DIMENSION_TEXTURE2D=3]="DDS_DIMENSION_TEXTURE2D",r[r.DDS_DIMENSION_TEXTURE3D=6]="DDS_DIMENSION_TEXTURE3D",r))(Bu||{});function ct(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var St=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.R8G8B8=20]="R8G8B8",r[r.A8R8G8B8=21]="A8R8G8B8",r[r.X8R8G8B8=22]="X8R8G8B8",r[r.R5G6B5=23]="R5G6B5",r[r.X1R5G5B5=24]="X1R5G5B5",r[r.A1R5G5B5=25]="A1R5G5B5",r[r.A4R4G4B4=26]="A4R4G4B4",r[r.R3G3B2=27]="R3G3B2",r[r.A8=28]="A8",r[r.A8R3G3B2=29]="A8R3G3B2",r[r.X4R4G4B4=30]="X4R4G4B4",r[r.A2B10G10R10=31]="A2B10G10R10",r[r.A8B8G8R8=32]="A8B8G8R8",r[r.X8B8G8R8=33]="X8B8G8R8",r[r.G16R16=34]="G16R16",r[r.A2R10G10B10=35]="A2R10G10B10",r[r.A16B16G16R16=36]="A16B16G16R16",r[r.A8P8=40]="A8P8",r[r.P8=41]="P8",r[r.L8=50]="L8",r[r.A8L8=51]="A8L8",r[r.A4L4=52]="A4L4",r[r.V8U8=60]="V8U8",r[r.L6V5U5=61]="L6V5U5",r[r.X8L8V8U8=62]="X8L8V8U8",r[r.Q8W8V8U8=63]="Q8W8V8U8",r[r.V16U16=64]="V16U16",r[r.A2W10V10U10=67]="A2W10V10U10",r[r.Q16W16V16U16=110]="Q16W16V16U16",r[r.R16F=111]="R16F",r[r.G16R16F=112]="G16R16F",r[r.A16B16G16R16F=113]="A16B16G16R16F",r[r.R32F=114]="R32F",r[r.G32R32F=115]="G32R32F",r[r.A32B32G32R32F=116]="A32B32G32R32F",r[r.UYVY=ct("UYVY")]="UYVY",r[r.R8G8_B8G8=ct("RGBG")]="R8G8_B8G8",r[r.YUY2=ct("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=ct("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=ct("DXT1")]="DXT1",r[r.DXT2=ct("DXT2")]="DXT2",r[r.DXT3=ct("DXT3")]="DXT3",r[r.DXT4=ct("DXT4")]="DXT4",r[r.DXT5=ct("DXT5")]="DXT5",r[r.ATI1=ct("ATI1")]="ATI1",r[r.AT1N=ct("AT1N")]="AT1N",r[r.ATI2=ct("ATI2")]="ATI2",r[r.AT2N=ct("AT2N")]="AT2N",r[r.BC4U=ct("BC4U")]="BC4U",r[r.BC4S=ct("BC4S")]="BC4S",r[r.BC5U=ct("BC5U")]="BC5U",r[r.BC5S=ct("BC5S")]="BC5S",r[r.DX10=ct("DX10")]="DX10",r))(St||{});const Gu={[St.DXT1]:"bc1-rgba-unorm",[St.DXT2]:"bc2-rgba-unorm",[St.DXT3]:"bc2-rgba-unorm",[St.DXT4]:"bc3-rgba-unorm",[St.DXT5]:"bc3-rgba-unorm",[St.ATI1]:"bc4-r-unorm",[St.BC4U]:"bc4-r-unorm",[St.BC4S]:"bc4-r-snorm",[St.ATI2]:"bc5-rg-unorm",[St.BC5U]:"bc5-rg-unorm",[St.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},Et={70:"bc1-rgba-unorm",71:"bc1-rgba-unorm",72:"bc1-rgba-unorm-srgb",73:"bc2-rgba-unorm",74:"bc2-rgba-unorm",75:"bc2-rgba-unorm-srgb",76:"bc3-rgba-unorm",77:"bc3-rgba-unorm",78:"bc3-rgba-unorm-srgb",79:"bc4-r-unorm",80:"bc4-r-unorm",81:"bc4-r-snorm",82:"bc5-rg-unorm",83:"bc5-rg-unorm",84:"bc5-rg-snorm",94:"bc6h-rgb-ufloat",95:"bc6h-rgb-ufloat",96:"bc6h-rgb-float",97:"bc7-rgba-unorm",98:"bc7-rgba-unorm",99:"bc7-rgba-unorm-srgb",28:"rgba8unorm",29:"rgba8unorm-srgb",87:"bgra8unorm",91:"bgra8unorm-srgb",41:"r32float",49:"rg8unorm",56:"r16uint",61:"r8unorm",24:"rgb10a2unorm",11:"rgba16uint",13:"rgba16sint",10:"rgba16float",54:"r16float",34:"rg16float",16:"rg32float",2:"rgba32float"},F={MAGIC_VALUE:542327876,MAGIC_SIZE:4,HEADER_SIZE:124,HEADER_DX10_SIZE:20,PIXEL_FORMAT_FLAGS:{ALPHAPIXELS:1,ALPHA:2,FOURCC:4,RGB:64,RGBA:65,YUV:512,LUMINANCE:131072,LUMINANCEA:131073},RESOURCE_MISC_TEXTURECUBE:4,HEADER_FIELDS:Z3,HEADER_DX10_FIELDS:Q3,DXGI_FORMAT:Ou,D3D10_RESOURCE_DIMENSION:Bu,D3DFMT:St},E_={"bc1-rgba-unorm":8,"bc1-rgba-unorm-srgb":8,"bc2-rgba-unorm":16,"bc2-rgba-unorm-srgb":16,"bc3-rgba-unorm":16,"bc3-rgba-unorm-srgb":16,"bc4-r-unorm":8,"bc4-r-snorm":8,"bc5-rg-unorm":16,"bc5-rg-snorm":16,"bc6h-rgb-ufloat":16,"bc6h-rgb-float":16,"bc7-rgba-unorm":16,"bc7-rgba-unorm-srgb":16};function w_(r,t){const{format:e,fourCC:s,width:i,height:n,dataOffset:o,mipmapCount:a}=tE(r);if(!t.includes(e))throw new Error(`Unsupported texture format: ${s} ${e}, supported: ${t}`);if(a<=1)return{format:e,width:i,height:n,resource:[new Uint8Array(r,o)],alphaMode:"no-premultiply-alpha"};const u=J3(e,i,n,o,a,r);return{format:e,width:i,height:n,resource:u,alphaMode:"no-premultiply-alpha"}}function J3(r,t,e,s,i,n){const o=[],a=E_[r];let u=t,l=e,c=s;for(let h=0;h>1,1),l=Math.max(l>>1,1)}return o}function tE(r){const t=new Uint32Array(r,0,F.HEADER_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(t[F.HEADER_FIELDS.MAGIC]!==F.MAGIC_VALUE)throw new Error("Invalid magic number in DDS header");const e=t[F.HEADER_FIELDS.HEIGHT],s=t[F.HEADER_FIELDS.WIDTH],i=Math.max(1,t[F.HEADER_FIELDS.MIPMAP_COUNT]),n=t[F.HEADER_FIELDS.PF_FLAGS],o=t[F.HEADER_FIELDS.FOURCC],a=eE(t,n,o,r),u=F.MAGIC_SIZE+F.HEADER_SIZE+(o===F.D3DFMT.DX10?F.HEADER_DX10_SIZE:0);return{format:a,fourCC:o,width:s,height:e,dataOffset:u,mipmapCount:i}}function eE(r,t,e,s){if(t&F.PIXEL_FORMAT_FLAGS.FOURCC){if(e===F.D3DFMT.DX10){const i=new Uint32Array(s,F.MAGIC_SIZE+F.HEADER_SIZE,F.HEADER_DX10_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(i[F.HEADER_DX10_FIELDS.MISC_FLAG]===F.RESOURCE_MISC_TEXTURECUBE)throw new Error("DDSParser does not support cubemap textures");if(i[F.HEADER_DX10_FIELDS.RESOURCE_DIMENSION]===F.D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");const n=i[F.HEADER_DX10_FIELDS.DXGI_FORMAT];if(n in Et)return Et[n];throw new Error(`DDSParser cannot parse texture data with DXGI format ${n}`)}if(e in Gu)return Gu[e];throw new Error(`DDSParser cannot parse texture data with fourCC format ${e}`)}if(t&F.PIXEL_FORMAT_FLAGS.RGB||t&F.PIXEL_FORMAT_FLAGS.RGBA)return rE(r);throw t&F.PIXEL_FORMAT_FLAGS.YUV?new Error("DDSParser does not supported YUV uncompressed texture data."):t&F.PIXEL_FORMAT_FLAGS.LUMINANCE||t&F.PIXEL_FORMAT_FLAGS.LUMINANCEA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):t&F.PIXEL_FORMAT_FLAGS.ALPHA||t&F.PIXEL_FORMAT_FLAGS.ALPHAPIXELS?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}function rE(r){const t=r[F.HEADER_FIELDS.RGB_BITCOUNT],e=r[F.HEADER_FIELDS.R_BIT_MASK],s=r[F.HEADER_FIELDS.G_BIT_MASK],i=r[F.HEADER_FIELDS.B_BIT_MASK],n=r[F.HEADER_FIELDS.A_BIT_MASK];switch(t){case 32:if(e===255&&s===65280&&i===16711680&&n===4278190080)return Et[F.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&s===65280&&i===255&&n===4278190080)return Et[F.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&s===1047552&&i===1023&&n===3221225472)return Et[F.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&s===4294901760&&i===0&&n===0)return Et[F.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&s===0&&i===0&&n===0)return Et[F.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&s===992&&i===31&&n===32768)return Et[F.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&s===2016&&i===31&&n===0)return Et[F.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&s===240&&i===15&&n===61440)return Et[F.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&s===0&&i===0&&n===65280)return Et[F.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&s===0&&i===0&&n===0)return Et[F.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&s===0&&i===0&&n===0)return Et[F.DXGI_FORMAT.DXGI_FORMAT_R8_UNORM];break}throw new Error(`DDSParser does not support uncompressed texture with configuration: bitCount = ${t}, rBitMask = ${e}, gBitMask = ${s}, aBitMask = ${n}`)}const sE={extension:{type:v.LoadParser,priority:Ct.High,name:"loadDDS"},name:"loadDDS",id:"dds",test(r){return Nt(r,[".dds"])},async load(r,t,e){const s=await ws(),i=await(await fetch(r)).arrayBuffer(),n=w_(i,s),o=new Es(n);return ve(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var C_=(r=>(r[r.RGBA8_SNORM=36759]="RGBA8_SNORM",r[r.RGBA=6408]="RGBA",r[r.RGBA8UI=36220]="RGBA8UI",r[r.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",r[r.RGBA8I=36238]="RGBA8I",r[r.RGBA8=32856]="RGBA8",r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",r[r.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",r[r.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",r[r.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",r[r.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",r[r.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",r[r.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",r[r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",r[r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",r[r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",r))(C_||{}),iE=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(iE||{}),nE=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(nE||{});const oE={33776:"bc1-rgba-unorm",33777:"bc1-rgba-unorm",33778:"bc2-rgba-unorm",33779:"bc3-rgba-unorm",35916:"bc1-rgba-unorm-srgb",35917:"bc1-rgba-unorm-srgb",35918:"bc2-rgba-unorm-srgb",35919:"bc3-rgba-unorm-srgb",36283:"bc4-r-unorm",36284:"bc4-r-snorm",36285:"bc5-rg-unorm",36286:"bc5-rg-snorm",37488:"eac-r11unorm",37490:"eac-rg11snorm",37492:"etc2-rgb8unorm",37496:"etc2-rgba8unorm",37493:"etc2-rgb8unorm-srgb",37497:"etc2-rgba8unorm-srgb",37494:"etc2-rgb8a1unorm",37495:"etc2-rgb8a1unorm-srgb",37808:"astc-4x4-unorm",37840:"astc-4x4-unorm-srgb",37809:"astc-5x4-unorm",37841:"astc-5x4-unorm-srgb",37810:"astc-5x5-unorm",37842:"astc-5x5-unorm-srgb",37811:"astc-6x5-unorm",37843:"astc-6x5-unorm-srgb",37812:"astc-6x6-unorm",37844:"astc-6x6-unorm-srgb",37813:"astc-8x5-unorm",37845:"astc-8x5-unorm-srgb",37814:"astc-8x6-unorm",37846:"astc-8x6-unorm-srgb",37815:"astc-8x8-unorm",37847:"astc-8x8-unorm-srgb",37816:"astc-10x5-unorm",37848:"astc-10x5-unorm-srgb",37817:"astc-10x6-unorm",37849:"astc-10x6-unorm-srgb",37818:"astc-10x8-unorm",37850:"astc-10x8-unorm-srgb",37819:"astc-10x10-unorm",37851:"astc-10x10-unorm-srgb",37820:"astc-12x10-unorm",37852:"astc-12x10-unorm-srgb",37821:"astc-12x12-unorm",37853:"astc-12x12-unorm-srgb",36492:"bc7-rgba-unorm",36493:"bc7-rgba-unorm-srgb",36494:"bc6h-rgb-float",36495:"bc6h-rgb-ufloat",35907:"rgba8unorm-srgb",36759:"rgba8snorm",36220:"rgba8uint",36238:"rgba8sint",6408:"rgba8unorm"},aE=[171,75,84,88,32,49,49,187,13,10,26,10],uE={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},lE=64,cE=67305985,hE={5121:1,5123:2,5124:4,5125:4,5126:4,36193:8},dE={6408:4,6407:3,33319:2,6403:1,6409:1,6410:2,6406:1},pE={32819:2,32820:2,33635:2},fE={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,36283:.5,36284:.5,36285:1,36286:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,37808:1,37840:1,37809:.8,37841:.8,37810:.64,37842:.64,37811:.53375,37843:.53375,37812:.445,37844:.445,37813:.4,37845:.4,37814:.33375,37846:.33375,37815:.25,37847:.25,37816:.32,37848:.32,37817:.26625,37849:.26625,37818:.2,37850:.2,37819:.16,37851:.16,37820:.13375,37852:.13375,37821:.11125,37853:.11125,36492:1,36493:1,36494:1,36495:1},tt={FILE_HEADER_SIZE:lE,FILE_IDENTIFIER:aE,FORMATS_TO_COMPONENTS:dE,INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:fE,INTERNAL_FORMAT_TO_TEXTURE_FORMATS:oE,FIELDS:uE,TYPES_TO_BYTES_PER_COMPONENT:hE,TYPES_TO_BYTES_PER_PIXEL:pE,ENDIANNESS:cE};function R_(r,t){const e=new DataView(r);if(!xE(e))throw new Error("Invalid KTX identifier in header");const{littleEndian:s,glType:i,glFormat:n,glInternalFormat:o,pixelWidth:a,pixelHeight:u,numberOfMipmapLevels:l,offset:c}=_E(e),h=tt.INTERNAL_FORMAT_TO_TEXTURE_FORMATS[o];if(!h)throw new Error(`Unknown texture format ${o}`);if(!t.includes(h))throw new Error(`Unsupported texture format: ${h}, supportedFormats: ${t}`);const d=gE(i,n,o),p=mE(e,i,d,a,u,c,l,s);return{format:h,width:a,height:u,resource:p,alphaMode:"no-premultiply-alpha"}}function mE(r,t,e,s,i,n,o,a){const u=s+3&-4,l=i+3&-4;let c=s*i;t===0&&(c=u*l);let h=c*e,d=s,p=i,f=u,g=l,m=n;const _=new Array(o);for(let b=0;b>1||1,p=p>>1||1,f=d+4-1&-4,g=p+4-1&-4,h=f*g*e}return _}function gE(r,t,e){let s=tt.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(tt.TYPES_TO_BYTES_PER_COMPONENT[r]?s=tt.TYPES_TO_BYTES_PER_COMPONENT[r]*tt.FORMATS_TO_COMPONENTS[t]:s=tt.TYPES_TO_BYTES_PER_PIXEL[r]),s===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");return s}function _E(r){const t=r.getUint32(tt.FIELDS.ENDIANNESS,!0)===tt.ENDIANNESS,e=r.getUint32(tt.FIELDS.GL_TYPE,t),s=r.getUint32(tt.FIELDS.GL_FORMAT,t),i=r.getUint32(tt.FIELDS.GL_INTERNAL_FORMAT,t),n=r.getUint32(tt.FIELDS.PIXEL_WIDTH,t),o=r.getUint32(tt.FIELDS.PIXEL_HEIGHT,t)||1,a=r.getUint32(tt.FIELDS.PIXEL_DEPTH,t)||1,u=r.getUint32(tt.FIELDS.NUMBER_OF_ARRAY_ELEMENTS,t)||1,l=r.getUint32(tt.FIELDS.NUMBER_OF_FACES,t),c=r.getUint32(tt.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),h=r.getUint32(tt.FIELDS.BYTES_OF_KEY_VALUE_DATA,t);if(o===0||a!==1)throw new Error("Only 2D textures are supported");if(l!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==1)throw new Error("WebGL does not support array textures");return{littleEndian:t,glType:e,glFormat:s,glInternalFormat:i,pixelWidth:n,pixelHeight:o,numberOfMipmapLevels:c,offset:tt.FILE_HEADER_SIZE+h}}function xE(r){for(let t=0;tt.destroy(!0)):r.destroy(!0)}},yE='(function(){"use strict";const s={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:i},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:i}};function f(r){const t=r.format;if(s[t]){const n=s[t].convertFunction,o=r.resource;for(let e=0;e{LIBKTX({locateFile:o=>t}).then(o=>{n(o)})})}return c}async function v(r,t){const n=await fetch(r);if(n.ok){const o=await n.arrayBuffer();return new t.ktxTexture(new Uint8Array(o))}throw new Error(`Failed to load KTX(2) texture: ${r}`)}const x=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function B(r){const t=await g(),n=await v(r,t);let o;if(n.needsTranscoding){o=u;const R=t.TranscodeTarget[l];if(n.transcodeBasis(R,0)!==t.ErrorCode.SUCCESS)throw new Error("Unable to transcode basis texture.")}else o=U(n);const e=d(n),b={width:n.baseWidth,height:n.baseHeight,format:o,mipLevelCount:n.numLevels,resource:e,alphaMode:"no-premultiply-alpha"};return f(b),b}async function A(r,t,n){r&&(a.jsUrl=r),t&&(a.wasmUrl=t),u=x.filter(o=>n.includes(o))[0],l=y(u),await g()}const m={init:async r=>{const{jsUrl:t,wasmUrl:n,supportedTextures:o}=r;await A(t,n,o)},load:async r=>{var t;try{const n=await B(r.url);return{type:"load",url:r.url,success:!0,textureOptions:n,transferables:(t=n.resource)==null?void 0:t.map(o=>o.buffer)}}catch(n){throw n}}};self.onmessage=async r=>{var t;const n=r.data,o=await((t=m[n.type])==null?void 0:t.call(m,n));o&&self.postMessage(o,o.transferables)}})();\n';let Sr=null;class P_{constructor(){Sr||(Sr=URL.createObjectURL(new Blob([yE],{type:"application/javascript"}))),this.worker=new Worker(Sr)}}P_.revokeObjectURL=function(){Sr&&(URL.revokeObjectURL(Sr),Sr=null)};const Qi={jsUrl:"https://files.pixijs.download/transcoders/ktx/libktx.js",wasmUrl:"https://files.pixijs.download/transcoders/ktx/libktx.wasm"};function vE(r){Object.assign(Qi,r)}let Rs;const D_={};function TE(r){return Rs||(Rs=new P_().worker,Rs.onmessage=t=>{const{success:e,url:s,textureOptions:i}=t.data;e||console.warn("Failed to load KTX texture",s),D_[s](i)},Rs.postMessage({type:"init",jsUrl:Qi.jsUrl,wasmUrl:Qi.wasmUrl,supportedTextures:r})),Rs}function M_(r,t){const e=TE(t);return new Promise(s=>{D_[r]=s,e.postMessage({type:"load",url:r})})}const AE={extension:{type:v.LoadParser,priority:Ct.High,name:"loadKTX2"},name:"loadKTX2",id:"ktx2",test(r){return Nt(r,".ktx2")},async load(r,t,e){const s=await ws(),i=await M_(r,s),n=new Es(i);return ve(n,e,r)},async unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},Fu={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:O_},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:O_}};function SE(r){const t=r.format;if(Fu[t]){const e=Fu[t].convertFunction,s=r.resource;for(let i=0;iNt(r,[".ktx",".ktx2",".dds"]),parse:r=>{var t,e;let s;const i=r.split(".");if(i.length>2){const n=i[i.length-2];Ji.includes(n)&&(s=n)}else s=i[i.length-1];return{resolution:parseFloat((e=(t=_e.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s,src:r}}};let tn;const OE={extension:{type:v.DetectionParser,priority:2},test:async()=>!!(await ys()||bs()),add:async r=>{const t=await Mu();return tn=BE(t),[...tn,...r]},remove:async r=>tn?r.filter(t=>!(t in tn)):r};function BE(r){const t=["basis"],e={};return r.forEach(s=>{const i=s.split("-")[0];i&&!e[i]&&(e[i]=!0,t.push(i))}),t.sort((s,i)=>{const n=Ji.indexOf(s),o=Ji.indexOf(i);return n===-1?1:o===-1?-1:n-o}),t}const GE=new ot,Iu=class{cull(t,e,s=!0){this._cullRecursive(t,e,s)}_cullRecursive(t,e,s=!0){var i;if(t.cullable&&t.measurable&&t.includeInBuild){const n=(i=t.cullArea)!=null?i:Jr(t,s,GE);t.culled=n.x>=e.x+e.width||n.y>=e.y+e.height||n.x+n.width<=e.x||n.y+n.height<=e.y}else t.culled=!1;if(!(!t.cullableChildren||t.culled||!t.renderable||!t.measurable||!t.includeInBuild))for(let n=0;n{var e;const s=((e=t==null?void 0:t.culler)==null?void 0:e.updateTransform)!==!0;F_.shared.cull(this.stage,this.renderer.screen,s),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}I_.extension={priority:10,type:v.Application,name:"culler"};const FE={extension:{type:v.Environment,name:"webworker",priority:0},test:()=>typeof self!="undefined"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(function(){return $S})}};var IE=Object.defineProperty,en=Object.getOwnPropertySymbols,U_=Object.prototype.hasOwnProperty,k_=Object.prototype.propertyIsEnumerable,L_=(r,t,e)=>t in r?IE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Uu=(r,t)=>{for(var e in t||(t={}))U_.call(t,e)&&L_(r,e,t[e]);if(en)for(var e of en(t))k_.call(t,e)&&L_(r,e,t[e]);return r},UE=(r,t)=>{var e={};for(var s in r)U_.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&en)for(var s of en(r))t.indexOf(s)<0&&k_.call(r,s)&&(e[s]=r[s]);return e};const N_=class wc extends Ft{constructor(t){t=Uu(Uu({},wc.defaultOptions),t),super(t),this.enabled=!0,this._state=Mt.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1)}apply(t,e,s,i){t.applyFilter(this,e,s,i)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const e=t,{gpu:s,gl:i}=e,n=UE(e,["gpu","gl"]);let o,a;return s&&(o=wt.from(s)),i&&(a=Dt.from(i)),new wc(Uu({gpuProgram:o,glProgram:a},n))}};N_.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let he=N_;var $_=` in vec2 vTextureCoord; in vec4 vColor; out vec4 finalColor; uniform float uBlend; uniform sampler2D uTexture; uniform sampler2D uBackTexture; {FUNCTIONS} void main() { vec4 back = texture(uBackTexture, vTextureCoord); vec4 front = texture(uTexture, vTextureCoord); float blendedAlpha = front.a + back.a * (1.0 - front.a); {MAIN} } `,X_=`in vec2 aPosition; out vec2 vTextureCoord; out vec2 backgroundUv; uniform vec4 uInputSize; uniform vec4 uOutputFrame; uniform vec4 uOutputTexture; vec4 filterVertexPosition( void ) { vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy; position.x = position.x * (2.0 / uOutputTexture.x) - 1.0; position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z; return vec4(position, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aPosition * (uOutputFrame.zw * uInputSize.zw); } void main(void) { gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); } `,H_=` struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct BlendUniforms { uBlend:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(0) @binding(3) var uBackTexture: texture_2d; @group(1) @binding(0) var blendUniforms : BlendUniforms; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2 }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition) ); } {FUNCTIONS} @fragment fn mainFragment( @location(0) uv: vec2 ) -> @location(0) vec4 { var back = textureSample(uBackTexture, uSampler, uv); var front = textureSample(uTexture, uSampler, uv); var blendedAlpha = front.a + back.a * (1.0 - front.a); var out = vec4(0.0,0.0,0.0,0.0); {MAIN} return out; }`,kE=Object.defineProperty,j_=Object.getOwnPropertySymbols,LE=Object.prototype.hasOwnProperty,NE=Object.prototype.propertyIsEnumerable,z_=(r,t,e)=>t in r?kE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,V_=(r,t)=>{for(var e in t||(t={}))LE.call(t,e)&&z_(r,e,t[e]);if(j_)for(var e of j_(t))NE.call(t,e)&&z_(r,e,t[e]);return r};class $E extends he{constructor(t){const e=t.gpu,s=W_(V_({source:H_},e)),i=wt.from({vertex:{source:s,entryPoint:"mainVertex"},fragment:{source:s,entryPoint:"mainFragment"}}),n=t.gl,o=W_(V_({source:$_},n)),a=Dt.from({vertex:X_,fragment:o}),u=new it({uBlend:{value:1,type:"f32"}});super({gpuProgram:i,glProgram:a,blendRequired:!0,resources:{blendUniforms:u,uBackTexture:C.EMPTY}})}}function W_(r){const{source:t,functions:e,main:s}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",s)}const XE=` float getLuminosity(vec3 c) { return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b; } vec3 setLuminosity(vec3 c, float lum) { float modLum = lum - getLuminosity(c); vec3 color = c.rgb + vec3(modLum); // clip back into legal range modLum = getLuminosity(color); vec3 modLumVec = vec3(modLum); float cMin = min(color.r, min(color.g, color.b)); float cMax = max(color.r, max(color.g, color.b)); if(cMin < 0.0) { color = mix(modLumVec, color, modLum / (modLum - cMin)); } if(cMax > 1.0) { color = mix(modLumVec, color, (1.0 - modLum) / (cMax - modLum)); } return color; } float getSaturation(vec3 c) { return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b)); } vec3 setSaturationMinMidMax(vec3 cSorted, float s) { vec3 colorSorted = cSorted; if(colorSorted.z > colorSorted.x) { colorSorted.y = (((colorSorted.y - colorSorted.x) * s) / (colorSorted.z - colorSorted.x)); colorSorted.z = s; } else { colorSorted.y = 0.0; colorSorted.z = 0.0; } colorSorted.x = 0.0; return colorSorted; } vec3 setSaturation(vec3 c, float s) { vec3 color = c; if(color.r <= color.g && color.r <= color.b) { if(color.g <= color.b) { color = setSaturationMinMidMax(color.rgb, s).rgb; } else { color = setSaturationMinMidMax(color.rbg, s).rbg; } } else if(color.g <= color.r && color.g <= color.b) { if(color.r <= color.b) { color = setSaturationMinMidMax(color.grb, s).grb; } else { color = setSaturationMinMidMax(color.gbr, s).gbr; } } else { // Using bgr for both fixes part of hue if(color.r <= color.g) { color = setSaturationMinMidMax(color.brg, s).brg; } else { color = setSaturationMinMidMax(color.bgr, s).bgr; } } return color; } `,HE=` fn getLuminosity(c: vec3) -> f32 { return 0.3*c.r + 0.59*c.g + 0.11*c.b; } fn setLuminosity(c: vec3, lum: f32) -> vec3 { var modLum: f32 = lum - getLuminosity(c); var color: vec3 = c.rgb + modLum; // clip back into legal range modLum = getLuminosity(color); let modLumVec = vec3(modLum); let cMin: f32 = min(color.r, min(color.g, color.b)); let cMax: f32 = max(color.r, max(color.g, color.b)); if(cMin < 0.0) { color = mix(modLumVec, color, modLum / (modLum - cMin)); } if(cMax > 1.0) { color = mix(modLumVec, color, (1 - modLum) / (cMax - modLum)); } return color; } fn getSaturation(c: vec3) -> f32 { return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b)); } fn setSaturationMinMidMax(cSorted: vec3, s: f32) -> vec3 { var colorSorted = cSorted; if(colorSorted.z > colorSorted.x) { colorSorted.y = (((colorSorted.y - colorSorted.x) * s) / (colorSorted.z - colorSorted.x)); colorSorted.z = s; } else { colorSorted.y = 0; colorSorted.z = 0; } colorSorted.x = 0; return colorSorted; } fn setSaturation(c: vec3, s: f32) -> vec3 { var color = c; if (color.r <= color.g && color.r <= color.b) { if (color.g <= color.b) { color = vec3(setSaturationMinMidMax(color.rgb, s)).rgb; } else { color = vec3(setSaturationMinMidMax(color.rbg, s)).rbg; } } else if (color.g <= color.r && color.g <= color.b) { if (color.r <= color.b) { color = vec3(setSaturationMinMidMax(color.grb, s)).grb; } else { color = vec3(setSaturationMinMidMax(color.gbr, s)).gbr; } } else { // Using bgr for both fixes part of hue if (color.r <= color.g) { color = vec3(setSaturationMinMidMax(color.brg, s)).brg; } else { color = vec3(setSaturationMinMidMax(color.bgr, s)).bgr; } } return color; } `;var rn=`in vec2 aPosition; out vec2 vTextureCoord; uniform vec4 uInputSize; uniform vec4 uOutputFrame; uniform vec4 uOutputTexture; vec4 filterVertexPosition( void ) { vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy; position.x = position.x * (2.0 / uOutputTexture.x) - 1.0; position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z; return vec4(position, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aPosition * (uOutputFrame.zw * uInputSize.zw); } void main(void) { gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); } `,Y_=` in vec2 vTextureCoord; out vec4 finalColor; uniform float uAlpha; uniform sampler2D uTexture; void main() { finalColor = texture(uTexture, vTextureCoord) * uAlpha; } `,ku=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct AlphaUniforms { uAlpha:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var alphaUniforms : AlphaUniforms; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2 }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition) ); } @fragment fn mainFragment( @location(0) uv: vec2, @builtin(position) position: vec4 ) -> @location(0) vec4 { var sample = textureSample(uTexture, uSampler, uv); return sample * alphaUniforms.uAlpha; }`,jE=Object.defineProperty,zE=Object.defineProperties,VE=Object.getOwnPropertyDescriptors,sn=Object.getOwnPropertySymbols,q_=Object.prototype.hasOwnProperty,K_=Object.prototype.propertyIsEnumerable,Z_=(r,t,e)=>t in r?jE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Lu=(r,t)=>{for(var e in t||(t={}))q_.call(t,e)&&Z_(r,e,t[e]);if(sn)for(var e of sn(t))K_.call(t,e)&&Z_(r,e,t[e]);return r},WE=(r,t)=>zE(r,VE(t)),YE=(r,t)=>{var e={};for(var s in r)q_.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&sn)for(var s of sn(r))t.indexOf(s)<0&&K_.call(r,s)&&(e[s]=r[s]);return e};const Q_=class ky extends he{constructor(t){t=Lu(Lu({},ky.defaultOptions),t);const e=wt.from({vertex:{source:ku,entryPoint:"mainVertex"},fragment:{source:ku,entryPoint:"mainFragment"}}),s=Dt.from({vertex:rn,fragment:Y_,name:"alpha-filter"}),i=t,{alpha:n}=i,o=YE(i,["alpha"]),a=new it({uAlpha:{value:n,type:"f32"}});super(WE(Lu({},o),{gpuProgram:e,glProgram:s,resources:{alphaUniforms:a}}))}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(t){this.resources.alphaUniforms.uniforms.uAlpha=t}};Q_.defaultOptions={alpha:1};let qE=Q_;const Nu={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},KE=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," finalColor = vec4(0.0);"," %blur%","}"].join(` `);function J_(r){const t=Nu[r],e=t.length;let s=KE,i="";const n="finalColor += texture(uTexture, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a=e&&(o=r-a-1),u=u.replace("%value%",t[o].toString()),i+=u,i+=` `}return s=s.replace("%blur%",i),s=s.replace("%size%",r.toString()),s}const ZE=` in vec2 aPosition; uniform float uStrength; out vec2 vBlurTexCoords[%size%]; uniform vec4 uInputSize; uniform vec4 uOutputFrame; uniform vec4 uOutputTexture; vec4 filterVertexPosition( void ) { vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy; position.x = position.x * (2.0 / uOutputTexture.x) - 1.0; position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z; return vec4(position, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aPosition * (uOutputFrame.zw * uInputSize.zw); } void main(void) { gl_Position = filterVertexPosition(); float pixelStrength = uInputSize.%dimension% * uStrength; vec2 textureCoord = filterTextureCoord(); %blur% }`;function t0(r,t){const e=Math.ceil(r/2);let s=ZE,i="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * pixelStrength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * pixelStrength);";for(let o=0;o, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct BlurUniforms { uStrength:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var blurUniforms : BlurUniforms; struct VSOutput { @builtin(position) position: vec4, %blur-struct% }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { let filteredCord = filterTextureCoord(aPosition); let pixelStrength = gfu.uInputSize.%dimension% * blurUniforms.uStrength; return VSOutput( filterVertexPosition(aPosition), %blur-vertex-out% ); } @fragment fn mainFragment( @builtin(position) position: vec4, %blur-fragment-in% ) -> @location(0) vec4 { var finalColor = vec4(0.0); %blur-sampling% return finalColor; }`;function s0(r,t){const e=Nu[t],s=e.length,i=[],n=[],o=[];for(let h=0;h,`,r?n[h]=`filteredCord + vec2(${h-s+1} * pixelStrength, 0.0),`:n[h]=`filteredCord + vec2(0.0, ${h-s+1} * pixelStrength),`;const d=ht in r?QE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$u=(r,t)=>{for(var e in t||(t={}))JE.call(t,e)&&n0(r,e,t[e]);if(i0)for(var e of i0(t))tw.call(t,e)&&n0(r,e,t[e]);return r};const o0=class Ly extends he{constructor(t){t=$u($u({},Ly.defaultOptions),t);const e=e0(t.horizontal,t.kernelSize),s=s0(t.horizontal,t.kernelSize);super($u({glProgram:e,gpuProgram:s,resources:{blurUniforms:{uStrength:{value:0,type:"f32"}}}},t)),this.horizontal=t.horizontal,this._quality=0,this.quality=t.quality,this.blur=t.strength,this._uniforms=this.resources.blurUniforms.uniforms}apply(t,e,s,i){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)t.applyFilter(this,e,s,i);else{const n=st.getSameSizeTexture(e);let o=e,a=n;this._state.blend=!1;const u=t.renderer.type===Tt.WEBGPU;for(let l=0;lt in r?ew(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ps=(r,t)=>{for(var e in t||(t={}))a0.call(t,e)&&l0(r,e,t[e]);if(on)for(var e of on(t))u0.call(t,e)&&l0(r,e,t[e]);return r},iw=(r,t)=>rw(r,sw(t)),nw=(r,t)=>{var e={};for(var s in r)a0.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&on)for(var s of on(r))t.indexOf(s)<0&&u0.call(r,s)&&(e[s]=r[s]);return e};class c0 extends he{constructor(...t){var e;let s=(e=t[0])!=null?e:{};typeof s=="number"&&(s={strength:s},t[1]!==void 0&&(s.quality=t[1]),t[2]!==void 0&&(s.resolution=t[2]||"inherit"),t[3]!==void 0&&(s.kernelSize=t[3])),s=Ps(Ps({},nn.defaultOptions),s);const i=s,{strength:n,strengthX:o,strengthY:a,quality:u}=i,l=nw(i,["strength","strengthX","strengthY","quality"]);super(iw(Ps({},l),{compatibleRenderers:Tt.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new nn(Ps({horizontal:!0},s)),this.blurYFilter=new nn(Ps({horizontal:!1},s)),this.quality=u,this.strengthX=o!=null?o:n,this.strengthY=a!=null?a:n,this.repeatEdgePixels=!1}apply(t,e,s,i){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=st.getSameSizeTexture(e);this.blurXFilter.blendMode="normal",this.blurXFilter.apply(t,e,a,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,a,s,i),st.returnTexture(a)}else o?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,e,s,i)):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter.apply(t,e,s,i))}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.blur),Math.abs(this.blurYFilter.blur))*2}get strength(){if(this.strengthX!==this.strengthY)throw new Error("BlurFilter's strengthX and strengthY are different");return this.strengthX}set strength(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get strengthX(){return this.blurXFilter.blur}set strengthX(t){this.blurXFilter.blur=t,this.updatePadding()}get strengthY(){return this.blurYFilter.blur}set strengthY(t){this.blurYFilter.blur=t,this.updatePadding()}get blur(){return this.strength}set blur(t){this.strength=t}get blurX(){return this.strengthX}set blurX(t){this.strengthX=t}get blurY(){return this.strengthY}set blurY(t){this.strengthY=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}c0.defaultOptions={strength:8,quality:4,kernelSize:5};var h0=` in vec2 vTextureCoord; in vec4 vColor; out vec4 finalColor; uniform float uColorMatrix[20]; uniform float uAlpha; uniform sampler2D uTexture; float rand(vec2 co) { return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); } void main() { vec4 color = texture(uTexture, vTextureCoord); float randomValue = rand(gl_FragCoord.xy * 0.2); float diff = (randomValue - 0.5) * 0.5; if (uAlpha == 0.0) { finalColor = color; return; } if (color.a > 0.0) { color.rgb /= color.a; } vec4 result; result.r = (uColorMatrix[0] * color.r); result.r += (uColorMatrix[1] * color.g); result.r += (uColorMatrix[2] * color.b); result.r += (uColorMatrix[3] * color.a); result.r += uColorMatrix[4]; result.g = (uColorMatrix[5] * color.r); result.g += (uColorMatrix[6] * color.g); result.g += (uColorMatrix[7] * color.b); result.g += (uColorMatrix[8] * color.a); result.g += uColorMatrix[9]; result.b = (uColorMatrix[10] * color.r); result.b += (uColorMatrix[11] * color.g); result.b += (uColorMatrix[12] * color.b); result.b += (uColorMatrix[13] * color.a); result.b += uColorMatrix[14]; result.a = (uColorMatrix[15] * color.r); result.a += (uColorMatrix[16] * color.g); result.a += (uColorMatrix[17] * color.b); result.a += (uColorMatrix[18] * color.a); result.a += uColorMatrix[19]; vec3 rgb = mix(color.rgb, result.rgb, uAlpha); // Premultiply alpha again. rgb *= result.a; finalColor = vec4(rgb, result.a); } `,Xu=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct ColorMatrixUniforms { uColorMatrix:array, 5>, uAlpha:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var colorMatrixUniforms : ColorMatrixUniforms; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2, }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition), ); } @fragment fn mainFragment( @location(0) uv: vec2, ) -> @location(0) vec4 { var c = textureSample(uTexture, uSampler, uv); if (colorMatrixUniforms.uAlpha == 0.0) { return c; } // Un-premultiply alpha before applying the color matrix. See issue #3539. if (c.a > 0.0) { c.r /= c.a; c.g /= c.a; c.b /= c.a; } var cm = colorMatrixUniforms.uColorMatrix; var result = vec4(0.); result.r = (cm[0][0] * c.r); result.r += (cm[0][1] * c.g); result.r += (cm[0][2] * c.b); result.r += (cm[0][3] * c.a); result.r += cm[1][0]; result.g = (cm[1][1] * c.r); result.g += (cm[1][2] * c.g); result.g += (cm[1][3] * c.b); result.g += (cm[2][0] * c.a); result.g += cm[2][1]; result.b = (cm[2][2] * c.r); result.b += (cm[2][3] * c.g); result.b += (cm[3][0] * c.b); result.b += (cm[3][1] * c.a); result.b += cm[3][2]; result.a = (cm[3][3] * c.r); result.a += (cm[4][0] * c.g); result.a += (cm[4][1] * c.b); result.a += (cm[4][2] * c.a); result.a += cm[4][3]; var rgb = mix(c.rgb, result.rgb, colorMatrixUniforms.uAlpha); rgb.r *= result.a; rgb.g *= result.a; rgb.b *= result.a; return vec4(rgb, result.a); }`,ow=Object.defineProperty,aw=Object.defineProperties,uw=Object.getOwnPropertyDescriptors,d0=Object.getOwnPropertySymbols,lw=Object.prototype.hasOwnProperty,cw=Object.prototype.propertyIsEnumerable,p0=(r,t,e)=>t in r?ow(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hw=(r,t)=>{for(var e in t||(t={}))lw.call(t,e)&&p0(r,e,t[e]);if(d0)for(var e of d0(t))cw.call(t,e)&&p0(r,e,t[e]);return r},dw=(r,t)=>aw(r,uw(t));class pw extends he{constructor(t={}){const e=new it({uColorMatrix:{value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],type:"f32",size:20},uAlpha:{value:1,type:"f32"}}),s=wt.from({vertex:{source:Xu,entryPoint:"mainVertex"},fragment:{source:Xu,entryPoint:"mainFragment"}}),i=Dt.from({vertex:rn,fragment:h0,name:"color-matrix-filter"});super(dw(hw({},t),{gpuProgram:s,glProgram:i,resources:{colorMatrixUniforms:e}})),this.alpha=1}_loadMatrix(t,e=!1){let s=t;e&&(this._multiply(s,this.matrix,t),s=this._colorMatrix(s)),this.resources.colorMatrixUniforms.uniforms.uColorMatrix=s,this.resources.colorMatrixUniforms.update()}_multiply(t,e,s){return t[0]=e[0]*s[0]+e[1]*s[5]+e[2]*s[10]+e[3]*s[15],t[1]=e[0]*s[1]+e[1]*s[6]+e[2]*s[11]+e[3]*s[16],t[2]=e[0]*s[2]+e[1]*s[7]+e[2]*s[12]+e[3]*s[17],t[3]=e[0]*s[3]+e[1]*s[8]+e[2]*s[13]+e[3]*s[18],t[4]=e[0]*s[4]+e[1]*s[9]+e[2]*s[14]+e[3]*s[19]+e[4],t[5]=e[5]*s[0]+e[6]*s[5]+e[7]*s[10]+e[8]*s[15],t[6]=e[5]*s[1]+e[6]*s[6]+e[7]*s[11]+e[8]*s[16],t[7]=e[5]*s[2]+e[6]*s[7]+e[7]*s[12]+e[8]*s[17],t[8]=e[5]*s[3]+e[6]*s[8]+e[7]*s[13]+e[8]*s[18],t[9]=e[5]*s[4]+e[6]*s[9]+e[7]*s[14]+e[8]*s[19]+e[9],t[10]=e[10]*s[0]+e[11]*s[5]+e[12]*s[10]+e[13]*s[15],t[11]=e[10]*s[1]+e[11]*s[6]+e[12]*s[11]+e[13]*s[16],t[12]=e[10]*s[2]+e[11]*s[7]+e[12]*s[12]+e[13]*s[17],t[13]=e[10]*s[3]+e[11]*s[8]+e[12]*s[13]+e[13]*s[18],t[14]=e[10]*s[4]+e[11]*s[9]+e[12]*s[14]+e[13]*s[19]+e[14],t[15]=e[15]*s[0]+e[16]*s[5]+e[17]*s[10]+e[18]*s[15],t[16]=e[15]*s[1]+e[16]*s[6]+e[17]*s[11]+e[18]*s[16],t[17]=e[15]*s[2]+e[16]*s[7]+e[17]*s[12]+e[18]*s[17],t[18]=e[15]*s[3]+e[16]*s[8]+e[17]*s[13]+e[18]*s[18],t[19]=e[15]*s[4]+e[16]*s[9]+e[17]*s[14]+e[18]*s[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const s=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}tint(t,e){const[s,i,n]=X.shared.setValue(t).toArray(),o=[s,0,0,0,0,0,i,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const s=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}grayscale(t,e){this.greyscale(t,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const s=Math.cos(t),i=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),u=s+(1-s)*o,l=o*(1-s)-a*i,c=o*(1-s)+a*i,h=o*(1-s)+a*i,d=s+o*(1-s),p=o*(1-s)-a*i,f=o*(1-s)-a*i,g=o*(1-s)+a*i,m=s+o*(1-s),_=[u,l,c,0,0,h,d,p,0,0,f,g,m,0,0,0,0,0,1,0];this._loadMatrix(_,e)}contrast(t,e){const s=(t||0)+1,i=-.5*(s-1),n=[s,0,0,0,i,0,s,0,0,i,0,0,s,0,i,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const s=t*2/3+1,i=(s-1)*-.5,n=[s,i,i,0,0,i,s,i,0,0,i,i,s,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,s,i,n){t||(t=.2),e||(e=.15),s||(s=16770432),i||(i=3375104);const o=X.shared,[a,u,l]=o.setValue(s).toArray(),[c,h,d]=o.setValue(i).toArray(),p=[.3,.59,.11,0,0,a,u,l,t,0,c,h,d,e,0,a-c,u-h,l-d,0,0];this._loadMatrix(p,n)}night(t,e){t||(t=.1);const s=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(s,e)}predator(t,e){const s=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(s,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.resources.colorMatrixUniforms.uniforms.uColorMatrix}set matrix(t){this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t}get alpha(){return this.resources.colorMatrixUniforms.uniforms.uAlpha}set alpha(t){this.resources.colorMatrixUniforms.uniforms.uAlpha=t}}var f0=` in vec2 vTextureCoord; in vec2 vFilterUv; out vec4 finalColor; uniform sampler2D uTexture; uniform sampler2D uMapTexture; uniform vec4 uInputClamp; uniform highp vec4 uInputSize; uniform mat2 uRotation; uniform vec2 uScale; void main() { vec4 map = texture(uMapTexture, vFilterUv); vec2 offset = uInputSize.zw * (uRotation * (map.xy - 0.5)) * uScale; finalColor = texture(uTexture, clamp(vTextureCoord + offset, uInputClamp.xy, uInputClamp.zw)); } `,m0=`in vec2 aPosition; out vec2 vTextureCoord; out vec2 vFilterUv; uniform vec4 uInputSize; uniform vec4 uOutputFrame; uniform vec4 uOutputTexture; uniform mat3 uFilterMatrix; vec4 filterVertexPosition( void ) { vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy; position.x = position.x * (2.0 / uOutputTexture.x) - 1.0; position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z; return vec4(position, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aPosition * (uOutputFrame.zw * uInputSize.zw); } vec2 getFilterCoord( void ) { return ( uFilterMatrix * vec3( filterTextureCoord(), 1.0) ).xy; } void main(void) { gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); vFilterUv = getFilterCoord(); } `,Hu=` struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct DisplacementUniforms { uFilterMatrix:mat3x3, uScale:vec2, uRotation:mat2x2 }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var filterUniforms : DisplacementUniforms; @group(1) @binding(1) var uMapTexture: texture_2d; @group(1) @binding(2) var uMapSampler : sampler; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2, @location(1) filterUv : vec2, }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getFilterCoord(aPosition:vec2 ) -> vec2 { return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy; } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition), getFilterCoord(aPosition) ); } @fragment fn mainFragment( @location(0) uv: vec2, @location(1) filterUv: vec2, @builtin(position) position: vec4 ) -> @location(0) vec4 { var map = textureSample(uMapTexture, uMapSampler, filterUv); var offset = gfu.uInputSize.zw * (filterUniforms.uRotation * (map.xy - 0.5)) * filterUniforms.uScale; return textureSample(uTexture, uSampler, clamp(uv + offset, gfu.uInputClamp.xy, gfu.uInputClamp.zw)); }`,fw=Object.defineProperty,mw=Object.defineProperties,gw=Object.getOwnPropertyDescriptors,an=Object.getOwnPropertySymbols,g0=Object.prototype.hasOwnProperty,_0=Object.prototype.propertyIsEnumerable,x0=(r,t,e)=>t in r?fw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_w=(r,t)=>{for(var e in t||(t={}))g0.call(t,e)&&x0(r,e,t[e]);if(an)for(var e of an(t))_0.call(t,e)&&x0(r,e,t[e]);return r},xw=(r,t)=>mw(r,gw(t)),bw=(r,t)=>{var e={};for(var s in r)g0.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&an)for(var s of an(r))t.indexOf(s)<0&&_0.call(r,s)&&(e[s]=r[s]);return e};class yw extends he{constructor(...t){let e=t[0];e instanceof zt&&(e={sprite:e,scale:t[1]});const s=e,{sprite:i,scale:n}=s,o=bw(s,["sprite","scale"]);let a=n!=null?n:20;typeof a=="number"&&(a=new nt(a,a));const u=new it({uFilterMatrix:{value:new M,type:"mat3x3"},uScale:{value:a,type:"vec2"},uRotation:{value:new Float32Array([0,0,0,0]),type:"mat2x2"}}),l=Dt.from({vertex:m0,fragment:f0,name:"displacement-filter"}),c=wt.from({vertex:{source:Hu,entryPoint:"mainVertex"},fragment:{source:Hu,entryPoint:"mainFragment"}}),h=i.texture.source;super(xw(_w({},o),{gpuProgram:c,glProgram:l,resources:{filterUniforms:u,uMapTexture:h,uMapSampler:h.style}})),this._sprite=e.sprite,this._sprite.renderable=!1}apply(t,e,s,i){const n=this.resources.filterUniforms.uniforms;t.calculateSpriteMatrix(n.uFilterMatrix,this._sprite);const o=this._sprite.worldTransform,a=Math.sqrt(o.a*o.a+o.b*o.b),u=Math.sqrt(o.c*o.c+o.d*o.d);a!==0&&u!==0&&(n.uRotation[0]=o.a/a,n.uRotation[1]=o.b/a,n.uRotation[2]=o.c/u,n.uRotation[3]=o.d/u),this.resources.uMapTexture=this._sprite.texture.source,t.applyFilter(this,e,s,i)}get scale(){return this.resources.filterUniforms.uniforms.uScale}}var b0=` in vec2 vTextureCoord; in vec4 vColor; out vec4 finalColor; uniform float uNoise; uniform float uSeed; uniform sampler2D uTexture; float rand(vec2 co) { return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); } void main() { vec4 color = texture(uTexture, vTextureCoord); float randomValue = rand(gl_FragCoord.xy * uSeed); float diff = (randomValue - 0.5) * uNoise; // Un-premultiply alpha before applying the color matrix. See issue #3539. if (color.a > 0.0) { color.rgb /= color.a; } color.r += diff; color.g += diff; color.b += diff; // Premultiply alpha again. color.rgb *= color.a; finalColor = color; } `,ju=` struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct NoiseUniforms { uNoise:f32, uSeed:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var noiseUniforms : NoiseUniforms; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2 }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition) ); } fn rand(co:vec2) -> f32 { return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); } @fragment fn mainFragment( @location(0) uv: vec2, @builtin(position) position: vec4 ) -> @location(0) vec4 { var pixelPosition = globalTextureCoord(position.xy);// / (getSize());//- gfu.uOutputFrame.xy); var sample = textureSample(uTexture, uSampler, uv); var randomValue = rand(pixelPosition.xy * noiseUniforms.uSeed); var diff = (randomValue - 0.5) * noiseUniforms.uNoise; // Un-premultiply alpha before applying the color matrix. See issue #3539. if (sample.a > 0.0) { sample.r /= sample.a; sample.g /= sample.a; sample.b /= sample.a; } sample.r += diff; sample.g += diff; sample.b += diff; // Premultiply alpha again. sample.r *= sample.a; sample.g *= sample.a; sample.b *= sample.a; return sample; }`,vw=Object.defineProperty,Tw=Object.defineProperties,Aw=Object.getOwnPropertyDescriptors,un=Object.getOwnPropertySymbols,y0=Object.prototype.hasOwnProperty,v0=Object.prototype.propertyIsEnumerable,T0=(r,t,e)=>t in r?vw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,zu=(r,t)=>{for(var e in t||(t={}))y0.call(t,e)&&T0(r,e,t[e]);if(un)for(var e of un(t))v0.call(t,e)&&T0(r,e,t[e]);return r},Sw=(r,t)=>Tw(r,Aw(t)),Ew=(r,t)=>{var e={};for(var s in r)y0.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&un)for(var s of un(r))t.indexOf(s)<0&&v0.call(r,s)&&(e[s]=r[s]);return e};const A0=class Ny extends he{constructor(t={}){t=zu(zu({},Ny.defaultOptions),t);const e=wt.from({vertex:{source:ju,entryPoint:"mainVertex"},fragment:{source:ju,entryPoint:"mainFragment"}}),s=Dt.from({vertex:rn,fragment:b0,name:"noise-filter"}),i=t,{noise:n,seed:o}=i,a=Ew(i,["noise","seed"]);super(Sw(zu({},a),{gpuProgram:e,glProgram:s,resources:{noiseUniforms:new it({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}})),this.noise=n,this.seed=o!=null?o:Math.random()}get noise(){return this.resources.noiseUniforms.uniforms.uNoise}set noise(t){this.resources.noiseUniforms.uniforms.uNoise=t}get seed(){return this.resources.noiseUniforms.uniforms.uSeed}set seed(t){this.resources.noiseUniforms.uniforms.uSeed=t}};A0.defaultOptions={noise:.5};let ww=A0;var S0=`in vec2 vMaskCoord; in vec2 vTextureCoord; uniform sampler2D uTexture; uniform sampler2D uMaskTexture; uniform float uAlpha; uniform vec4 uMaskClamp; uniform float uInverse; out vec4 finalColor; void main(void) { float clip = step(3.5, step(uMaskClamp.x, vMaskCoord.x) + step(uMaskClamp.y, vMaskCoord.y) + step(vMaskCoord.x, uMaskClamp.z) + step(vMaskCoord.y, uMaskClamp.w)); // TODO look into why this is needed float npmAlpha = uAlpha; vec4 original = texture(uTexture, vTextureCoord); vec4 masky = texture(uMaskTexture, vMaskCoord); float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a); float a = alphaMul * masky.r * npmAlpha * clip; if (uInverse == 1.0) { a = 1.0 - a; } finalColor = original * a; } `,E0=`in vec2 aPosition; out vec2 vTextureCoord; out vec2 vMaskCoord; uniform vec4 uInputSize; uniform vec4 uOutputFrame; uniform vec4 uOutputTexture; uniform mat3 uFilterMatrix; vec4 filterVertexPosition( vec2 aPosition ) { vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy; position.x = position.x * (2.0 / uOutputTexture.x) - 1.0; position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z; return vec4(position, 0.0, 1.0); } vec2 filterTextureCoord( vec2 aPosition ) { return aPosition * (uOutputFrame.zw * uInputSize.zw); } vec2 getFilterCoord( vec2 aPosition ) { return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy; } void main(void) { gl_Position = filterVertexPosition(aPosition); vTextureCoord = filterTextureCoord(aPosition); vMaskCoord = getFilterCoord(aPosition); } `,Vu=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct MaskUniforms { uFilterMatrix:mat3x3, uMaskClamp:vec4, uAlpha:f32, uInverse:f32, }; @group(0) @binding(0) var gfu: GlobalFilterUniforms; @group(0) @binding(1) var uTexture: texture_2d; @group(0) @binding(2) var uSampler : sampler; @group(1) @binding(0) var filterUniforms : MaskUniforms; @group(1) @binding(1) var uMaskTexture: texture_2d; struct VSOutput { @builtin(position) position: vec4, @location(0) uv : vec2, @location(1) filterUv : vec2, }; fn filterVertexPosition(aPosition:vec2) -> vec4 { var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy; position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0; position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z; return vec4(position, 0.0, 1.0); } fn filterTextureCoord( aPosition:vec2 ) -> vec2 { return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw); } fn globalTextureCoord( aPosition:vec2 ) -> vec2 { return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); } fn getFilterCoord(aPosition:vec2 ) -> vec2 { return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy; } fn getSize() -> vec2 { return gfu.uGlobalFrame.zw; } @vertex fn mainVertex( @location(0) aPosition : vec2, ) -> VSOutput { return VSOutput( filterVertexPosition(aPosition), filterTextureCoord(aPosition), getFilterCoord(aPosition) ); } @fragment fn mainFragment( @location(0) uv: vec2, @location(1) filterUv: vec2, @builtin(position) position: vec4 ) -> @location(0) vec4 { var maskClamp = filterUniforms.uMaskClamp; var uAlpha = filterUniforms.uAlpha; var clip = step(3.5, step(maskClamp.x, filterUv.x) + step(maskClamp.y, filterUv.y) + step(filterUv.x, maskClamp.z) + step(filterUv.y, maskClamp.w)); var mask = textureSample(uMaskTexture, uSampler, filterUv); var source = textureSample(uTexture, uSampler, uv); var alphaMul = 1.0 - uAlpha * (1.0 - mask.a); var a: f32 = alphaMul * mask.r * uAlpha * clip; if (filterUniforms.uInverse == 1.0) { a = 1.0 - a; } return source * a; } `,Cw=Object.defineProperty,Rw=Object.defineProperties,Pw=Object.getOwnPropertyDescriptors,ln=Object.getOwnPropertySymbols,w0=Object.prototype.hasOwnProperty,C0=Object.prototype.propertyIsEnumerable,R0=(r,t,e)=>t in r?Cw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Dw=(r,t)=>{for(var e in t||(t={}))w0.call(t,e)&&R0(r,e,t[e]);if(ln)for(var e of ln(t))C0.call(t,e)&&R0(r,e,t[e]);return r},Mw=(r,t)=>Rw(r,Pw(t)),Ow=(r,t)=>{var e={};for(var s in r)w0.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&ln)for(var s of ln(r))t.indexOf(s)<0&&C0.call(r,s)&&(e[s]=r[s]);return e};class P0 extends he{constructor(t){const e=t,{sprite:s}=e,i=Ow(e,["sprite"]),n=new bo(s.texture),o=new it({uFilterMatrix:{value:new M,type:"mat3x3"},uMaskClamp:{value:n.uClampFrame,type:"vec4"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"}}),a=wt.from({vertex:{source:Vu,entryPoint:"mainVertex"},fragment:{source:Vu,entryPoint:"mainFragment"}}),u=Dt.from({vertex:E0,fragment:S0,name:"mask-filter"});super(Mw(Dw({},i),{gpuProgram:a,glProgram:u,clipToViewport:!1,resources:{filterUniforms:o,uMaskTexture:s.texture.source}})),this.sprite=s,this._textureMatrix=n}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}apply(t,e,s,i){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,s,i)}}var Bw=`fn getLuminosity(c: vec3) -> f32 { return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b; } fn setLuminosity(c: vec3, lum: f32) -> vec3 { let d: f32 = lum - getLuminosity(c); let newColor: vec3 = c.rgb + vec3(d, d, d); // clip back into legal range let newLum: f32 = getLuminosity(newColor); let cMin: f32 = min(newColor.r, min(newColor.g, newColor.b)); let cMax: f32 = max(newColor.r, max(newColor.g, newColor.b)); let t1: f32 = newLum / (newLum - cMin); let t2: f32 = (1.0 - newLum) / (cMax - newLum); let finalColor = mix(vec3(newLum, newLum, newLum), newColor, select(select(1.0, t2, cMax > 1.0), t1, cMin < 0.0)); return finalColor; } fn getSaturation(c: vec3) -> f32 { return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b)); } // Set saturation if color components are sorted in ascending order. fn setSaturationMinMidMax(cSorted: vec3, s: f32) -> vec3 { var result: vec3; if (cSorted.z > cSorted.x) { let newY = (((cSorted.y - cSorted.x) * s) / (cSorted.z - cSorted.x)); result = vec3(0.0, newY, s); } else { result = vec3(0.0, 0.0, 0.0); } return vec3(result.x, result.y, result.z); } fn setSaturation(c: vec3, s: f32) -> vec3 { var result: vec3 = c; if (c.r <= c.g && c.r <= c.b) { if (c.g <= c.b) { result = setSaturationMinMidMax(result, s); } else { var temp: vec3 = vec3(result.r, result.b, result.g); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.r, temp.b, temp.g); } } else if (c.g <= c.r && c.g <= c.b) { if (c.r <= c.b) { var temp: vec3 = vec3(result.g, result.r, result.b); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.g, temp.r, temp.b); } else { var temp: vec3 = vec3(result.g, result.b, result.r); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.g, temp.b, temp.r); } } else { if (c.r <= c.g) { var temp: vec3 = vec3(result.b, result.r, result.g); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.b, temp.r, temp.g); } else { var temp: vec3 = vec3(result.b, result.g, result.r); temp = setSaturationMinMidMax(temp, s); result = vec3(temp.b, temp.g, temp.r); } } return result; }`;function Wu(r,t,e,s,i,n,o,a){const u=o-e,l=a-s,c=i-e,h=n-s,d=r-e,p=t-s,f=u*u+l*l,g=u*c+l*h,m=u*d+l*p,_=c*c+h*h,b=c*d+h*p,x=1/(f*_-g*g),y=(_*m-g*b)*x,A=(f*b-g*m)*x;return y>=0&&A>=0&&y+A<1}class Dc{constructor(t=0,e=0,s=0,i=0,n=0,o=0){this.type="triangle",this.x=t,this.y=e,this.x2=s,this.y2=i,this.x3=n,this.y3=o}contains(t,e){const s=(this.x-this.x3)*(e-this.y3)-(this.y-this.y3)*(t-this.x3),i=(this.x2-this.x)*(e-this.y)-(this.y2-this.y)*(t-this.x);if(s<0!=i<0&&s!==0&&i!==0)return!1;const n=(this.x3-this.x2)*(e-this.y2)-(this.y3-this.y2)*(t-this.x2);return n===0||n<0==s+i<=0}strokeContains(t,e,s,i=.5){const n=s/2,o=n*n,{x:a,x2:u,x3:l,y:c,y2:h,y3:d}=this;return hs(t,e,a,c,u,d)<=o||hs(t,e,u,h,l,d)<=o||hs(t,e,l,d,a,c)<=o}clone(){return new Dc(this.x,this.y,this.x2,this.y2,this.x3,this.y3)}copyFrom(t){return this.x=t.x,this.y=t.y,this.x2=t.x2,this.y2=t.y2,this.x3=t.x3,this.y3=t.y3,this}copyTo(t){return t.copyFrom(this),t}getBounds(t){t||(t=new j);const e=Math.min(this.x,this.x2,this.x3),s=Math.max(this.x,this.x2,this.x3),i=Math.min(this.y,this.y2,this.y3),n=Math.max(this.y,this.y2,this.y3);return t.x=e,t.y=i,t.width=s-e,t.height=n-i,t}}const D0=class $y{constructor(t){this._tick=()=>{this.timeout=setTimeout(this._processQueue,0)},this._processQueue=()=>{const{queue:e}=this;let s=0;for(;e.length&&s<$y.uploadsPerFrame;){const i=e.shift();this.uploadQueueItem(i),s++}e.length?ft.system.addOnce(this._tick,this,ge.UTILITY):this._resolve()},this.renderer=t,this.queue=[],this.resolves=[]}getQueue(){return[...this.queue]}add(t){const e=Array.isArray(t)?t:[t];for(const s of e)s instanceof et?this._addContainer(s):this.resolveQueueItem(s,this.queue);return this}_addContainer(t){this.resolveQueueItem(t,this.queue);for(const e of t.children)this._addContainer(e)}upload(t){return t&&this.add(t),new Promise(e=>{this.queue.length?(this.resolves.push(e),this.dedupeQueue(),ft.system.addOnce(this._tick,this,ge.UTILITY)):e()})}dedupeQueue(){const t=Object.create(null);let e=0;for(let s=0;st in r?Gw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fw=(r,t)=>{for(var e in t||(t={}))O0.call(t,e)&&G0(r,e,t[e]);if(cn)for(var e of cn(t))B0.call(t,e)&&G0(r,e,t[e]);return r},Iw=(r,t)=>{var e={};for(var s in r)O0.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&cn)for(var s of cn(r))t.indexOf(s)<0&&B0.call(r,s)&&(e[s]=r[s]);return e};class Er extends ae{constructor(...t){var e;let s=t[0];s instanceof Fe&&(s={geometry:s,shader:t[1]},t[3]&&(s.geometry.topology=t[3]));const i=s,{geometry:n,shader:o,texture:a,roundPixels:u,state:l}=i,c=Iw(i,["geometry","shader","texture","roundPixels","state"]);super(Fw({label:"Mesh"},c)),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=o!=null?o:null,this.texture=(e=a!=null?a:o==null?void 0:o.texture)!=null?e:C.WHITE,this.state=l!=null?l:Mt.for2d(),this._geometry=n,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=u!=null?u:!1}get material(){return this._shader}set shader(t){this._shader!==t&&(this._shader=t,this.onViewUpdate())}get shader(){return this._shader}set geometry(t){var e;this._geometry!==t&&((e=this._geometry)==null||e.off("update",this.onViewUpdate,this),t.on("update",this.onViewUpdate,this),this._geometry=t,this.onViewUpdate())}get geometry(){return this._geometry}set texture(t){t||(t=C.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=t),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get batched(){return this._shader||this.state.data&12?!1:this._geometry instanceof $e?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(t){const{x:e,y:s}=t;if(!this.bounds.containsPoint(e,s))return!1;const i=this.geometry.getBuffer("aPosition").data,n=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){const o=this.geometry.getIndex().data,a=o.length;for(let u=0;u+2t in r?Uw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nw=(r,t)=>{for(var e in t||(t={}))F0.call(t,e)&&U0(r,e,t[e]);if(hn)for(var e of hn(t))I0.call(t,e)&&U0(r,e,t[e]);return r},$w=(r,t)=>kw(r,Lw(t)),Xw=(r,t)=>{var e={};for(var s in r)F0.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&hn)for(var s of hn(r))t.indexOf(s)<0&&I0.call(r,s)&&(e[s]=r[s]);return e};class ks extends zt{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const s=e,{animationSpeed:i=1,autoPlay:n=!1,autoUpdate:o=!0,loop:a=!0,onComplete:u=null,onFrameChange:l=null,onLoop:c=null,textures:h,updateAnchor:d=!1}=s,p=Xw(s,["animationSpeed","autoPlay","autoUpdate","loop","onComplete","onFrameChange","onLoop","textures","updateAnchor"]),[f]=h;super($w(Nw({},p),{texture:f instanceof C?f:f.texture})),this._textures=null,this._durations=null,this._autoUpdate=o,this._isConnectedToTicker=!1,this.animationSpeed=i,this.loop=a,this.updateAnchor=d,this.onComplete=u,this.onFrameChange=l,this.onLoop=c,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=h,n&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(ft.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(ft.shared.add(this.update,this,ge.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,s=this.animationSpeed*e,i=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=s/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const o=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=s;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):i!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFramei)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.texture.defaultAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t=!1){if(typeof t=="boolean"?t:t!=null&&t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._textures.forEach(s=>{this.texture!==s&&s.destroy(e)})}this._textures=[],this._durations=null,this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let s=0;sthis.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(ft.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(ft.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class k0{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t!=null?t:new M,this.observer=e,this.position=new q(this,0,0),this.scale=new q(this,1,1),this.pivot=new q(this,0,0),this.skew=new q(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const t=this._matrix;return this.dirty&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this.dirty=!1),t}_onUpdate(t){var e;this.dirty=!0,t===this.skew&&this.updateSkew(),(e=this.observer)==null||e._onUpdate(this)}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this.dirty=!0}setFromMatrix(t){t.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this.skew))}}var Hw=Object.defineProperty,dn=Object.getOwnPropertySymbols,L0=Object.prototype.hasOwnProperty,N0=Object.prototype.propertyIsEnumerable,$0=(r,t,e)=>t in r?Hw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ds=(r,t)=>{for(var e in t||(t={}))L0.call(t,e)&&$0(r,e,t[e]);if(dn)for(var e of dn(t))N0.call(t,e)&&$0(r,e,t[e]);return r},jw=(r,t)=>{var e={};for(var s in r)L0.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&dn)for(var s of dn(r))t.indexOf(s)<0&&N0.call(r,s)&&(e[s]=r[s]);return e};const X0=class kn extends ae{constructor(...t){let e=t[0]||{};e instanceof C&&(e={texture:e}),t.length>1&&(e.width=t[1],e.height=t[2]),e=Ds(Ds({},kn.defaultOptions),e);const s=e!=null?e:{},{texture:i,anchor:n,tilePosition:o,tileScale:a,tileRotation:u,width:l,height:c,applyAnchorToTexture:h,roundPixels:d}=s,p=jw(s,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(Ds({label:"TilingSprite"},p)),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new q({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=h,this.texture=i,this._width=l!=null?l:i.width,this._height=c!=null?c:i.height,this._tileTransform=new k0({observer:{_onUpdate:()=>this.onViewUpdate()}}),n&&(this.anchor=n),this.tilePosition=o,this.tileScale=a,this.tileRotation=u,this.roundPixels=d!=null?d:!1}static from(t,e={}){return typeof t=="string"?new kn(Ds({texture:z.get(t)},e)):new kn(Ds({texture:t},e))}get uvRespectAnchor(){return Lt("uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(t){Lt("uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture=t}get clampMargin(){return this._texture.textureMatrix.clampMargin}set clampMargin(t){this._texture.textureMatrix.clampMargin=t}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get tilePosition(){return this._tileTransform.position}set tilePosition(t){this._tileTransform.position.copyFrom(t)}get tileScale(){return this._tileTransform.scale}set tileScale(t){typeof t=="number"?this._tileTransform.scale.set(t):this._tileTransform.scale.copyFrom(t)}set tileRotation(t){this._tileTransform.rotation=t}get tileRotation(){return this._tileTransform.rotation}get tileTransform(){return this._tileTransform}set texture(t){t||(t=C.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}set width(t){this._width=t,this.onViewUpdate()}get width(){return this._width}set height(t){this._height=t,this.onViewUpdate()}get height(){return this._height}setSize(t,e){var s;typeof t=="object"&&(e=(s=t.height)!=null?s:t.width,t=t.width),this._width=t,this._height=e!=null?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}updateBounds(){const t=this._bounds,e=this._anchor,s=this._width,i=this._height;t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*i,t.maxY=t.minY+i}containsPoint(t){const e=this._width,s=this._height,i=-e*this._anchor._x;let n=0;return t.x>=i&&t.x<=i+e&&(n=-s*this._anchor._y,t.y>=n&&t.y<=n+s)}destroy(t=!1){if(super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}};X0.defaultOptions={texture:C.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let H0=X0;var zw=Object.defineProperty,pn=Object.getOwnPropertySymbols,j0=Object.prototype.hasOwnProperty,z0=Object.prototype.propertyIsEnumerable,V0=(r,t,e)=>t in r?zw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vw=(r,t)=>{for(var e in t||(t={}))j0.call(t,e)&&V0(r,e,t[e]);if(pn)for(var e of pn(t))z0.call(t,e)&&V0(r,e,t[e]);return r},Ww=(r,t)=>{var e={};for(var s in r)j0.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&pn)for(var s of pn(r))t.indexOf(s)<0&&z0.call(r,s)&&(e[s]=r[s]);return e};class fn extends ae{constructor(t,e){const s=t,{text:i,resolution:n,style:o,anchor:a,width:u,height:l,roundPixels:c}=s,h=Ww(s,["text","resolution","style","anchor","width","height","roundPixels"]);super(Vw({},h)),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i!=null?i:"",this.style=o,this.resolution=n!=null?n:null,this.allowChildren=!1,this._anchor=new q({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c!=null?c:!1,u!==void 0&&(this.width=u),l!==void 0&&(this.height=l)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t||(t={}),(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){var s;typeof t=="object"?(e=(s=t.height)!=null?s:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,s=this.bounds.height,i=-e*this.anchor.x;let n=0;return t.x>=i&&t.x<=i+e&&(n=-s*this.anchor.y,t.y>=n&&t.y<=n+s)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function mn(r,t){var e;let s=(e=r[0])!=null?e:{};return(typeof s=="string"||r[1])&&(s={text:s,style:r[1]}),s}class gn extends fn{constructor(...t){const e=mn(t,"Text");super(e,Bt),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof Pt?e.textureStyle:new Pt(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor;let s=0,i=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=xr.getCanvasAndContext({text:this.text,style:this._style,resolution:1});xr.returnCanvasAndContext(o),s=n.width,i=n.height}else{const n=pt.measureText(this._text,this._style);s=n.width,i=n.height}t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*i,t.maxY=t.minY+i}}class W0 extends M0{resolveQueueItem(t,e){return t instanceof et?this.resolveContainerQueueItem(t,e):t instanceof K||t instanceof C?e.push(t.source):t instanceof mt&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof zt||t instanceof H0||t instanceof Er?e.push(t.texture.source):t instanceof gn?e.push(t):t instanceof Or?e.push(t.context):t instanceof ks&&t.textures.forEach(s=>{s.source?e.push(s.source):e.push(s.texture.source)})}resolveGraphicsContextQueueItem(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const s of e)if(s.action==="texture"){const{image:i}=s.data;return i.source}else if(s.action==="fill"){const{texture:i}=s.data.style;return i.source}return null}}class Yu extends fn{constructor(...t){var e,s,i;const n=mn(t,"BitmapText");(e=n.style)!=null||(n.style=n.style||{}),(i=(s=n.style).fill)!=null||(s.fill=16777215),super(n,Bt),this.renderPipeId="bitmapText"}updateBounds(){const t=this._bounds,e=this._anchor,s=br.measureText(this.text,this._style),i=s.scale,n=s.offsetY*i;let o=s.width*i,a=s.height*i;const u=this._style._stroke;u&&(o+=u.width,a+=u.width),t.minX=-e._x*o,t.maxX=t.minX+o,t.minY=-e._y*(a+n),t.maxY=t.minY+a}set resolution(t){}get resolution(){return this._resolution}}function Y0(r){const t=r._stroke,e=r._fill,s=[`div { ${[`color: ${X.shared.setValue(e.color).toHex()}`,`font-size: ${r.fontSize}px`,`font-family: ${r.fontFamily}`,`font-weight: ${r.fontWeight}`,`font-style: ${r.fontStyle}`,`font-variant: ${r.fontVariant}`,`letter-spacing: ${r.letterSpacing}px`,`text-align: ${r.align}`,`padding: ${r.padding}px`,`white-space: ${r.whiteSpace==="pre"&&r.wordWrap?"pre-wrap":r.whiteSpace}`,...r.lineHeight?[`line-height: ${r.lineHeight}px`]:[],...r.wordWrap?[`word-wrap: ${r.breakWords?"break-all":"break-word"}`,`max-width: ${r.wordWrapWidth}px`]:[],...t?[K0(t)]:[],...r.dropShadow?[q0(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return Yw(r.tagStyles,s),s.join(" ")}function q0(r){const t=X.shared.setValue(r.color).setAlpha(r.alpha).toHexa(),e=Math.round(Math.cos(r.angle)*r.distance),s=Math.round(Math.sin(r.angle)*r.distance),i=`${e}px ${s}px`;return r.blur>0?`text-shadow: ${i} ${r.blur}px ${t}`:`text-shadow: ${i} ${t}`}function K0(r){return[`-webkit-text-stroke-width: ${r.width}px`,`-webkit-text-stroke-color: ${X.shared.setValue(r.color).toHex()}`,`text-stroke-width: ${r.width}px`,`text-stroke-color: ${X.shared.setValue(r.color).toHex()}`,"paint-order: stroke"].join(";")}const Z0={fontSize:"font-size: {{VALUE}}px",fontFamily:"font-family: {{VALUE}}",fontWeight:"font-weight: {{VALUE}}",fontStyle:"font-style: {{VALUE}}",fontVariant:"font-variant: {{VALUE}}",letterSpacing:"letter-spacing: {{VALUE}}px",align:"text-align: {{VALUE}}",padding:"padding: {{VALUE}}px",whiteSpace:"white-space: {{VALUE}}",lineHeight:"line-height: {{VALUE}}px",wordWrapWidth:"max-width: {{VALUE}}px"},Q0={fill:r=>`color: ${X.shared.setValue(r).toHex()}`,breakWords:r=>`word-wrap: ${r?"break-all":"break-word"}`,stroke:K0,dropShadow:q0};function Yw(r,t){for(const e in r){const s=r[e],i=[];for(const n in s)Q0[n]?i.push(Q0[n](s[n])):Z0[n]&&i.push(Z0[n].replace("{{VALUE}}",s[n]));t.push(`${e} { ${i.join(";")} }`)}}var qw=Object.defineProperty,J0=Object.getOwnPropertySymbols,Kw=Object.prototype.hasOwnProperty,Zw=Object.prototype.propertyIsEnumerable,t2=(r,t,e)=>t in r?qw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,e2=(r,t)=>{for(var e in t||(t={}))Kw.call(t,e)&&t2(r,e,t[e]);if(J0)for(var e of J0(t))Zw.call(t,e)&&t2(r,e,t[e]);return r};class jn extends Bt{constructor(t={}){var e,s;super(t),this._cssOverrides=[],this.cssOverrides=(e=t.cssOverrides)!=null?e:[],this.tagStyles=(s=t.tagStyles)!=null?s:{}}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}update(){this._cssStyle=null,super.update()}clone(){return new jn({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?e2({},this.dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides,tagStyles:e2({},this.tagStyles)})}get cssStyle(){return this._cssStyle||(this._cssStyle=Y0(this)),this._cssStyle}addOverride(...t){const e=t.filter(s=>!this.cssOverrides.includes(s));e.length>0&&(this.cssOverrides.push(...e),this.update())}removeOverride(...t){const e=t.filter(s=>this.cssOverrides.includes(s));e.length>0&&(this.cssOverrides=this.cssOverrides.filter(s=>!e.includes(s)),this.update())}set fill(t){super.fill=t}set stroke(t){super.stroke=t}}class r2 extends fn{constructor(...t){const e=mn(t,"HtmlText");super(e,jn),this.renderPipeId="htmlText",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof Pt?e.textureStyle:new Pt(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor,s=tu(this.text,this._style),{width:i,height:n}=s;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}get text(){return this._text}set text(t){const e=this._sanitiseText(t.toString());super.text=e}_sanitiseText(t){return this._removeInvalidHtmlTags(t.replace(/
/gi,"
").replace(/
/gi,"
").replace(/ /gi," "))}_removeInvalidHtmlTags(t){const e=/<[^>]*?(?=<|$)/g;return t.replace(e,"")}}class s2 extends W0{uploadQueueItem(t){t instanceof K?this.uploadTextureSource(t):t instanceof gn?this.uploadText(t):t instanceof r2?this.uploadHTMLText(t):t instanceof Yu?this.uploadBitmapText(t):t instanceof mt&&this.uploadGraphicsContext(t)}uploadTextureSource(t){this.renderer.texture.initSource(t)}uploadText(t){this.renderer.renderPipes.text.initGpuText(t)}uploadBitmapText(t){this.renderer.renderPipes.bitmapText.initGpuText(t)}uploadHTMLText(t){this.renderer.renderPipes.htmlText.initGpuText(t)}uploadGraphicsContext(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const s of e)if(s.action==="texture"){const{image:i}=s.data;this.uploadTextureSource(i.source)}else if(s.action==="fill"){const{texture:i}=s.data.style;this.uploadTextureSource(i.source)}return null}}class i2 extends s2{destroy(){clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}i2.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"prepare"};class qu{constructor(){this._tempState=Mt.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,s){const i=t.renderer,n=this._didUploadHash[s.uid];i.shader.bind(s,n),n||(this._didUploadHash[s.uid]=!0),i.shader.updateUniformGroup(i.globalUniforms.uniformGroup),i.geometry.bind(e,s.glProgram)}execute(t,e){const s=t.renderer;this._tempState.blendMode=e.blendMode,s.state.set(this._tempState);const i=e.textures.textures;for(let n=0;ns.trim()).filter(s=>s.length);let e="";return t.map(s=>{let i=e+s;return s==="{"?e+=" ":s==="}"&&(e=e.substr(0,e.length-4),i=e+s),i}).join(` `)}const n2={name:"texture-bit",vertex:{header:` struct TextureUniforms { uTextureMatrix:mat3x3, } @group(2) @binding(2) var textureUniforms : TextureUniforms; `,main:` uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy; `},fragment:{header:` @group(2) @binding(0) var uTexture: texture_2d; @group(2) @binding(1) var uSampler: sampler; `,main:` outColor = textureSample(uTexture, uSampler, vUV); `}},o2={name:"texture-bit",vertex:{header:` uniform mat3 uTextureMatrix; `,main:` uv = (uTextureMatrix * vec3(uv, 1.0)).xy; `},fragment:{header:` uniform sampler2D uTexture; `,main:` outColor = texture(uTexture, vUV); `}},eC=new ot;let rC=class extends Qr{constructor(){super(),this.filters=[new P0({sprite:new zt(C.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}get inverse(){return this.filters[0].inverse}set inverse(t){this.filters[0].inverse=t}};class Ju{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,s){const i=this._renderer;if(i.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.renderMaskToTexture){const n=t.mask;n.includeInBuild=!0,n.collectRenderables(s,i,null),n.includeInBuild=!1}i.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){const e=this._renderer,s=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const i=lt.get(rC);if(i.inverse=t.inverse,s){t.mask.mask.measurable=!0;const n=Jr(t.mask.mask,!0,eC);t.mask.mask.measurable=!1,n.ceil();const o=e.renderTarget.renderTarget.colorTexture.source,a=st.getOptimalTexture(n.width,n.height,o._resolution,o.antialias);e.renderTarget.push(a,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});const u=i.sprite;u.texture=a,u.worldTransform.tx=n.minX,u.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer,filterTexture:a})}else i.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const i=this._activeMaskStage[this._activeMaskStage.length-1];s&&(e.type===Tt.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:i.maskedContainer,filterEffect:i.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const i=this._activeMaskStage.pop();s&&st.returnTexture(i.filterTexture),lt.return(i.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}Ju.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"alphaMask"};class tl{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,s){this._renderer.renderPipes.batch.break(s);const i=this._colorStack;i[this._colorStackIndex]=i[this._colorStackIndex-1]&t.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,s){this._renderer.renderPipes.batch.break(s);const i=this._colorStack;this._colorStackIndex--;const n=i[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._colorStack=null}}tl.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"colorMask"};class sC{constructor(t){this.priority=0,this.pipe="scissorMask",this.mask=t,this.mask.renderable=!1,this.mask.measurable=!1}addBounds(t,e){hi(this.mask,t,e)}addLocalBounds(t,e){di(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}reset(){this.mask.measurable=!0,this.mask=null}destroy(){this.reset()}}class el{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,s){var i,n;const o=t,a=this._renderer;a.renderPipes.batch.break(s),a.renderPipes.blendMode.setBlendMode(o.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const u=o.mask;u.includeInBuild=!0,this._maskHash.has(o)||this._maskHash.set(o,{instructionsStart:0,instructionsLength:0});const l=this._maskHash.get(o);l.instructionsStart=s.instructionSize,u.collectRenderables(s,a,null),u.includeInBuild=!1,a.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const c=s.instructionSize-l.instructionsStart-1;l.instructionsLength=c;const h=a.renderTarget.renderTarget.uid;(n=(i=this._maskStackHash)[h])!=null||(i[h]=0)}pop(t,e,s){const i=t,n=this._renderer;n.renderPipes.batch.break(s),n.renderPipes.blendMode.setBlendMode(i.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});const o=this._maskHash.get(t);for(let a=0;a(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Ms||{});class a2{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class rl{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBuffers")}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gl=this._renderer.gl,this._gpuBuffers=Object.create(null),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(t){return this._gpuBuffers[t.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,s=this.getGlBuffer(t);e.bindBuffer(s.type,s.buffer)}bindBufferBase(t,e){const{_gl:s}=this;this._boundBufferBases[e]!==t&&(this._boundBufferBases[e]=t,t._lastBindBaseLocation=e,s.bindBufferBase(s.UNIFORM_BUFFER,e,t.buffer))}nextBindBase(t){this._bindCallId++,this._minBaseLocation=0,t&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(t){let e=this.getLastBindBaseLocation(t);if(e>=this._minBaseLocation)return t._lastBindCallId=this._bindCallId,e;let s=0,i=this._nextBindBaseIndex;for(;s<2;){i>=this._maxBindings&&(i=this._minBaseLocation,s++);const n=this._boundBufferBases[i];if(n&&n._lastBindCallId===this._bindCallId){i++;continue}break}return e=i,this._nextBindBaseIndex=i+1,s>=2?-1:(t._lastBindCallId=this._bindCallId,this._boundBufferBases[e]=null,e)}getLastBindBaseLocation(t){const e=t._lastBindBaseLocation;return this._boundBufferBases[e]===t?e:-1}bindBufferRange(t,e,s,i){const{_gl:n}=this;s||(s=0),e||(e=0),this._boundBufferBases[e]=null,n.bindBufferRange(n.UNIFORM_BUFFER,e||0,t.buffer,s*256,i||256)}updateBuffer(t){const{_gl:e}=this,s=this.getGlBuffer(t);if(t._updateID===s.updateID)return s;s.updateID=t._updateID,e.bindBuffer(s.type,s.buffer);const i=t.data,n=t.descriptor.usage&$.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return i?s.byteLength>=i.byteLength?e.bufferSubData(s.type,0,i,0,t._updateSize/i.BYTES_PER_ELEMENT):(s.byteLength=i.byteLength,e.bufferData(s.type,i,n)):(s.byteLength=t.descriptor.size,e.bufferData(s.type,s.byteLength,n)),s}destroyAll(){const t=this._gl;for(const e in this._gpuBuffers)t.deleteBuffer(this._gpuBuffers[e].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(t,e){const s=this._gpuBuffers[t.uid],i=this._gl;e||i.deleteBuffer(s.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let s=Ms.ARRAY_BUFFER;t.descriptor.usage&$.INDEX?s=Ms.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&$.UNIFORM&&(s=Ms.UNIFORM_BUFFER);const i=new a2(e.createBuffer(),s);return this._gpuBuffers[t.uid]=i,t.on("destroy",this.onBufferDestroy,this),i}resetState(){this._boundBufferBases=Object.create(null)}}rl.extension={type:[v.WebGLSystem],name:"buffer"};var iC=Object.defineProperty,nC=Object.defineProperties,oC=Object.getOwnPropertyDescriptors,u2=Object.getOwnPropertySymbols,aC=Object.prototype.hasOwnProperty,uC=Object.prototype.propertyIsEnumerable,l2=(r,t,e)=>t in r?iC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xn=(r,t)=>{for(var e in t||(t={}))aC.call(t,e)&&l2(r,e,t[e]);if(u2)for(var e of u2(t))uC.call(t,e)&&l2(r,e,t[e]);return r},c2=(r,t)=>nC(r,oC(t));const sl=class Hy{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(t){var e,s;t=xn(xn({},Hy.defaultOptions),t);let i=this.multiView=t.multiView;if(t.context&&i&&(Lt("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),i=!1),i?this.canvas=I.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{const n=this._renderer.background.alpha<1,o=(e=t.premultipliedAlpha)!=null?e:!0,a=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:n,premultipliedAlpha:o,antialias:a,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:(s=t.powerPreference)!=null?s:"default"})}}ensureCanvasSize(t){if(!this.multiView){t!==this.canvas&&Lt("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:e}=this;(e.width{var e;this.gl.isContextLost()&&((e=this.extensions.loseContext)==null||e.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(t=this.extensions.loseContext)==null||t.loseContext()}forceContextLoss(){var t;(t=this.extensions.loseContext)==null||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&e.stencil;const s=this.supports,i=this.webGLVersion===2,n=this.extensions;s.uint32Indices=i||!!n.uint32ElementIndex,s.uniformBufferObject=i,s.vertexArrayObject=i||!!n.vertexArrayObject,s.srgbTextures=i||!!n.srgb,s.nonPowOf2wrapping=i,s.nonPowOf2mipmaps=i,s.msaa=i,s.uint32Indices}};sl.extension={type:[v.WebGLSystem],name:"context"},sl.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let h2=sl;function il(r,t){var e,s,i;for(const n in r.attributes){const o=r.attributes[n],a=t[n];a?((e=o.format)!=null||(o.format=a.format),(s=o.offset)!=null||(o.offset=a.offset),(i=o.instance)!=null||(o.instance=a.instance)):Lt(`Attribute ${n} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}lC(r)}function lC(r){var t,e;const{buffers:s,attributes:i}=r,n={},o={};for(const a in s){const u=s[a];n[u.uid]=0,o[u.uid]=0}for(const a in i){const u=i[a];n[u.buffer.uid]+=ue(u.format).stride}for(const a in i){const u=i[a];(t=u.stride)!=null||(u.stride=n[u.buffer.uid]),(e=u.start)!=null||(u.start=o[u.buffer.uid]),o[u.buffer.uid]+=ue(u.format).stride}}var bn=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(bn||{}),nl=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(nl||{}),d2=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(d2||{}),H=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(H||{});const p2={uint8x2:H.UNSIGNED_BYTE,uint8x4:H.UNSIGNED_BYTE,sint8x2:H.BYTE,sint8x4:H.BYTE,unorm8x2:H.UNSIGNED_BYTE,unorm8x4:H.UNSIGNED_BYTE,snorm8x2:H.BYTE,snorm8x4:H.BYTE,uint16x2:H.UNSIGNED_SHORT,uint16x4:H.UNSIGNED_SHORT,sint16x2:H.SHORT,sint16x4:H.SHORT,unorm16x2:H.UNSIGNED_SHORT,unorm16x4:H.UNSIGNED_SHORT,snorm16x2:H.SHORT,snorm16x4:H.SHORT,float16x2:H.HALF_FLOAT,float16x4:H.HALF_FLOAT,float32:H.FLOAT,float32x2:H.FLOAT,float32x3:H.FLOAT,float32x4:H.FLOAT,uint32:H.UNSIGNED_INT,uint32x2:H.UNSIGNED_INT,uint32x3:H.UNSIGNED_INT,uint32x4:H.UNSIGNED_INT,sint32:H.INT,sint32x2:H.INT,sint32x3:H.INT,sint32x4:H.INT};function f2(r){var t;return(t=p2[r])!=null?t:p2.float32}const cC={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class ol{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._renderer.renderableGC.addManagedHash(this,"_geometryVaoHash")}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=i=>e.bindVertexArrayOES(i),t.deleteVertexArray=i=>e.deleteVertexArrayOES(i));const s=this._renderer.context.extensions.vertexAttribDivisorANGLE;s&&(t.drawArraysInstanced=(i,n,o,a)=>{s.drawArraysInstancedANGLE(i,n,o,a)},t.drawElementsInstanced=(i,n,o,a,u)=>{s.drawElementsInstancedANGLE(i,n,o,a,u)},t.vertexAttribDivisor=(i,n)=>s.vertexAttribDivisorANGLE(i,n)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(t,e){const s=this.gl;this._activeGeometry=t;const i=this.getVao(t,e);this._activeVao!==i&&(this._activeVao=i,s.bindVertexArray(i)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let s=0;s1?n.drawElementsInstanced(a,e||o.indexBuffer.data.length,l,(s||0)*u,i):n.drawElements(a,e||o.indexBuffer.data.length,l,(s||0)*u)}else i>1?n.drawArraysInstanced(a,s||0,e||o.getSize(),i):n.drawArrays(a,s||0,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ol.extension={type:[v.WebGLSystem],name:"geometry"};var hC=Object.defineProperty,m2=Object.getOwnPropertySymbols,dC=Object.prototype.hasOwnProperty,pC=Object.prototype.propertyIsEnumerable,g2=(r,t,e)=>t in r?hC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_2=(r,t)=>{for(var e in t||(t={}))dC.call(t,e)&&g2(r,e,t[e]);if(m2)for(var e of m2(t))pC.call(t,e)&&g2(r,e,t[e]);return r};const fC=new Fe({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),al=class jy{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:s}=_2(_2({},jy.defaultOptions),t);this.useBackBuffer=e,this._antialias=s,this._renderer.context.supports.msaa||(Lt("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Mt.for2d();const i=new Dt({vertex:` attribute vec2 aPosition; out vec2 vUv; void main() { gl_Position = vec4(aPosition, 0.0, 1.0); vUv = (aPosition + 1.0) / 2.0; // flip dem UVs vUv.y = 1.0 - vUv.y; }`,fragment:` in vec2 vUv; out vec4 finalColor; uniform sampler2D uTexture; void main() { finalColor = texture(uTexture, vUv); }`,name:"big-triangle"});this._bigTriangleShader=new Ft({glProgram:i,resources:{uTexture:C.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const s=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=s.colorTexture,t.target=this._getBackBufferTexture(s.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:fC,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new C({source:new K({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};al.extension={type:[v.WebGLSystem],name:"backBuffer",priority:1},al.defaultOptions={useBackBuffer:!1};let x2=al;class ul{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(t&8),!!(t&4),!!(t&2),!!(t&1)))}}ul.extension={type:[v.WebGLSystem],name:"colorMask"};class ll{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:s,shader:i,state:n,skipSync:o,topology:a,size:u,start:l,instanceCount:c}=t;e.shader.bind(i,o),e.geometry.bind(s,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,u,l,c!=null?c:s.instanceCount)}destroy(){this._renderer=null}}ll.extension={type:[v.WebGLSystem],name:"encoder"};class cl{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=Xo(this.maxTextures,t),this.maxUniformBindings=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS)}destroy(){}}cl.extension={type:[v.WebGLSystem],name:"limits"};class b2{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const de=[];de[J.NONE]=void 0,de[J.DISABLED]={stencilWriteMask:0,stencilReadMask:0},de[J.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},de[J.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},de[J.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},de[J.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class hl{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:J.NONE},this._renderTargetStencilState=Object.create(null),t.renderTarget.onRenderTargetChange.add(this)}contextChange(t){this._gl=t,this._comparisonFuncMapping={always:t.ALWAYS,never:t.NEVER,equal:t.EQUAL,"not-equal":t.NOTEQUAL,less:t.LESS,"less-equal":t.LEQUAL,greater:t.GREATER,"greater-equal":t.GEQUAL},this._stencilOpsMapping={keep:t.KEEP,zero:t.ZERO,replace:t.REPLACE,invert:t.INVERT,"increment-clamp":t.INCR,"decrement-clamp":t.DECR,"increment-wrap":t.INCR_WRAP,"decrement-wrap":t.DECR_WRAP},this.resetState()}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:J.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=J.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const s=this._renderTargetStencilState[this._activeRenderTarget.uid],i=this._gl,n=de[t],o=this._stencilCache;if(s.stencilMode=t,s.stencilReference=e,t===J.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,i.disable(i.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,i.enable(i.STENCIL_TEST)),(t!==o.stencilMode||o.stencilReference!==e)&&(o.stencilMode=t,o.stencilReference=e,i.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),i.stencilOp(i.KEEP,i.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}}hl.extension={type:[v.WebGLSystem],name:"stencil"};class dl{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!cu())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const e=this.getUniformGroupData(t);t.buffer||(t.buffer=new vt({data:new Float32Array(e.layout.size/4),usage:$.UNIFORM|$.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let s=this._syncFunctionHash[e];if(!s){const i=Object.keys(t.uniformStructures).map(a=>t.uniformStructures[a]),n=this._adaptor.createUboElements(i),o=this._generateUboSync(n.uboElements);s=this._syncFunctionHash[e]={layout:n,syncFunction:o}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,s){const i=this.getUniformGroupData(t);t.buffer||(t.buffer=new vt({data:new Float32Array(i.layout.size/4),usage:$.UNIFORM|$.COPY_DST}));let n=null;return e||(e=t.buffer.data,n=t.buffer.dataInt32),s||(s=0),i.syncFunction(t.uniforms,e,n,s),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}const pl={f32:4,i32:4,"vec2":8,"vec3":12,"vec4":16,"vec2":8,"vec3":12,"vec4":16,"mat2x2":32,"mat3x3":48,"mat4x4":64};function y2(r){const t=r.map(n=>({data:n,offset:0,size:0})),e=16;let s=0,i=0;for(let n=0;n1&&(s=Math.max(s,e)*o.data.size);const a=s===12?16:s;o.size=s;const u=i%e;u>0&&e-u",test:r=>r.value.a!==void 0,ubo:` var matrix = uv[name].toArray(true); data[offset] = matrix[0]; data[offset + 1] = matrix[1]; data[offset + 2] = matrix[2]; data[offset + 4] = matrix[3]; data[offset + 5] = matrix[4]; data[offset + 6] = matrix[5]; data[offset + 8] = matrix[6]; data[offset + 9] = matrix[7]; data[offset + 10] = matrix[8]; `,uniform:` gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true)); `},{type:"vec4",test:r=>r.type==="vec4"&&r.size===1&&r.value.width!==void 0,ubo:` v = uv[name]; data[offset] = v.x; data[offset + 1] = v.y; data[offset + 2] = v.width; data[offset + 3] = v.height; `,uniform:` cv = ud[name].value; v = uv[name]; if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) { cv[0] = v.x; cv[1] = v.y; cv[2] = v.width; cv[3] = v.height; gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height); } `},{type:"vec2",test:r=>r.type==="vec2"&&r.size===1&&r.value.x!==void 0,ubo:` v = uv[name]; data[offset] = v.x; data[offset + 1] = v.y; `,uniform:` cv = ud[name].value; v = uv[name]; if (cv[0] !== v.x || cv[1] !== v.y) { cv[0] = v.x; cv[1] = v.y; gl.uniform2f(ud[name].location, v.x, v.y); } `},{type:"vec4",test:r=>r.type==="vec4"&&r.size===1&&r.value.red!==void 0,ubo:` v = uv[name]; data[offset] = v.red; data[offset + 1] = v.green; data[offset + 2] = v.blue; data[offset + 3] = v.alpha; `,uniform:` cv = ud[name].value; v = uv[name]; if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) { cv[0] = v.red; cv[1] = v.green; cv[2] = v.blue; cv[3] = v.alpha; gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha); } `},{type:"vec3",test:r=>r.type==="vec3"&&r.size===1&&r.value.red!==void 0,ubo:` v = uv[name]; data[offset] = v.red; data[offset + 1] = v.green; data[offset + 2] = v.blue; `,uniform:` cv = ud[name].value; v = uv[name]; if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) { cv[0] = v.red; cv[1] = v.green; cv[2] = v.blue; gl.uniform3f(ud[name].location, v.red, v.green, v.blue); } `}];function fl(r,t,e,s){const i=[` var v = null; var v2 = null; var t = 0; var index = 0; var name = null; var arrayOffset = null; `];let n=0;for(let a=0;a1)h=u.offset/4,i.push(e(u,h-n));else{const d=s[u.data.type];h=u.offset/4,i.push(` v = uv.${l}; offset += ${h-n}; ${d}; `)}n=h}const o=i.join(` `);return new Function("uv","data","dataInt32","offset",o)}var mC=Object.defineProperty,gC=Object.defineProperties,_C=Object.getOwnPropertyDescriptors,v2=Object.getOwnPropertySymbols,xC=Object.prototype.hasOwnProperty,bC=Object.prototype.propertyIsEnumerable,T2=(r,t,e)=>t in r?mC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yC=(r,t)=>{for(var e in t||(t={}))xC.call(t,e)&&T2(r,e,t[e]);if(v2)for(var e of v2(t))bC.call(t,e)&&T2(r,e,t[e]);return r},vC=(r,t)=>gC(r,_C(t));function wr(r,t){return` for (let i = 0; i < ${r*t}; i++) { data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i]; } `}const ml={f32:` data[offset] = v;`,i32:` dataInt32[offset] = v;`,"vec2":` data[offset] = v[0]; data[offset + 1] = v[1];`,"vec3":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2];`,"vec4":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2]; data[offset + 3] = v[3];`,"vec2":` dataInt32[offset] = v[0]; dataInt32[offset + 1] = v[1];`,"vec3":` dataInt32[offset] = v[0]; dataInt32[offset + 1] = v[1]; dataInt32[offset + 2] = v[2];`,"vec4":` dataInt32[offset] = v[0]; dataInt32[offset + 1] = v[1]; dataInt32[offset + 2] = v[2]; dataInt32[offset + 3] = v[3];`,"mat2x2":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 4] = v[2]; data[offset + 5] = v[3];`,"mat3x3":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2]; data[offset + 4] = v[3]; data[offset + 5] = v[4]; data[offset + 6] = v[5]; data[offset + 8] = v[6]; data[offset + 9] = v[7]; data[offset + 10] = v[8];`,"mat4x4":` for (let i = 0; i < 16; i++) { data[offset + i] = v[i]; }`,"mat3x2":wr(3,2),"mat4x2":wr(4,2),"mat2x3":wr(2,3),"mat4x3":wr(4,3),"mat2x4":wr(2,4),"mat3x4":wr(3,4)},A2=vC(yC({},ml),{"mat2x2":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2]; data[offset + 3] = v[3]; `});function S2(r,t){const e=Math.max(pl[r.data.type]/16,1),s=r.data.value.length/r.data.size,i=(4-s%4)%4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return` v = uv.${r.data.name}; offset += ${t}; arrayOffset = offset; t = 0; for(var i=0; i < ${r.data.size*e}; i++) { for(var j = 0; j < ${s}; j++) { ${n}[arrayOffset++] = v[t++]; } ${i!==0?`arrayOffset += ${i};`:""} } `}function E2(r){return fl(r,"uboStd40",S2,ml)}class gl extends dl{constructor(){super({createUboElements:y2,generateUboSync:E2})}}gl.extension={type:[v.WebGLSystem],name:"ubo"};class w2{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new j}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new j}copyToTexture(t,e,s,i,n){const o=this._renderTargetSystem,a=this._renderer,u=o.getGpuRenderTarget(t),l=a.gl;return this.finishRenderPass(t),l.bindFramebuffer(l.FRAMEBUFFER,u.resolveTargetFramebuffer),a.texture.bind(e,0),l.copyTexSubImage2D(l.TEXTURE_2D,0,n.x,n.y,s.x,s.y,i.width,i.height),e}startRenderPass(t,e=!0,s,i){const n=this._renderTargetSystem,o=t.colorTexture,a=n.getGpuRenderTarget(t);let u=i.y;t.isRoot&&(u=o.pixelHeight-i.height),t.colorTextures.forEach(h=>{this._renderer.texture.unbind(h)});const l=this._renderer.gl;l.bindFramebuffer(l.FRAMEBUFFER,a.framebuffer);const c=this._viewPortCache;(c.x!==i.x||c.y!==u||c.width!==i.width||c.height!==i.height)&&(c.x=i.x,c.y=u,c.width=i.width,c.height=i.height,l.viewport(i.x,u,i.width,i.height)),!a.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(a),this.clear(t,e,s)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;const s=this._renderer.gl;s.bindFramebuffer(s.FRAMEBUFFER,e.resolveTargetFramebuffer),s.bindFramebuffer(s.READ_FRAMEBUFFER,e.framebuffer),s.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,s.COLOR_BUFFER_BIT,s.NEAREST),s.bindFramebuffer(s.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){const e=this._renderer.gl,s=new b2;return t.colorTexture instanceof Kt?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),s.framebuffer=null,s):(this._initColor(t,s),e.bindFramebuffer(e.FRAMEBUFFER,null),s)}destroyGpuRenderTarget(t){const e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(s=>{e.deleteRenderbuffer(s)}),t.msaaRenderBuffer=null}clear(t,e,s){if(!e)return;const i=this._renderTargetSystem;typeof e=="boolean"&&(e=e?At.ALL:At.NONE);const n=this._renderer.gl;if(e&At.COLOR){s!=null||(s=i.defaultClearColor);const o=this._clearColorCache,a=s;(o[0]!==a[0]||o[1]!==a[1]||o[2]!==a[2]||o[3]!==a[3])&&(o[0]=a[0],o[1]=a[1],o[2]=a[2],o[3]=a[3],n.clearColor(a[0],a[1],a[2],a[3]))}n.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const s=this._renderer,i=s.gl,n=i.createFramebuffer();if(e.resolveTargetFramebuffer=n,i.bindFramebuffer(i.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((o,a)=>{const u=o.source;u.antialias&&(s.context.supports.msaa?e.msaa=!0:Lt("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),s.texture.bindSource(u,0);const l=s.texture.getGlSource(u).texture;i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+a,3553,l,0)}),e.msaa){const o=i.createFramebuffer();e.framebuffer=o,i.bindFramebuffer(i.FRAMEBUFFER,o),t.colorTextures.forEach((a,u)=>{const l=i.createRenderbuffer();e.msaaRenderBuffer[u]=l})}else e.framebuffer=n;this._resizeColor(t,e)}_resizeColor(t,e){const s=t.colorTexture.source;if(e.width=s.pixelWidth,e.height=s.pixelHeight,t.colorTextures.forEach((i,n)=>{n!==0&&i.source.resize(s.width,s.height,s._resolution)}),e.msaa){const i=this._renderer,n=i.gl,o=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,o),t.colorTextures.forEach((a,u)=>{const l=a.source;i.texture.bindSource(l,0);const c=i.texture.getGlSource(l).internalFormat,h=e.msaaRenderBuffer[u];n.bindRenderbuffer(n.RENDERBUFFER,h),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,c,l.pixelWidth,l.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+u,n.RENDERBUFFER,h)})}}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,s=e.createRenderbuffer();t.depthStencilRenderBuffer=s,e.bindRenderbuffer(e.RENDERBUFFER,s),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,s),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,this._renderer.context.webGLVersion===2?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){const e=t.colorTexture.resource;this._renderer.context.multiView&&Kt.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&Kt.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,s=t.colorTexture;s.context2D.drawImage(e,0,s.pixelHeight-e.height)}}}function C2(r,t,e,s,i,n){const o=n?1:-1;return r.identity(),r.a=1/s*2,r.d=o*(1/i*2),r.tx=-1-t*r.a,r.ty=-o-e*r.d,r}var TC=Object.defineProperty,R2=Object.getOwnPropertySymbols,AC=Object.prototype.hasOwnProperty,SC=Object.prototype.propertyIsEnumerable,P2=(r,t,e)=>t in r?TC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,EC=(r,t)=>{for(var e in t||(t={}))AC.call(t,e)&&P2(r,e,t[e]);if(R2)for(var e of R2(t))SC.call(t,e)&&P2(r,e,t[e]);return r};const Cr=new Map;function _l(r,t){if(!Cr.has(r)){const e=new C({source:new Kt(EC({resource:r},t))}),s=()=>{Cr.get(r)===e&&Cr.delete(r)};e.once("destroy",s),e.source.once("destroy",s),Cr.set(r,e)}return Cr.get(r)}function wC(r){return Cr.has(r)}function D2(r){const t=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var CC=Object.defineProperty,M2=Object.getOwnPropertySymbols,RC=Object.prototype.hasOwnProperty,PC=Object.prototype.propertyIsEnumerable,O2=(r,t,e)=>t in r?CC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,B2=(r,t)=>{for(var e in t||(t={}))RC.call(t,e)&&O2(r,e,t[e]);if(M2)for(var e of M2(t))PC.call(t,e)&&O2(r,e,t[e]);return r};const G2=class zy{constructor(t={}){if(this.uid=Y("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t=B2(B2({},zy.defaultOptions),t),this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures=="number"){this._managedColorTextures=!0;for(let e=0;es.source)];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof C||t.depthStencilTexture instanceof K?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new K({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,s=this.resolution,i=!1){this.dirtyId++,this.colorTextures.forEach((n,o)=>{i&&o===0||n.source.resize(t,e,s)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,s)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};G2.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let yn=G2;class xl{constructor(t){this.rootViewPort=new j,this.viewport=new j,this.onRenderTargetChange=new hu("onRenderTargetChange"),this.projectionMatrix=new M,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuRenderTargetHash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:s,frame:i}){var n,o;this._renderTargetStack.length=0,this.push(t,e,s,i),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=D2(this.rootRenderTarget),(o=(n=this.adaptor).prerender)==null||o.call(n,this.rootRenderTarget)}postrender(){var t,e;(e=(t=this.adaptor).postrender)==null||e.call(t,this.rootRenderTarget)}bind(t,e=!0,s,i){const n=this.getRenderTarget(t),o=this.renderTarget!==n;this.renderTarget=n,this.renderSurface=t;const a=this.getGpuRenderTarget(n);(n.pixelWidth!==a.width||n.pixelHeight!==a.height)&&(this.adaptor.resizeGpuRenderTarget(n),a.width=n.pixelWidth,a.height=n.pixelHeight);const u=n.colorTexture,l=this.viewport,c=u.pixelWidth,h=u.pixelHeight;if(!i&&t instanceof C&&(i=t.frame),i){const d=u._resolution;l.x=i.x*d+.5|0,l.y=i.y*d+.5|0,l.width=i.width*d+.5|0,l.height=i.height*d+.5|0}else l.x=0,l.y=0,l.width=c,l.height=h;return C2(this.projectionMatrix,0,0,l.width/u.resolution,l.height/u.resolution,!n.isRoot),this.adaptor.startRenderPass(n,e,s,l),o&&this.onRenderTargetChange.emit(n),n}clear(t,e=At.ALL,s){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,s,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=At.ALL,s,i){const n=this.bind(t,e,s,i);return this._renderTargetStack.push({renderTarget:n,frame:i}),n}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){var e;return t.isTexture&&(t=t.source),(e=this._renderSurfaceToRenderTargetHash.get(t))!=null?e:this._initRenderTarget(t)}copyToTexture(t,e,s,i,n){s.x<0&&(i.width+=s.x,n.x-=s.x,s.x=0),s.y<0&&(i.height+=s.y,n.y-=s.y,s.y=0);const{pixelWidth:o,pixelHeight:a}=t;return i.width=Math.min(i.width,o-s.x),i.height=Math.min(i.height,a-s.y),this.adaptor.copyToTexture(t,e,s,i,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return Kt.test(t)&&(t=_l(t).source),t instanceof yn?e=t:t instanceof K&&(e=new yn({colorTextures:[t]}),t.source instanceof Kt&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);const s=this._gpuRenderTargetHash[e.uid];s&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(s))})),this._renderSurfaceToRenderTargetHash.set(t,e),e}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}resetState(){this.renderTarget=null,this.renderSurface=null}}class bl extends xl{constructor(t){super(t),this.adaptor=new w2,this.adaptor.init(t,this)}}bl.extension={type:[v.WebGLSystem],name:"renderTarget"};class vn extends Rt{constructor({buffer:t,offset:e,size:s}){super(),this.uid=Y("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=Y("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=s,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=Y("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}function F2(r,t){const e=[],s=[` var g = s.groups; var sS = r.shader; var p = s.glProgram; var ugS = r.uniformGroup; var resources; `];let i=!1,n=0;const o=t._getProgramData(r.glProgram);for(const u in r.groups){const l=r.groups[u];e.push(` resources = g[${u}].resources; `);for(const c in l.resources){const h=l.resources[c];if(h instanceof it)if(h.ubo){const d=r._uniformBindMap[u][Number(c)];e.push(` sS.bindUniformBlock( resources[${c}], '${d}', ${r.glProgram._uniformBlockData[d].index} ); `)}else e.push(` ugS.updateUniformGroup(resources[${c}], p, sD); `);else if(h instanceof vn){const d=r._uniformBindMap[u][Number(c)];e.push(` sS.bindUniformBlock( resources[${c}], '${d}', ${r.glProgram._uniformBlockData[d].index} ); `)}else if(h instanceof K){const d=r._uniformBindMap[u][c],p=o.uniformData[d];p&&(i||(i=!0,s.push(` var tS = r.texture; `)),t._gl.uniform1i(p.location,n),e.push(` tS.bind(resources[${c}], ${n}); `),n++)}}}const a=[...s,...e].join(` `);return new Function("r","s","sD",a)}class DC{}class I2{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function yl(r,t,e){const s=r.createShader(t);return r.shaderSource(s,e),r.compileShader(s),s}function vl(r){const t=new Array(r);for(let e=0;eo>a?1:-1);for(let o=0;o`${c}: ${l}`),s=r.getShaderInfoLog(t),i=s.split(` `),n={},o=i.map(l=>parseFloat(l.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(l=>l&&!n[l]?(n[l]=!0,!0):!1),a=[""];o.forEach(l=>{e[l-1]=`%c${e[l-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const u=e.join(` `);a[0]=u,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function H2(r,t,e,s){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||X2(r,e),r.getShaderParameter(s,r.COMPILE_STATUS)||X2(r,s),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function j2(r,t){const e=yl(r,r.VERTEX_SHADER,t.vertex),s=yl(r,r.FRAGMENT_SHADER,t.fragment),i=r.createProgram();r.attachShader(i,e),r.attachShader(i,s);const n=t.transformFeedbackVaryings;n&&(typeof r.transformFeedbackVaryings!="function"||r.transformFeedbackVaryings(i,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(i),r.getProgramParameter(i,r.LINK_STATUS)||H2(r,i,e,s),t._attributeData=L2(i,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=$2(i,r),t._uniformBlockData=N2(i,r),r.deleteShader(e),r.deleteShader(s);const o={};for(const a in t._uniformData){const u=t._uniformData[a];o[a]={location:r.getUniformLocation(i,a),value:Tl(u.type,u.size)}}return new I2(i,o)}const An={textureCount:0,blockIndex:0};class Sl{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_programDataHash")}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;An.textureCount=0,An.blockIndex=0;let s=this._shaderSyncFunctions[t.glProgram._key];s||(s=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),s(this._renderer,t,An)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,An)}bindUniformBlock(t,e,s=0){const i=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource;o||this._renderer.ubo.updateUniformGroup(t);const a=t.buffer,u=i.updateBuffer(a),l=i.freeLocationForBufferBase(u);if(o){const{offset:h,size:d}=t;h===0&&d===a.data.byteLength?i.bindBufferBase(u,l):i.bindBufferRange(u,l,h)}else i.getLastBindBaseLocation(u)!==l&&i.bindBufferBase(u,l);const c=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[s]!==l&&(n.uniformBlockBindings[s]=l,this._renderer.gl.uniformBlockBinding(n.program,c,l))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;const e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){const e=t._key;return this._programDataHash[e]=j2(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy(),this._programDataHash[t]=null;this._programDataHash=null}_generateShaderSync(t,e){return F2(t,e)}resetState(){this._activeProgram=null}}Sl.extension={type:[v.WebGLSystem],name:"shader"};const z2={f32:`if (cv !== v) { cu.value = v; gl.uniform1f(location, v); }`,"vec2":`if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2f(location, v[0], v[1]); }`,"vec3":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3f(location, v[0], v[1], v[2]); }`,"vec4":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4f(location, v[0], v[1], v[2], v[3]); }`,i32:`if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`,"vec2":`if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2i(location, v[0], v[1]); }`,"vec3":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3i(location, v[0], v[1], v[2]); }`,"vec4":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4i(location, v[0], v[1], v[2], v[3]); }`,u32:`if (cv !== v) { cu.value = v; gl.uniform1ui(location, v); }`,"vec2":`if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2ui(location, v[0], v[1]); }`,"vec3":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3ui(location, v[0], v[1], v[2]); }`,"vec4":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4ui(location, v[0], v[1], v[2], v[3]); }`,bool:`if (cv !== v) { cu.value = v; gl.uniform1i(location, v); }`,"vec2":`if (cv[0] !== v[0] || cv[1] !== v[1]) { cv[0] = v[0]; cv[1] = v[1]; gl.uniform2i(location, v[0], v[1]); }`,"vec3":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; gl.uniform3i(location, v[0], v[1], v[2]); }`,"vec4":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) { cv[0] = v[0]; cv[1] = v[1]; cv[2] = v[2]; cv[3] = v[3]; gl.uniform4i(location, v[0], v[1], v[2], v[3]); }`,"mat2x2":"gl.uniformMatrix2fv(location, false, v);","mat3x3":"gl.uniformMatrix3fv(location, false, v);","mat4x4":"gl.uniformMatrix4fv(location, false, v);"},V2={f32:"gl.uniform1fv(location, v);","vec2":"gl.uniform2fv(location, v);","vec3":"gl.uniform3fv(location, v);","vec4":"gl.uniform4fv(location, v);","mat2x2":"gl.uniformMatrix2fv(location, false, v);","mat3x3":"gl.uniformMatrix3fv(location, false, v);","mat4x4":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);"};function W2(r,t){const e=[` var v = null; var cv = null; var cu = null; var t = 0; var gl = renderer.gl; var name = null; `];for(const s in r.uniforms){if(!t[s]){r.uniforms[s]instanceof it?r.uniforms[s].ubo?e.push(` renderer.shader.bindUniformBlock(uv.${s}, "${s}"); `):e.push(` renderer.shader.updateUniformGroup(uv.${s}); `):r.uniforms[s]instanceof vn&&e.push(` renderer.shader.bindBufferResource(uv.${s}, "${s}"); `);continue}const i=r.uniformStructures[s];let n=!1;for(let o=0;o>=1,s++;this.stateId=t.data}for(let e=0;e>1,1),i=Math.max(i>>1,1)}}},wl={id:"image",upload(r,t,e,s){const i=t.width,n=t.height,o=r.pixelWidth,a=r.pixelHeight,u=r.resourceWidth,l=r.resourceHeight;u1){const l=Math.min(r.maxAnisotropy,t.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[i](u,s.TEXTURE_MAX_ANISOTROPY_EXT,l)}r.compare&&t[i](u,t.TEXTURE_COMPARE_FUNC,rx[r.compare])}function sx(r){return{r8unorm:r.RED,r8snorm:r.RED,r8uint:r.RED,r8sint:r.RED,r16uint:r.RED,r16sint:r.RED,r16float:r.RED,rg8unorm:r.RG,rg8snorm:r.RG,rg8uint:r.RG,rg8sint:r.RG,r32uint:r.RED,r32sint:r.RED,r32float:r.RED,rg16uint:r.RG,rg16sint:r.RG,rg16float:r.RG,rgba8unorm:r.RGBA,"rgba8unorm-srgb":r.RGBA,rgba8snorm:r.RGBA,rgba8uint:r.RGBA,rgba8sint:r.RGBA,bgra8unorm:r.RGBA,"bgra8unorm-srgb":r.RGBA,rgb9e5ufloat:r.RGB,rgb10a2unorm:r.RGBA,rg11b10ufloat:r.RGB,rg32uint:r.RG,rg32sint:r.RG,rg32float:r.RG,rgba16uint:r.RGBA,rgba16sint:r.RGBA,rgba16float:r.RGBA,rgba32uint:r.RGBA,rgba32sint:r.RGBA,rgba32float:r.RGBA,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT,depth24plus:r.DEPTH_COMPONENT,"depth24plus-stencil8":r.DEPTH_STENCIL,depth32float:r.DEPTH_COMPONENT,"depth32float-stencil8":r.DEPTH_STENCIL}}var XC=Object.defineProperty,HC=Object.defineProperties,jC=Object.getOwnPropertyDescriptors,ix=Object.getOwnPropertySymbols,zC=Object.prototype.hasOwnProperty,VC=Object.prototype.propertyIsEnumerable,nx=(r,t,e)=>t in r?XC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,He=(r,t)=>{for(var e in t||(t={}))zC.call(t,e)&&nx(r,e,t[e]);if(ix)for(var e of ix(t))VC.call(t,e)&&nx(r,e,t[e]);return r},WC=(r,t)=>HC(r,jC(t));function ox(r,t){let e={},s=r.RGBA;return r instanceof I.get().getWebGLRenderingContext()?t.srgb&&(e={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(e={"rgba8unorm-srgb":r.SRGB8_ALPHA8,"bgra8unorm-srgb":r.SRGB8_ALPHA8},s=r.RGBA8),He(He(He(He(He(He(WC(He({r8unorm:r.R8,r8snorm:r.R8_SNORM,r8uint:r.R8UI,r8sint:r.R8I,r16uint:r.R16UI,r16sint:r.R16I,r16float:r.R16F,rg8unorm:r.RG8,rg8snorm:r.RG8_SNORM,rg8uint:r.RG8UI,rg8sint:r.RG8I,r32uint:r.R32UI,r32sint:r.R32I,r32float:r.R32F,rg16uint:r.RG16UI,rg16sint:r.RG16I,rg16float:r.RG16F,rgba8unorm:r.RGBA},e),{rgba8snorm:r.RGBA8_SNORM,rgba8uint:r.RGBA8UI,rgba8sint:r.RGBA8I,bgra8unorm:s,rgb9e5ufloat:r.RGB9_E5,rgb10a2unorm:r.RGB10_A2,rg11b10ufloat:r.R11F_G11F_B10F,rg32uint:r.RG32UI,rg32sint:r.RG32I,rg32float:r.RG32F,rgba16uint:r.RGBA16UI,rgba16sint:r.RGBA16I,rgba16float:r.RGBA16F,rgba32uint:r.RGBA32UI,rgba32sint:r.RGBA32I,rgba32float:r.RGBA32F,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT16,depth24plus:r.DEPTH_COMPONENT24,"depth24plus-stencil8":r.DEPTH24_STENCIL8,depth32float:r.DEPTH_COMPONENT32F,"depth32float-stencil8":r.DEPTH32F_STENCIL8}),t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{}),t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{}),t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{}),t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{}),t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{}),t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{})}function ax(r){return{r8unorm:r.UNSIGNED_BYTE,r8snorm:r.BYTE,r8uint:r.UNSIGNED_BYTE,r8sint:r.BYTE,r16uint:r.UNSIGNED_SHORT,r16sint:r.SHORT,r16float:r.HALF_FLOAT,rg8unorm:r.UNSIGNED_BYTE,rg8snorm:r.BYTE,rg8uint:r.UNSIGNED_BYTE,rg8sint:r.BYTE,r32uint:r.UNSIGNED_INT,r32sint:r.INT,r32float:r.FLOAT,rg16uint:r.UNSIGNED_SHORT,rg16sint:r.SHORT,rg16float:r.HALF_FLOAT,rgba8unorm:r.UNSIGNED_BYTE,"rgba8unorm-srgb":r.UNSIGNED_BYTE,rgba8snorm:r.BYTE,rgba8uint:r.UNSIGNED_BYTE,rgba8sint:r.BYTE,bgra8unorm:r.UNSIGNED_BYTE,"bgra8unorm-srgb":r.UNSIGNED_BYTE,rgb9e5ufloat:r.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:r.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:r.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:r.UNSIGNED_INT,rg32sint:r.INT,rg32float:r.FLOAT,rgba16uint:r.UNSIGNED_SHORT,rgba16sint:r.SHORT,rgba16float:r.HALF_FLOAT,rgba32uint:r.UNSIGNED_INT,rgba32sint:r.INT,rgba32float:r.FLOAT,stencil8:r.UNSIGNED_BYTE,depth16unorm:r.UNSIGNED_SHORT,depth24plus:r.UNSIGNED_INT,"depth24plus-stencil8":r.UNSIGNED_INT_24_8,depth32float:r.FLOAT,"depth32float-stencil8":r.FLOAT_32_UNSIGNED_INT_24_8_REV}}function YC(r){r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));const t=r.length;for(let e=0;e1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",s.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t){const e=this._glTextures[t.uid];e&&(this.unbind(t),this._glTextures[t.uid]=null,this._gl.deleteTexture(e.texture))}onSourceUpdate(t){const e=this._gl,s=this.getGlSource(t);e.bindTexture(e.TEXTURE_2D,s.texture),this._boundTextures[this._activeTextureLocation]=t;const i=t.alphaMode==="premultiply-alpha-on-upload";this._premultiplyAlpha!==i&&(this._premultiplyAlpha=i,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i)),this._uploads[t.uploadMethodId]?this._uploads[t.uploadMethodId].upload(t,s,e,this._renderer.context.webGLVersion):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t.pixelWidth,t.pixelHeight,0,e.RGBA,e.UNSIGNED_BYTE,null),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const s=this.getGlSource(t);this._gl.generateMipmap(s.target)}onSourceDestroy(t){t.off("destroy",this.onSourceDestroy,this),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}_initSampler(t){const e=this._gl,s=this._gl.createSampler();return this._glSamplers[t._resourceId]=s,Rl(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",s,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return this._glTextures[t.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:s,height:i}=this.getPixels(t),n=I.get().createCanvas();n.width=s,n.height=i;const o=n.getContext("2d");if(o){const a=o.createImageData(s,i);a.data.set(e),o.putImageData(a,0,0)}return n}getPixels(t){const e=t.source.resolution,s=t.frame,i=Math.max(Math.round(s.width*e),1),n=Math.max(Math.round(s.height*e),1),o=new Uint8Array(qC*i*n),a=this._renderer,u=a.renderTarget.getRenderTarget(t),l=a.renderTarget.getGpuRenderTarget(u),c=a.gl;return c.bindFramebuffer(c.FRAMEBUFFER,l.resolveTargetFramebuffer),c.readPixels(Math.round(s.x*e),Math.round(s.y*e),i,n,c.RGBA,c.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:i,height:n}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(C.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}Pl.extension={type:[v.WebGLSystem],name:"texture"};class Dl{contextChange(t){const e=new it({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new M,type:"mat3x3"},uRound:{value:0,type:"f32"}}),s=t.limits.maxBatchableTextures,i=cr({name:"graphics",bits:[bi,vi(s),$i,dr]});this.shader=new Ft({glProgram:i,resources:{localUniforms:e,batchSamplers:Ti(s)}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:u}=o.getContextRenderData(s);i.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(i),n.geometry.bind(a.geometry,i.glProgram);const l=u.instructions;for(let c=0;c",value:new M}}}})}execute(t,e){const s=t.renderer;let i=e._shader;if(i){if(!i.glProgram)return}else{i=this._shader;const n=e.texture,o=n.source;i.resources.uTexture=o,i.resources.uSampler=o.style,i.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}i.groups[100]=s.globalUniforms.bindGroup,i.groups[101]=t.localUniformsBindGroup,s.encoder.draw({geometry:e._geometry,shader:i,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Ml.extension={type:[v.WebGLPipesAdaptor],name:"mesh"};class Ol{constructor(t){this._renderer=t}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}Ol.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"customRender"};function En(r,t){const e=r.instructionSet,s=e.instructions;for(let i=0;i1?1:e,r.worldAlpha=e,r.worldColorAlpha=r.worldColor+((e*255|0)<<24)}function Fl(r,t,e){if(t===r.updateTick)return;r.updateTick=t,r.didChange=!1;const s=r.localTransform;r.updateLocalTransform();const i=r.parent;if(i&&!i.renderGroup?(e|=r._updateFlags,r.relativeGroupTransform.appendFrom(s,i.relativeGroupTransform),e&ux&&cx(r,i,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(s),e&ux&&cx(r,ZC,e)),!r.renderGroup){const n=r.children,o=n.length;for(let l=0;l1?1:s,r.groupAlpha=s,r.groupColorAlpha=r.groupColor+((s*255|0)<<24)}e&li&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&sr&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function hx(r,t){const{list:e,index:s}=r.childrenRenderablesToUpdate;let i=!1;for(let n=0;n=0;n--)this._updateCachedRenderGroups(t.renderGroupChildren[n],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const n=t.root.getLocalBounds();n.ceil();const o=t.texture;t.texture&&st.returnTexture(t.texture,!0);const a=this._renderer,u=t.textureOptions.resolution||a.view.resolution,l=(s=t.textureOptions.antialias)!=null?s:a.view.antialias,c=(i=t.textureOptions.scaleMode)!=null?i:"linear",h=st.getOptimalTexture(n.width,n.height,u,l);h._source.style=new Pt({scaleMode:c}),t.texture=h,t._textureBounds||(t._textureBounds=new ot),t._textureBounds.copyFrom(n),o!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(st.returnTexture(t.texture,!0),t.texture=null)}_updateRenderGroups(t){const e=this._renderer,s=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=s,t.structureDidChange?wn(t.childrenRenderablesToUpdate.list,0):hx(t,s),Gl(t),t.structureDidChange?(t.structureDidChange=!1,this._buildInstructions(t,e)):this._updateRenderables(t),t.childrenRenderablesToUpdate.index=0,e.renderPipes.batch.upload(t.instructionSet),!(t.isCachedAsTexture&&!t.textureNeedsUpdate))for(let i=0;it in r?JC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fx=(r,t)=>{for(var e in t||(t={}))tR.call(t,e)&&px(r,e,t[e]);if(dx)for(var e of dx(t))eR.call(t,e)&&px(r,e,t[e]);return r};const kl=class Vy{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new X(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=fx(fx({},Vy.defaultOptions),t),this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};kl.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"background",priority:0},kl.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let mx=kl;const Os={};U.handle(v.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");Os[r.name]=r.ref},r=>{delete Os[r.name]});class Ll{constructor(t){this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}setBlendMode(t,e,s){if(this._activeBlendMode===e){this._isAdvanced&&this._renderableList.push(t);return}this._activeBlendMode=e,this._isAdvanced&&this._endAdvancedBlendMode(s),this._isAdvanced=!!Os[e],this._isAdvanced&&(this._beginAdvancedBlendMode(s),this._renderableList.push(t))}_beginAdvancedBlendMode(t){this._renderer.renderPipes.batch.break(t);const e=this._activeBlendMode;if(!Os[e])return;let s=this._filterHash[e];s||(s=this._filterHash[e]=new Qr,s.filters=[new Os[e]]);const i={renderPipeId:"filter",action:"pushFilter",renderables:[],filterEffect:s,canBundle:!1};this._renderableList=i.renderables,t.add(i)}_endAdvancedBlendMode(t){this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}Ll.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"blendMode"};var rR=Object.defineProperty,gx=Object.getOwnPropertySymbols,sR=Object.prototype.hasOwnProperty,iR=Object.prototype.propertyIsEnumerable,_x=(r,t,e)=>t in r?rR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nl=(r,t)=>{for(var e in t||(t={}))sR.call(t,e)&&_x(r,e,t[e]);if(gx)for(var e of gx(t))iR.call(t,e)&&_x(r,e,t[e]);return r};const $l={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Xl=class Wy{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof et||t instanceof C?Nl({target:t},e):Nl(Nl({},e),t)}async image(t){const e=I.get().createImage();return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,Wy.defaultImageOptions);const{format:e,quality:s}=t,i=this.canvas(t);if(i.toBlob!==void 0)return new Promise((n,o)=>{i.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}const u=new FileReader;u.onload=()=>n(u.result),u.onerror=o,u.readAsDataURL(a)},$l[e],s)});if(i.toDataURL!==void 0)return i.toDataURL($l[e],s);if(i.convertToBlob!==void 0){const n=await i.convertToBlob({type:$l[e],quality:s});return new Promise((o,a)=>{const u=new FileReader;u.onload=()=>o(u.result),u.onerror=a,u.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);const e=t.target,s=this._renderer;if(e instanceof C)return s.texture.generateCanvas(e);const i=s.textureGenerator.generateTexture(t),n=s.texture.generateCanvas(i);return i.destroy(!0),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,s=this._renderer,i=e instanceof C?e:s.textureGenerator.generateTexture(t),n=s.texture.getPixels(i);return e instanceof et&&i.destroy(!0),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof C?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var e;t=this._normalizeOptions(t);const s=this.canvas(t),i=document.createElement("a");i.download=(e=t.filename)!=null?e:"image.png",i.href=s.toDataURL("image/png"),document.body.appendChild(i),i.click(),document.body.removeChild(i)}log(t){var e;const s=(e=t.width)!=null?e:200;t=this._normalizeOptions(t);const i=this.canvas(t),n=i.toDataURL();console.log(`[Pixi Texture] ${i.width}px ${i.height}px`);const o=["font-size: 1px;",`padding: ${s}px 300px;`,`background: url(${n}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",o)}destroy(){this._renderer=null}};Xl.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"extract"},Xl.defaultImageOptions={format:"png",quality:1};let xx=Xl;class zn extends C{static create(t){return new zn({source:new K(t)})}resize(t,e,s){return this.source.resize(t,e,s),this}}var nR=Object.defineProperty,oR=Object.defineProperties,aR=Object.getOwnPropertyDescriptors,bx=Object.getOwnPropertySymbols,uR=Object.prototype.hasOwnProperty,lR=Object.prototype.propertyIsEnumerable,yx=(r,t,e)=>t in r?nR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cR=(r,t)=>{for(var e in t||(t={}))uR.call(t,e)&&yx(r,e,t[e]);if(bx)for(var e of bx(t))lR.call(t,e)&&yx(r,e,t[e]);return r},hR=(r,t)=>oR(r,aR(t));const dR=new j,pR=new ot,fR=[0,0,0,0];class Hl{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof et&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const s=t.resolution||this._renderer.resolution,i=t.antialias||this._renderer.view.antialias,n=t.target;let o=t.clearColor;o?o=Array.isArray(o)&&o.length===4?o:X.shared.setValue(o).toArray():o=fR;const a=((e=t.frame)==null?void 0:e.copyTo(dR))||ai(n,pR).rectangle;a.width=Math.max(a.width,1/s)|0,a.height=Math.max(a.height,1/s)|0;const u=zn.create(hR(cR({},t.textureSourceOptions),{width:a.width,height:a.height,resolution:s,antialias:i})),l=M.shared.translate(-a.x,-a.y);return this._renderer.render({container:n,transform:l,target:u,clearColor:o}),u.source.updateMipmaps(),u}destroy(){this._renderer=null}}Hl.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"textureGenerator"};class jl{constructor(t){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=t}reset(){this._stackIndex=0;for(let t=0;t"},uWorldTransformMatrix:{value:new M,type:"mat3x3"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4"},uResolution:{value:[0,0],type:"vec2"}},{isStatic:!0})}destroy(){this._renderer=null}}jl.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"globalUniforms"};let mR=1;class zl{constructor(){this._tasks=[],this._offset=0}init(){ft.system.add(this._update,this)}repeat(t,e,s=!0){const i=mR++;let n=0;return s&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:i}),i}cancel(t){for(let e=0;e=s.duration){const i=t-s.start;s.func(i),s.last=t}}}destroy(){ft.system.remove(this._update,this),this._tasks.length=0}}zl.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"scheduler",priority:0};let vx=!1;function Tx(r){if(!vx){if(I.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${Ts} (${r}) http://www.pixijs.com/ `,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${Ts} - ${r} - http://www.pixijs.com/`);vx=!0}}class Cn{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===Tt.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),Tx(e)}}}Cn.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"hello",priority:-2},Cn.defaultOptions={hello:!1};function Ax(r){let t=!1;for(const s in r)if(r[s]==null){t=!0;break}if(!t)return r;const e=Object.create(null);for(const s in r){const i=r[s];i&&(e[s]=i)}return e}function Sx(r){let t=0;for(let e=0;et in r?gR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cx=(r,t)=>{for(var e in t||(t={}))_R.call(t,e)&&wx(r,e,t[e]);if(Ex)for(var e of Ex(t))xR.call(t,e)&&wx(r,e,t[e]);return r};let bR=0;const Vl=class Yy{constructor(t){this._managedRenderables=[],this._managedHashes=[],this._managedArrays=[],this._renderer=t}init(t){t=Cx(Cx({},Yy.defaultOptions),t),this.maxUnusedTime=t.renderableGCMaxUnusedTime,this._frequency=t.renderableGCFrequency,this.enabled=t.renderableGCActive}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency,!1),this._hashHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedHashes)e.context[e.hash]=Ax(e.context[e.hash])},this._frequency),this._arrayHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedArrays)Sx(e.context[e.hash])},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._hashHandler),this._renderer.scheduler.cancel(this._arrayHandler)))}addManagedHash(t,e){this._managedHashes.push({context:t,hash:e})}addManagedArray(t,e){this._managedArrays.push({context:t,hash:e})}prerender({container:t}){this._now=performance.now(),t.renderGroup.gcTick=bR++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}addRenderable(t){this.enabled&&(t._lastUsed===-1&&(this._managedRenderables.push(t),t.once("destroyed",this._removeRenderable,this)),t._lastUsed=this._now)}run(){var t,e,s,i;const n=this._now,o=this._managedRenderables,a=this._renderer.renderPipes;let u=0;for(let l=0;lthis.maxUnusedTime){if(!c.destroyed){const p=a;h&&(h.structureDidChange=!0),p[c.renderPipeId].destroyRenderable(c)}c._lastUsed=-1,u++,c.off("destroyed",this._removeRenderable,this)}else o[l-u]=c}o.length-=u}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0,this._managedHashes.length=0,this._managedArrays.length=0}_removeRenderable(t){const e=this._managedRenderables.indexOf(t);e>=0&&(t.off("destroyed",this._removeRenderable,this),this._managedRenderables[e]=null)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e;for(const s of t.renderGroupChildren)this._updateInstructionGCTick(s,e)}};Vl.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"renderableGC",priority:0},Vl.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Rx=Vl;var yR=Object.defineProperty,Px=Object.getOwnPropertySymbols,vR=Object.prototype.hasOwnProperty,TR=Object.prototype.propertyIsEnumerable,Dx=(r,t,e)=>t in r?yR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Mx=(r,t)=>{for(var e in t||(t={}))vR.call(t,e)&&Dx(r,e,t[e]);if(Px)for(var e of Px(t))TR.call(t,e)&&Dx(r,e,t[e]);return r};const Wl=class qy{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(t){var e;t=Mx(Mx({},qy.defaultOptions),t),this.checkCountMax=t.textureGCCheckCountMax,this.maxIdle=(e=t.textureGCAMaxIdle)!=null?e:t.textureGCMaxIdle,this.active=t.textureGCActive}postrender(){this._renderer.renderingToScreen&&(this.count++,this.active&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this._renderer.texture.managedTextures;for(let e=0;e-1&&this.count-s._touched>this.maxIdle&&(s._touched=-1,s.unload())}}destroy(){this._renderer=null}};Wl.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"textureGC"},Wl.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:60*60,textureGCCheckCountMax:600};let Ox=Wl;var AR=Object.defineProperty,Bx=Object.getOwnPropertySymbols,SR=Object.prototype.hasOwnProperty,ER=Object.prototype.propertyIsEnumerable,Gx=(r,t,e)=>t in r?AR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fx=(r,t)=>{for(var e in t||(t={}))SR.call(t,e)&&Gx(r,e,t[e]);if(Bx)for(var e of Bx(t))ER.call(t,e)&&Gx(r,e,t[e]);return r};const Yl=class Ky{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(t){this.texture.source.autoDensity=t}get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}init(t){t=Fx(Fx({},Ky.defaultOptions),t),t.view&&(t.canvas=t.view),this.screen=new j(0,0,t.width,t.height),this.canvas=t.canvas||I.get().createCanvas(),this.antialias=!!t.antialias,this.texture=_l(this.canvas,t),this.renderTarget=new yn({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.resolution=t.resolution}resize(t,e,s){this.texture.source.resize(t,e,s),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){(typeof t=="boolean"?t:t!=null&&t.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}};Yl.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"view",priority:0},Yl.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let Ix=Yl;const ql=[mx,jl,Cn,Ix,Il,Ox,Hl,xx,mu,Rx,zl],Kl=[Ll,Qu,Ul,Bl,Ju,el,tl,Ol],wR=[...ql,gl,x2,h2,cl,rl,Pl,bl,ol,El,Sl,ll,K2,hl,ul],CR=[...Kl],RR=[qu,Ml,Dl],Ux=[],kx=[],Lx=[];U.handleByNamedList(v.WebGLSystem,Ux),U.handleByNamedList(v.WebGLPipes,kx),U.handleByNamedList(v.WebGLPipesAdaptor,Lx),U.add(...wR,...CR,...RR);class Nx extends xs{constructor(){const t={name:"webgl",type:Tt.WEBGL,systems:Ux,renderPipes:kx,renderPipeAdaptors:Lx};super(t)}}var PR={__proto__:null,WebGLRenderer:Nx};class Zl{constructor(t){this._hash=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_hash")}contextChange(t){this._gpu=t}getBindGroup(t,e,s){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,s)}_createBindGroup(t,e,s){var i;const n=this._gpu.device,o=e.layout[s],a=[],u=this._renderer;for(const h in o){const d=(i=t.resources[h])!=null?i:t.resources[o[h]];let p;if(d._resourceType==="uniformGroup"){const f=d;u.ubo.updateUniformGroup(f);const g=f.buffer;p={buffer:u.buffer.getGPUBuffer(g),offset:0,size:g.descriptor.size}}else if(d._resourceType==="buffer"){const f=d;p={buffer:u.buffer.getGPUBuffer(f),offset:0,size:f.descriptor.size}}else if(d._resourceType==="bufferResource"){const f=d;p={buffer:u.buffer.getGPUBuffer(f.buffer),offset:f.offset,size:f.size}}else if(d._resourceType==="textureSampler"){const f=d;p=u.texture.getGpuSampler(f)}else if(d._resourceType==="textureSource"){const f=d;p=u.texture.getGpuSource(f).createView({})}a.push({binding:o[h],resource:p})}const l=u.shader.getProgramData(e).bindGroups[s],c=n.createBindGroup({layout:l,entries:a});return this._hash[t._key]=c,c}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}Zl.extension={type:[v.WebGPUSystem],name:"bindGroup"};class Ql{constructor(t){this._gpuBuffers=Object.create(null),this._managedBuffers=[],t.renderableGC.addManagedHash(this,"_gpuBuffers")}contextChange(t){this._gpu=t}getGPUBuffer(t){return this._gpuBuffers[t.uid]||this.createGPUBuffer(t)}updateBuffer(t){const e=this._gpuBuffers[t.uid]||this.createGPUBuffer(t),s=t.data;return t._updateID&&s&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,s.buffer,0,(t._updateSize||s.byteLength)+3&-4)),e}destroyAll(){for(const t in this._gpuBuffers)this._gpuBuffers[t].destroy();this._gpuBuffers={}}createGPUBuffer(t){this._gpuBuffers[t.uid]||(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this),t.on("destroy",this.onBufferDestroy,this),this._managedBuffers.push(t));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(mi(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,e}onBufferChange(t){this._gpuBuffers[t.uid].destroy(),t._updateID=0,this._gpuBuffers[t.uid]=this.createGPUBuffer(t)}onBufferDestroy(t){this._managedBuffers.splice(this._managedBuffers.indexOf(t),1),this._destroyBuffer(t)}destroy(){this._managedBuffers.forEach(t=>this._destroyBuffer(t)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(t){this._gpuBuffers[t.uid].destroy(),t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this),t.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[t.uid]=null}}Ql.extension={type:[v.WebGPUSystem],name:"buffer"};class $x{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${t*4}`);const e=this.byteIndex;let s=e+t*4;if(s=Math.ceil(s/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,s>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=s,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let s=0;s{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await I.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),s=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>e.features.has(n)),i=await e.requestDevice({requiredFeatures:s});return{adapter:e,device:i}}destroy(){this.gpu=null,this._renderer=null}}Rn.extension={type:[v.WebGPUSystem],name:"device"},Rn.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var DR=Object.defineProperty,Xx=Object.getOwnPropertySymbols,MR=Object.prototype.hasOwnProperty,OR=Object.prototype.propertyIsEnumerable,Hx=(r,t,e)=>t in r?DR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jx=(r,t)=>{for(var e in t||(t={}))MR.call(t,e)&&Hx(r,e,t[e]);if(Xx)for(var e of Xx(t))OR.call(t,e)&&Hx(r,e,t[e]);return r};class tc{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,s,i){const n=this._renderer.pipeline.getPipeline(t,e,s,i);this.setPipeline(n)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,s){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.textureGC.count);const i=this._renderer.bindGroup.getBindGroup(e,s,t);this.renderPassEncoder.setBindGroup(t,i)}setGeometry(t,e){const s=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const i in s)this._setVertexBuffer(i,t.attributes[s[i]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const s in t.groups){const i=t.groups[s];e||this._syncBindGroup(i),this.setBindGroup(s,i,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const s=t.resources[e];s.isUniformGroup&&this._renderer.ubo.updateUniformGroup(s)}}draw(t){const{geometry:e,shader:s,state:i,topology:n,size:o,start:a,instanceCount:u,skipSync:l}=t;this.setPipelineFromGeometryProgramAndState(e,s.gpuProgram,i,n),this.setGeometry(e,s.gpuProgram),this._setShaderBindGroups(s,l),e.indexBuffer?this.renderPassEncoder.drawIndexed(o||e.indexBuffer.data.length,u!=null?u:e.instanceCount,a||0):this.renderPassEncoder.draw(o||e.getSize(),u!=null?u:e.instanceCount,a||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,s=jx({},this._boundVertexBuffer),i=this._boundIndexBuffer,n=jx({},this._boundBindGroup);this._clearCache();const o=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(o.x,o.y,o.width,o.height,0,1),this.setPipeline(e);for(const a in s)this._setVertexBuffer(a,s[a]);for(const a in n)this.setBindGroup(a,n[a],null);this._setIndexBuffer(i)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}tc.extension={type:[v.WebGPUSystem],name:"encoder",priority:1};class ec{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}ec.extension={type:[v.WebGPUSystem],name:"limits"};class rc{constructor(t){this._renderTargetStencilState=Object.create(null),this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:J.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const s=this._renderTargetStencilState[this._activeRenderTarget.uid];s.stencilMode=t,s.stencilReference=e;const i=this._renderer;i.pipeline.setStencilMode(t),i.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}rc.extension={type:[v.WebGPUSystem],name:"stencil"};const Bs={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:4,size:4},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:8,size:6},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:8,size:8},"mat2x2":{align:8,size:16},"mat2x2":{align:4,size:8},"mat3x2":{align:8,size:24},"mat3x2":{align:4,size:12},"mat4x2":{align:8,size:32},"mat4x2":{align:4,size:16},"mat2x3":{align:16,size:32},"mat2x3":{align:8,size:16},"mat3x3":{align:16,size:48},"mat3x3":{align:8,size:24},"mat4x3":{align:16,size:64},"mat4x3":{align:8,size:32},"mat2x4":{align:16,size:32},"mat2x4":{align:8,size:16},"mat3x4":{align:16,size:48},"mat3x4":{align:8,size:24},"mat4x4":{align:16,size:64},"mat4x4":{align:8,size:32}};function zx(r){const t=r.map(s=>({data:s,offset:0,size:0}));let e=0;for(let s=0;s1&&(n=Math.max(n,o)*i.data.size),e=Math.ceil(e/o)*o,i.size=n,i.offset=e,e+=n}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function Vx(r,t){const{size:e,align:s}=Bs[r.data.type],i=(s-e)/4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return` v = uv.${r.data.name}; ${t!==0?`offset += ${t};`:""} arrayOffset = offset; t = 0; for(var i=0; i < ${r.data.size*(e/4)}; i++) { for(var j = 0; j < ${e/4}; j++) { ${n}[arrayOffset++] = v[t++]; } ${i!==0?`arrayOffset += ${i};`:""} } `}function Wx(r){return fl(r,"uboWgsl",Vx,A2)}class sc extends dl{constructor(){super({createUboElements:zx,generateUboSync:Wx})}}sc.extension={type:[v.WebGPUSystem],name:"ubo"};const Ae=128;class ic{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_bindGroupHash"),this._batchBuffer=new $x({minUniformOffsetAlignment:Ae});const e=256/Ae;for(let s=0;st in r?BR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,kR=(r,t)=>{for(var e in t||(t={}))IR.call(t,e)&&qx(r,e,t[e]);if(Yx)for(var e of Yx(t))UR.call(t,e)&&qx(r,e,t[e]);return r},LR=(r,t)=>GR(r,FR(t));const NR={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function $R(r,t,e,s,i){return r<<24|t<<16|e<<10|s<<5|i}function XR(r,t,e,s){return e<<6|r<<3|s<<1|t}class nc{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(J.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=de[t],this._updatePipeHash())}setPipeline(t,e,s,i){const n=this.getPipeline(t,e,s);i.setPipeline(n)}getPipeline(t,e,s,i){t._layoutKey||(il(t,e.attributeData),this._generateBufferKey(t)),i||(i=t.topology);const n=$R(t._layoutKey,e._layoutKey,s.data,s._blendModeId,NR[i]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(t,e,s,i),this._pipeCache[n])}_createPipeline(t,e,s,i){const n=this._gpu.device,o=this._createVertexBufferLayouts(t,e),a=this._renderer.state.getColorTargets(s);a[0].writeMask=this._stencilMode===J.RENDERING_MASK_ADD?0:this._colorMask;const u=this._renderer.shader.getProgramData(e).pipeline,l={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:o},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:a},primitive:{topology:i,cullMode:s.cullMode},layout:u,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(l.depthStencil=LR(kR({},this._stencilState),{format:"depth24plus-stencil8",depthWriteEnabled:s.depthTest,depthCompare:s.depthTest?"less":"always"})),n.createRenderPipeline(l)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let s=0;const i=Object.keys(t.attributes).sort();for(let o=0;o{var o;const a={arrayStride:0,stepMode:"vertex",attributes:[]},u=a.attributes;for(const l in e.attributeData){const c=t.attributes[l];((o=c.divisor)!=null?o:1)!==1&&Lt(`Attribute ${l} has an invalid divisor value of '${c.divisor}'. WebGPU only supports a divisor value of 1`),c.buffer===n&&(a.arrayStride=c.stride,a.stepMode=c.instance?"instance":"vertex",u.push({shaderLocation:e.attributeData[l].location,offset:c.offset,format:c.format}))}u.length&&i.push(a)}),this._bufferLayoutsCache[s]=i,i}_updatePipeHash(){const t=XR(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}nc.extension={type:[v.WebGPUSystem],name:"pipeline"};class Kx{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class Zx{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,s,i,n){const o=this._renderer,a=this._getGpuColorTexture(t),u=o.texture.getGpuSource(e.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:s},{texture:u,origin:n},i),e}startRenderPass(t,e=!0,s,i){const n=this._renderTargetSystem.getGpuRenderTarget(t),o=this.getDescriptor(t,e,s);n.descriptor=o,this._renderer.pipeline.setRenderTarget(n),this._renderer.encoder.beginRenderPass(n),this._renderer.encoder.setViewport(i)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,s){typeof e=="boolean"&&(e=e?At.ALL:At.NONE);const i=this._renderTargetSystem,n=i.getGpuRenderTarget(t),o=t.colorTextures.map((u,l)=>{const c=n.contexts[l];let h,d;c?h=c.getCurrentTexture().createView():h=this._renderer.texture.getGpuSource(u).createView({mipLevelCount:1}),n.msaaTextures[l]&&(d=h,h=this._renderer.texture.getTextureView(n.msaaTextures[l]));const p=e&At.COLOR?"clear":"load";return s!=null||(s=i.defaultClearColor),{view:h,resolveTarget:d,clearValue:s,storeOp:"store",loadOp:p}});let a;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=n.msaa?4:1),t.depthStencilTexture){const u=e&At.STENCIL?"clear":"load",l=e&At.DEPTH?"clear":"load";a={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:u,depthClearValue:1,depthLoadOp:l,depthStoreOp:"store"}}return{colorAttachments:o,depthStencilAttachment:a}}clear(t,e=!0,s,i){if(!e)return;const{gpu:n,encoder:o}=this._renderer,a=n.device;if(o.commandEncoder===null){const u=a.createCommandEncoder(),l=this.getDescriptor(t,e,s),c=u.beginRenderPass(l);c.setViewport(i.x,i.y,i.width,i.height,0,1),c.end();const h=u.finish();a.queue.submit([h])}else this.startRenderPass(t,e,s,i)}initGpuRenderTarget(t){t.isRoot=!0;const e=new Kx;return t.colorTextures.forEach((s,i)=>{if(s instanceof Kt){const n=s.resource.getContext("webgpu"),o=s.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:o})}catch(a){console.error(a)}e.contexts[i]=n}if(e.msaa=s.source.antialias,s.source.antialias){const n=new K({width:0,height:0,sampleCount:4});e.msaaTextures[i]=n}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(e=>{e.unconfigure()}),t.msaaTextures.forEach(e=>{e.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((s,i)=>{const n=e.msaaTextures[i];n==null||n.resize(s.source.width,s.source.height,s.source._resolution)})}}class oc extends xl{constructor(t){super(t),this.adaptor=new Zx,this.adaptor.init(t,this)}}oc.extension={type:[v.WebGPUSystem],name:"renderTarget"};class ac{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,s=t.gpuLayout.map(n=>e.createBindGroupLayout({entries:n})),i={bindGroupLayouts:s};return this._gpuProgramData[t._layoutKey]={bindGroups:s,pipeline:e.createPipelineLayout(i)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}ac.extension={type:[v.WebGPUSystem],name:"shader"};const gt={};gt.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},gt.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},gt.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},gt.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},gt.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},gt.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},gt["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},gt["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},gt["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},gt.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},gt.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},gt.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class uc{constructor(){this.defaultState=new Mt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:gt[t.blendMode]||gt.normal}]}destroy(){this.gpu=null}}uc.extension={type:[v.WebGPUSystem],name:"state"};const Qx={type:"image",upload(r,t,e){const s=r.resource,i=(r.pixelWidth|0)*(r.pixelHeight|0),n=s.byteLength/i;e.device.queue.writeTexture({texture:t},s,{offset:0,rowsPerImage:r.pixelHeight,bytesPerRow:r.pixelHeight*n},{width:r.pixelWidth,height:r.pixelHeight,depthOrArrayLayers:1})}},lc={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},HR={blockBytes:4,blockWidth:1,blockHeight:1},Jx={type:"compressed",upload(r,t,e){let s=r.pixelWidth,i=r.pixelHeight;const n=lc[r.format]||HR;for(let o=0;o>1,1),i=Math.max(i>>1,1)}}},cc={type:"image",upload(r,t,e){const s=r.resource;if(!s)return;if(globalThis.HTMLImageElement&&s instanceof HTMLImageElement){const a=I.get().createCanvas(s.width,s.height);a.getContext("2d").drawImage(s,0,0,s.width,s.height),r.resource=a}const i=Math.min(t.width,r.resourceWidth||r.pixelWidth),n=Math.min(t.height,r.resourceHeight||r.pixelHeight),o=r.alphaMode==="premultiply-alpha-on-upload";e.device.queue.copyExternalImageToTexture({source:s},{texture:t,premultipliedAlpha:o},{width:i,height:n})}},tb={type:"video",upload(r,t,e){cc.upload(r,t,e)}};class eb{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:` var pos : array, 3> = array, 3>( vec2(-1.0, -1.0), vec2(-1.0, 3.0), vec2(3.0, -1.0)); struct VertexOutput { @builtin(position) position : vec4, @location(0) texCoord : vec2, }; @vertex fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput { var output : VertexOutput; output.texCoord = pos[vertexIndex] * vec2(0.5, -0.5) + vec2(0.5); output.position = vec4(pos[vertexIndex], 0.0, 1.0); return output; } @group(0) @binding(0) var imgSampler : sampler; @group(0) @binding(1) var img : texture_2d; @fragment fn fragmentMain(@location(0) texCoord : vec2) -> @location(0) vec4 { return textureSample(img, imgSampler, texCoord); } `})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if(t.dimension==="3d"||t.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let s=t;const i=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){const u={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:i},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};s=this.device.createTexture(u)}const o=this.device.createCommandEncoder({}),a=e.getBindGroupLayout(0);for(let u=0;u1&&this.onUpdateMipmaps(t))}onSourceUnload(t){const e=this._gpuSources[t.uid];e&&(this._gpuSources[t.uid]=null,e.destroy())}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new eb(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceDestroy(t){t.off("update",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("destroy",this.onSourceDestroy,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}onSourceResize(t){const e=this._gpuSources[t.uid];e?(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(this._textureViewHash[t.uid]=null,this._bindGroupHash[t.uid]=null,this.onSourceUnload(t),this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){return this._gpuSources[t.uid]||this.initSource(t)}getTextureBindGroup(t){var e;return(e=this._bindGroupHash[t.uid])!=null?e:this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source;return this._bindGroupHash[t.uid]=new Zt({0:e,1:e.style,2:new it({uTextureMatrix:{type:"mat3x3",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){var e;const s=t.source;return(e=this._textureViewHash[s.uid])!=null?e:this._createTextureView(s)}_createTextureView(t){return this._textureViewHash[t.uid]=this.getGpuSource(t).createView(),this._textureViewHash[t.uid]}generateCanvas(t){const e=this._renderer,s=e.gpu.device.createCommandEncoder(),i=I.get().createCanvas();i.width=t.source.pixelWidth,i.height=t.source.pixelHeight;const n=i.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:I.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),s.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:i.width,height:i.height}),e.gpu.device.queue.submit([s.finish()]),i}getPixels(t){const e=this.generateCanvas(t),s=le.getOptimalCanvasAndContext(e.width,e.height),i=s.context;i.drawImage(e,0,0);const{width:n,height:o}=e,a=i.getImageData(0,0,n,o),u=new Uint8ClampedArray(a.data.buffer);return le.returnCanvasAndContext(s),{pixels:u,width:n,height:o}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null;for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),s=this._bindGroupHash[e];s==null||s.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}hc.extension={type:[v.WebGPUSystem],name:"texture"};class dc{constructor(){this._maxTextures=0}contextChange(t){const e=new it({uTransformMatrix:{value:new M,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const s=lr({name:"graphics",bits:[xi,yi(this._maxTextures),ug,hr]});this.shader=new Ft({gpuProgram:s,resources:{localUniforms:e}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:u}=o.getContextRenderData(s),l=n.encoder;l.setGeometry(a.geometry,i.gpuProgram);const c=n.globalUniforms.bindGroup;l.setBindGroup(0,c,i.gpuProgram);const h=n.renderPipes.uniformBatch.getUniformBindGroup(i.resources.localUniforms,!0);l.setBindGroup(2,h,i.gpuProgram);const d=u.instructions;let p=null;for(let f=0;f",value:new M}}}})}execute(t,e){const s=t.renderer;let i=e._shader;if(!i)i=this._shader,i.groups[2]=s.texture.getTextureBindGroup(e.texture);else if(!i.gpuProgram)return;const n=i.gpuProgram;if(n.autoAssignGlobalUniforms&&(i.groups[0]=s.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const o=t.localUniforms;i.groups[1]=s.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}s.encoder.draw({geometry:e._geometry,shader:i,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}pc.extension={type:[v.WebGPUPipesAdaptor],name:"mesh"};const jR=[...ql,sc,tc,Rn,ec,Ql,hc,oc,ac,uc,nc,Jl,rc,Zl],zR=[...Kl,ic],VR=[Ku,pc,dc],rb=[],sb=[],ib=[];U.handleByNamedList(v.WebGPUSystem,rb),U.handleByNamedList(v.WebGPUPipes,sb),U.handleByNamedList(v.WebGPUPipesAdaptor,ib),U.add(...jR,...zR,...VR);class nb extends xs{constructor(){const t={name:"webgpu",type:Tt.WEBGPU,systems:rb,renderPipes:sb,renderPipeAdaptors:ib};super(t)}}var WR={__proto__:null,WebGPURenderer:nb};const YR={POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},qR=new Proxy(YR,{get(r,t){return r[t]}});var fc=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))(fc||{});const KR=new Proxy(fc,{get(r,t){return r[t]}});var mc=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))(mc||{});const ZR=new Proxy(mc,{get(r,t){return r[t]}});class QR{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,s){const i=e.width,n=e.height;if(s){const o=t.width/2/i,a=t.height/2/n,u=t.x/i+o,l=t.y/n+a;s=k.add(s,k.NW),this.x0=u+o*k.uX(s),this.y0=l+a*k.uY(s),s=k.add(s,2),this.x1=u+o*k.uX(s),this.y1=l+a*k.uY(s),s=k.add(s,2),this.x2=u+o*k.uX(s),this.y2=l+a*k.uY(s),s=k.add(s,2),this.x3=u+o*k.uX(s),this.y3=l+a*k.uY(s)}else this.x0=t.x/i,this.y0=t.y/n,this.x1=(t.x+t.width)/i,this.y1=t.y/n,this.x2=(t.x+t.width)/i,this.y2=(t.y+t.height)/n,this.x3=t.x/i,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}function JR(r){const t=r.toString(),e=t.indexOf("{"),s=t.lastIndexOf("}");if(e===-1||s===-1)throw new Error("getFunctionBody: No body found in function definition");return t.slice(e+1,s).trim()}function tP(r,t){return r.getFastGlobalBounds(!0,t)}var eP=Object.defineProperty,Pn=Object.getOwnPropertySymbols,ob=Object.prototype.hasOwnProperty,ab=Object.prototype.propertyIsEnumerable,ub=(r,t,e)=>t in r?eP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rP=(r,t)=>{for(var e in t||(t={}))ob.call(t,e)&&ub(r,e,t[e]);if(Pn)for(var e of Pn(t))ab.call(t,e)&&ub(r,e,t[e]);return r},sP=(r,t)=>{var e={};for(var s in r)ob.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Pn)for(var s of Pn(r))t.indexOf(s)<0&&ab.call(r,s)&&(e[s]=r[s]);return e};class iP extends ae{constructor(t){var e,s;typeof t=="function"&&(t={render:t});const i=t,{render:n}=i,o=sP(i,["render"]);super(rP({label:"RenderContainer"},o)),this.renderPipeId="customRender",this.batched=!1,n&&(this.render=n),this.containsPoint=(e=t.containsPoint)!=null?e:()=>!1,this.addBounds=(s=t.addBounds)!=null?s:()=>!1}updateBounds(){this._bounds.clear(),this.addBounds(this._bounds)}render(t){}}function nP(r,t,e){const s=e.renderPipes?e:e.batch.renderer;return r.collectRenderables(t,s,null)}function oP(r,t){const e=t._scale,s=t._pivot,i=t._position,n=e._x,o=e._y,a=s._x,u=s._y;r.a=t._cx*n,r.b=t._sx*n,r.c=t._cy*o,r.d=t._sy*o,r.tx=i._x-(a*r.a+u*r.c),r.ty=i._y-(a*r.b+u*r.d)}function aP(r,t,e){const s=r.a,i=r.b,n=r.c,o=r.d,a=r.tx,u=r.ty,l=t.a,c=t.b,h=t.c,d=t.d;e.a=s*l+i*h,e.b=s*c+i*d,e.c=n*l+o*h,e.d=n*c+o*d,e.tx=a*l+u*h+t.tx,e.ty=a*c+u*d+t.ty}var uP=Object.defineProperty,lb=Object.getOwnPropertySymbols,lP=Object.prototype.hasOwnProperty,cP=Object.prototype.propertyIsEnumerable,cb=(r,t,e)=>t in r?uP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hb=(r,t)=>{for(var e in t||(t={}))lP.call(t,e)&&cb(r,e,t[e]);if(lb)for(var e of lb(t))cP.call(t,e)&&cb(r,e,t[e]);return r};const db=class Zy extends et{constructor(t={}){t=hb(hb({},Zy.defaultOptions),t),super(),this.renderLayerChildren=[],this.sortableChildren=t.sortableChildren,this.sortFunction=t.sortFunction}attach(...t){for(let e=0;er.zIndex-t.zIndex};let hP=db;const dP=hP;function pb(r,t,e,s){const i=e.buffers[0],n=i.data,{verticesX:o,verticesY:a}=e,u=r/(o-1),l=t/(a-1);let c=0;const h=s[0],d=s[1],p=s[2],f=s[3],g=s[4],m=s[5],_=s[6],b=s[7],x=s[8];for(let y=0;yt in r?xP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,gc=(r,t)=>{for(var e in t||(t={}))bb.call(t,e)&&vb(r,e,t[e]);if(Mn)for(var e of Mn(t))yb.call(t,e)&&vb(r,e,t[e]);return r},vP=(r,t)=>bP(r,yP(t)),TP=(r,t)=>{var e={};for(var s in r)bb.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Mn)for(var s of Mn(r))t.indexOf(s)<0&&yb.call(r,s)&&(e[s]=r[s]);return e};const Tb=class Qy extends Er{constructor(t){t=gc(gc({},Qy.defaultOptions),t);const e=t,{texture:s,verticesX:i,verticesY:n}=e,o=TP(e,["texture","verticesX","verticesY"]),a=new xb(Ht({width:s.width,height:s.height,verticesX:i,verticesY:n}));super(Ht(vP(gc({},o),{geometry:a}))),this._texture=s,this.geometry.setCorners(t.x0,t.y0,t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}textureUpdated(){const t=this.geometry;if(!t)return;const{width:e,height:s}=this.texture;(t.width!==e||t.height!==s)&&(t.width=e,t.height=s,t.updateProjection())}set texture(t){this._texture!==t&&(super.texture=t,this.textureUpdated())}get texture(){return this._texture}setCorners(t,e,s,i,n,o,a,u){this.geometry.setCorners(t,e,s,i,n,o,a,u)}};Tb.defaultOptions={texture:C.WHITE,verticesX:10,verticesY:10,x0:0,y0:0,x1:100,y1:0,x2:100,y2:100,x3:0,y3:100};let AP=Tb;var SP=Object.defineProperty,EP=Object.defineProperties,wP=Object.getOwnPropertyDescriptors,On=Object.getOwnPropertySymbols,Ab=Object.prototype.hasOwnProperty,Sb=Object.prototype.propertyIsEnumerable,Eb=(r,t,e)=>t in r?SP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,CP=(r,t)=>{for(var e in t||(t={}))Ab.call(t,e)&&Eb(r,e,t[e]);if(On)for(var e of On(t))Sb.call(t,e)&&Eb(r,e,t[e]);return r},RP=(r,t)=>EP(r,wP(t)),PP=(r,t)=>{var e={};for(var s in r)Ab.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&On)for(var s of On(r))t.indexOf(s)<0&&Sb.call(r,s)&&(e[s]=r[s]);return e};class DP extends Er{constructor(t){const e=t,{texture:s,verticesX:i,verticesY:n}=e,o=PP(e,["texture","verticesX","verticesY"]),a=new Hi(Ht({width:s.width,height:s.height,verticesX:i,verticesY:n}));super(Ht(RP(CP({},o),{geometry:a,texture:s}))),this.texture=s,this.autoResize=!0}textureUpdated(){const t=this.geometry,{width:e,height:s}=this.texture;this.autoResize&&(t.width!==e||t.height!==s)&&(t.width=e,t.height=s,t.build({}))}set texture(t){var e;(e=this._texture)==null||e.off("update",this.textureUpdated,this),super.texture=t,t.on("update",this.textureUpdated,this),this.textureUpdated()}get texture(){return this._texture}destroy(t){this.texture.off("update",this.textureUpdated,this),super.destroy(t)}}var MP=Object.defineProperty,wb=Object.getOwnPropertySymbols,OP=Object.prototype.hasOwnProperty,BP=Object.prototype.propertyIsEnumerable,Cb=(r,t,e)=>t in r?MP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Rb=(r,t)=>{for(var e in t||(t={}))OP.call(t,e)&&Cb(r,e,t[e]);if(wb)for(var e of wb(t))BP.call(t,e)&&Cb(r,e,t[e]);return r};const Pb=class Jy extends $e{constructor(t){const{width:e,points:s,textureScale:i}=Rb(Rb({},Jy.defaultOptions),t);super({positions:new Float32Array(s.length*4),uvs:new Float32Array(s.length*4),indices:new Uint32Array((s.length-1)*6)}),this.points=s,this._width=e,this.textureScale=i,this._build()}get width(){return this._width}_build(){const t=this.points;if(!t)return;const e=this.getBuffer("aPosition"),s=this.getBuffer("aUV"),i=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),s.data=new Float32Array(t.length*4),i.data=new Uint16Array((t.length-1)*6));const n=s.data,o=i.data;n[0]=0,n[1]=0,n[2]=0,n[3]=1;let a=0,u=t[0];const l=this._width*this.textureScale,c=t.length;for(let d=0;d0){const f=u.x-t[d].x,g=u.y-t[d].y,m=Math.sqrt(f*f+g*g);u=t[d],a+=m/l}else a=d/(c-1);n[p]=a,n[p+1]=0,n[p+2]=a,n[p+3]=1}let h=0;for(let d=0;d0?this.textureScale*this._width/2:this._width/2;for(let l=0;l1&&(d=1);const p=Math.sqrt(i*i+n*n);p<1e-6?(i=0,n=0):(i/=p,n/=p,i*=u,n*=u),o[h]=c.x+i,o[h+1]=c.y+n,o[h+2]=c.x-i,o[h+3]=c.y-n,e=c}this.buffers[0].update()}update(){this.textureScale>0?this._build():this.updateVertices()}};Pb.defaultOptions={width:200,points:[],textureScale:0};let Db=Pb;var GP=Object.defineProperty,FP=Object.defineProperties,IP=Object.getOwnPropertyDescriptors,Bn=Object.getOwnPropertySymbols,Mb=Object.prototype.hasOwnProperty,Ob=Object.prototype.propertyIsEnumerable,Bb=(r,t,e)=>t in r?GP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_c=(r,t)=>{for(var e in t||(t={}))Mb.call(t,e)&&Bb(r,e,t[e]);if(Bn)for(var e of Bn(t))Ob.call(t,e)&&Bb(r,e,t[e]);return r},UP=(r,t)=>FP(r,IP(t)),kP=(r,t)=>{var e={};for(var s in r)Mb.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Bn)for(var s of Bn(r))t.indexOf(s)<0&&Ob.call(r,s)&&(e[s]=r[s]);return e};const Gb=class tv extends Er{constructor(t){const e=_c(_c({},tv.defaultOptions),t),{texture:s,points:i,textureScale:n}=e,o=kP(e,["texture","points","textureScale"]),a=new Db(Ht({width:s.height,points:i,textureScale:n}));n>0&&(s.source.style.addressMode="repeat"),super(Ht(UP(_c({},o),{texture:s,geometry:a}))),this.autoUpdate=!0,this.onRender=this._render}_render(){const t=this.geometry;(this.autoUpdate||t._width!==this.texture.height)&&(t._width=this.texture.height,t.update())}};Gb.defaultOptions={textureScale:0};let LP=Gb;var NP=Object.defineProperty,$P=Object.defineProperties,XP=Object.getOwnPropertyDescriptors,Gn=Object.getOwnPropertySymbols,Fb=Object.prototype.hasOwnProperty,Ib=Object.prototype.propertyIsEnumerable,Ub=(r,t,e)=>t in r?NP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,HP=(r,t)=>{for(var e in t||(t={}))Fb.call(t,e)&&Ub(r,e,t[e]);if(Gn)for(var e of Gn(t))Ib.call(t,e)&&Ub(r,e,t[e]);return r},jP=(r,t)=>$P(r,XP(t)),zP=(r,t)=>{var e={};for(var s in r)Fb.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Gn)for(var s of Gn(r))t.indexOf(s)<0&&Ib.call(r,s)&&(e[s]=r[s]);return e};class VP extends Er{constructor(t){const e=t,{texture:s,vertices:i,uvs:n,indices:o,topology:a}=e,u=zP(e,["texture","vertices","uvs","indices","topology"]),l=new $e(Ht({positions:i,uvs:n,indices:o,topology:a}));super(Ht(jP(HP({},u),{texture:s,geometry:l}))),this.autoUpdate=!0,this.onRender=this._render}get vertices(){return this.geometry.getBuffer("aPosition").data}set vertices(t){this.geometry.getBuffer("aPosition").data=t}_render(){this.autoUpdate&&this.geometry.getBuffer("aPosition").update()}}function WP(r,t){const{width:e,height:s}=r.frame;return t.scale(1/e,1/s),t}var YP=Object.defineProperty,kb=Object.getOwnPropertySymbols,qP=Object.prototype.hasOwnProperty,KP=Object.prototype.propertyIsEnumerable,Lb=(r,t,e)=>t in r?YP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nb=(r,t)=>{for(var e in t||(t={}))qP.call(t,e)&&Lb(r,e,t[e]);if(kb)for(var e of kb(t))KP.call(t,e)&&Lb(r,e,t[e]);return r};const $b=class Rc{constructor(t){if(t instanceof C)this.texture=t,ui(this,Rc.defaultOptions,{});else{const e=Nb(Nb({},Rc.defaultOptions),t);ui(this,e,{})}}get alpha(){return this._alpha}set alpha(t){this._alpha=Math.min(Math.max(t,0),1),this._updateColor()}get tint(){return rr(this._tint)}set tint(t){this._tint=X.shared.setValue(t!=null?t:16777215).toBgrNumber(),this._updateColor()}_updateColor(){this.color=this._tint+((this._alpha*255|0)<<24)}};$b.defaultOptions={anchorX:0,anchorY:0,x:0,y:0,scaleX:1,scaleY:1,rotation:0,tint:16777215,alpha:1};let ZP=$b;const xc={vertex:{attributeName:"aVertex",format:"float32x2",code:` const texture = p.texture; const sx = p.scaleX; const sy = p.scaleY; const ax = p.anchorX; const ay = p.anchorY; const trim = texture.trim; const orig = texture.orig; if (trim) { w1 = trim.x - (ax * orig.width); w0 = w1 + trim.width; h1 = trim.y - (ay * orig.height); h0 = h1 + trim.height; } else { w1 = -ax * (orig.width); w0 = w1 + orig.width; h1 = -ay * (orig.height); h0 = h1 + orig.height; } f32v[offset] = w1 * sx; f32v[offset + 1] = h1 * sy; f32v[offset + stride] = w0 * sx; f32v[offset + stride + 1] = h1 * sy; f32v[offset + (stride * 2)] = w0 * sx; f32v[offset + (stride * 2) + 1] = h0 * sy; f32v[offset + (stride * 3)] = w1 * sx; f32v[offset + (stride * 3) + 1] = h0 * sy; `,dynamic:!1},position:{attributeName:"aPosition",format:"float32x2",code:` var x = p.x; var y = p.y; f32v[offset] = x; f32v[offset + 1] = y; f32v[offset + stride] = x; f32v[offset + stride + 1] = y; f32v[offset + (stride * 2)] = x; f32v[offset + (stride * 2) + 1] = y; f32v[offset + (stride * 3)] = x; f32v[offset + (stride * 3) + 1] = y; `,dynamic:!0},rotation:{attributeName:"aRotation",format:"float32",code:` var rotation = p.rotation; f32v[offset] = rotation; f32v[offset + stride] = rotation; f32v[offset + (stride * 2)] = rotation; f32v[offset + (stride * 3)] = rotation; `,dynamic:!1},uvs:{attributeName:"aUV",format:"float32x2",code:` var uvs = p.texture.uvs; f32v[offset] = uvs.x0; f32v[offset + 1] = uvs.y0; f32v[offset + stride] = uvs.x1; f32v[offset + stride + 1] = uvs.y1; f32v[offset + (stride * 2)] = uvs.x2; f32v[offset + (stride * 2) + 1] = uvs.y2; f32v[offset + (stride * 3)] = uvs.x3; f32v[offset + (stride * 3) + 1] = uvs.y3; `,dynamic:!1},color:{attributeName:"aColor",format:"unorm8x4",code:` const c = p.color; u32v[offset] = c; u32v[offset + stride] = c; u32v[offset + (stride * 2)] = c; u32v[offset + (stride * 3)] = c; `,dynamic:!1}};var QP=Object.defineProperty,JP=Object.defineProperties,tD=Object.getOwnPropertyDescriptors,Fn=Object.getOwnPropertySymbols,Xb=Object.prototype.hasOwnProperty,Hb=Object.prototype.propertyIsEnumerable,jb=(r,t,e)=>t in r?QP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Rr=(r,t)=>{for(var e in t||(t={}))Xb.call(t,e)&&jb(r,e,t[e]);if(Fn)for(var e of Fn(t))Hb.call(t,e)&&jb(r,e,t[e]);return r},zb=(r,t)=>JP(r,tD(t)),eD=(r,t)=>{var e={};for(var s in r)Xb.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Fn)for(var s of Fn(r))t.indexOf(s)<0&&Hb.call(r,s)&&(e[s]=r[s]);return e};const rD=new ot(0,0,0,0),Vb=class Pc extends ae{constructor(t={}){t=zb(Rr(Rr({},Pc.defaultOptions),t),{dynamicProperties:Rr(Rr({},Pc.defaultOptions.dynamicProperties),t==null?void 0:t.dynamicProperties)});const e=t,{dynamicProperties:s,shader:i,roundPixels:n,texture:o,particles:a}=e,u=eD(e,["dynamicProperties","shader","roundPixels","texture","particles"]);super(Rr({label:"ParticleContainer"},u)),this.renderPipeId="particle",this.batched=!1,this._childrenDirty=!1,this.texture=o||null,this.shader=i,this._properties={};for(const l in xc){const c=xc[l],h=s[l];this._properties[l]=zb(Rr({},c),{dynamic:h})}this.allowChildren=!0,this.roundPixels=n!=null?n:!1,this.particleChildren=a!=null?a:[]}addParticle(...t){for(let e=0;e-1&&(this.particleChildren.splice(i,1),e=!0)}return e&&this.onViewUpdate(),t[0]}update(){this._childrenDirty=!0}onViewUpdate(){this._childrenDirty=!0,super.onViewUpdate()}get bounds(){return rD}updateBounds(){}destroy(t=!1){var e,s,i;if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const n=typeof t=="boolean"?t:t==null?void 0:t.textureSource,o=(s=this.texture)!=null?s:(e=this.particleChildren[0])==null?void 0:e.texture;o&&o.destroy(n)}this.texture=null,(i=this.shader)==null||i.destroy()}removeParticles(t,e){t!=null||(t=0),e!=null||(e=this.particleChildren.length);const s=this.particleChildren.splice(t,e-t);return this.onViewUpdate(),s}removeParticleAt(t){const e=this.particleChildren.splice(t,1);return this.onViewUpdate(),e[0]}addParticleAt(t,e){return this.particleChildren.splice(e,0,t),this.onViewUpdate(),t}addChild(...t){throw new Error("ParticleContainer.addChild() is not available. Please use ParticleContainer.addParticle()")}removeChild(...t){throw new Error("ParticleContainer.removeChild() is not available. Please use ParticleContainer.removeParticle()")}removeChildren(t,e){throw new Error("ParticleContainer.removeChildren() is not available. Please use ParticleContainer.removeParticles()")}removeChildAt(t){throw new Error("ParticleContainer.removeChildAt() is not available. Please use ParticleContainer.removeParticleAt()")}getChildAt(t){throw new Error("ParticleContainer.getChildAt() is not available. Please use ParticleContainer.getParticleAt()")}setChildIndex(t,e){throw new Error("ParticleContainer.setChildIndex() is not available. Please use ParticleContainer.setParticleIndex()")}getChildIndex(t){throw new Error("ParticleContainer.getChildIndex() is not available. Please use ParticleContainer.getParticleIndex()")}addChildAt(t,e){throw new Error("ParticleContainer.addChildAt() is not available. Please use ParticleContainer.addParticleAt()")}swapChildren(t,e){throw new Error("ParticleContainer.swapChildren() is not available. Please use ParticleContainer.swapParticles()")}reparentChild(...t){throw new Error("ParticleContainer.reparentChild() is not available with the particle container")}reparentChildAt(t,e){throw new Error("ParticleContainer.reparentChildAt() is not available with the particle container")}};Vb.defaultOptions={dynamicProperties:{vertex:!1,position:!0,rotation:!1,uvs:!1,color:!1},roundPixels:!1};let sD=Vb;var iD=Object.defineProperty,In=Object.getOwnPropertySymbols,Wb=Object.prototype.hasOwnProperty,Yb=Object.prototype.propertyIsEnumerable,qb=(r,t,e)=>t in r?iD(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nD=(r,t)=>{for(var e in t||(t={}))Wb.call(t,e)&&qb(r,e,t[e]);if(In)for(var e of In(t))Yb.call(t,e)&&qb(r,e,t[e]);return r},oD=(r,t)=>{var e={};for(var s in r)Wb.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&In)for(var s of In(r))t.indexOf(s)<0&&Yb.call(r,s)&&(e[s]=r[s]);return e};const Kb=class ev extends ae{constructor(t){var e,s,i,n,o,a,u,l,c,h;t instanceof C&&(t={texture:t});const d=t,{width:p,height:f,anchor:g,leftWidth:m,rightWidth:_,topHeight:b,bottomHeight:x,texture:y,roundPixels:A}=d,T=oD(d,["width","height","anchor","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]);super(nD({label:"NineSliceSprite"},T)),this.renderPipeId="nineSliceSprite",this.batched=!0,this._leftWidth=(s=m!=null?m:(e=y==null?void 0:y.defaultBorders)==null?void 0:e.left)!=null?s:ye.defaultOptions.leftWidth,this._topHeight=(n=b!=null?b:(i=y==null?void 0:y.defaultBorders)==null?void 0:i.top)!=null?n:ye.defaultOptions.topHeight,this._rightWidth=(a=_!=null?_:(o=y==null?void 0:y.defaultBorders)==null?void 0:o.right)!=null?a:ye.defaultOptions.rightWidth,this._bottomHeight=(l=x!=null?x:(u=y==null?void 0:y.defaultBorders)==null?void 0:u.bottom)!=null?l:ye.defaultOptions.bottomHeight,this._width=(c=p!=null?p:y.width)!=null?c:ye.defaultOptions.width,this._height=(h=f!=null?f:y.height)!=null?h:ye.defaultOptions.height,this.allowChildren=!1,this.texture=y!=null?y:ev.defaultOptions.texture,this.roundPixels=A!=null?A:!1,this._anchor=new q({_onUpdate:()=>{this.onViewUpdate()}}),g?this.anchor=g:this.texture.defaultAnchor&&(this.anchor=this.texture.defaultAnchor)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return this._width}set width(t){this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this._height=t,this.onViewUpdate()}setSize(t,e){var s;typeof t=="object"&&(e=(s=t.height)!=null?s:t.width,t=t.width),this._width=t,this._height=e!=null?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=C.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}updateBounds(){const t=this._bounds,e=this._anchor,s=this._width,i=this._height;t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*i,t.maxY=t.minY+i}};Kb.defaultOptions={texture:C.EMPTY};let Zb=Kb;class aD extends Zb{constructor(...t){let e=t[0];e instanceof C&&(e={texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}),super(e)}}function Qb(r){const{text:t,style:e,chars:s}=r,i=e,n=br.getFont(t,i),o=pt.graphemeSegmenter(t),a=ki(o,i,n,!0),u=a.scale,l=[],c=[],h=[],d=e.lineHeight?e.lineHeight:n.lineHeight*u;let p=0;for(const f of a.lines){if(f.chars.length===0)continue;const g=new et({label:"line"});g.y=p,h.push(g);let m=new et({label:"word"}),_=0;for(let b=0;b0?(T=s.shift(),T.text=x,T.style=i,T.label=`char-${x}`,T.x=f.charPositions[b]*u-f.charPositions[_]*u):T=new Yu({text:x,style:i,label:`char-${x}`,x:f.charPositions[b]*u-f.charPositions[_]*u}),y||(l.push(T),m.addChild(T)),(y||A)&&m.children.length>0&&(m.x=f.charPositions[_]*u,c.push(m),g.addChild(m),m=new et({label:"word"}),_=b+1)}p+=d}return{chars:l,lines:h,words:c}}var Jb=Object.getOwnPropertySymbols,uD=Object.prototype.hasOwnProperty,lD=Object.prototype.propertyIsEnumerable,cD=(r,t)=>{var e={};for(var s in r)uD.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Jb)for(var s of Jb(r))t.indexOf(s)<0&&lD.call(r,s)&&(e[s]=r[s]);return e};class bc extends et{constructor(t){const e=t,{text:s,style:i,autoSplit:n,lineAnchor:o,wordAnchor:a,charAnchor:u}=e,l=cD(e,["text","style","autoSplit","lineAnchor","wordAnchor","charAnchor"]);super(l),this._dirty=!1,this._canReuseChars=!1,this.chars=[],this.words=[],this.lines=[],this._originalText=s,this._autoSplit=n,this._lineAnchor=o,this._wordAnchor=a,this._charAnchor=u,this.style=i}split(){const t=this.splitFn();this.chars=t.chars,this.words=t.words,this.lines=t.lines,this.addChild(...this.lines),this.charAnchor=this._charAnchor,this.wordAnchor=this._wordAnchor,this.lineAnchor=this._lineAnchor,this._dirty=!1,this._canReuseChars=!0}get text(){return this._originalText}set text(t){this._originalText=t,this.lines.forEach(e=>e.destroy({children:!0})),this.lines.length=0,this.words.length=0,this.chars.length=0,this._canReuseChars=!1,this.onTextUpdate()}_setOrigin(t,e,s){let i;typeof t=="number"?i={x:t,y:t}:i={x:t.x,y:t.y},e.forEach(n=>{const o=n.getLocalBounds(),a=o.minX+o.width*i.x,u=o.minY+o.height*i.y;n.origin.set(a,u)}),this[s]=t}get lineAnchor(){return this._lineAnchor}set lineAnchor(t){this._setOrigin(t,this.lines,"_lineAnchor")}get wordAnchor(){return this._wordAnchor}set wordAnchor(t){this._setOrigin(t,this.words,"_wordAnchor")}get charAnchor(){return this._charAnchor}set charAnchor(t){this._setOrigin(t,this.chars,"_charAnchor")}get style(){return this._style}set style(t){t||(t={}),this._style=new Bt(t),this.words.forEach(e=>e.destroy()),this.words.length=0,this.lines.forEach(e=>e.destroy()),this.lines.length=0,this._canReuseChars=!0,this.onTextUpdate()}onTextUpdate(){this._dirty=!0,this._autoSplit&&this.split()}destroy(t){super.destroy(t),this.chars=[],this.words=[],this.lines=[],(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._originalText=""}}var hD=Object.defineProperty,dD=Object.defineProperties,pD=Object.getOwnPropertyDescriptors,ty=Object.getOwnPropertySymbols,fD=Object.prototype.hasOwnProperty,mD=Object.prototype.propertyIsEnumerable,ey=(r,t,e)=>t in r?hD(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gs=(r,t)=>{for(var e in t||(t={}))fD.call(t,e)&&ey(r,e,t[e]);if(ty)for(var e of ty(t))mD.call(t,e)&&ey(r,e,t[e]);return r},gD=(r,t)=>dD(r,pD(t));const ry=class Ln extends bc{constructor(t){const e=Gs(Gs({},Ln.defaultOptions),t);super(e)}static from(t,e){const s=gD(Gs(Gs({},Ln.defaultOptions),e),{text:t.text,style:new Bt(t.style)});return new Ln(Gs({},s))}splitFn(){return Qb({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};ry.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let _D=ry;function xD(r,t,e){switch(r){case"center":return(e-t)/2;case"right":return e-t;case"left":default:return 0}}function sy(r){return r==="\r"||r===` `||r===`\r `}function bD(r,t,e){const s=[];let i=t.lines[0],n="",o=[],a=0;return e.wordWrap=!1,r.forEach(u=>{const l=/^\s*$/.test(u),c=sy(u),h=n.length===0&&l;if(l&&!c&&h)return;c||(n+=u);const d=pt.measureText(u,e);o.push({char:u,metric:d}),n.length>=i.length&&(s.push({line:n,chars:o,width:o.reduce((p,f)=>p+f.metric.width,0)}),o=[],n="",a++,i=t.lines[a])}),s}function iy(r){var t,e;const{text:s,style:i,chars:n}=r,o=i,a=pt.measureText(s,o),u=pt.graphemeSegmenter(s),l=bD(u,a,o.clone()),c=o.align,h=a.lineWidths.reduce((b,x)=>Math.max(b,x),0),d=[],p=[],f=[];let g=0;const m=((t=o.stroke)==null?void 0:t.width)||0,_=((e=o.dropShadow)==null?void 0:e.distance)||0;return l.forEach((b,x)=>{const y=new et({label:`line-${x}`});y.y=g,p.push(y);const A=a.lineWidths[x];let T=xD(c,A,h),S=new et({label:"word"});S.x=T,b.chars.forEach((D,R)=>{if(D.metric.width!==0){if(sy(D.char)){T+=D.metric.width-m;return}if(D.char===" ")S.children.length>0&&(f.push(S),y.addChild(S)),T+=D.metric.width+o.letterSpacing-m,S=new et({label:"word"}),S.x=T;else{let w;n.length>0?(w=n.shift(),w.text=D.char,w.style=o,w.setFromMatrix(M.IDENTITY),w.x=T-S.x-_*R):w=new gn({text:D.char,style:o,x:T-S.x-_*R}),d.push(w),S.addChild(w),T+=D.metric.width+o.letterSpacing-m}}}),S.children.length>0&&(f.push(S),y.addChild(S)),g+=a.lineHeight}),{chars:d,lines:p,words:f}}var yD=Object.defineProperty,vD=Object.defineProperties,TD=Object.getOwnPropertyDescriptors,ny=Object.getOwnPropertySymbols,AD=Object.prototype.hasOwnProperty,SD=Object.prototype.propertyIsEnumerable,oy=(r,t,e)=>t in r?yD(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fs=(r,t)=>{for(var e in t||(t={}))AD.call(t,e)&&oy(r,e,t[e]);if(ny)for(var e of ny(t))SD.call(t,e)&&oy(r,e,t[e]);return r},ED=(r,t)=>vD(r,TD(t));const ay=class Nn extends bc{constructor(t){const e=Fs(Fs({},Nn.defaultOptions),t);super(e)}static from(t,e){const s=ED(Fs(Fs({},Nn.defaultOptions),e),{text:t.text,style:new Bt(t.style)});return new Nn(Fs({},s))}splitFn(){return iy({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};ay.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let wD=ay;var yc=/iPhone/i,uy=/iPod/i,ly=/iPad/i,cy=/\biOS-universal(?:.+)Mac\b/i,vc=/\bAndroid(?:.+)Mobile\b/i,hy=/Android/i,Pr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Un=/Silk/i,pe=/Windows Phone/i,dy=/\bWindows(?:.+)ARM\b/i,py=/BlackBerry/i,fy=/BB10/i,my=/Opera Mini/i,gy=/\b(CriOS|Chrome)(?:.+)Mobile/i,_y=/Mobile(?:.+)Firefox\b/i,xy=function(r){return typeof r!="undefined"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream=="undefined"};function CD(r){return function(t){return t.test(r)}}function by(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator!="undefined"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,s=e.split("[FBAN");typeof s[1]!="undefined"&&(e=s[0]),s=e.split("Twitter"),typeof s[1]!="undefined"&&(e=s[0]);var i=CD(e),n={apple:{phone:i(yc)&&!i(pe),ipod:i(uy),tablet:!i(yc)&&(i(ly)||xy(t))&&!i(pe),universal:i(cy),device:(i(yc)||i(uy)||i(ly)||i(cy)||xy(t))&&!i(pe)},amazon:{phone:i(Pr),tablet:!i(Pr)&&i(Un),device:i(Pr)||i(Un)},android:{phone:!i(pe)&&i(Pr)||!i(pe)&&i(vc),tablet:!i(pe)&&!i(Pr)&&!i(vc)&&(i(Un)||i(hy)),device:!i(pe)&&(i(Pr)||i(Un)||i(vc)||i(hy))||i(/\bokhttp\b/i)},windows:{phone:i(pe),tablet:i(dy),device:i(pe)||i(dy)},other:{blackberry:i(py),blackberry10:i(fy),opera:i(my),firefox:i(_y),chrome:i(gy),device:i(py)||i(fy)||i(my)||i(_y)||i(gy)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}var yy;const RD=(yy=by.default)!=null?yy:by,PD=RD(globalThis.navigator);async function DD(r,t,e=200){const s=await t.extract.base64(r);await t.encoder.commandFinished;const i=e;console.log(`logging texture ${r.source.width}px ${r.source.height}px`);const n=["font-size: 1px;",`padding: ${i}px 300px;`,`background: url(${s}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}var MD=Object.defineProperty,OD=Object.defineProperties,BD=Object.getOwnPropertyDescriptors,vy=Object.getOwnPropertySymbols,GD=Object.prototype.hasOwnProperty,FD=Object.prototype.propertyIsEnumerable,Ty=(r,t,e)=>t in r?MD(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ay=(r,t)=>{for(var e in t||(t={}))GD.call(t,e)&&Ty(r,e,t[e]);if(vy)for(var e of vy(t))FD.call(t,e)&&Ty(r,e,t[e]);return r},ID=(r,t)=>OD(r,BD(t));const UD=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let kD=0;function Sy(r,t=0,e={color:"#000000"}){r.renderGroup&&(e.color=UD[kD++]);let s="";for(let o=0;o