/*! * PixiJS - v8.1.1 * Compiled Tue, 30 Apr 2024 22:15:03 UTC * * PixiJS is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license */const wx={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},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 Ql=wx;const X={get(){return Ql},set(r){Ql=r}};var Ow=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Cs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Bw(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Gw(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function Iw(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={},Qt={},Jt={};function Cx(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==$e?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==$e?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(r){var t=this.lookupPrefix(r);return t==null}};function mc(r){return r=="<"&&"<"||r==">"&&">"||r=="&"&&"&"||r=='"'&&"""||"&#"+r.charCodeAt()+";"}Sr(gt,W),Sr(gt,W.prototype);function Er(r,t){if(t(r))return!0;if(r=r.firstChild)do if(Er(r,t))return!0;while(r=r.nextSibling)}function wr(){this.ownerDocument=this}function Ix(r,t,e){r&&r._inc++;var s=e.namespaceURI;s===Ar.XMLNS&&(t._nsMap[e.prefix?e.localName:""]=e.value)}function gc(r,t,e,s){r&&r._inc++;var i=e.namespaceURI;i===Ar.XMLNS&&delete t._nsMap[e.prefix?e.localName:""]}function Sn(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 _c(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,Sn(r.ownerDocument,r),t}function Fx(r){return r&&(r.nodeType===W.DOCUMENT_NODE||r.nodeType===W.DOCUMENT_FRAGMENT_NODE||r.nodeType===W.ELEMENT_NODE)}function Ux(r){return r&&(jt(r)||En(r)||re(r)||r.nodeType===W.DOCUMENT_FRAGMENT_NODE||r.nodeType===W.COMMENT_NODE||r.nodeType===W.PROCESSING_INSTRUCTION_NODE)}function re(r){return r&&r.nodeType===W.DOCUMENT_TYPE_NODE}function jt(r){return r&&r.nodeType===W.ELEMENT_NODE}function En(r){return r&&r.nodeType===W.TEXT_NODE}function xc(r,t){var e=r.childNodes||[];if(zt(e,jt)||re(t))return!1;var s=zt(e,re);return!(t&&s&&e.indexOf(s)>e.indexOf(t))}function bc(r,t){var e=r.childNodes||[];function s(n){return jt(n)&&n!==t}if(zt(e,s))return!1;var i=zt(e,re);return!(t&&i&&e.indexOf(i)>e.indexOf(t))}function Nx(r,t,e){if(!Fx(r))throw new rt(_t,"Unexpected parent node type "+r.nodeType);if(e&&e.parentNode!==r)throw new rt(lc,"child not in parent");if(!Ux(t)||re(t)&&r.nodeType!==W.DOCUMENT_NODE)throw new rt(_t,"Unexpected node type "+t.nodeType+" for parent node type "+r.nodeType)}function kx(r,t,e){var s=r.childNodes||[],i=t.childNodes||[];if(t.nodeType===W.DOCUMENT_FRAGMENT_NODE){var n=i.filter(jt);if(n.length>1||zt(i,En))throw new rt(_t,"More than one element or text in fragment");if(n.length===1&&!xc(r,e))throw new rt(_t,"Element in fragment can not be inserted before doctype")}if(jt(t)&&!xc(r,e))throw new rt(_t,"Only one element can be added and only after doctype");if(re(t)){if(zt(s,re))throw new rt(_t,"Only one doctype is allowed");var o=zt(s,jt);if(e&&s.indexOf(o)1||zt(i,En))throw new rt(_t,"More than one element or text in fragment");if(n.length===1&&!bc(r,e))throw new rt(_t,"Element in fragment can not be inserted before doctype")}if(jt(t)&&!bc(r,e))throw new rt(_t,"Only one element can be added and only after doctype");if(re(t)){if(zt(s,function(u){return re(u)&&u!==e}))throw new rt(_t,"Only one doctype is allowed");var o=zt(s,jt);if(e&&s.indexOf(o)0&&Er(e.documentElement,function(i){if(i!==e&&i.nodeType===Ft){var n=i.getAttribute("class");if(n){var o=r===n;if(!o){var a=rc(n);o=t.every(Ox(a))}o&&s.push(i)}}}),s})},createElement:function(r){var t=new Ae;t.ownerDocument=this,t.nodeName=r,t.tagName=r,t.localName=r,t.childNodes=new ee;var e=t.attributes=new Ps;return e._ownerElement=t,t},createDocumentFragment:function(){var r=new Bs;return r.ownerDocument=this,r.childNodes=new ee,r},createTextNode:function(r){var t=new wn;return t.ownerDocument=this,t.appendData(r),t},createComment:function(r){var t=new Cn;return t.ownerDocument=this,t.appendData(r),t},createCDATASection:function(r){var t=new Rn;return t.ownerDocument=this,t.appendData(r),t},createProcessingInstruction:function(r,t){var e=new Dn;return e.ownerDocument=this,e.tagName=e.nodeName=e.target=r,e.nodeValue=e.data=t,e},createAttribute:function(r){var t=new Ms;return t.ownerDocument=this,t.name=r,t.nodeName=r,t.localName=r,t.specified=!0,t},createEntityReference:function(r){var t=new Pn;return t.ownerDocument=this,t.nodeName=r,t},createElementNS:function(r,t){var e=new Ae,s=t.split(":"),i=e.attributes=new Ps;return e.childNodes=new ee,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 Ms,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}},mt(wr,W);function Ae(){this._nsMap={}}Ae.prototype={nodeType:Ft,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===te?this.insertBefore(r,null):Lx(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 He(this,function(t){var e=[];return Er(t,function(s){s!==t&&s.nodeType==Ft&&(r==="*"||s.tagName==r)&&e.push(s)}),e})},getElementsByTagNameNS:function(r,t){return new He(this,function(e){var s=[];return Er(e,function(i){i!==e&&i.nodeType===Ft&&(r==="*"||i.namespaceURI===r)&&(t==="*"||i.localName==t)&&s.push(i)}),s})}},wr.prototype.getElementsByTagName=Ae.prototype.getElementsByTagName,wr.prototype.getElementsByTagNameNS=Ae.prototype.getElementsByTagNameNS,mt(Ae,W);function Ms(){}Ms.prototype.nodeType=$e,mt(Ms,W);function Cr(){}Cr.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(ut[_t])},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}},mt(Cr,W);function wn(){}wn.prototype={nodeName:"#text",nodeType:Rs,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}},mt(wn,Cr);function Cn(){}Cn.prototype={nodeName:"#comment",nodeType:oc},mt(Cn,Cr);function Rn(){}Rn.prototype={nodeName:"#cdata-section",nodeType:sc},mt(Rn,Cr);function Os(){}Os.prototype.nodeType=uc,mt(Os,W);function yc(){}yc.prototype.nodeType=Gx,mt(yc,W);function Tc(){}Tc.prototype.nodeType=Bx,mt(Tc,W);function Pn(){}Pn.prototype.nodeType=ic,mt(Pn,W);function Bs(){}Bs.prototype.nodeName="#document-fragment",Bs.prototype.nodeType=te,mt(Bs,W);function Dn(){}Dn.prototype.nodeType=nc,mt(Dn,W);function Ac(){}Ac.prototype.serializeToString=function(r,t,e){return Sc.call(r,t,e)},W.prototype.toString=Sc;function Sc(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 Xe(this,e,r,t,o),e.join("")}function Ec(r,t,e){var s=r.prefix||"",i=r.namespaceURI;if(!i||s==="xml"&&i===Ar.XML||i===Ar.XMLNS)return!1;for(var n=e.length;n--;){var o=e[n];if(o.prefix===s)return o.namespace!==i}return!0}function Mn(r,t,e){r.push(" ",t,'="',e.replace(/[<>&"\t\n\r]/g,mc),'"')}function Xe(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 Ft:var n=r.attributes,o=n.length,_=r.firstChild,a=r.tagName;e=Ar.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):Xe(_,t,e,s,i.slice()),_=_.nextSibling;else for(;_;)Xe(_,t,e,s,i.slice()),_=_.nextSibling;t.push("")}else t.push("/>");return;case ac:case te:for(var _=r.firstChild;_;)Xe(_,t,e,s,i.slice()),_=_.nextSibling;return;case $e:return Mn(t,r.name,r.value);case Rs:return t.push(r.data.replace(/[<&>]/g,mc));case sc:return t.push("");case oc:return t.push("");case uc: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 nc:return t.push("");case ic:return t.push("&",r.nodeName,";");default:t.push("??",r.nodeName)}}function wc(r,t,e){var s;switch(t.nodeType){case Ft:s=t.cloneNode(!1),s.ownerDocument=r;case te:break;case $e:e=!0;break}if(s||(s=t.cloneNode(!1)),s.ownerDocument=r,s.parentNode=null,e)for(var i=t.firstChild;i;)s.appendChild(wc(r,i,e)),i=i.nextSibling;return s}function On(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 ee),s.ownerDocument=r,s.nodeType){case Ft:var o=t.attributes,a=s.attributes=new Ps,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})(Bn);var oC=Cs(Bn),Gn={},Rr=Jt.NAMESPACE,In=/[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]/,Rc=new RegExp("[\\-\\.0-9"+In.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),Pc=new RegExp("^"+In.source+Rc.source+"*(?::"+In.source+Rc.source+"*)?$"),Pr=0,ue=1,ze=2,Dr=3,je=4,Ve=5,Mr=6,Is=7;function We(r,t){this.message=r,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,We)}We.prototype=new Error,We.prototype.name=We.name;function Dc(){}Dc.prototype={parse:function(r,t,e){var s=this.domBuilder;s.startDocument(),Bc(t,t={}),$x(r,t,e,s,this.errorHandler),s.endDocument()}};function $x(r,t,e,s,i){function n(D){if(D>65535){D-=65536;var Z=55296+(D>>10),Le=56320+(D&1023);return String.fromCharCode(Z,Le)}else return String.fromCharCode(D)}function o(D){var Z=D.slice(1,-1);return Object.hasOwnProperty.call(e,Z)?e[Z]:Z.charAt(0)==="#"?n(parseInt(Z.substr(1).replace("x","0x"))):(i.error("entity not found:"+D),D)}function a(D){if(D>g){var Z=r.substring(g,D).replace(/&#?\w+;/g,o);d&&u(g),s.characters(Z,0,D-g),g=D}}function u(D,Z){for(;D>=c&&(Z=h.exec(r));)l=Z.index,c=l+Z[0].length,d.lineNumber++;d.columnNumber=D-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 G=r.indexOf(">",m+3),x=r.substring(m+2,G).replace(/[ \t\n\r]+$/g,""),y=p.pop();G<0?(x=r.substring(m+2).replace(/[\s<].*/,""),i.error("end tag name: "+x+" is not complete:"+y.tagName),G=m+1+x.length):x.match(/\sg?g=G:a(Math.max(m,g)+1)}}function Mc(r,t){return t.lineNumber=r.lineNumber,t.columnNumber=r.columnNumber,t}function Hx(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=Pr;;){var h=r.charAt(l);switch(h){case"=":if(c===ue)a=r.slice(t,l),c=Dr;else if(c===ze)c=Dr;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(c===Dr||c===ue)if(c===ue&&(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=Ve;else throw new Error("attribute value no end '"+h+"' match");else if(c==je)u=r.slice(t,l),o(a,u,t),n.warning('attribute "'+a+'" missed start quot('+h+")!!"),t=l+1,c=Ve;else throw new Error('attribute value must after "="');break;case"/":switch(c){case Pr:e.setTagName(r.slice(t,l));case Ve:case Mr:case Is:c=Is,e.closed=!0;case je:case ue:break;case ze:e.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return n.error("unexpected end of input"),c==Pr&&e.setTagName(r.slice(t,l)),l;case">":switch(c){case Pr:e.setTagName(r.slice(t,l));case Ve:case Mr:case Is:break;case je:case ue:u=r.slice(t,l),u.slice(-1)==="/"&&(e.closed=!0,u=u.slice(0,-1));case ze:c===ze&&(u=a),c==je?(n.warning('attribute "'+u+'" missed quot(")!'),o(a,u,t)):((!Rr.isHTML(s[""])||!u.match(/^(?:disabled|checked|selected)$/i))&&n.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),o(u,u,t));break;case Dr:throw new Error("attribute value missed!!")}return l;case"\x80":h=" ";default:if(h<=" ")switch(c){case Pr:e.setTagName(r.slice(t,l)),c=Mr;break;case ue:a=r.slice(t,l),c=ze;break;case je:var u=r.slice(t,l);n.warning('attribute "'+u+'" missed quot(")!!'),o(a,u,t);case Ve:c=Mr;break}else switch(c){case ze:var d=e.tagName;(!Rr.isHTML(s[""])||!a.match(/^(?:disabled|checked|selected)$/i))&&n.warning('attribute "'+a+'" missed value!! "'+a+'" instead2!!'),o(a,a,t),t=l,c=ue;break;case Ve:n.warning('attribute space is required"'+a+'"!!');case Mr:c=ue,t=l;break;case Dr:c=je,t=l;break;case Is:throw new Error("elements closed character '/' and '>' must be connected to")}}l++}}function Oc(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={},Bc(e,e={})),e[c]=i[c]=a,n.uri=Rr.XMLNS,t.startPrefixMapping(c,a))}for(var h=r.length;h--;){n=r[h];var u=n.prefix;u&&(u==="xml"&&(n.uri=Rr.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 Xx(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 zx(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=Wx(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 Vx(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 Gc(){this.attributeNames={}}Gc.prototype={setTagName:function(r){if(!Pc.test(r))throw new Error("invalid tagName:"+r);this.tagName=r},addValue:function(r,t,e){if(!Pc.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 Wx(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 aC=Gn.XMLReader=Dc,uC=Gn.ParseError=We,Yx=Jt,qx=Qt,Ic=Bn,Fc=Gn,Kx=qx.DOMImplementation,Uc=Yx.NAMESPACE,Zx=Fc.ParseError,Qx=Fc.XMLReader;function Nc(r){return r.replace(/\r[\n\u0085]/g,` `).replace(/[\r\u0085\u2028]/g,` `)}function kc(r){this.options=r||{locator:{}}}kc.prototype.parseFromString=function(r,t){var e=this.options,s=new Qx,i=e.domBuilder||new Or,n=e.errorHandler,o=e.locator,a=e.xmlns||{},u=/\/x?html?$/.test(t),l=u?Ic.HTML_ENTITIES:Ic.XML_ENTITIES;o&&i.setDocumentLocator(o),s.errorHandler=Jx(n,i,o),s.domBuilder=e.domBuilder||i,u&&(a[""]=Uc.HTML),a.xml=a.xml||Uc.XML;var c=e.normalizeLineEndings||Nc;return r&&typeof r=="string"?s.parse(c(r),a,l):s.errorHandler.error("invalid doc source"),i.doc};function Jx(r,t,e){if(!r){if(t instanceof Or)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+Fn(e))}||function(){}}return n("warning"),n("error"),n("fatalError"),s}function Or(){this.cdata=!1}function Ye(r,t){t.lineNumber=r.lineNumber,t.columnNumber=r.columnNumber}Or.prototype={startDocument:function(){this.doc=new Kx().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;Fs(this,n),this.currentElement=n,this.locator&&Ye(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){Or.prototype[r]=function(){return null}});function Fs(r,t){r.currentElement?r.currentElement.appendChild(t):r.doc.appendChild(t)}var lC=Gs.__DOMHandler=Or,cC=Gs.normalizeLineEndings=Nc,hC=Gs.DOMParser=kc,$c=Qt,dC=yn.DOMImplementation=$c.DOMImplementation,pC=yn.XMLSerializer=$c.XMLSerializer,tb=yn.DOMParser=Gs.DOMParser;const Hc={createCanvas:(r,t)=>new OffscreenCanvas(r!=null?r:0,t!=null?t:0),getCanvasRenderingContext2D:()=>OffscreenCanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>globalThis.location.href,getFontFaceSet:()=>globalThis.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new tb().parseFromString(r,"text/xml")};var eb=Object.defineProperty,rb=Object.defineProperties,sb=Object.getOwnPropertyDescriptors,Xc=Object.getOwnPropertySymbols,ib=Object.prototype.hasOwnProperty,nb=Object.prototype.propertyIsEnumerable,zc=(r,t,e)=>t in r?eb(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jc=(r,t)=>{for(var e in t||(t={}))ib.call(t,e)&&zc(r,e,t[e]);if(Xc)for(var e of Xc(t))nb.call(t,e)&&zc(r,e,t[e]);return r},ob=(r,t)=>rb(r,sb(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))(v||{});const Un=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=ob(jc({},t),{ref:r})}if(typeof r=="object")r=jc({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},Br=(r,t)=>{var e;return(e=Un(r).priority)!=null?e:t},L={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Un).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(Un).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)=>Br(n.value,e)-Br(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)=>Br(n,e)-Br(i,e)))},s=>{const i=t.indexOf(s.ref);i!==-1&&t.splice(i,1)})}};class Nn{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}}Nn.extension=v.Application;var le=(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))(le||{});class Us{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 Vc=class Rt{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 Us(null,null,1/0),this.deltaMS=1/Rt.targetFPMS,this.elapsedMS=1/Rt.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=le.NORMAL){return this._addListener(new Us(t,e,s))}addOnce(t,e,s=le.NORMAL){return this._addListener(new Us(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?yt.shared:new yt,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}kn.extension=v.Application,L.add(Nn),L.add(kn);var Tt=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Tt||{});function Ut(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function Gr(r){return r.split("?")[0].split("#")[0]}function ab(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ub(r,t,e){return r.replace(new RegExp(ab(t),"g"),e)}function lb(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 xt={toPosix(r){return ub(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){Ut(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(Ut(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const s=Gr(this.toPosix(t!=null?t:X.get().getBaseUrl())),i=Gr(this.toPosix(e!=null?e:this.rootname(s)));return r=this.toPosix(r),r.startsWith("/")?xt.join(i,r.slice(1)):this.isAbsolute(r)?r:this.join(s,r)},normalize(r){if(Ut(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=lb(r,!1),r.length>0&&s&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Ut(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(Ut(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){Ut(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){Ut(r),t&&Ut(t),r=Gr(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){Ut(r),r=Gr(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){Ut(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=Gr(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"]},Mt=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(s=>typeof s=="string"||e?t(s):s):r);function Wc(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)}),Wc(r,i,0,e,s)}else s.push(r);return s}const Ir=r=>!Array.isArray(r);var cb=Object.defineProperty,hb=Object.defineProperties,db=Object.getOwnPropertyDescriptors,qc=Object.getOwnPropertySymbols,pb=Object.prototype.hasOwnProperty,fb=Object.prototype.propertyIsEnumerable,Kc=(r,t,e)=>t in r?cb(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qe=(r,t)=>{for(var e in t||(t={}))pb.call(t,e)&&Kc(r,e,t[e]);if(qc)for(var e of qc(t))fb.call(t,e)&&Kc(r,e,t[e]);return r},mb=(r,t)=>hb(r,db(t));class ce{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 Mt(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}:qe({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(mb(qe({},n),{alias:u,src:o}))}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;Mt(e).forEach(i=>{const{src:n}=i;let{data:o,format:a,loadParser:u}=i;const l=Mt(n).map(d=>typeof d=="string"?Yc(d):Array.isArray(d)?d:[d]),c=this.getAlias(i),h=[];l.forEach(d=>{d.forEach(p=>{var f,g,m;let _={};if(typeof p!="object"){_.src=p;for(let b=0;b{this._assetMap[d]=h})})}resolveBundle(t){const e=Ir(t);t=Mt(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=Ir(t);t=Mt(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,format:u}=e;return(this._basePath||this._rootPath)&&(t.src=xt.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=qe(qe({},o||{}),t.data),t.loadParser=a!=null?a:t.loadParser,t.format=(i=u!=null?u:t.format)!=null?i:Zc(t.src),t}}ce.RETINA_PREFIX=/@([0-9\.]+)x/;function Zc(r){return r.split(".").pop().split("?").shift().split("#").shift()}const Ns=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};var Ln={exports:{}},fC=Ln.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);dSe[r],uY:r=>Ee[r],vX:r=>we[r],vY:r=>Ce[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Hn[r][t],sub:(r,t)=>Hn[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=eh[k.inv(t)];i.tx=e,i.ty=s,r.append(i)}},Ls=[new it,new it,new it,new it];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=u&&t<=l&&e>=c&&e<=h&&!(t>d&&tf&&et.right?t.right:this.right)<=R)return!1;const T=this.yt.bottom?t.bottom:this.bottom)>T}const s=this.left,i=this.right,n=this.top,o=this.bottom;if(i<=s||o<=n)return!1;const a=Ls[0].set(t.left,t.top),u=Ls[1].set(t.left,t.bottom),l=Ls[2].set(t.right,t.top),c=Ls[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,C=b*s+x*o,E=b*i+x*o;return!(Math.max(y,A,C,E)<=b*a.x+x*a.y||Math.min(y,A,C,E)>=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}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}}const Fr={default:-1};function J(r="default"){return Fr[r]===void 0&&(Fr[r]=-1),++Fr[r]}function vb(){for(const r in Fr)delete Fr[r]}const Xn=()=>{};function Re(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 zn(r){return!(r&r-1)&&!!r}function yb(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 he(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var Tb=Object.defineProperty,rh=Object.getOwnPropertySymbols,Ab=Object.prototype.hasOwnProperty,Sb=Object.prototype.propertyIsEnumerable,sh=(r,t,e)=>t in r?Tb(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ih=(r,t)=>{for(var e in t||(t={}))Ab.call(t,e)&&sh(r,e,t[e]);if(rh)for(var e of rh(t))Sb.call(t,e)&&sh(r,e,t[e]);return r};const nh=Object.create(null);function Eb(r){const t=nh[r];return t===void 0&&(nh[r]=J("resource")),t}const oh=class J2 extends At{constructor(t={}){var e,s,i,n,o,a,u;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=ih(ih({},J2.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=Eb(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};oh.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let ah=oh;var wb=Object.defineProperty,uh=Object.getOwnPropertySymbols,Cb=Object.prototype.hasOwnProperty,Rb=Object.prototype.propertyIsEnumerable,lh=(r,t,e)=>t in r?wb(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ch=(r,t)=>{for(var e in t||(t={}))Cb.call(t,e)&&lh(r,e,t[e]);if(uh)for(var e of uh(t))Rb.call(t,e)&&lh(r,e,t[e]);return r};const hh=class tx extends At{constructor(t={}){var e,s,i;super(),this.options=t,this.uid=J("textureSource"),this._resourceType="textureSource",this._resourceId=J("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=ch(ch({},tx.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 ah(he(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())}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=J("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=J("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=zn(this.pixelWidth)&&zn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};hh.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let st=hh;var Pb=Object.defineProperty,Db=Object.defineProperties,Mb=Object.getOwnPropertyDescriptors,dh=Object.getOwnPropertySymbols,Ob=Object.prototype.hasOwnProperty,Bb=Object.prototype.propertyIsEnumerable,ph=(r,t,e)=>t in r?Pb(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gb=(r,t)=>{for(var e in t||(t={}))Ob.call(t,e)&&ph(r,e,t[e]);if(dh)for(var e of dh(t))Bb.call(t,e)&&ph(r,e,t[e]);return r},Ib=(r,t)=>Db(r,Mb(t));class $s extends st{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(Ib(Gb({},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}}$s.extension=v.TextureSource;const fh=new B;class jn{constructor(t,e){this.mapCoord=new B,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<=ys.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=ys.BATCH_SIZE;for(;e-t{this._batchIndex*ys.BATCH_SIZE{s[i]=t}),Object.keys(t.textures).forEach(i=>{s[i]=t.textures[i]}),!e){const i=xt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=gh([`${i}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const _h={extension:v.Asset,cache:{test:r=>r instanceof Vn,getCacheableAssets:(r,t)=>gh(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),s=t.pop();return e==="json"&&Fb.includes(s)},parse:r=>{var t,e;const s=r.split(".");return{resolution:parseFloat((e=(t=ce.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s[s.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:v.LoadParser,priority:Tt.Normal},async testParse(r,t){return xt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var s,i,n;const{texture:o,imageFilename:a}=(s=t==null?void 0:t.data)!=null?s:{};let u=xt.dirname(t.src);u&&u.lastIndexOf("/")!==u.length-1&&(u+="/");let l;if(o instanceof w)l=o;else{const d=Ns(u+(a!=null?a:r.meta.image),t.src);l=(await e.load([d]))[d]}const c=new Vn(l.source,r);await c.parse();const h=(i=r==null?void 0:r.meta)==null?void 0:i.related_multi_packs;if(Array.isArray(h)){const d=[];for(const f of h){if(typeof f!="string")continue;let g=u+f;(n=t.data)!=null&&n.ignoreMultiPack||(g=Ns(g,t.src),d.push(e.load({src:g,data:{ignoreMultiPack:!0}})))}const p=await Promise.all(d);c.linkedSheets=p,p.forEach(f=>{f.linkedSheets=[c].concat(c.linkedSheets.filter(g=>g!==f))})}return c},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};L.add(_h);class nt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new nt(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 Ur(r,t,e,s){const{width:i,height:n}=e.orig,o=e.trim;if(o){const a=o.width,u=o.height;r.minX=o.x-t._x*i-s,r.maxX=r.minX+a,r.minY=o.y-t._y*n-s,r.maxY=r.minY+u}else r.minX=-t._x*i-s,r.maxX=r.minX+i,r.minY=-t._y*n-s,r.maxY=r.minY+n}var Ub={grad:.9,turn:360,rad:360/(2*Math.PI)},se=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},lt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},Ot=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},xh=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},bh=function(r){return{r:Ot(r.r,0,255),g:Ot(r.g,0,255),b:Ot(r.b,0,255),a:Ot(r.a)}},Wn=function(r){return{r:lt(r.r),g:lt(r.g),b:lt(r.b),a:lt(r.a,3)}},Nb=/^#([0-9a-f]{3,8})$/i,Hs=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},vh=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}},yh=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}},Th=function(r){return{h:xh(r.h),s:Ot(r.s,0,100),l:Ot(r.l,0,100),a:Ot(r.a)}},Ah=function(r){return{h:lt(r.h),s:lt(r.s),l:lt(r.l),a:lt(r.a,3)}},Sh=function(r){return yh((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},Nr=function(r){return{h:(t=vh(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},kb=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Lb=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$b=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Hb=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Yn={string:[[function(r){var t=Nb.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?lt(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?lt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=$b.exec(r)||Hb.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:bh({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=kb.exec(r)||Lb.exec(r);if(!t)return null;var e,s,i=Th({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(Ub[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Sh(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 se(t)&&se(e)&&se(s)?bh({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(!se(t)||!se(e)||!se(s))return null;var o=Th({h:Number(t),s:Number(e),l:Number(s),a:Number(n)});return Sh(o)},"hsl"],[function(r){var t=r.h,e=r.s,s=r.v,i=r.a,n=i===void 0?1:i;if(!se(t)||!se(e)||!se(s))return null;var o=function(a){return{h:xh(a.h),s:Ot(a.s,0,100),v:Ot(a.v,0,100),a:Ot(a.a)}}({h:Number(t),s:Number(e),v:Number(s),a:Number(n)});return yh(o)},"hsv"]]},Eh=function(r,t){for(var e=0;e=.5},r.prototype.toHex=function(){return t=Wn(this.rgba),e=t.r,s=t.g,i=t.b,o=(n=t.a)<1?Hs(lt(255*n)):"","#"+Hs(e)+Hs(s)+Hs(i)+o;var t,e,s,i,n,o},r.prototype.toRgb=function(){return Wn(this.rgba)},r.prototype.toRgbString=function(){return t=Wn(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 Ah(Nr(this.rgba))},r.prototype.toHslString=function(){return t=Ah(Nr(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=vh(this.rgba),{h:lt(t.h),s:lt(t.s),v:lt(t.v),a:lt(t.a,3)};var t},r.prototype.invert=function(){return Vt({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),Vt(qn(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),Vt(qn(this.rgba,-t))},r.prototype.grayscale=function(){return Vt(qn(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),Vt(Ch(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),Vt(Ch(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"?Vt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):lt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=Nr(this.rgba);return typeof t=="number"?Vt({h:t,s:e.s,l:e.l,a:e.a}):lt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===Vt(t).toHex()},r}(),Vt=function(r){return r instanceof Xs?r:new Xs(r)},Rh=[],Xb=function(r){r.forEach(function(t){Rh.indexOf(t)<0&&(t(Xs,Yn),Rh.push(t))})},gC=function(){return new Xs({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function zb(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?jb(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yb=(r,t)=>{for(var e in t||(t={}))Vb.call(t,e)&&Dh(r,e,t[e]);if(Ph)for(var e of Ph(t))Wb.call(t,e)&&Dh(r,e,t[e]);return r};Xb([zb]);const Ke=class Ts{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 Ts)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._normalize(t),this._value=this._cloneSource(t))}}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?Yb({},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]=Ts._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=Ts.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Vt(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 Ts||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}};Ke.shared=new Ke,Ke._temp=new Ke,Ke.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Y=Ke;const Mh={cullArea:null,cullable:!1,cullableChildren:!0};function Oh(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&&s<=e){for(let n=e-1;n>=r;n--){const o=this.children[n];o&&(this.renderGroup&&this.renderGroup.removeChild(o),i.push(o),o.parent=null)}Oh(this.children,r,e);for(let n=0;n=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 s=r.parent.children.indexOf(r);if(r.parent===this&&s===t)return r;s!==-1&&r.parent.children.splice(s,1)}return t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r.didViewUpdate=!1,r._updateFlags=15,this.renderGroup&&this.renderGroup.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},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)}};class zs{constructor(t){this.pipe="filter",this.priority=1,this.filters=t==null?void 0:t.filters,this.filterArea=t==null?void 0:t.filterArea}destroy(){for(let t=0;t0?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}}class Gh{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 js(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 z=new Gh;class Ih{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(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.priority-e.priority),this.renderGroup&&(this.renderGroup.structureDidChange=!0),this._updateIsSimple())},removeEffect(r){const t=this.effects.indexOf(r);t!==-1&&(this.effects.splice(t,1),!this.isRenderGroupRoot&&this.renderGroup&&(this.renderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(r){if(this._mask||(this._mask={mask:null,effect:null}),this._mask.mask===r||(this._mask.effect&&(this.removeEffect(this._mask.effect),Vs.returnMaskEffect(this._mask.effect),this._mask.effect=null),this._mask.mask=r,r==null))return;const t=Vs.getMaskEffect(r);this._mask.effect=t,this.addEffect(t)},get mask(){var r;return(r=this._mask)==null?void 0:r.mask},set filters(r){!Array.isArray(r)&&r&&(r=[r]),r=r,this._filters||(this._filters={filters:null,effect:null,filterArea:null});const t=(r==null?void 0:r.length)>0,e=this._filters.effect&&!t||!this._filters.effect&&t;if(r=Array.isArray(r)?r.slice(0):r,this._filters.filters=Object.freeze(r),e)if(t){const s=z.get(zs);this._filters.effect=s,this.addEffect(s)}else{const s=this._filters.effect;this.removeEffect(s),s.filterArea=null,s.filters=null,this._filters.effect=null,z.return(s)}t&&(this._filters.effect.filters=r,this._filters.effect.filterArea=this.filterArea)},get filters(){var r;return(r=this._filters)==null?void 0:r.filters},set filterArea(r){this._filters||(this._filters={filters:null,effect:null,filterArea:null}),this._filters.filterArea=r},get filterArea(){var r;return(r=this._filters)==null?void 0:r.filterArea}},Uh={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;sthis.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=Nh,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 pt(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}]`}}const Wt=new js(B),Yt=new js(pt);function kr(r,t,e){e.clear();let s,i;return r.parent?t?s=r.parent.worldTransform:(i=Wt.get().identity(),s=Lr(r,i)):s=B.IDENTITY,Zn(r,e,s,t),i&&Wt.return(i),e.isValid||e.set(0,0,0,0),e}function Zn(r,t,e,s){var i,n;if(!r.visible||!r.measurable)return;let o;s?o=r.worldTransform:(r.updateLocalTransform(),o=Wt.get(),o.appendFrom(r.localTransform,e));const a=t,u=!!r.effects.length;if(u&&(t=Yt.get().clear()),r.boundsArea)t.addRect(r.boundsArea,o);else{r.addBounds&&(t.matrix=o,r.addBounds(t));for(let l=0;l>12&&(r.didChange=!0,r.data[0]=this._didChangeId>>12),Qn(this,r),r.didChange&&Ws(this,r.localBounds,qb),r.localBounds},getBounds(r,t){return kr(this,r,t||new pt)}},Hh={_onRender:null,set onRender(r){const t=this.renderGroup;if(!r){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=r},get onRender(){return this._onRender}},Xh={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(r){this._zIndex!==r&&(this._zIndex=r,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.renderGroup&&!this.isRenderGroupRoot&&(this.renderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(Kb))}};function Kb(r,t){return r._zIndex-t._zIndex}const zh={getGlobalPosition(r=new it,t=!1){return this.parent?this.parent.toGlobal(this._position,r,t):(r.x=this._position.x,r.y=this._position.y),r},toGlobal(r,t,e=!1){if(!e){this.updateLocalTransform();const s=Lr(this,new B);return s.append(this.localTransform),s.apply(r,t)}return this.worldTransform.apply(r,t)},toLocal(r,t,e,s){if(t&&(r=t.toGlobal(r,e,s)),!s){this.updateLocalTransform();const i=Lr(this,new B);return i.append(this.localTransform),i.applyInverse(r,e)}return this.worldTransform.applyInverse(r,e)}};class Jn{constructor(){this.uid=J("instructionSet"),this.instructions=[],this.instructionSize=0}reset(){this.instructionSize=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class jh{constructor(t){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this._children=[],this.worldTransform=new B,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new Jn,this._onRenderContainers=[],this.root=t,this.addChild(t)}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.onChildUpdate(t.root),this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){t.root.didChange&&this._removeChildFromUpdate(t.root);const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t!==this.root&&(this._children.push(t),t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1),t.renderGroup){if(t.renderGroup.root===t){this.addRenderGroupChild(t.renderGroup);return}}else t.renderGroup=this,t.didChange=!0;t._onRender&&(t.isRenderGroupRoot?t.renderGroup.root===t&&this.addOnRender(t):this.addOnRender(t));const e=t.children;t.isRenderGroupRoot||this.onChildUpdate(t);for(let s=0;s-1&&this._children.splice(e,1)}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(t.didViewUpdate=!1,this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t))}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}_removeChildFromUpdate(t){const e=this.childrenToUpdate[t.relativeRenderGroupDepth];if(!e)return;const s=e.list.indexOf(t);s>-1&&e.list.splice(s,1),e.index--}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;tthis.addChild(i)),this.effects=[],(s=t.parent)==null||s.addChild(this)}static mixin(t){Object.defineProperties(K.prototype,Object.getOwnPropertyDescriptors(t))}addChild(...t){if(t.length>1){for(let s=0;s1){for(let i=0;i-1&&(this._didChangeId+=4096,this.children.splice(s,1),this.renderGroup&&this.renderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,s),e.emit("removed",this)),e}_onUpdate(t){if(t&&t===this._skew&&this._updateSkew(),this._didChangeId++,!this.didChange)if(this.didChange=!0,this.isRenderGroupRoot){const e=this.renderGroup.renderGroupParent;e&&e.onChildUpdate(this)}else this.renderGroup&&this.renderGroup.onChildUpdate(this)}set isRenderGroup(t){if(this.isRenderGroupRoot&&t===!1)throw new Error("[Pixi] cannot undo a render group just yet");t&&this.enableRenderGroup()}get isRenderGroup(){return this.isRenderGroupRoot}enableRenderGroup(){if(this.renderGroup&&this.renderGroup.root===this)return;this.isRenderGroupRoot=!0;const t=this.renderGroup;if(t&&t.removeChild(this),this.renderGroup=new jh(this),t){for(let e=0;e>16&255)}set blendMode(t){this.localBlendMode!==t&&(this.renderGroup&&!this.isRenderGroupRoot&&(this.renderGroup.structureDidChange=!0),this._updateFlags|=so,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?1:0;(this.localDisplayStatus&2)>>1!==e&&(this.renderGroup&&!this.isRenderGroupRoot&&(this.renderGroup.structureDidChange=!0),this._updateFlags|=$r,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?1:0;(this.localDisplayStatus&4)>>2!==e&&(this.renderGroup&&!this.isRenderGroupRoot&&(this.renderGroup.structureDidChange=!0),this._updateFlags|=$r,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|=$r,this.localDisplayStatus^=1,this.renderGroup&&!this.isRenderGroupRoot&&(this.renderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){if(this.destroyed)return;this.destroyed=!0,this.removeFromParent(),this.parent=null,this._mask=null,this._filters=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners();const e=typeof t=="boolean"?t:t==null?void 0:t.children,s=this.removeChildren(0,this.children.length);if(e)for(let i=0;it in r?Qb(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jb=(r,t)=>{for(var e in t||(t={}))Wh.call(t,e)&&qh(r,e,t[e]);if(qs)for(var e of qs(t))Yh.call(t,e)&&qh(r,e,t[e]);return r},tv=(r,t)=>{var e={};for(var s in r)Wh.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&qs)for(var s of qs(r))t.indexOf(s)<0&&Yh.call(r,s)&&(e[s]=r[s]);return e};class Xt extends K{constructor(t=w.EMPTY){t instanceof w&&(t={texture:t});const e=t,{texture:s,anchor:i,roundPixels:n,width:o,height:a}=e,u=tv(e,["texture","anchor","roundPixels","width","height"]);super(Jb({label:"Sprite"},u)),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._bounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._boundsDirty=!0,this._sourceBoundsDirty=!0,this._roundPixels=0,this._anchor=new nt({_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&&(this.width=o),a&&(this.height=a)}static from(t,e=!1){return t instanceof w?new Xt(t):new Xt(w.from(t,e))}set texture(t){t||(t=w.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}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get sourceBounds(){return this._sourceBoundsDirty&&(this._updateSourceBounds(),this._sourceBoundsDirty=!1),this._sourceBounds}containsPoint(t){const e=this.sourceBounds;return t.x>=e.maxX&&t.x<=e.minX&&t.y>=e.maxY&&t.y<=e.minY}addBounds(t){const e=this._texture.trim?this.sourceBounds:this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}onViewUpdate(){this._didChangeId+=4096,this._didSpriteUpdate=!0,this._sourceBoundsDirty=this._boundsDirty=!0,!this.didViewUpdate&&(this.didViewUpdate=!0,this.renderGroup&&this.renderGroup.onChildViewUpdate(this))}_updateBounds(){Ur(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,s=this._sourceBounds,{width:i,height:n}=e.orig;s.maxX=-t._x*i,s.minX=s.maxX+i,s.maxY=-t._y*n,s.minY=s.maxY+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._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width)}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height)}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;let i,n;typeof t!="object"?(i=t,n=e!=null?e:t):(i=t.width,n=(s=t.height)!=null?s:t.width),i!==void 0&&this._setWidth(i,this._texture.orig.width),n!==void 0&&this._setHeight(n,this._texture.orig.height)}}const ev=new pt;function Ks(r,t,e){const s=ev;r.measurable=!0,kr(r,e,s),t.addBoundsMask(s),r.measurable=!1}function Zs(r,t,e){const s=Yt.get();r.measurable=!0;const i=Wt.get().identity(),n=io(r,e,i);Ws(r,s,n),r.measurable=!1,t.addBoundsMask(s),Wt.return(i),Yt.return(s)}function io(r,t,e){return r&&r!==t&&(io(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class no{constructor(t){this.priority=0,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Xt),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){Ks(this.mask,t,e)}addLocalBounds(t,e){Zs(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Xt}}no.extension=v.MaskEffect;class oo{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"}}oo.extension=v.MaskEffect;class ao{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){Ks(this.mask,t,e)}addLocalBounds(t,e){Zs(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof K}}ao.extension=v.MaskEffect;class Pe extends st{constructor(t){t.resource||(t.resource=X.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;const e=t.resource;(this.pixelWidth!==e.width||this.pixelWidth!==e.height)&&this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&(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}}Pe.extension=v.TextureSource;class De extends st{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=X.get().createCanvas(t.resource.width,t.resource.height);e.getContext("2d").drawImage(t.resource,0,0),t.resource=e}super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap}}De.extension=v.TextureSource;let uo;async function lo(){return uo!=null||(uo=(async()=>{var r;const t=document.createElement("canvas").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"})()),uo}var rv=Object.defineProperty,sv=Object.defineProperties,iv=Object.getOwnPropertyDescriptors,Kh=Object.getOwnPropertySymbols,nv=Object.prototype.hasOwnProperty,ov=Object.prototype.propertyIsEnumerable,Zh=(r,t,e)=>t in r?rv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,co=(r,t)=>{for(var e in t||(t={}))nv.call(t,e)&&Zh(r,e,t[e]);if(Kh)for(var e of Kh(t))ov.call(t,e)&&Zh(r,e,t[e]);return r},av=(r,t)=>sv(r,iv(t));const Qs=class ex extends st{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=co(co({},ex.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=yt.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 lo(),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&&(yt.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||(yt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(yt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||globalThis.VideoFrame&&t instanceof VideoFrame}};Qs.extension=v.TextureSource,Qs.defaultOptions=av(co({},st.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),Qs.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Hr=Qs,uv=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=Mt(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 q=new uv,ho=[];L.handleByList(v.TextureSource,ho);function Qh(r={}){const t=r&&r.resource,e=t?r.resource:r,s=t?r:{resource:r};for(let i=0;i{q.has(s)&&q.remove(s)}),t||q.set(s,n),n}function td(r,t=!1){return typeof r=="string"?q.get(r):r instanceof st?new w({source:r}):Jh(r,t)}w.from=td,L.add(no,oo,ao,Hr,De,Pe,$s);var $=(r=>(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 St extends At{constructor(t){let{data:e,size:s}=t;const{usage:i,label:n,shrinkToFit:o}=t;super(),this.uid=J("buffer"),this._resourceType="buffer",this._resourceId=J("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s=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 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,i.length!==t.length){!this.shrinkToFit&&t.byteLengtha&&(a=p),f>u&&(u=f),pe.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const cv=new Float32Array(1),hv=new Uint32Array(1);class fo extends Ze{constructor(){const t=new St({data:cv,label:"attribute-batch-buffer",usage:$.VERTEX|$.COPY_DST,shrinkToFit:!1}),e=new St({data:hv,label:"index-batch-buffer",usage:$.INDEX|$.COPY_DST,shrinkToFit:!1}),s=6*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:s,offset:0,location:1},aUV:{buffer:t,format:"float32x2",stride:s,offset:2*4,location:3},aColor:{buffer:t,format:"unorm8x4",stride:s,offset:4*4,location:0},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:s,offset:5*4,location:2}},indexBuffer:e})}}class qt{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 Bt=16,rd={};function Js(r,t){let e=0;for(let s=0;s>>0;return rd[e]||dv(r,e)}function dv(r,t){const e={};let s=0;for(let n=0;n0){const n=new Uint8Array(r,e*8,i);new Uint8Array(t,e*8,i).set(n)}}const sd={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var ot=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",r[r.NONE=4]="NONE",r))(ot||{});function go(r,t){return t.alphaMode==="no-premultiply-alpha"&&sd[r]||r}class _o{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;tt in r?pv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,od=(r,t)=>{for(var e in t||(t={}))fv.call(t,e)&&nd(r,e,t[e]);if(id)for(var e of id(t))mv.call(t,e)&&nd(r,e,t[e]);return r};class xo{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}let Xr=0;const ad=class rx{constructor(t={}){this.uid=J("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._vertexSize=6,this._elements=[],this._batchPool=[],this._batchPoolIndex=0,this._textureBatchPool=[],this._textureBatchPoolIndex=0,t=od(od({},rx.defaultOptions),t);const{vertexSize:e,indexSize:s}=t;this.attributeBuffer=new mo(e*this._vertexSize*4),this.indexBuffer=new Uint16Array(s)}begin(){this.batchIndex=0,this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0,this._batchPoolIndex=0,this._textureBatchPoolIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t.indexStart=this.indexSize,t.location=this.attributeSize,t.batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.vertexSize*this._vertexSize}checkAndUpdateTexture(t,e){const s=t.batch.textures.ids[e._source.uid];return!s&&s!==0?!1:(t.textureId=s,t.texture=e,!0)}updateElement(t){this.dirty=!0,t.packAttributes(this.attributeBuffer.float32View,this.attributeBuffer.uint32View,t.location,t.textureId)}break(t){const e=this._elements;let s=this._textureBatchPool[this._textureBatchPoolIndex++]||new _o;if(s.clear(),!e[this.elementStart])return;const i=e[this.elementStart];let n=go(i.blendMode,i.texture._source);this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const o=this.attributeBuffer.float32View,a=this.attributeBuffer.uint32View,u=this.indexBuffer;let l=this._batchIndexSize,c=this._batchIndexStart,h="startBatch",d=this._batchPool[this._batchPoolIndex++]||new xo;for(let p=this.elementStart;p=Bt||_)&&(this._finishBatch(d,c,l-c,s,n,t,h),h="renderBatch",c=l,n=m,s=this._textureBatchPool[this._textureBatchPoolIndex++]||new _o,s.clear(),d=this._batchPool[this._batchPoolIndex++]||new xo,++Xr),f.textureId=g._textureBindLocation=s.count,s.ids[g.uid]=s.count,s.textures[s.count++]=g,f.batch=d,l+=f.indexSize,f.packAttributes(o,a,f.location,f.textureId),f.packIndex(u,f.indexStart,f.location/this._vertexSize)}s.count>0&&(this._finishBatch(d,c,l-c,s,n,t,h),c=l,++Xr),this.elementStart=this.elementSize,this._batchIndexStart=c,this._batchIndexSize=l}_finishBatch(t,e,s,i,n,o,a){t.gpuBindGroup=null,t.action=a,t.batcher=this,t.textures=i,t.blendMode=n,t.start=e,t.size=s,++Xr,o.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 mo(e);ti(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>16&255,s=r>>8&255,i=r&255,n=t>>16&255,o=t>>8&255,a=t&255,u=e*n/255,l=s*o/255,c=i*a/255;return(u<<16)+(l<<8)+c}class ri{constructor(){this.batcher=null,this.batch=null,this.applyTransform=!0,this.roundPixels=0}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}packIndex(t,e,s){const i=this.geometryData.indices;for(let n=0;n>16|h&65280|(h&255)<<16;if(this.applyTransform){const p=ud(d,o.groupColor)+(this.alpha*o.groupAlpha*255<<24),f=o.groupTransform,g=i<<16|this.roundPixels&65535,m=f.a,_=f.b,b=f.c,x=f.d,y=f.tx,A=f.ty;for(let C=l;C=0&&a>=0&&i>=0&&n>=0))return t;const u=Math.ceil(2.3*Math.sqrt(o+a)),l=u*8+(i?4:0)+(n?4:0);if(l===0)return t;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,t;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}},ld=1e-4,To=1e-4;function cd(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&&(c.join==="round"?b+=Oe(T,S,T-M*I,S-O*I,T-V*I,S-D*I,m,!1)+4:b+=2,m.push(T-V*U,S-D*U),m.push(T+V*I,S+D*I));continue}const ql=(-M+E)*(-O+S)-(-M+T)*(-O+R),Kl=(-V+G)*(-D+S)-(-V+T)*(-D+N),Es=(ae*Kl-vr*ql)/Ss,ws=(yr*ql-br*Kl)/Ss,vn=(Es-T)*(Es-T)+(ws-S)*(ws-S),be=T+(Es-T)*I,ve=S+(ws-S)*I,ye=T-(Es-T)*U,Te=S-(ws-S)*U,Sx=Math.min(ae*ae+br*br,vr*vr+yr*yr),Zl=Tr?I:U,Ex=Sx+Zl*Zl*A;vn<=Ex?c.join==="bevel"||vn/A>C?(Tr?(m.push(be,ve),m.push(T+M*U,S+O*U),m.push(be,ve),m.push(T+V*U,S+D*U)):(m.push(T-M*I,S-O*I),m.push(ye,Te),m.push(T-V*I,S-D*I),m.push(ye,Te)),b+=2):c.join==="round"?Tr?(m.push(be,ve),m.push(T+M*U,S+O*U),b+=Oe(T,S,T+M*U,S+O*U,T+V*U,S+D*U,m,!0)+4,m.push(be,ve),m.push(T+V*U,S+D*U)):(m.push(T-M*I,S-O*I),m.push(ye,Te),b+=Oe(T,S,T-M*I,S-O*I,T-V*I,S-D*I,m,!1)+4,m.push(T-V*I,S-D*I),m.push(ye,Te)):(m.push(be,ve),m.push(ye,Te)):(m.push(T-M*I,S-O*I),m.push(T+M*U,S+O*U),c.join==="round"?Tr?b+=Oe(T,S,T+M*U,S+O*U,T+V*U,S+D*U,m,!0)+2:b+=Oe(T,S,T-M*I,S-O*I,T-V*I,S-D*I,m,!1)+2:c.join==="miter"&&vn/A<=C&&(Tr?(m.push(ye,Te),m.push(ye,Te)):(m.push(be,ve),m.push(be,ve)),b+=2),m.push(T-V*I,S-D*I),m.push(T+V*U,S+D*U),b+=2)}E=r[(_-2)*2],R=r[(_-2)*2+1],T=r[(_-1)*2],S=r[(_-1)*2+1],M=-(R-S),O=E-T,Z=Math.sqrt(M*M+O*O),M/=Z,O/=Z,M*=y,O*=y,m.push(T-M*I,S-O*I),m.push(T+M*U,S+O*U),f||(c.cap==="round"?b+=Oe(T-M*(I-U)*.5,S-O*(I-U)*.5,T-M*I,S-O*I,T+M*U,S+O*U,m,!1)+2:c.cap==="square"&&(b+=hd(T,S,M,O,I,U,!1,m)));const Ax=To*To;for(let Q=x;Q80*e){a=l=r[0],u=c=r[1];for(var f=e;fl&&(l=h),d>c&&(c=d);p=Math.max(l-a,c-u),p=p!==0?32767/p:0}return zr(n,o,e,a,u,p,0),o}function pd(r,t,e,s,i){var n,o;if(i===Eo(r,t,e,s)>0)for(n=t;n=t;n-=s)o=gd(n,r[n],r[n+1],o);return o&&ni(o,o.next)&&(Vr(o),o=o.next),o}function Be(r,t){if(!r)return r;t||(t=r);var e=r,s;do if(s=!1,!e.steiner&&(ni(e,e.next)||tt(e.prev,e,e.next)===0)){if(Vr(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function zr(r,t,e,s,i,n,o){if(r){!o&&n&&Ev(r,s,i,n);for(var a=r,u,l;r.prev!==r.next;){if(u=r.prev,l=r.next,n?_v(r,s,i,n):gv(r)){t.push(u.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),Vr(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=xv(Be(r),t,e),zr(r,t,e,s,i,n,2)):o===2&&bv(r,t,e,s,i,n):zr(Be(r),t,e,s,i,n,1);break}}}}function gv(r){var t=r.prev,e=r,s=r.next;if(tt(t,e,s)>=0)return!1;for(var i=t.x,n=e.x,o=s.x,a=t.y,u=e.y,l=s.y,c=in?i>o?i:o:n>o?n:o,p=a>u?a>l?a:l:u>l?u:l,f=s.next;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=h&&f.y<=p&&Qe(i,a,n,u,o,l,f.x,f.y)&&tt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function _v(r,t,e,s){var i=r.prev,n=r,o=r.next;if(tt(i,n,o)>=0)return!1;for(var a=i.x,u=n.x,l=o.x,c=i.y,h=n.y,d=o.y,p=au?a>l?a:l:u>l?u:l,m=c>h?c>d?c:d:h>d?h:d,_=Ao(p,f,t,e,s),b=Ao(g,m,t,e,s),x=r.prevZ,y=r.nextZ;x&&x.z>=_&&y&&y.z<=b;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==i&&x!==o&&Qe(a,c,u,h,l,d,x.x,x.y)&&tt(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&&Qe(a,c,u,h,l,d,y.x,y.y)&&tt(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&&Qe(a,c,u,h,l,d,x.x,x.y)&&tt(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&&Qe(a,c,u,h,l,d,y.x,y.y)&&tt(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function xv(r,t,e){var s=r;do{var i=s.prev,n=s.next.next;!ni(i,n)&&fd(i,s,s.next,n)&&jr(i,n)&&jr(n,i)&&(t.push(i.i/e|0),t.push(s.i/e|0),t.push(n.i/e|0),Vr(s),Vr(s.next),s=r=n),s=s.next}while(s!==r);return Be(s)}function bv(r,t,e,s,i,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Rv(o,a)){var u=md(o,a);o=Be(o,o.next),u=Be(u,u.next),zr(o,t,e,s,i,n,0),zr(u,t,e,s,i,n,0);return}a=a.next}o=o.next}while(o!==r)}function vv(r,t,e,s){var i=[],n,o,a,u,l;for(n=0,o=t.length;n=e.next.y&&e.next.y!==e.y){var a=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=s&&a>n&&(n=a,o=e.x=e.x&&e.x>=l&&s!==e.x&&Qe(io.x||e.x===o.x&&Sv(o,e)))&&(o=e,h=d)),e=e.next;while(e!==u);return o}function Sv(r,t){return tt(r.prev,r,t.prev)<0&&tt(t.next,r,r.next)<0}function Ev(r,t,e,s){var i=r;do i.z===0&&(i.z=Ao(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,wv(i)}function wv(r){var t,e,s,i,n,o,a,u,l=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,s=e,a=0,t=0;t0||u>0&&s;)a!==0&&(u===0||!s||e.z<=s.z)?(i=e,e=e.nextZ,a--):(i=s,s=s.nextZ,u--),n?n.nextZ=i:r=i,i.prevZ=n,n=i;e=s}n.nextZ=null,l*=2}while(o>1);return r}function Ao(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 Cv(r){var 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 Rv(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Pv(r,t)&&(jr(r,t)&&jr(t,r)&&Dv(r,t)&&(tt(r.prev,r,t.prev)||tt(r,t.prev,t))||ni(r,t)&&tt(r.prev,r,r.next)>0&&tt(t.prev,t,t.next)>0)}function tt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function ni(r,t){return r.x===t.x&&r.y===t.y}function fd(r,t,e,s){var i=ai(tt(r,t,e)),n=ai(tt(r,t,s)),o=ai(tt(e,s,r)),a=ai(tt(e,s,t));return!!(i!==n&&o!==a||i===0&&oi(r,e,t)||n===0&&oi(r,s,t)||o===0&&oi(e,r,s)||a===0&&oi(e,t,s))}function oi(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 ai(r){return r>0?1:r<0?-1:0}function Pv(r,t){var e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&fd(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function jr(r,t){return tt(r.prev,r,r.next)<0?tt(r,t,r.next)>=0&&tt(r,r.prev,t)>=0:tt(r,t,r.prev)<0||tt(r,r.next,t)<0}function Dv(r,t){var e=r,s=!1,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 md(r,t){var e=new So(r.i,r.x,r.y),s=new So(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 gd(r,t,e,s){var i=new So(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 Vr(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 So(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}ii.deviation=function(r,t,e,s){var i=t&&t.length,n=i?t[0]*e:r.length,o=Math.abs(Eo(r,0,n,e));if(i)for(var a=0,u=t.length;a0&&(s+=r[i-1].length,e.holes.push(s))}return e};var Mv=si.exports,_d=Cs(Mv);function wo(r,t,e,s,i,n,o){const a=_d(r,t,2);if(!a)return;for(let l=0;l=0&&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),t},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}},Po={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,t},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}},Do={rectangle:Ro,polygon:Co,triangle:Po,circle:Me,ellipse:Me,roundedRectangle:Me},Bv=new j;function xd(r,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let i=0;i{var p;const f=u.length,g=o.length/2,m=[],_=Do[c.type];if(_.build(c,m),h&&ei(m,h),s){const A=(p=c.closePath)!=null?p:!0;dd(m,t,!1,A,o,2,g,u,f)}else if(e&&l===d){l!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const A=[],C=m.slice();Iv(e.shapePath).forEach(E=>{A.push(C.length/2),C.push(...E)}),wo(C,A,o,2,g,u,f)}else _.triangulate(m,o,2,g,u,f);const b=a.length/2,x=t.texture;if(x!==w.WHITE){const A=t.matrix;h&&A.append(h.clone().invert()),vo(o,2,g,a,b,2,o.length/2-g,A)}else yo(a,b,2,o.length/2-g);const y=z.get(ri);y.indexOffset=f,y.indexSize=u.length-f,y.vertexOffset=g,y.vertexSize=o.length/2-g,y.color=t.color,y.alpha=t.alpha,y.texture=x,y.geometryData=n,i.push(y)})}function Iv(r){if(!r)return[];const t=r.shapePrimitives,e=[];for(let s=0;s{z.return(s)})}destroy(){for(const t of this._needsContextNeedsRebuild)this._gpuContextHash[t.uid]&&this.onGraphicsContextDestroy(t);this._needsContextNeedsRebuild.length=0}};Mo.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"graphicsContext"},Mo.defaultOptions={bezierSmoothness:.5};let ui=Mo;const Fv={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8},Oo=0,Bo=1,Go=2,Io=3,Fo=4,Uo=5,No=class sx{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 Wr(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 ko{constructor(t,e){this.state=Nt.for2d(),this._graphicsBatchesHash=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=t.context,s=!!this._graphicsBatchesHash[t.uid],i=this.renderer.graphicsContext.updateGpuContext(e);return!!(i.isBatchable||s!==i.isBatchable)}addRenderable(t,e){const s=this.renderer.graphicsContext.updateGpuContext(t.context);t._didGraphicsUpdate&&(t._didGraphicsUpdate=!1,this._rebuild(t)),s.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._graphicsBatchesHash[t.uid];if(e)for(let s=0;s{const a=z.get(ri);return o.copyTo(a),a.renderable=t,a.roundPixels=i,a});return this._graphicsBatchesHash[t.uid]=n,t.on("destroyed",()=>{this.destroyRenderable(t)}),n}_removeBatchForRenderable(t){this._graphicsBatchesHash[t].forEach(e=>{z.return(e)}),this._graphicsBatchesHash[t]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(const t in this._graphicsBatchesHash)this._removeBatchForRenderable(t);this._graphicsBatchesHash=null}}ko.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"graphics"},L.add(ko),L.add(ui);const Lo=Object.create(null),Td=Object.create(null);function Yr(r,t){let e=Td[r];return e===void 0&&(Lo[t]===void 0&&(Lo[t]=1),Td[r]=e=Lo[t]++),e}function Ad(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 Nv=Object.defineProperty,Sd=Object.getOwnPropertySymbols,kv=Object.prototype.hasOwnProperty,Lv=Object.prototype.propertyIsEnumerable,Ed=(r,t,e)=>t in r?Nv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wd=(r,t)=>{for(var e in t||(t={}))kv.call(t,e)&&Ed(r,e,t[e]);if(Sd)for(var e of Sd(t))Lv.call(t,e)&&Ed(r,e,t[e]);return r};const Cd=class ix{constructor(t,e){this._touched=0,this.uid=J("uniform"),this._resourceType="uniformGroup",this._resourceId=J("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1;var s,i;e=wd(wd({},ix.defaultOptions),e),this.uniformStructures=t;const n={};for(const o in t){const a=t[o];a.name=o,a.size=(s=a.size)!=null?s:1,(i=a.value)!=null||(a.value=Ad(a.type,a.size)),n[o]=a.value}this.uniforms=n,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Yr(Object.keys(n).map(o=>`${o}-${t[o].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Cd.defaultOptions={ubo:!1,isStatic:!1};let at=Cd;class li{constructor(){this.batcher=null,this.batch=null,this.roundPixels=0,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get blendMode(){return this.mesh.groupBlendMode}reset(){this.mesh=null,this.texture=null,this.batcher=null,this.batch=null}packIndex(t,e,s){const i=this.geometry.indices;for(let n=0;n"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new qt({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),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),a=t.texture;if(o.texture._source!==a._source&&o.texture._source!==a._source)return!o.batcher.checkAndUpdateTexture(o,a)}return!1}addRenderable(t,e){const s=this.renderer.renderPipes.batch,{batched:i}=this._getMeshData(t);if(i){const n=this._getBatchableMesh(t);n.texture=t._texture,n.geometry=t._geometry,s.addToBatch(n)}else s.break(e),e.add({renderPipeId:"mesh",mesh:t})}updateRenderable(t){if(t.batched){const e=this._gpuBatchableMeshHash[t.uid];e.texture=t._texture,e.geometry=t._geometry,e.batcher.updateElement(e)}}destroyRenderable(t){this._meshDataHash[t.uid]=null;const e=this._gpuBatchableMeshHash[t.uid];e&&(z.return(e),this._gpuBatchableMeshHash[t.uid]=null)}execute({mesh:t}){if(!t.isRenderable)return;t.state.blendMode=t.groupBlendMode;const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),Wr(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){return this._meshDataHash[t.uid]||this._initMeshData(t)}_initMeshData(t){var e,s;return this._meshDataHash[t.uid]={batched:t.batched,indexSize:(e=t._geometry.indices)==null?void 0:e.length,vertexSize:(s=t._geometry.positions)==null?void 0:s.length},t.on("destroyed",()=>{this.destroyRenderable(t)}),this._meshDataHash[t.uid]}_getBatchableMesh(t){return this._gpuBatchableMeshHash[t.uid]||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=z.get(li);return e.mesh=t,e.texture=t._texture,e.roundPixels=this.renderer._roundPixels|t._roundPixels,this._gpuBatchableMeshHash[t.uid]=e,e.mesh=t,e}destroy(){for(const t in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[t]&&z.return(this._gpuBatchableMeshHash[t]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}$o.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"mesh"},L.add($o);class ci{constructor(){this.vertexSize=4,this.indexSize=6,this.location=0,this.batcher=null,this.batch=null,this.roundPixels=0}get blendMode(){return this.renderable.groupBlendMode}packAttributes(t,e,s,i){const n=this.renderable,o=this.texture,a=n.groupTransform,u=a.a,l=a.b,c=a.c,h=a.d,d=a.tx,p=a.ty,f=this.bounds,g=f.maxX,m=f.minX,_=f.maxY,b=f.minY,x=o.uvs,y=n.groupColorAlpha,A=i<<16|this.roundPixels&65535;t[s+0]=u*m+c*b+d,t[s+1]=h*b+l*m+p,t[s+2]=x.x0,t[s+3]=x.y0,e[s+4]=y,e[s+5]=A,t[s+6]=u*g+c*b+d,t[s+7]=h*b+l*g+p,t[s+8]=x.x1,t[s+9]=x.y1,e[s+10]=y,e[s+11]=A,t[s+12]=u*g+c*_+d,t[s+13]=h*_+l*g+p,t[s+14]=x.x2,t[s+15]=x.y2,e[s+16]=y,e[s+17]=A,t[s+18]=u*m+c*_+d,t[s+19]=h*_+l*m+p,t[s+20]=x.x3,t[s+21]=x.y3,e[s+22]=y,e[s+23]=A}packIndex(t,e,s){t[e]=s+0,t[e+1]=s+1,t[e+2]=s+2,t[e+3]=s+0,t[e+4]=s+2,t[e+5]=s+3}reset(){this.renderable=null,this.texture=null,this.batcher=null,this.batch=null,this.bounds=null}}class Ho{constructor(t){this._gpuText=Object.create(null),this._renderer=t}validateRenderable(t){var e;const s=this._getGpuText(t),i=t._getKey();if(s.currentKey!==i){const n=(e=t.resolution)!=null?e:this._renderer.resolution,{width:o,height:a}=this._renderer.canvasText.getTextureSize(t.text,n,t._style);return!(this._renderer.canvasText.getReferenceCount(s.currentKey)===1&&o===s.texture._source.width&&a===s.texture._source.height)}return!1}addRenderable(t,e){const s=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(s)}updateRenderable(t){const e=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),e.batcher.updateElement(e)}destroyRenderable(t){this._destroyRenderableById(t.uid)}_destroyRenderableById(t){const e=this._gpuText[t];this._renderer.canvasText.decreaseReferenceCount(e.currentKey),z.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){const e=t._getKey(),s=this._getGpuText(t),i=s.batchableSprite;s.currentKey!==e&&this._updateGpuText(t),t._didTextUpdate=!1;const n=t._style.padding;Ur(i.bounds,t._anchor,i.texture,n)}_updateGpuText(t){const e=this._getGpuText(t),s=e.batchableSprite;e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),e.texture=s.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t._getKey(),s.texture=e.texture}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:null,currentKey:"--",batchableSprite:z.get(ci)};return e.batchableSprite.renderable=t,e.batchableSprite.bounds={minX:0,maxX:1,minY:0,maxY:0},e.batchableSprite.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuText[t.uid]=e,this._updateText(t),t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}Ho.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"text"};class Rd{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=X.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=Re(t),e=Re(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{width:e,height:s}=t.canvas,i=(e<<17)+(s<<1);this._canvasPool[i].push(t)}clear(){this._canvasPool={}}}const Kt=new Rd;var $v=Object.defineProperty,Hv=Object.defineProperties,Xv=Object.getOwnPropertyDescriptors,Pd=Object.getOwnPropertySymbols,zv=Object.prototype.hasOwnProperty,jv=Object.prototype.propertyIsEnumerable,Dd=(r,t,e)=>t in r?$v(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vv=(r,t)=>{for(var e in t||(t={}))zv.call(t,e)&&Dd(r,e,t[e]);if(Pd)for(var e of Pd(t))jv.call(t,e)&&Dd(r,e,t[e]);return r},Wv=(r,t)=>Hv(r,Xv(t));let Yv=0;class Md{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1}createTexture(t,e,s){const i=new st(Wv(Vv({},this.textureOptions),{width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!0}));return new w({source:i,label:`texturePool_${Yv++}`})}getOptimalTexture(t,e,s=1,i){let n=Math.ceil(t*s-1e-6),o=Math.ceil(e*s-1e-6);n=Re(n),o=Re(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){const e=this._poolKeyHash[t.uid];this._texturePool[e].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;i2&&(t.push([s].concat(i.splice(0,2))),n="l",s=s=="m"?"l":"L");;){if(i.length==Xo[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){if(this.radius===0)return!1;const i=this.x-t,n=this.y-e,o=this.radius,a=s/2,u=Math.sqrt(i*i+n*n);return uo-a}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){const{halfWidth:i,halfHeight:n}=this;if(i<=0||n<=0)return!1;const o=s/2,a=i-o,u=n-o,l=i+o,c=n+o,h=t-this.x,d=e-this.y,p=h*h/(a*a)+d*d/(u*u),f=h*h/(l*l)+d*d/(c*c);return p>1&&f<=1}getBounds(){return new j(this.x-this.halfWidth,this.y-this.halfHeight,this.halfWidth*2,this.halfHeight*2)}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 qr(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}class _r{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){const i=s/2,n=i*i,{points:o}=this,a=o.length-(this.closePath?0:2);for(let u=0;ui?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]}}const di=(r,t,e,s,i,n)=>{const o=r-e,a=t-s,u=Math.sqrt(o*o+a*a);return u>=i-n&&u<=i+n};class bn{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 bn(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){const{x:i,y:n,width:o,height:a,radius:u}=this,l=s/2,c=i+u,h=n+u,d=o-u*2,p=a-u*2,f=i+o,g=n+a;return(t>=i-l&&t<=i+l||t>=f-l&&t<=f+l)&&e>=h&&e<=h+p||(e>=n-l&&e<=n+l||e>=g-l&&e<=g+l)&&t>=c&&t<=c+d?!0:tf-u&&ef-u&&e>g-u&&di(t,e,f-u,g-u,u,l)||tg-u&&di(t,e,c,g-u,u,l)}}const ry=8,pi=11920929e-14,sy=1,zo=.01,Je=0,Ge=0;function jo(r,t,e,s,i,n,o,a,u,l){const c=Math.min(.99,Math.max(0,l!=null?l:ui.defaultOptions.bezierSmoothness));let h=(sy-c)/1;return h*=h,iy(t,e,s,i,n,o,a,u,r,h),r}function iy(r,t,e,s,i,n,o,a,u,l){Vo(r,t,e,s,i,n,o,a,u,l,0),u.push(o,a)}function Vo(r,t,e,s,i,n,o,a,u,l,c){if(c>ry)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,C=(b+y)/2,E=(x+A)/2;if(c>0){let R=o-r,T=a-t;const S=Math.abs((e-o)*T-(s-a)*R),G=Math.abs((i-o)*T-(n-a)*R);let N,M;if(S>pi&&G>pi){if((S+G)*(S+G)<=l*(R*R+T*T)){if(Je=h&&(N=2*h-N),M>=h&&(M=2*h-M),N+MGe){u.push(e,s);return}if(M>Ge){u.push(i,n);return}}}}else if(S>pi){if(S*S<=l*(R*R+T*T)){if(Je=h&&(N=2*h-N),NGe){u.push(e,s);return}}}else if(G>pi){if(G*G<=l*(R*R+T*T)){if(Je=h&&(N=2*h-N),NGe){u.push(i,n);return}}}else if(R=C-(r+o)/2,T=E-(t+a)/2,R*R+T*T<=l){u.push(C,E);return}}Vo(r,t,d,p,b,x,C,E,u,l,c+1),Vo(C,E,y,A,m,_,o,a,u,l,c+1)}const ny=8,oy=11920929e-14,ay=1,uy=.01,kd=0;function Ld(r,t,e,s,i,n,o,a){const u=Math.min(.99,Math.max(0,a!=null?a:ui.defaultOptions.bezierSmoothness));let l=(ay-u)/1;return l*=l,ly(t,e,s,i,n,o,r,l),r}function ly(r,t,e,s,i,n,o,a){Wo(o,r,t,e,s,i,n,a,0),o.push(i,n)}function Wo(r,t,e,s,i,n,o,a,u){if(u>ny)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>oy){if(b*b<=a*(m*m+_*_)){if(kd=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 Kr=Math.PI*2,qo={centerX:0,centerY:0,ang1:0,ang2:0},Ko=({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 cy(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 Hd=(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)},hy=(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,C=(c-b)/i,E=(h-x)/n,R=(-c-b)/i,T=(-h-x)/n,S=Hd(1,0,C,E);let G=Hd(C,E,R,T);a===0&&G>0&&(G-=Kr),a===1&&G<0&&(G+=Kr),d.centerX=y,d.centerY=A,d.ang1=S,d.ang2=G};function Xd(r,t,e,s,i,n,o,a=0,u=0,l=0){if(n===0||o===0)return;const c=Math.sin(a*Kr/360),h=Math.cos(a*Kr/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)),hy(t,e,s,i,n,o,u,l,c,h,d,p,qo);let{ang1:g,ang2:m}=qo;const{centerX:_,centerY:b}=qo;let x=Math.abs(m)/(Kr/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],C=r[r.length-1];const E={x:0,y:0};for(let R=0;R{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,C=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,C,g),o=u}}function jd(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;u=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 bn(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 _r,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 _r,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,i=e.shape.y;if(!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?py(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fi=(r,t)=>{for(var e in t||(t={}))fy.call(t,e)&&Yd(r,e,t[e]);if(Wd)for(var e of Wd(t))my.call(t,e)&&Yd(r,e,t[e]);return r};function qd(r,t){if(typeof r=="string"){const s=document.createElement("div");s.innerHTML=r.trim(),r=s.querySelector("svg")}const e={context:t,path:new xe};return Kd(r,e,null,null),t}function Kd(r,t,e,s){const i=r.children,{fillStyle:n,strokeStyle:o}=gy(r);n&&e?e=fi(fi({},e),n):n&&(e=n),o&&s?s=fi(fi({},s),o):o&&(s=o),t.context.fillStyle=e,t.context.strokeStyle=s;let a,u,l,c,h,d,p,f,g,m,_,b,x,y,A,C,E;switch(r.nodeName.toLowerCase()){case"path":y=r.getAttribute("d"),A=new xe(y),t.context.path(A),e&&t.context.fill(),s&&t.context.stroke();break;case"circle":p=ct(r,"cx",0),f=ct(r,"cy",0),g=ct(r,"r",0),t.context.ellipse(p,f,g,g),e&&t.context.fill(),s&&t.context.stroke();break;case"rect":a=ct(r,"x",0),u=ct(r,"y",0),C=ct(r,"width",0),E=ct(r,"height",0),m=ct(r,"rx",0),_=ct(r,"ry",0),m||_?t.context.roundRect(a,u,C,E,m||_):t.context.rect(a,u,C,E),e&&t.context.fill(),s&&t.context.stroke();break;case"ellipse":p=ct(r,"cx",0),f=ct(r,"cy",0),m=ct(r,"rx",0),_=ct(r,"ry",0),t.context.beginPath(),t.context.ellipse(p,f,m,_),e&&t.context.fill(),s&&t.context.stroke();break;case"line":l=ct(r,"x1",0),c=ct(r,"y1",0),h=ct(r,"x2",0),d=ct(r,"y2",0),t.context.beginPath(),t.context.moveTo(l,c),t.context.lineTo(h,d),s&&t.context.stroke();break;case"polygon":x=r.getAttribute("points"),b=x.match(/\d+/g).map(R=>parseInt(R,10)),t.context.poly(b,!0),e&&t.context.fill(),s&&t.context.stroke();break;case"polyline":x=r.getAttribute("points"),b=x.match(/\d+/g).map(R=>parseInt(R,10)),t.context.poly(b,!1),s&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}for(let R=0;Rt in r?_y(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ie=(r,t)=>{for(var e in t||(t={}))vy.call(t,e)&&Jd(r,e,t[e]);if(Qd)for(var e of Qd(t))yy.call(t,e)&&Jd(r,e,t[e]);return r},Qo=(r,t)=>xy(r,by(t));function ie(r,t){var e,s;if(r==null)return null;let i,n;if(r!=null&&r.fill?(n=r.fill,i=Ie(Ie({},t),r)):(n=r,i=t),Y.isColorLike(n)){const u=Y.shared.setValue(n!=null?n:0);return Qo(Ie({},i),{color:u.toNumber(),alpha:u.alpha===1?i.alpha:u.alpha,texture:w.WHITE})}else if(n instanceof Zo){const u=n;return Qo(Ie({},i),{color:16777215,texture:u.texture,matrix:u.transform,fill:(e=i.fill)!=null?e:null})}else if(n instanceof hi){const u=n;return u.buildLinearGradient(),Qo(Ie({},i),{color:16777215,texture:u.texture,matrix:u.transform})}const o=Ie(Ie({},t),r);if(o.texture){if(o.texture!==w.WHITE){const l=((s=o.matrix)==null?void 0:s.invert())||new B;l.scale(1/o.texture.frame.width,1/o.texture.frame.height),o.matrix=l}const u=o.texture.source.style;u.addressMode==="clamp-to-edge"&&(u.addressMode="repeat")}const a=Y.shared.setValue(o.color);return o.alpha*=a.alpha,o.color=a.toNumber(),o.matrix=o.matrix?o.matrix.clone():null,o}var Ty=Object.defineProperty,tp=Object.getOwnPropertySymbols,Ay=Object.prototype.hasOwnProperty,Sy=Object.prototype.propertyIsEnumerable,ep=(r,t,e)=>t in r?Ty(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,tr=(r,t)=>{for(var e in t||(t={}))Ay.call(t,e)&&ep(r,e,t[e]);if(tp)for(var e of tp(t))Sy.call(t,e)&&ep(r,e,t[e]);return r};const Ey=new it,rp=new B,Jo=class Zt extends At{constructor(){super(...arguments),this.uid=J("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new xe,this._transform=new B,this._fillStyle=tr({},Zt.defaultFillStyle),this._strokeStyle=tr({},Zt.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new pt,this._boundsDirty=!0}clone(){const t=new Zt;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=tr({},this._fillStyle),t._strokeStyle=tr({},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=ie(t,Zt.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=ie(t,Zt.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=ie(t,Zt.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=ie(t,Zt.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?Y.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new xe,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=ie(t,Zt.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(it.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=ie(t,Zt.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++,qd(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:tr({},this._fillStyle),strokeStyle:tr({},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 B?(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 B?(this._transform.append(t),this):(rp.set(t,e,s,i,n,o),this._transform.append(rp),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return 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?Cy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qr=(r,t)=>{for(var e in t||(t={}))Ry.call(t,e)&&op(r,e,t[e]);if(np)for(var e of np(t))Py.call(t,e)&&op(r,e,t[e]);return r};const ea=class gr extends At{constructor(t={}){super(),Dy(t);const e=Qr(Qr({},gr.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=Qr(Qr({},gr.defaultDropShadow),t):this._dropShadow=t?Qr({},gr.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,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 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._fill=ie(t===0?"black":t,kt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._stroke=ie(t,kt.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=ta(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=gr.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new gr({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow,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})}destroy(t=!1){var e,s,i,n;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(e=this._fill)!=null&&e.texture&&this._fill.texture.destroy(o),(s=this._originalFill)!=null&&s.texture&&this._originalFill.texture.destroy(o),(i=this._stroke)!=null&&i.texture&&this._stroke.texture.destroy(o),(n=this._originalStroke)!=null&&n.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}};ea.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},ea.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 Lt=ea;function Dy(r){var t,e,s,i,n;const o=r;if(typeof o.dropShadow=="boolean"&&o.dropShadow){const a=Lt.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;r.stroke={color:a,width:o.strokeThickness}}if(Array.isArray(o.fill)){const a=new hi(0,0,0,r.fontSize*1.7),u=o.fill.map(l=>Y.shared.setValue(l).toNumber());u.forEach((l,c)=>{var h;const d=(h=o.fillGradientStops[c])!=null?h:c/u.length;a.addColorStop(d,l)}),r.fill={fill:a}}}const My=new pt;function ra(r,t,e,s){const i=My;i.minX=0,i.minY=0,i.maxX=r.width/s|0,i.maxY=r.height/s|0;const n=dt.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}const Oy=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Jr(r){const t=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let e=r.fontFamily;Array.isArray(r.fontFamily)||(e=r.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let i=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(i)&&!Oy.includes(i)&&(i=`"${i}"`),e[s]=i}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const sa={willReadFrequently:!0},$t=class P{static get experimentalLetterSpacingSupported(){let t=P._experimentalLetterSpacingSupported;if(t!==void 0){const e=X.get().getCanvasRenderingContext2D().prototype;t=P._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=P._canvas,i=e.wordWrap){var n;const o=`${t}:${e.styleKey}`;if(P._measurementCache[o])return P._measurementCache[o];const a=Jr(e),u=P.measureFont(a);u.fontSize===0&&(u.fontSize=e.fontSize,u.ascent=e.fontSize);const l=P.__context;l.font=a;const c=(i?P._wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),h=new Array(c.length);let d=0;for(let _=0;_0&&(i?n-=e:n+=(P.graphemeSegmenter(t).length-1)*e),n}static _wordWrap(t,e,s=P._canvas){const i=s.getContext("2d",sa);let n=0,o="",a="";const u=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,h=P._collapseSpaces(c),d=P._collapseNewlines(c);let p=!h;const f=e.wordWrapWidth+l,g=P._tokenize(t);for(let m=0;mf)if(o!==""&&(a+=P._addLine(o),o="",n=0),P.canBreakWords(_,e.breakWords)){const x=P.wordWrapSplit(_);for(let y=0;yf&&(a+=P._addLine(o),p=!1,o="",n=0),o+=A,n+=R}}else{o.length>0&&(a+=P._addLine(o),o="",n=0);const x=m===g.length-1;a+=P._addLine(_,!x),p=!1,o="",n=0}else b+n>f&&(p=!1,a+=P._addLine(o),o="",n=0),(o.length>0||!P.isBreakingSpace(_)||p)&&(o+=_,n+=b)}return a+=P._addLine(o,!1),a}static _addLine(t,e=!0){return t=P._trimRight(t),t=e?`${t} `:t,t}static _getFromCache(t,e,s,i){let n=s[t];return typeof n!="number"&&(n=P._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(!P.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:P._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:P._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=>[...r.segment(t)].map(e=>e.segment)}return r=>[...r]})(),$t.experimentalLetterSpacing=!1,$t._fonts={},$t._newlines=[10,13],$t._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],$t._measurementCache={};let Ht=$t;function ts(r,t){if(r.texture===w.WHITE&&!r.fill)return Y.shared.setValue(r.color).toHex();if(r.fill){if(r.fill instanceof Zo){const e=r.fill,s=t.createPattern(e.texture.source.resource,"repeat"),i=e.transform.copyTo(B.shared);return i.scale(e.texture.frame.width,e.texture.frame.height),s.setTransform(i),s}else if(r.fill instanceof hi){const e=r.fill;if(e.type==="linear"){const s=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(i=>{s.addColorStop(i.offset,Y.shared.setValue(i.color).toHex())}),s}}}else{const e=t.createPattern(r.texture.source.resource,"repeat"),s=r.matrix.copyTo(B.shared);return s.scale(r.texture.frame.width,r.texture.frame.height),e.setTransform(s),e}return"red"}class ia{constructor(t){this._activeTextures={},this._renderer=t}getTextureSize(t,e,s){const i=Ht.measureText(t||" ",s);let n=Math.ceil(Math.ceil(Math.max(1,i.width)+s.padding*2)*e),o=Math.ceil(Math.ceil(Math.max(1,i.height)+s.padding*2)*e);return n=Math.ceil(n-1e-6),o=Math.ceil(o-1e-6),n=Re(n),o=Re(o),{width:n,height:o}}getTexture(t,e,s,i){typeof t=="string"&&(Fd("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:s,resolution:e}),t.style instanceof Lt||(t.style=new Lt(t.style));const{texture:n,canvasAndContext:o}=this.createTextureAndCanvas(t);return this._renderer.texture.initSource(n._source),Kt.returnCanvasAndContext(o),n}createTextureAndCanvas(t){var e;const{text:s,style:i}=t,n=(e=t.resolution)!=null?e:this._renderer.resolution,o=Ht.measureText(s||" ",i),a=Math.ceil(Math.ceil(Math.max(1,o.width)+i.padding*2)*n),u=Math.ceil(Math.ceil(Math.max(1,o.height)+i.padding*2)*n),l=Kt.getOptimalCanvasAndContext(a,u),{canvas:c}=l;this.renderTextToCanvas(s,i,n,l);const h=ra(c,a,u,n);if(i.trim){const d=Gd(c,n);h.frame.copyFrom(d),h.updateUvs()}return{texture:h,canvasAndContext:l}}getManagedTexture(t){const e=t._getKey();if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const{texture:s,canvasAndContext:i}=this.createTextureAndCanvas(t);return this._activeTextures[e]={canvasAndContext:i,texture:s,usageCount:1},s}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];if(e.usageCount--,e.usageCount===0){Kt.returnCanvasAndContext(e.canvasAndContext),dt.returnTexture(e.texture);const s=e.texture.source;s.resource=null,s.uploadMethodId="unknown",s.alphaMode="no-premultiply-alpha",this._activeTextures[t]=null}}getReferenceCount(t){return this._activeTextures[t].usageCount}renderTextToCanvas(t,e,s,i){var n,o,a,u,l,c,h;const{canvas:d,context:p}=i,f=Jr(e),g=Ht.measureText(t||" ",e),m=g.lines,_=g.lineHeight,b=g.lineWidths,x=g.maxLineWidth,y=g.fontProperties,A=d.height;p.resetTransform(),p.scale(s,s);const C=e.padding*2;if(p.clearRect(0,0,g.width+4+C,g.height+4+C),(n=e._stroke)!=null&&n.width){const S=e._stroke;p.lineWidth=S.width,p.miterLimit=S.miterLimit,p.lineJoin=S.join,p.lineCap=S.cap}p.font=f;let E,R;const T=e.dropShadow?2:1;for(let S=0;Se.texture.destroy(!0)),this.pages=null)}}function oa(r){if(r==="")return[];typeof r=="string"&&(r=[r]);const t=[];for(let e=0,s=r.length;e!this._currentChars.includes(x)).filter((x,y,A)=>A.indexOf(x)===y);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;const f=this.baseRenderedFontSize/this.baseMeasurementFontSize,g=this._padding*f,m=h.fontStyle==="italic"?2:1;let _=0,b=!1;for(let x=0;x512&&(p+=_,_=T,d=0,p+_>512)){c.update();const G=this._nextPage();u=G.canvasAndContext.canvas,l=G.canvasAndContext.context,c=G.texture.source,p=0}const S=C/f-((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[y]={id:y.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:S,kerning:{}},b){this._drawGlyph(l,A,d+g,p+g,f,h);const G=c.width*f,N=c.height*f,M=new j(d/G*c.width,p/N*c.height,R/G*c.width,T/N*c.height);this.chars[y].texture=new w({source:c,frame:M}),d+=Math.ceil(R)}}c.update(),this._currentX=d,this._currentY=p,this._skipKerning&&this._applyKerning(o,l)}get pageTextures(){return this.pages}_applyKerning(t,e){const s=this._measureCache;for(let i=0;i{const f=i.width;for(let g=0;g{let p=i.chars.length-1,f=i.chars[p];for(;f===" ";)i.width-=e.chars[f].xAdvance,f=i.chars[--p];s.width=Math.max(s.width,i.width),i={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,s.lines.push(i),s.height+=e.lineHeight},c=e.baseMeasurementFontSize/t.fontSize,h=t.letterSpacing*c,d=t.wordWrapWidth*c;for(let p=0;pd?(l(),u(a),g||i.charPositions.push(0)):(a.start=i.width,u(a),g||i.charPositions.push(0)),f==="\r"||f===` `)i.width!==0&&l();else if(!g){const _=m.xAdvance+(m.kerning[n]||0)+h;i.width+=_,i.spaceWidth=_,i.spacesIndex.push(i.charPositions.length),i.chars.push(f)}}else{const _=m.kerning[n]||0,b=m.xAdvance+_+h;a.positions[a.index++]=a.width+_,a.chars.push(f),a.width+=b}n=f}return l(),t.align==="center"?By(s):t.align==="right"?Gy(s):t.align==="justify"&&Iy(s),s}function By(r){for(let t=0;tt in r?Fy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,la=(r,t)=>{for(var e in t||(t={}))Uy.call(t,e)&&up(r,e,t[e]);if(ap)for(var e of ap(t))Ny.call(t,e)&&up(r,e,t[e]);return r};let ky=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}}getFont(t,e){var s;let i=`${e.fontFamily}-bitmap`,n=!0;if(e._fill.fill&&(i+=e._fill.fill.uid,n=!1),!q.has(i)){const a=new aa(la({style:e,overrideFill:n,overrideSize:!0},this.defaultOptions));a.once("destroy",()=>q.remove(i)),q.set(i,a)}const o=q.get(i);return(s=o.ensureCharacters)==null||s.call(o,t),o}getLayout(t,e){const s=this.getFont(t,e);return ua(t.split(""),e,s)}measureText(t,e){return this.getLayout(t,e)}install(...t){var e,s,i,n;let o=t[0];typeof o=="string"&&(o={name:o,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 a=o==null?void 0:o.name;if(!a)throw new Error("[BitmapFontManager] Property `name` is required.");o=la(la({},this.defaultOptions),o);const u=o.style,l=u instanceof Lt?u:new Lt(u),c=l._fill.fill!==null&&l._fill.fill!==void 0,h=new aa({style:l,overrideFill:c,skipKerning:o.skipKerning,padding:o.padding,resolution:o.resolution,overrideSize:!1}),d=oa(o.chars);return h.ensureCharacters(d.join("")),q.set(`${a}-bitmap`,h),h.once("destroy",()=>q.remove(`${a}-bitmap`)),h}uninstall(t){const e=`${t}-bitmap`,s=q.get(e);s&&(q.remove(e),s.destroy())}};const es=new ky;class ca extends na{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}=i[u.page],h=new j(u.x+l.x,u.y+l.y,u.width,u.height),d=new w({source:c,frame:h});this.chars[o]={id:o.codePointAt(0),xOffset:u.xOffset,yOffset:u.yOffset,xAdvance:u.xAdvance,kerning:(a=u.kerning)!=null?a:{},texture:d}}),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")?ha.test(X.get().parseXML(r)):!1},parse(r){return ha.parse(X.get().parseXML(r))}},Ly=[".xml",".fnt"],lp={extension:v.CacheParser,test:r=>r instanceof ca,getCacheableAssets(r,t){const e={};return r.forEach(s=>{e[s]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},cp={extension:{type:v.LoadParser,priority:Tt.Normal},test(r){return Ly.includes(xt.extname(r).toLowerCase())},async testParse(r){return mi.test(r)||da.test(r)},async parse(r,t,e){const s=mi.test(r)?mi.parse(r):da.parse(r),{src:i}=t,{pages:n}=s,o=[];for(let l=0;la[l]);return new ca({data:s,textures:u},i)},async load(r,t){return await(await X.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(s=>e.unload(s.texture.source._sourceOrigin))),r.destroy()}};var $y=Object.defineProperty,gi=Object.getOwnPropertySymbols,hp=Object.prototype.hasOwnProperty,dp=Object.prototype.propertyIsEnumerable,pp=(r,t,e)=>t in r?$y(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hy=(r,t)=>{for(var e in t||(t={}))hp.call(t,e)&&pp(r,e,t[e]);if(gi)for(var e of gi(t))dp.call(t,e)&&pp(r,e,t[e]);return r},Xy=(r,t)=>{var e={};for(var s in r)hp.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&gi)for(var s of gi(r))t.indexOf(s)<0&&dp.call(r,s)&&(e[s]=r[s]);return e};class xr extends K{constructor(t){t instanceof kt&&(t={context:t});const e=t||{},{context:s,roundPixels:i}=e,n=Xy(e,["context","roundPixels"]);super(Hy({label:"Graphics"},n)),this.canBundle=!0,this.renderPipeId="graphics",this._roundPixels=0,s?this._context=s:this._context=this._ownedContext=new kt,this._context.on("update",this.onViewUpdate,this),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}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}onViewUpdate(){this._didChangeId+=4096,this._didGraphicsUpdate=!0,!this.didViewUpdate&&(this.didViewUpdate=!0,this.renderGroup&&this.renderGroup.onChildViewUpdate(this))}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 xr(this._context.clone()):(this._ownedContext=null,new xr(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&&(s.color=t),e&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){this.context.fill();const t=this.context.strokeStyle;return(t.width!==kt.defaultStrokeStyle.width||t.color!==kt.defaultStrokeStyle.color||t.alpha!==kt.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)}}let rs;function fp(){return(!rs||rs!=null&&rs.isContextLost())&&(rs=X.get().createCanvas().getContext("webgl",{})),rs}let _i;function mp(){if(!_i){_i="mediump";const r=fp();r&&r.getShaderPrecisionFormat&&(_i=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return _i}function gp(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 _p(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 xp(r,t){return t?`#version 300 es ${r}`:r}const zy={},jy={};function bp(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?zy:jy;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`} ${r}`}function vp(r,t){return t?r.replace("#version 300 es",""):r}var Vy=Object.defineProperty,yp=Object.getOwnPropertySymbols,Wy=Object.prototype.hasOwnProperty,Yy=Object.prototype.propertyIsEnumerable,Tp=(r,t,e)=>t in r?Vy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ap=(r,t)=>{for(var e in t||(t={}))Wy.call(t,e)&&Tp(r,e,t[e]);if(yp)for(var e of yp(t))Yy.call(t,e)&&Tp(r,e,t[e]);return r};const pa={stripVersion:vp,ensurePrecision:_p,addProgramDefines:gp,setProgramName:bp,insertVersion:xp},fa=Object.create(null),Sp=class Xl{constructor(t){t=Ap(Ap({},Xl.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:mp()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let i=t.fragment,n=t.vertex;Object.keys(pa).forEach(o=>{const a=s[o];i=pa[o](i,a,!0),n=pa[o](n,a,!1)}),this.fragment=i,this.vertex=n,this._key=Yr(`${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 fa[e]||(fa[e]=new Xl(t)),fa[e]}};Sp.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Gt=Sp;const Ep={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 er(r){var t;return(t=Ep[r])!=null?t:Ep.float32}const qy={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 wp({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=qy[u[3]])!=null?e:"float32";s[u[2]]={location:parseInt(u[1],10),format:l,stride:er(l).stride,offset:0,instance:!1,start:0}}}}return s}function xi(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 rr=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(rr||{});function Cp({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 ma=Object.create(null);class Pt{constructor(t){this._layoutKey=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=xi(i.source);this.structsAndGroups=l}else{const l=xi(n.source),c=xi(i.source);this.structsAndGroups=Pp(l,c)}this.layout=o!=null?o:Rp(this.structsAndGroups),this.gpuLayout=a!=null?a:Cp(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=Yr(s,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=wp(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 ma[e]||(ma[e]=new Pt(t)),ma[e]}}function ga(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 Dp=/\{\{(.*?)\}\}/g;function _a(r){var t,e;const s={};return((e=(t=r.match(Dp))==null?void 0:t.map(i=>i.replace(/[{()}]/g,"")))!=null?e:[]).forEach(i=>{s[i]=[]}),s}function Mp(r,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function xa(r,t,e=!1){const s=[];Mp(t,s),r.forEach(a=>{a.header&&Mp(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 Op(r,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function Ky(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function Zy(r){const t=/@.*?\s+/g;return r.replace(t,"")}function Bp(r,t){const e=[];Op(t,e),r.forEach(u=>{u.header&&Op(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 ${Zy(u)};`).join(` `),o=`return VSOutput( ${e.sort().map(u=>` ${Ky(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 ba(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 Fe=Object.create(null),va=new Map;let Qy=0;function Gp({template:r,bits:t}){const e=Fp(r,t);if(Fe[e])return Fe[e];const{vertex:s,fragment:i}=Jy(r,t);return Fe[e]=Up(s,i,t),Fe[e]}function Ip({template:r,bits:t}){const e=Fp(r,t);return Fe[e]||(Fe[e]=Up(r.vertex,r.fragment,t)),Fe[e]}function Jy(r,t){const e=t.map(o=>o.vertex).filter(o=>!!o),s=t.map(o=>o.fragment).filter(o=>!!o);let i=xa(e,r.vertex,!0);i=Bp(e,i);const n=xa(s,r.fragment,!0);return{vertex:i,fragment:n}}function Fp(r,t){return t.map(e=>(va.has(e)||va.set(e,Qy++),va.get(e))).sort((e,s)=>e-s).join("-")+r.vertex+r.fragment}function Up(r,t,e){const s=_a(r),i=_a(t);return e.forEach(n=>{ga(n.vertex,s,n.name),ga(n.fragment,i,n.name)}),{vertex:ba(r,s),fragment:ba(t,i)}}const Np=` @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}} }; `,kp=` @in vUV : vec2; @in vColor : vec4; {{header}} @fragment fn main( {{in}} ) -> @location(0) vec4 { {{start}} var outColor:vec4; {{main}} return outColor * vColor; }; `,Lp=` 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}} } `,$p=` in vec4 vColor; in vec2 vUV; out vec4 finalColor; {{header}} void main(void) { {{start}} vec4 outColor; {{main}} finalColor = outColor * vColor; } `,Hp={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, uWorldColorAlpha: vec4, uResolution: vec2, } @group(0) @binding(0) var globalUniforms : GlobalUniforms; `}},t1={name:"global-uniforms-ubo-bit",vertex:{header:` uniform globalUniforms { mat3 uProjectionMatrix; mat3 uWorldTransformMatrix; vec4 uWorldColorAlpha; vec2 uResolution; }; `}},Xp={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; `}};var e1=Object.defineProperty,zp=Object.getOwnPropertySymbols,r1=Object.prototype.hasOwnProperty,s1=Object.prototype.propertyIsEnumerable,jp=(r,t,e)=>t in r?e1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,i1=(r,t)=>{for(var e in t||(t={}))r1.call(t,e)&&jp(r,e,t[e]);if(zp)for(var e of zp(t))s1.call(t,e)&&jp(r,e,t[e]);return r};function sr({bits:r,name:t}){const e=Gp({template:{fragment:kp,vertex:Np},bits:[Hp,...r]});return Pt.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function ir({bits:r,name:t}){return new Gt(i1({name:t},Ip({template:{vertex:Lp,fragment:$p},bits:[Xp,...r]})))}const bi={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},vi={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},ya={};function n1(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 o1(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; ${n1(16)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); ${o1(16)} `}}),ya[r]}const Ta={};function a1(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; } `}},or={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; } `}},Vp=new Int32Array(Bt);for(let r=0;r(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.BOTH=3]="BOTH",r))(Et||{}),u1=Object.defineProperty,Si=Object.getOwnPropertySymbols,Wp=Object.prototype.hasOwnProperty,Yp=Object.prototype.propertyIsEnumerable,qp=(r,t,e)=>t in r?u1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,l1=(r,t)=>{for(var e in t||(t={}))Wp.call(t,e)&&qp(r,e,t[e]);if(Si)for(var e of Si(t))Yp.call(t,e)&&qp(r,e,t[e]);return r},c1=(r,t)=>{var e={};for(var s in r)Wp.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Si)for(var s of Si(r))t.indexOf(s)<0&&Yp.call(r,s)&&(e[s]=r[s]);return e};class Dt extends At{constructor(t){super(),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|=Et.WEBGPU),s&&(o|=Et.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){if(e){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{a={},i={99:new qt},this._ownedBindGroups.push(i[99]);let l=0;for(const c in n)u[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++}i={};for(const l in n){const c=l;let h=n[l];!h.source&&!h._resourceType&&(h=new at(h));const d=u[c];d&&(i[d.group]||(i[d.group]=new qt,this._ownedBindGroups.push(i[d.group])),i[d.group].setResource(h,d.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 qt,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=c1(e,["gpu","gl"]);let o,a;return s&&(o=Pt.from(s)),i&&(a=Gt.from(i)),new Dt(l1({gpuProgram:o,glProgram:a},n))}}const Kp={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 = vColor * calculateMSDFAlpha(outColor, localUniforms.uDistance); `}},Zp={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 = vColor * calculateMSDFAlpha(outColor, uDistance); `}},Qp={name:"msdf-bit",fragment:{header:` fn calculateMSDFAlpha(msdfColor: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; } return alpha; } `}},Jp={name:"msdf-bit",fragment:{header:` float calculateMSDFAlpha(vec4 msdfColor, 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; } return alpha; } `}};class tf extends Dt{constructor(){const t=new at({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new B,type:"mat3x3"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}}),e=sr({name:"sdf-shader",bits:[bi,yi(Bt),Kp,Qp,nr]}),s=ir({name:"sdf-shader",bits:[vi,Ti(Bt),Zp,Jp,or]});super({glProgram:s,gpuProgram:e,resources:{localUniforms:t,batchSamplers:Ai}})}}class Aa{constructor(t){this._gpuBitmapText={},this._renderer=t}validateRenderable(t){const e=this._getGpuBitmapText(t);return t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,e)),this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const s=this._getGpuBitmapText(t);ef(t,s),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,s)),this._renderer.renderPipes.graphics.addRenderable(s,e),s.context.customShader&&this._updateDistanceField(t)}destroyRenderable(t){this._destroyRenderableByUid(t.uid)}_destroyRenderableByUid(t){z.return(this._gpuBitmapText[t]),this._gpuBitmapText[t]=null}updateRenderable(t){const e=this._getGpuBitmapText(t);ef(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){var s;const{context:i}=e,n=es.getFont(t.text,t._style);i.clear(),n.distanceField.type!=="none"&&(i.customShader||(this._sdfShader||(this._sdfShader=new tf),i.customShader=this._sdfShader));const o=Array.from(t.text),a=t._style;let u=(((s=a._stroke)==null?void 0:s.width)||0)/2;u+=n.baseLineOffset;const l=ua(o,a,n);let c=0;const h=a.padding,d=l.scale;i.translate(-t._anchor._x*l.width-h,-t._anchor._y*(l.height+l.offsetY)-h).scale(d,d);const p=a._fill.color;for(let f=0;f{this.destroyRenderable(t)}),this._gpuBitmapText[t.uid]}_updateDistanceField(t){var e;const s=this._getGpuBitmapText(t).context,i=t._style.fontFamily,n=q.get(`${i}-bitmap`),{a:o,b:a,c:u,d:l}=t.groupTransform,c=Math.sqrt(o*o+a*a),h=Math.sqrt(u*u+l*l),d=(Math.abs(c)+Math.abs(h))/2,p=n.baseRenderedFontSize/t._style.fontSize,f=(e=t.resolution)!=null?e:this._renderer.resolution,g=d*n.distanceField.range*(1/p)*f;s.customShader.resources.localUniforms.uniforms.uDistance=g}destroy(){var t;for(const e in this._gpuBitmapText)this._destroyRenderableByUid(e);this._gpuBitmapText=null,(t=this._sdfShader)==null||t.destroy(!0),this._sdfShader=null,this._renderer=null}}Aa.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"bitmapText"};function ef(r,t){t.groupTransform=r.groupTransform,t.groupColorAlpha=r.groupColorAlpha,t.groupColor=r.groupColor,t.groupBlendMode=r.groupBlendMode,t.globalDisplayStatus=r.globalDisplayStatus,t.groupTransform=r.groupTransform,t.localDisplayStatus=r.localDisplayStatus,t.groupAlpha=r.groupAlpha,t._roundPixels=r._roundPixels}L.add(Aa,cp,lp);class Sa{constructor(t){this._gpuText=Object.create(null),this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),s=t._getKey();return e.textureNeedsUploading?(e.textureNeedsUploading=!1,!0):e.currentKey!==s}addRenderable(t){const e=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(e)}updateRenderable(t){const e=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),e.batcher.updateElement(e)}destroyRenderable(t){this._destroyRenderableById(t.uid)}_destroyRenderableById(t){const e=this._gpuText[t];this._renderer.htmlText.decreaseReferenceCount(e.currentKey),z.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){const e=t._getKey(),s=this._getGpuText(t),i=s.batchableSprite;s.currentKey!==e&&this._updateGpuText(t).catch(o=>{console.error(o)}),t._didTextUpdate=!1;const n=t._style.padding;Ur(i.bounds,t._anchor,i.texture,n)}async _updateGpuText(t){var e;t._didTextUpdate=!1;const s=this._getGpuText(t);if(s.generatingTexture)return;const i=t._getKey();this._renderer.htmlText.decreaseReferenceCount(s.currentKey),s.generatingTexture=!0,s.currentKey=i;const n=(e=t.resolution)!=null?e:this._renderer.resolution,o=await this._renderer.htmlText.getManagedTexture(t.text,n,t._style,t._getKey()),a=s.batchableSprite;a.texture=s.texture=o,s.generatingTexture=!1,s.textureNeedsUploading=!0,t.onViewUpdate();const u=t._style.padding;Ur(a.bounds,t._anchor,a.texture,u)}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:w.EMPTY,currentKey:"--",batchableSprite:z.get(ci),textureNeedsUploading:!1,generatingTexture:!1},s=e.batchableSprite;return s.renderable=t,s.texture=w.EMPTY,s.bounds={minX:0,maxX:1,minY:0,maxY:0},s.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuText[t.uid]=e,t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}Sa.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"htmlText"};function rf(){const{userAgent:r}=X.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}const Ea="http://www.w3.org/2000/svg",wa="http://www.w3.org/1999/xhtml";class Ca{constructor(){this.svgRoot=document.createElementNS(Ea,"svg"),this.foreignObject=document.createElementNS(Ea,"foreignObject"),this.domElement=document.createElementNS(wa,"div"),this.styleElement=document.createElementNS(wa,"style"),this.image=new Image;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)}}function sf(r){const t=r._stroke,e=r._fill,s=[`div { ${[`color: ${Y.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?[of(t)]:[],...r.dropShadow?[nf(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return h1(r.tagStyles,s),s.join(" ")}function nf(r){const t=Y.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 of(r){return[`-webkit-text-stroke-width: ${r.width}px`,`-webkit-text-stroke-color: ${Y.shared.setValue(r.color).toHex()}`,`text-stroke-width: ${r.width}px`,`text-stroke-color: ${Y.shared.setValue(r.color).toHex()}`,"paint-order: stroke"].join(";")}const af={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"},uf={fill:r=>`color: ${Y.shared.setValue(r).toHex()}`,breakWords:r=>`word-wrap: ${r?"break-all":"break-word"}`,stroke:of,dropShadow:nf};function h1(r,t){for(const e in r){const s=r[e],i=[];for(const n in s)uf[n]?i.push(uf[n](s[n])):af[n]&&i.push(af[n].replace("{{VALUE}}",s[n]));t.push(`${e} { ${i.join(";")} }`)}}class ke extends Lt{constructor(t={}){var e,s;super(t),this._cssOverrides=[],(e=this.cssOverrides)!=null||(this.cssOverrides=t.cssOverrides),this.tagStyles=(s=t.tagStyles)!=null?s:{}}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=ta(this)+this._cssOverrides.join("-"),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new ke({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow,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})}get cssStyle(){return this._cssStyle||(this._cssStyle=sf(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}}function lf(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 cf(r){const t=await(await X.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 Ra(r,t){const e=await cf(t);return`@font-face { font-family: "${r.fontFamily}"; src: url('${e}'); font-weight: ${r.fontWeight}; font-style: ${r.fontStyle}; }`}const ss=new Map;async function hf(r,t,e){const s=r.filter(i=>q.has(`${i}-and-url`)).map((i,n)=>{if(!ss.has(i)){const{url:o}=q.get(`${i}-and-url`);n===0?ss.set(i,Ra(t,o)):ss.set(i,Ra({fontWeight:e.fontWeight,fontStyle:e.fontStyle,fontFamily:i},o))}return ss.get(i)});return(await Promise.all(s)).join(` `)}function df(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 pf(r,t){const e=Kt.getOptimalCanvasAndContext(r.width,r.height,t),{context:s}=e;return s.clearRect(0,0,r.width,r.height),s.drawImage(r,0,0),Kt.returnCanvasAndContext(e),e.canvas}function ff(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 mf;function Pa(r,t,e,s){s=s||mf||(mf=new Ca);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=Ht.measureFont(t.fontStyle).descent;return{width:a.width,height:a.height+u}}class Ei{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===Et.WEBGPU}getTexture(t){return this._buildTexturePromise(t.text,t.resolution,t.style)}getManagedTexture(t,e,s,i){if(this._activeTextures[i])return this._increaseReferenceCount(i),this._activeTextures[i].promise;const n=this._buildTexturePromise(t,e,s).then(o=>(this._activeTextures[i].texture=o,o));return this._activeTextures[i]={texture:null,promise:n,usageCount:1},n}async _buildTexturePromise(t,e,s){const i=z.get(Ca),n=lf(t,s),o=await hf(n,s,ke.defaultTextStyle),a=Pa(t,s,o,i),u=Math.ceil(Math.ceil(Math.max(1,a.width)+s.padding*2)*e),l=Math.ceil(Math.ceil(Math.max(1,a.height)+s.padding*2)*e),c=i.image;c.width=u|0,c.height=l|0;const h=df(t,s,e,o,i);await ff(c,h,rf()&&n.length>0);let d=c;this._createCanvas&&(d=pf(c,e));const p=ra(d,c.width,c.height,e);return this._createCanvas&&this._renderer.texture.initSource(p.source),z.return(i),p}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e):e.promise.then(s=>{e.texture=s,this._cleanUp(e)}).catch(()=>{}),this._activeTextures[t]=null))}_cleanUp(t){dt.returnTexture(t.texture),t.texture.source.resource=null,t.texture.source.uploadMethodId="unknown"}getReferenceCount(t){return this._activeTextures[t].usageCount}destroy(){this._activeTextures=null}}Ei.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"htmlText"},Ei.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"},L.add(Ei),L.add(Sa);var d1=Object.defineProperty,gf=Object.getOwnPropertySymbols,p1=Object.prototype.hasOwnProperty,f1=Object.prototype.propertyIsEnumerable,_f=(r,t,e)=>t in r?d1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xf=(r,t)=>{for(var e in t||(t={}))p1.call(t,e)&&_f(r,e,t[e]);if(gf)for(var e of gf(t))f1.call(t,e)&&_f(r,e,t[e]);return r};const bf=class nx extends Ze{constructor(...t){var e;let s=(e=t[0])!=null?e:{};s instanceof Float32Array&&(s={positions:s,uvs:t[1],indices:t[2]}),s=xf(xf({},nx.defaultOptions),s);const i=s.positions||new Float32Array([0,0,1,0,1,1,0,1]),n=s.uvs||new Float32Array([0,0,1,0,1,1,0,1]),o=s.indices||new Uint32Array([0,1,2,0,2,3]),a=s.shrinkBuffersToFit,u=new St({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:$.VERTEX|$.COPY_DST}),l=new St({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:$.VERTEX|$.COPY_DST}),c=new St({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}};bf.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let de=bf;var m1=Object.defineProperty,g1=Object.defineProperties,_1=Object.getOwnPropertyDescriptors,vf=Object.getOwnPropertySymbols,x1=Object.prototype.hasOwnProperty,b1=Object.prototype.propertyIsEnumerable,yf=(r,t,e)=>t in r?m1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Tf=(r,t)=>{for(var e in t||(t={}))x1.call(t,e)&&yf(r,e,t[e]);if(vf)for(var e of vf(t))b1.call(t,e)&&yf(r,e,t[e]);return r},Af=(r,t)=>g1(r,_1(t));const ar={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); } `}},Sf=Af(Tf({},ar),{vertex:Af(Tf({},ar.vertex),{header:ar.vertex.header.replace("group(1)","group(2)")})}),wi={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); } `}},Ef={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); `}},wf={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 Da,Ma;class Cf extends Dt{constructor(){Da!=null||(Da=sr({name:"tiling-sprite-shader",bits:[ar,Ef,nr]})),Ma!=null||(Ma=ir({name:"tiling-sprite-shader",bits:[wi,wf,or]}));const t=new at({uMapCoord:{value:new B,type:"mat3x3"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2"},uTextureTransform:{value:new B,type:"mat3x3"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4"}});super({glProgram:Ma,gpuProgram:Da,resources:{localUniforms:new at({uTransformMatrix:{value:new B,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:w.EMPTY.source,uSampler:w.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 Rf extends de{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 Pf(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 Df(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;i{this.destroyRenderable(t)}),this._tilingSpriteDataHash[t.uid]}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:s}=e,i=t.texture.source.style;i.addressMode!=="repeat"&&(i.addressMode="repeat",i.update()),Mf(t,s.uvs),Pf(t,s.positions)}destroy(){for(const t in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[t].renderable);this._tilingSpriteDataHash=null,this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),s=t.texture;let i=!0;return this._renderer.type===Et.WEBGL&&(i=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=s.textureMatrix.isSimple&&(i||s.source.isPowerOfTwo),e.canBatch}}Oa.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"tilingSprite"},L.add(Oa);var v1=Object.defineProperty,Of=Object.getOwnPropertySymbols,y1=Object.prototype.hasOwnProperty,T1=Object.prototype.propertyIsEnumerable,Bf=(r,t,e)=>t in r?v1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gf=(r,t)=>{for(var e in t||(t={}))y1.call(t,e)&&Bf(r,e,t[e]);if(Of)for(var e of Of(t))T1.call(t,e)&&Bf(r,e,t[e]);return r};const If=class ox extends de{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=Gf(Gf({},ox.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?A1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nf=(r,t)=>{for(var e in t||(t={}))S1.call(t,e)&&Uf(r,e,t[e]);if(Ff)for(var e of Ff(t))E1.call(t,e)&&Uf(r,e,t[e]);return r};const kf=class ax extends Ba{constructor(t={}){t=Nf(Nf({},ax.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;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.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,e=this._leftWidth+this._rightWidth,s=this.width>e?1:this.width/e,i=this._topHeight+this._bottomHeight,n=this.height>i?1:this.height/i,o=Math.min(s,n);t[9]=t[11]=t[13]=t[15]=this._topHeight*o,t[17]=t[19]=t[21]=t[23]=this.height-this._bottomHeight*o,t[25]=t[27]=t[29]=t[31]=this.height,t[2]=t[10]=t[18]=t[26]=this._leftWidth*o,t[4]=t[12]=t[20]=t[28]=this.width-this._rightWidth*o,t[6]=t[14]=t[22]=t[30]=this.width,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()}};kf.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let pe=kf;class Ga{constructor(t){this._gpuSpriteHash=Object.create(null),this._renderer=t}addRenderable(t,e){const s=this._getGpuSprite(t);t._didSpriteUpdate&&this._updateBatchableSprite(t,s),this._renderer.renderPipes.batch.addToBatch(s)}updateRenderable(t){const e=this._gpuSpriteHash[t.uid];t._didSpriteUpdate&&this._updateBatchableSprite(t,e),e.batcher.updateElement(e)}validateRenderable(t){const e=t._texture,s=this._getGpuSprite(t);return s.texture._source!==e._source?!s.batcher.checkAndUpdateTexture(s,e):!1}destroyRenderable(t){const e=this._gpuSpriteHash[t.uid];z.return(e),this._gpuSpriteHash[t.uid]=null}_updateBatchableSprite(t,e){t._didSpriteUpdate=!1,e.geometry.update(t),e.texture=t._texture}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new li;return e.geometry=new pe,e.mesh=t,e.texture=t._texture,e.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuSpriteHash[t.uid]=e,t.on("destroyed",()=>{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuSpriteHash)this._gpuSpriteHash[t].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null}}Ga.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"nineSliceSprite"},L.add(Ga);class Ia{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}}Ia.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"filter"};const w1=new B;function Lf(r,t){return t.clear(),Fa(r,t),t.isValid||t.set(0,0,0,0),r.isRenderGroupRoot?t.applyMatrix(r.renderGroup.localTransform):t.applyMatrix(r.renderGroup.worldTransform),t}function Fa(r,t){if(r.localDisplayStatus!==7||!r.measurable)return;const e=!!r.effects.length;let s=t;if((r.isRenderGroupRoot||e)&&(s=Yt.get().clear()),r.boundsArea)t.addRect(r.boundsArea,r.worldTransform);else{if(r.renderPipeId){const n=r.bounds;s.addFrame(n.minX,n.minY,n.maxX,n.maxY,r.groupTransform)}const i=r.children;for(let n=0;n"},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 qt({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){var e,s;const i=this.renderer,n=t.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());const o=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,n.length===0){o.skip=!0;return}const a=o.bounds;t.renderables?$f(t.renderables,a):t.filterEffect.filterArea?(a.clear(),a.addRect(t.filterEffect.filterArea),a.applyMatrix(t.container.worldTransform)):Lf(t.container,a);const u=i.renderTarget.rootRenderTarget.colorTexture.source;let l=u._resolution,c=0,h=u.antialias,d=!1,p=!1;for(let g=0;g0?this._filterStack[this._filterStackIndex-1].bounds:null,u=t.renderTarget.getRenderTarget(e.previousRenderSurface);n=this.getBackTexture(u,i,a)}e.backTexture=n;const o=e.filterEffect.filters;if(this._globalFilterBindGroup.setResource(s.source.style,2),this._globalFilterBindGroup.setResource(n.source,3),t.globalUniforms.pop(),o.length===1)o[0].apply(this,s,e.previousRenderSurface,!1),dt.returnTexture(s);else{let a=e.inputTexture,u=dt.getOptimalTexture(i.width,i.height,a.source._resolution,!1),l=0;for(l=0;l0&&this._filterStack[h].skip;)--h;h>0&&(c=this._filterStack[h].inputTexture.source._resolution);const d=this._filterGlobalUniforms,p=d.uniforms,f=p.uOutputFrame,g=p.uInputSize,m=p.uInputPixel,_=p.uInputClamp,b=p.uGlobalFrame,x=p.uOutputTexture;if(l){let C=this._filterStackIndex;for(;C>0;){C--;const E=this._filterStack[this._filterStackIndex-1];if(!E.skip){u.x=E.bounds.minX,u.y=E.bounds.minY;break}}f[0]=a.minX-u.x,f[1]=a.minY-u.y}else f[0]=0,f[1]=0;f[2]=e.frame.width,f[3]=e.frame.height,g[0]=e.source.width,g[1]=e.source.height,g[2]=1/g[0],g[3]=1/g[1],m[0]=e.source.pixelWidth,m[1]=e.source.pixelHeight,m[2]=1/m[0],m[3]=1/m[1],_[0]=.5*m[2],_[1]=.5*m[3],_[2]=e.frame.width*g[2]-.5*m[2],_[3]=e.frame.height*g[3]-.5*m[3];const y=this.renderer.renderTarget.rootRenderTarget.colorTexture;b[0]=u.x*c,b[1]=u.y*c,b[2]=y.source.width*c,b[3]=y.source.height*c;const A=this.renderer.renderTarget.getRenderTarget(s);if(n.renderTarget.bind(s,!!i),s instanceof w?(x[0]=s.frame.width,x[1]=s.frame.height):(x[0]=A.width,x[1]=A.height),x[2]=A.isRoot?-1:1,d.update(),n.renderPipes.uniformBatch){const C=n.renderPipes.uniformBatch.getUboResource(d);this._globalFilterBindGroup.setResource(C,0)}else this._globalFilterBindGroup.setResource(d,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:C1,shader:t,state:t._state,topology:"triangle-list"}),n.type===Et.WEBGL&&n.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new pt,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}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(B.shared);return n.invert(),i.prepend(n),i.scale(1/e.texture.frame.width,1/e.texture.frame.height),i.translate(e.anchor.x,e.anchor.y),i}}Ua.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"filter"},L.add(Ua),L.add(Ia);var R1={__proto__:null};const Na=[];L.handleByNamedList(v.Environment,Na);async function Hf(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))(bt||{});class La{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?P1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ri=(r,t)=>{for(var e in t||(t={}))D1.call(t,e)&&zf(r,e,t[e]);if(Xf)for(var e of Xf(t))M1.call(t,e)&&zf(r,e,t[e]);return r};const O1=["init","destroy","contextChange","resolutionChange","reset","renderEnd","renderStart","render","update","postrender","prerender"],jf=class ux extends At{constructor(t){var e;super(),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;const s=[...O1,...(e=t.runners)!=null?e:[]];this._addRunners(...s),this._addSystems(t.systems),this._addPipes(t.renderPipes,t.renderPipeAdaptors),this._unsafeEvalCheck()}async init(t={}){for(const e in this._systemsHash){const s=this._systemsHash[e].constructor.defaultOptions;t=Ri(Ri({},s),t)}t=Ri(Ri({},ux.defaultOptions),t),this._roundPixels=t.roundPixels?1:0;for(let e=0;e{this.runners[e]=new La(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(!ka())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};jf.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let ns=jf,$a;function os(r){return $a!==void 0||($a=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:ns.defaultOptions.failIfMajorPerformanceCaveat};try{if(!X.get().getWebGLRenderingContext())return!1;let s=X.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}})()),$a}let Ha;async function as(r={}){return Ha!==void 0||(Ha=await(async()=>{if(!X.get().getNavigator().gpu)return!1;try{return await(await navigator.gpu.requestAdapter(r)).requestDevice(),!0}catch(t){return!1}})()),Ha}var B1=Object.defineProperty,Vf=Object.getOwnPropertySymbols,G1=Object.prototype.hasOwnProperty,I1=Object.prototype.propertyIsEnumerable,Wf=(r,t,e)=>t in r?B1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,us=(r,t)=>{for(var e in t||(t={}))G1.call(t,e)&&Wf(r,e,t[e]);if(Vf)for(var e of Vf(t))I1.call(t,e)&&Wf(r,e,t[e]);return r};const Yf=["webgl","webgpu","canvas"];async function qf(r){var t,e;let s=[];r.preference?(s.push(r.preference),Yf.forEach(a=>{a!==r.preference&&s.push(a)})):s=Yf.slice();let i;await Hf((t=r.manageImports)!=null?t:!0);let n={};for(let a=0;at in r?F1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,k1=(r,t)=>{for(var e in t||(t={}))U1.call(t,e)&&Zf(r,e,t[e]);if(Kf)for(var e of Kf(t))N1.call(t,e)&&Zf(r,e,t[e]);return r};const Qf=class zl{constructor(...t){this.stage=new K}async init(t){t=k1({},t),this.renderer=await qf(t),zl._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=zl._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}};Qf._plugins=[];let Jf=Qf;L.handleByList(v.Application,Jf._plugins);class tm{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 w),getCacheableAssets:(r,t)=>{const e={};return r.forEach(s=>{t.forEach((i,n)=>{e[s+(n===0?"":n+1)]=i})}),e}};async function Xa(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 rm={extension:{type:v.DetectionParser,priority:1},test:async()=>Xa("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},sm=["png","jpg","jpeg"],im={extension:{type:v.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...sm],remove:async r=>r.filter(t=>!sm.includes(t))},L1="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Pi(r){return L1?!1:document.createElement("video").canPlayType(r)!==""}const nm={extension:{type:v.DetectionParser,priority:0},test:async()=>Pi("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},om={extension:{type:v.DetectionParser,priority:0},test:async()=>Pi("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},am={extension:{type:v.DetectionParser,priority:0},test:async()=>Pi("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},um={extension:{type:v.DetectionParser,priority:0},test:async()=>Xa("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};var $1=Object.defineProperty,H1=Object.defineProperties,X1=Object.getOwnPropertyDescriptors,lm=Object.getOwnPropertySymbols,z1=Object.prototype.hasOwnProperty,j1=Object.prototype.propertyIsEnumerable,cm=(r,t,e)=>t in r?$1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,V1=(r,t)=>{for(var e in t||(t={}))z1.call(t,e)&&cm(r,e,t[e]);if(lm)for(var e of lm(t))j1.call(t,e)&&cm(r,e,t[e]);return r},W1=(r,t)=>H1(r,X1(t));class hm{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.loadParser&&(a=this._parserHash[e.loadParser]),!a){for(let u=0;u({alias:[l],src:l})),a=o.length,u=o.map(async l=>{const c=xt.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=Mt(t,s=>({alias:[s],src:s})).map(async s=>{var i,n;const o=xt.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).reduce((t,e)=>(e.name&&t[e.name],W1(V1({},t),{[e.name]:e})),{})}}function Ue(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 It(r,t){const e=r.split("?")[0],s=xt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const Y1=".json",q1="application/json",dm={extension:{type:v.LoadParser,priority:Tt.Low},name:"loadJson",test(r){return Ue(r,q1)||It(r,Y1)},async load(r){return await(await X.get().fetch(r)).json()}},K1=".txt",Z1="text/plain",pm={name:"loadTxt",extension:{type:v.LoadParser,priority:Tt.Low},test(r){return Ue(r,Z1)||It(r,K1)},async load(r){return await(await X.get().fetch(r)).text()}};var Q1=Object.defineProperty,J1=Object.defineProperties,tT=Object.getOwnPropertyDescriptors,fm=Object.getOwnPropertySymbols,eT=Object.prototype.hasOwnProperty,rT=Object.prototype.propertyIsEnumerable,mm=(r,t,e)=>t in r?Q1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,sT=(r,t)=>{for(var e in t||(t={}))eT.call(t,e)&&mm(r,e,t[e]);if(fm)for(var e of fm(t))rT.call(t,e)&&mm(r,e,t[e]);return r},iT=(r,t)=>J1(r,tT(t));const nT=["normal","bold","100","200","300","400","500","600","700","800","900"],oT=[".ttf",".otf",".woff",".woff2"],aT=["font/ttf","font/otf","font/woff","font/woff2"],uT=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function gm(r){const t=xt.extname(r),e=xt.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(uT)){s=!1;break}let i=e.join(" ");return s||(i=`"${i.replace(/[\\"]/g,"\\$&")}"`),i}const lT=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function cT(r){return lT.test(r)?r:encodeURI(r)}const _m={extension:{type:v.LoadParser,priority:Tt.Low},name:"loadWebFont",test(r){return Ue(r,aT)||It(r,oT)},async load(r,t){var e,s,i,n,o,a;const u=X.get().getFontFaceSet();if(u){const l=[],c=(s=(e=t.data)==null?void 0:e.family)!=null?s:gm(r),h=(o=(n=(i=t.data)==null?void 0:i.weights)==null?void 0:n.filter(p=>nT.includes(p)))!=null?o:["normal"],d=(a=t.data)!=null?a:{};for(let p=0;p{q.remove(t.family),X.get().getFontFaceSet().delete(t)})}};function Di(r,t=1){var e;const s=(e=ce.RETINA_PREFIX)==null?void 0:e.exec(r);return s?parseFloat(s[1]):t}function fe(r,t,e){r.label=e,r._sourceOrigin=e;const s=new w({source:r,label:e}),i=()=>{delete t.promiseCache[e],q.has(e)&&q.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&i()}),s.once("destroy",()=>{r.destroyed||i()}),s}var hT=Object.defineProperty,Mi=Object.getOwnPropertySymbols,xm=Object.prototype.hasOwnProperty,bm=Object.prototype.propertyIsEnumerable,vm=(r,t,e)=>t in r?hT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,dT=(r,t)=>{for(var e in t||(t={}))xm.call(t,e)&&vm(r,e,t[e]);if(Mi)for(var e of Mi(t))bm.call(t,e)&&vm(r,e,t[e]);return r},pT=(r,t)=>{var e={};for(var s in r)xm.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Mi)for(var s of Mi(r))t.indexOf(s)<0&&bm.call(r,s)&&(e[s]=r[s]);return e};const fT=".svg",mT="image/svg+xml",ym={extension:{type:v.LoadParser,priority:Tt.Low},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return Ue(r,mT)||It(r,fT)},async load(r,t,e){var s;return((s=t.data.parseAsGraphicsContext)!=null?s:this.config.parseAsGraphicsContext)?_T(r):gT(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function gT(r,t,e,s){var i,n,o,a,u;const l=await(await X.get().fetch(r)).blob(),c=URL.createObjectURL(l),h=new Image;h.src=c,h.crossOrigin=s,await h.decode(),URL.revokeObjectURL(c);const d=document.createElement("canvas"),p=d.getContext("2d"),f=((i=t.data)==null?void 0:i.resolution)||Di(r),g=(o=(n=t.data)==null?void 0:n.width)!=null?o:h.width,m=(u=(a=t.data)==null?void 0:a.height)!=null?u:h.height;d.width=g*f,d.height=m*f,p.drawImage(h,0,0,g*f,m*f);const _=t.data,{parseAsGraphicsContext:b}=_,x=pT(_,["parseAsGraphicsContext"]),y=new De(dT({resource:d,alphaMode:"premultiply-alpha-on-upload",resolution:f},x));return fe(y,e,r)}async function _T(r){const t=await(await X.get().fetch(r)).text(),e=new kt;return e.svg(t),e}const xT=`(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 ur=null,za=class{constructor(){ur||(ur=URL.createObjectURL(new Blob([xT],{type:"application/javascript"}))),this.worker=new Worker(ur)}};za.revokeObjectURL=function(){ur&&(URL.revokeObjectURL(ur),ur=null)};const bT='(function(){"use strict";async function e(t){const a=await fetch(t);if(!a.ok)throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${t}: ${a.status} ${a.statusText}`);const s=await a.blob();return await createImageBitmap(s)}self.onmessage=async t=>{try{const a=await e(t.data.data[0]);self.postMessage({data:a,uuid:t.data.uuid,id:t.data.id},[a])}catch(a){self.postMessage({error:a,uuid:t.data.uuid,id:t.data.id})}}})();\n';let lr=null,Tm=class{constructor(){lr||(lr=URL.createObjectURL(new Blob([bT],{type:"application/javascript"}))),this.worker=new Worker(lr)}};Tm.revokeObjectURL=function(){lr&&(URL.revokeObjectURL(lr),lr=null)};let Am=0,ja,vT=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 za;e.addEventListener("message",s=>{e.terminate(),za.revokeObjectURL(),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){ja===void 0&&(ja=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[Am]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Am++,id:s})}};const Va=new vT;var yT=Object.defineProperty,Sm=Object.getOwnPropertySymbols,TT=Object.prototype.hasOwnProperty,AT=Object.prototype.propertyIsEnumerable,Em=(r,t,e)=>t in r?yT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ST=(r,t)=>{for(var e in t||(t={}))TT.call(t,e)&&Em(r,e,t[e]);if(Sm)for(var e of Sm(t))AT.call(t,e)&&Em(r,e,t[e]);return r};const ET=[".jpeg",".jpg",".png",".webp",".avif"],wT=["image/jpeg","image/png","image/webp","image/avif"];async function wm(r){const t=await X.get().fetch(r);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const Wa={name:"loadTextures",extension:{type:v.LoadParser,priority:Tt.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Ue(r,wT)||It(r,ET)},async load(r,t,e){var s;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Va.isImageBitmapSupported()?i=await Va.loadImageBitmap(r):i=await wm(r):i=await new Promise(o=>{i=new Image,i.crossOrigin=this.config.crossOrigin,i.src=r,i.complete?o(i):i.onload=()=>{o(i)}});const n=new De(ST({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((s=t.data)==null?void 0:s.resolution)||Di(r)},t.data));return fe(n,e,r)},unload(r){r.destroy(!0)}};var CT=Object.defineProperty,RT=Object.defineProperties,PT=Object.getOwnPropertyDescriptors,Cm=Object.getOwnPropertySymbols,DT=Object.prototype.hasOwnProperty,MT=Object.prototype.propertyIsEnumerable,Rm=(r,t,e)=>t in r?CT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ya=(r,t)=>{for(var e in t||(t={}))DT.call(t,e)&&Rm(r,e,t[e]);if(Cm)for(var e of Cm(t))MT.call(t,e)&&Rm(r,e,t[e]);return r},Pm=(r,t)=>RT(r,PT(t));const Dm=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],OT=Dm.map(r=>`video/${r.substring(1)}`);function Mm(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=Bm(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function Om(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 Bm(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":""}const Gm={name:"loadVideo",extension:{type:v.LoadParser},config:null,test(r){const t=Ue(r,OT),e=It(r,Dm);return t||e},async load(r,t,e){var s,i;const n=Ya(Pm(Ya({},Hr.defaultOptions),{resolution:((s=t.data)==null?void 0:s.resolution)||Di(r),alphaMode:((i=t.data)==null?void 0:i.alphaMode)||await lo()}),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),Mm(o,r,n.crossorigin);const u=document.createElement("source");let l;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=Hr.MIME_TYPES[c]||`video/${c}`}return u.src=r,l&&(u.type=l),new Promise(c=>{const h=async()=>{const d=new Hr(Pm(Ya({},n),{resource:o}));o.removeEventListener("canplay",h),t.data.preload&&await Om(o),c(fe(d,e,r))};o.addEventListener("canplay",h),o.appendChild(u)})},unload(r){r.destroy(!0)}},qa={extension:v.ResolveParser,test:Wa.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=ce.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},Im={extension:v.ResolveParser,test:r=>ce.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:qa.parse};class Fm{constructor(){this._detections=[],this._initialized=!1,this.resolver=new ce,this.loader=new hm,this.cache=q,this._backgroundLoader=new tm(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=Ir(t),i=Mt(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];return u+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(p=>{n[h]=p})});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 q.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}),q.set(u,a)}),n}async unload(t){this._initialized||await this.init();const e=Mt(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=Mt(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=>{q.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 ls=new Fm;L.handleByList(v.LoadParser,ls.loader.parsers).handleByList(v.ResolveParser,ls.resolver.parsers).handleByList(v.CacheParser,ls.cache.parsers).handleByList(v.DetectionParser,ls.detections),L.add(em,im,rm,um,nm,om,am,dm,pm,_m,ym,Wa,Gm,qa,Im);const Um={loader:v.LoadParser,resolver:v.ResolveParser,cache:v.CacheParser,detection:v.DetectionParser};L.handle(v.Asset,r=>{const t=r.ref;Object.entries(Um).filter(([e])=>!!t[e]).forEach(([e,s])=>{var i;return L.add(Object.assign(t[e],{extension:(i=t[e].extension)!=null?i:s}))})},r=>{const t=r.ref;Object.keys(Um).filter(e=>!!t[e]).forEach(e=>L.remove(t[e]))});const BT={extension:{type:v.DetectionParser,priority:3},test:async()=>!!(await as()||os()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};class cs extends st{constructor(t){super(t),this.uploadMethodId="compressed",this.resource=t.resource,this.mipLevelCount=this.resource.length}}let Oi;function Ka(){if(Oi)return Oi;const r=document.createElement("canvas").getContext("webgl");return r?(Oi=[...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"]:[]],Oi):[]}let Bi;async function Za(){if(Bi)return Bi;const r=await navigator.gpu.requestAdapter();return Bi=[...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"]:[]],Bi}let Qa;async function Ja(){return Qa!==void 0||(Qa=await(async()=>{const r=await as(),t=os();if(r&&t){const e=await Za(),s=Ka();return e.filter(i=>s.includes(i))}else{if(r)return await Za();if(t)return Ka()}return[]})()),Qa}const Nm=["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 Gi;async function hs(){if(Gi!==void 0)return Gi;const r=await Ja();return Gi=[...Nm,...r],Gi}const GT='(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 cr=null,km=class{constructor(){cr||(cr=URL.createObjectURL(new Blob([GT],{type:"application/javascript"}))),this.worker=new Worker(cr)}};km.revokeObjectURL=function(){cr&&(URL.revokeObjectURL(cr),cr=null)};const Ii={jsUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.js",wasmUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.wasm"};function IT(r){Object.assign(Ii,r)}let ds;const Lm={};function FT(r){return ds||(ds=new km().worker,ds.onmessage=t=>{const{success:e,url:s,textureOptions:i}=t.data;e||console.warn("Failed to load Basis texture",s),Lm[s](i)},ds.postMessage({type:"init",jsUrl:Ii.jsUrl,wasmUrl:Ii.wasmUrl,supportedTextures:r})),ds}function $m(r,t){const e=FT(t);return new Promise(s=>{Lm[r]=s,e.postMessage({type:"load",url:r})})}const UT={extension:{type:v.LoadParser,priority:Tt.High},name:"loadBasis",test(r){return It(r,[".basis"])},async load(r,t,e){const s=await hs(),i=await $m(r,s),n=new cs(i);return fe(n,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function NT(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))(Hm||{}),Xm=(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))(Xm||{});function ht(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var wt=(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=ht("UYVY")]="UYVY",r[r.R8G8_B8G8=ht("RGBG")]="R8G8_B8G8",r[r.YUY2=ht("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=ht("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=ht("DXT1")]="DXT1",r[r.DXT2=ht("DXT2")]="DXT2",r[r.DXT3=ht("DXT3")]="DXT3",r[r.DXT4=ht("DXT4")]="DXT4",r[r.DXT5=ht("DXT5")]="DXT5",r[r.ATI1=ht("ATI1")]="ATI1",r[r.AT1N=ht("AT1N")]="AT1N",r[r.ATI2=ht("ATI2")]="ATI2",r[r.AT2N=ht("AT2N")]="AT2N",r[r.BC4U=ht("BC4U")]="BC4U",r[r.BC4S=ht("BC4S")]="BC4S",r[r.BC5U=ht("BC5U")]="BC5U",r[r.BC5S=ht("BC5S")]="BC5S",r[r.DX10=ht("DX10")]="DX10",r))(wt||{});const tu={[wt.DXT1]:"bc1-rgba-unorm",[wt.DXT2]:"bc2-rgba-unorm",[wt.DXT3]:"bc2-rgba-unorm",[wt.DXT4]:"bc3-rgba-unorm",[wt.DXT5]:"bc3-rgba-unorm",[wt.ATI1]:"bc4-r-unorm",[wt.BC4U]:"bc4-r-unorm",[wt.BC4S]:"bc4-r-snorm",[wt.ATI2]:"bc5-rg-unorm",[wt.BC5U]:"bc5-rg-unorm",[wt.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},vt={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:$T,HEADER_DX10_FIELDS:HT,DXGI_FORMAT:Hm,D3D10_RESOURCE_DIMENSION:Xm,D3DFMT:wt},zm={"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 jm(r,t){const{format:e,fourCC:s,width:i,height:n,dataOffset:o,mipmapCount:a}=zT(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=XT(e,i,n,o,a,r);return{format:e,width:i,height:n,resource:u,alphaMode:"no-premultiply-alpha"}}function XT(r,t,e,s,i,n){const o=[],a=zm[r];let u=t,l=e,c=s;for(let h=0;h>1,1),l=Math.max(l>>1,1)}return o}function zT(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=jT(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 jT(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 vt)return vt[n];throw new Error(`DDSParser cannot parse texture data with DXGI format ${n}`)}if(e in tu)return tu[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 VT(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 VT(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 vt[F.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&s===65280&&i===255&&n===4278190080)return vt[F.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&s===1047552&&i===1023&&n===3221225472)return vt[F.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&s===4294901760&&i===0&&n===0)return vt[F.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&s===0&&i===0&&n===0)return vt[F.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&s===992&&i===31&&n===32768)return vt[F.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&s===2016&&i===31&&n===0)return vt[F.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&s===240&&i===15&&n===61440)return vt[F.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&s===0&&i===0&&n===65280)return vt[F.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&s===0&&i===0&&n===0)return vt[F.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&s===0&&i===0&&n===0)return vt[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 WT={extension:{type:v.LoadParser,priority:Tt.High},name:"loadDDS",test(r){return It(r,[".dds"])},async load(r,t,e){const s=await hs(),i=await(await fetch(r)).arrayBuffer(),n=jm(i,s),o=new cs(n);return fe(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var Vm=(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))(Vm||{}),YT=(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))(YT||{}),qT=(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))(qT||{});const KT={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"},ZT=[171,75,84,88,32,49,49,187,13,10,26,10],QT={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},JT=64,tA=67305985,eA={5121:1,5123:2,5124:4,5125:4,5126:4,36193:8},rA={6408:4,6407:3,33319:2,6403:1,6409:1,6410:2,6406:1},sA={32819:2,32820:2,33635:2},iA={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},et={FILE_HEADER_SIZE:JT,FILE_IDENTIFIER:ZT,FORMATS_TO_COMPONENTS:rA,INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:iA,INTERNAL_FORMAT_TO_TEXTURE_FORMATS:KT,FIELDS:QT,TYPES_TO_BYTES_PER_COMPONENT:eA,TYPES_TO_BYTES_PER_PIXEL:sA,ENDIANNESS:tA};function Wm(r,t){const e=new DataView(r);if(!uA(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}=aA(e),h=et.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=oA(i,n,o),p=nA(e,i,d,a,u,c,l,s);return{format:h,width:a,height:u,resource:p,alphaMode:"no-premultiply-alpha"}}function nA(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 oA(r,t,e){let s=et.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(et.TYPES_TO_BYTES_PER_COMPONENT[r]?s=et.TYPES_TO_BYTES_PER_COMPONENT[r]*et.FORMATS_TO_COMPONENTS[t]:s=et.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 aA(r){const t=r.getUint32(et.FIELDS.ENDIANNESS,!0)===et.ENDIANNESS,e=r.getUint32(et.FIELDS.GL_TYPE,t),s=r.getUint32(et.FIELDS.GL_FORMAT,t),i=r.getUint32(et.FIELDS.GL_INTERNAL_FORMAT,t),n=r.getUint32(et.FIELDS.PIXEL_WIDTH,t),o=r.getUint32(et.FIELDS.PIXEL_HEIGHT,t)||1,a=r.getUint32(et.FIELDS.PIXEL_DEPTH,t)||1,u=r.getUint32(et.FIELDS.NUMBER_OF_ARRAY_ELEMENTS,t)||1,l=r.getUint32(et.FIELDS.NUMBER_OF_FACES,t),c=r.getUint32(et.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),h=r.getUint32(et.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:et.FILE_HEADER_SIZE+h}}function uA(r){for(let t=0;tt.destroy(!0)):r.destroy(!0)}},cA='(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 hr=null;class Ym{constructor(){hr||(hr=URL.createObjectURL(new Blob([cA],{type:"application/javascript"}))),this.worker=new Worker(hr)}}Ym.revokeObjectURL=function(){hr&&(URL.revokeObjectURL(hr),hr=null)};const Fi={jsUrl:"https://files.pixijs.download/transcoders/ktx/libktx.js",wasmUrl:"https://files.pixijs.download/transcoders/ktx/libktx.wasm"};function hA(r){Object.assign(Fi,r)}let ps;const qm={};function dA(r){return ps||(ps=new Ym().worker,ps.onmessage=t=>{const{success:e,url:s,textureOptions:i}=t.data;e||console.warn("Failed to load KTX texture",s),qm[s](i)},ps.postMessage({type:"init",jsUrl:Fi.jsUrl,wasmUrl:Fi.wasmUrl,supportedTextures:r})),ps}function Km(r,t){const e=dA(t);return new Promise(s=>{qm[r]=s,e.postMessage({type:"load",url:r})})}const pA={extension:{type:v.LoadParser,priority:Tt.High},name:"loadKTX2",test(r){return It(r,".ktx2")},async load(r,t,e){const s=await hs(),i=await Km(r,s),n=new cs(i);return fe(n,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},eu={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:Zm},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:Zm}};function fA(r){const t=r.format;if(eu[t]){const e=eu[t].convertFunction,s=r.resource;for(let i=0;iIt(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];Ui.includes(n)&&(s=n)}else s=i[i.length-1];return{resolution:parseFloat((e=(t=ce.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s,src:r}}};let Ni;const TA={extension:{type:v.DetectionParser,priority:2},test:async()=>!!(await as()||os()),add:async r=>{const t=await Ja();return Ni=AA(t),[...Ni,...r]},remove:async r=>Ni?r.filter(t=>!(t in Ni)):r};function AA(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=Ui.indexOf(s),o=Ui.indexOf(i);return n===-1?1:o===-1?-1:n-o}),t}const SA=new pt,ru=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:kr(t,s,SA);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)}if(!(!t.cullableChildren||t.culled||!t.renderable||!t.measurable||!t.includeInBuild))for(let n=0;n{tg.shared.cull(this.stage,this.renderer.screen),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}eg.extension={priority:10,type:v.Application,name:"culler"};const EA={extension:{type:v.Environment,name:"webworker",priority:0},test:()=>typeof self!="undefined"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(function(){return R1})}};var wA=Object.defineProperty,ki=Object.getOwnPropertySymbols,rg=Object.prototype.hasOwnProperty,sg=Object.prototype.propertyIsEnumerable,ig=(r,t,e)=>t in r?wA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,su=(r,t)=>{for(var e in t||(t={}))rg.call(t,e)&&ig(r,e,t[e]);if(ki)for(var e of ki(t))sg.call(t,e)&&ig(r,e,t[e]);return r},CA=(r,t)=>{var e={};for(var s in r)rg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&ki)for(var s of ki(r))t.indexOf(s)<0&&sg.call(r,s)&&(e[s]=r[s]);return e};const ng=class jl extends Dt{constructor(t){t=su(su({},jl.defaultOptions),t),super(t),this.enabled=!0,this._state=Nt.for2d(),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.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=CA(e,["gpu","gl"]);let o,a;return s&&(o=Pt.from(s)),i&&(a=Gt.from(i)),new jl(su({gpuProgram:o,glProgram:a},n))}};ng.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1};let ne=ng;var og=` 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); {MAIN} } `,ag=`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(); } `,ug=` 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 out = vec4(0.0,0.0,0.0,0.0); {MAIN} return out; }`,RA=Object.defineProperty,lg=Object.getOwnPropertySymbols,PA=Object.prototype.hasOwnProperty,DA=Object.prototype.propertyIsEnumerable,cg=(r,t,e)=>t in r?RA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hg=(r,t)=>{for(var e in t||(t={}))PA.call(t,e)&&cg(r,e,t[e]);if(lg)for(var e of lg(t))DA.call(t,e)&&cg(r,e,t[e]);return r};class MA extends ne{constructor(t){const e=t.gpu,s=dg(hg({source:ug},e)),i=Pt.from({vertex:{source:s,entryPoint:"mainVertex"},fragment:{source:s,entryPoint:"mainFragment"}}),n=t.gl,o=dg(hg({source:og},n)),a=Gt.from({vertex:ag,fragment:o}),u=new at({uBlend:{value:1,type:"f32"}});super({gpuProgram:i,glProgram:a,blendRequired:!0,resources:{blendUniforms:u,uBackTexture:w.EMPTY}})}}function dg(r){const{source:t,functions:e,main:s}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",s)}const OA=` 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; } `,BA=` 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 Li=`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(); } `,pg=` in vec2 vTextureCoord; out vec4 finalColor; uniform float uAlpha; uniform sampler2D uTexture; void main() { finalColor = texture(uTexture, vTextureCoord) * uAlpha; } `,iu=`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; }`,GA=Object.defineProperty,IA=Object.defineProperties,FA=Object.getOwnPropertyDescriptors,$i=Object.getOwnPropertySymbols,fg=Object.prototype.hasOwnProperty,mg=Object.prototype.propertyIsEnumerable,gg=(r,t,e)=>t in r?GA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nu=(r,t)=>{for(var e in t||(t={}))fg.call(t,e)&&gg(r,e,t[e]);if($i)for(var e of $i(t))mg.call(t,e)&&gg(r,e,t[e]);return r},UA=(r,t)=>IA(r,FA(t)),NA=(r,t)=>{var e={};for(var s in r)fg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&$i)for(var s of $i(r))t.indexOf(s)<0&&mg.call(r,s)&&(e[s]=r[s]);return e};const _g=class lx extends ne{constructor(t){t=nu(nu({},lx.defaultOptions),t);const e=Pt.from({vertex:{source:iu,entryPoint:"mainVertex"},fragment:{source:iu,entryPoint:"mainFragment"}}),s=Gt.from({vertex:Li,fragment:pg,name:"alpha-filter"}),i=t,{alpha:n}=i,o=NA(i,["alpha"]),a=new at({uAlpha:{value:n,type:"f32"}});super(UA(nu({},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}};_g.defaultOptions={alpha:1};let kA=_g;const ou={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]},LA=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," finalColor = vec4(0.0);"," %blur%","}"].join(` `);function xg(r){const t=ou[r],e=t.length;let s=LA,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 $A=` 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 bg(r,t){const e=Math.ceil(r/2);let s=$A,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 strength = gfu.uInputSize.w * 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 Tg(r,t){const e=ou[t],s=e.length,i=[],n=[],o=[];for(let h=0;h,`,r?n[h]=`filteredCord + vec2(${h-s+1} * strength, 0.0),`:n[h]=`filteredCord + vec2(0.0, ${h-s+1} * strength),`;const d=ht in r?HA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,au=(r,t)=>{for(var e in t||(t={}))XA.call(t,e)&&Sg(r,e,t[e]);if(Ag)for(var e of Ag(t))zA.call(t,e)&&Sg(r,e,t[e]);return r};const Eg=class cx extends ne{constructor(t){t=au(au({},cx.defaultOptions),t);const e=vg(t.horizontal,t.kernelSize),s=Tg(t.horizontal,t.kernelSize);super(au({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=dt.getSameSizeTexture(e);let o=e,a=n;this._state.blend=!1;for(let u=0;ut in r?jA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fs=(r,t)=>{for(var e in t||(t={}))wg.call(t,e)&&Rg(r,e,t[e]);if(Xi)for(var e of Xi(t))Cg.call(t,e)&&Rg(r,e,t[e]);return r},YA=(r,t)=>VA(r,WA(t)),qA=(r,t)=>{var e={};for(var s in r)wg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Xi)for(var s of Xi(r))t.indexOf(s)<0&&Cg.call(r,s)&&(e[s]=r[s]);return e};class Pg extends ne{constructor(...t){var e;let s=(e=t[0])!=null?e:{};typeof s=="number"&&(s={strength:s},t[1]&&(s.quality=t[1]),t[2]&&(s.resolution=t[2]),t[3]&&(s.kernelSize=t[3])),s=fs(fs({},Hi.defaultOptions),s);const i=s,{strength:n,quality:o}=i,a=qA(i,["strength","quality"]);super(YA(fs({},a),{compatibleRenderers:Et.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new Hi(fs({horizontal:!1},s)),this.blurYFilter=new Hi(fs({horizontal:!0},s)),this.quality=o,this.blur=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=dt.getSameSizeTexture(e);this.blurXFilter.apply(t,e,a,!0),this.blurYFilter.apply(t,a,s,i),dt.returnTexture(a)}else o?this.blurYFilter.apply(t,e,s,i):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 blur(){return this.blurXFilter.blur}set blur(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 blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}Pg.defaultOptions={strength:8,quality:4,kernelSize:5};var Dg=` 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); } `,uu=`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); }`,KA=Object.defineProperty,ZA=Object.defineProperties,QA=Object.getOwnPropertyDescriptors,Mg=Object.getOwnPropertySymbols,JA=Object.prototype.hasOwnProperty,tS=Object.prototype.propertyIsEnumerable,Og=(r,t,e)=>t in r?KA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,eS=(r,t)=>{for(var e in t||(t={}))JA.call(t,e)&&Og(r,e,t[e]);if(Mg)for(var e of Mg(t))tS.call(t,e)&&Og(r,e,t[e]);return r},rS=(r,t)=>ZA(r,QA(t));class sS extends ne{constructor(t={}){const e=new at({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=Pt.from({vertex:{source:uu,entryPoint:"mainVertex"},fragment:{source:uu,entryPoint:"mainFragment"}}),i=Gt.from({vertex:Li,fragment:Dg,name:"color-matrix-filter"});super(rS(eS({},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]=Y.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=Y.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 Bg=` 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)); } `,Gg=`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(); } `,lu=` 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)); }`,iS=Object.defineProperty,nS=Object.defineProperties,oS=Object.getOwnPropertyDescriptors,zi=Object.getOwnPropertySymbols,Ig=Object.prototype.hasOwnProperty,Fg=Object.prototype.propertyIsEnumerable,Ug=(r,t,e)=>t in r?iS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,aS=(r,t)=>{for(var e in t||(t={}))Ig.call(t,e)&&Ug(r,e,t[e]);if(zi)for(var e of zi(t))Fg.call(t,e)&&Ug(r,e,t[e]);return r},uS=(r,t)=>nS(r,oS(t)),lS=(r,t)=>{var e={};for(var s in r)Ig.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&zi)for(var s of zi(r))t.indexOf(s)<0&&Fg.call(r,s)&&(e[s]=r[s]);return e};class cS extends ne{constructor(...t){let e=t[0];e instanceof Xt&&(e={sprite:e,scale:t[1]});const s=e,{sprite:i,scale:n}=s,o=lS(s,["sprite","scale"]);let a=n!=null?n:20;typeof a=="number"&&(a=new it(a,a));const u=new at({uFilterMatrix:{value:new B,type:"mat3x3"},uScale:{value:a,type:"vec2"},uRotation:{value:new Float32Array([0,0,0,0]),type:"mat2x2"}}),l=Gt.from({vertex:Gg,fragment:Bg,name:"displacement-filter"}),c=Pt.from({vertex:{source:lu,entryPoint:"mainVertex"},fragment:{source:lu,entryPoint:"mainFragment"}}),h=i.texture.source;super(uS(aS({},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 Ng=` 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; } `,cu=` 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; }`,hS=Object.defineProperty,dS=Object.defineProperties,pS=Object.getOwnPropertyDescriptors,ji=Object.getOwnPropertySymbols,kg=Object.prototype.hasOwnProperty,Lg=Object.prototype.propertyIsEnumerable,$g=(r,t,e)=>t in r?hS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hu=(r,t)=>{for(var e in t||(t={}))kg.call(t,e)&&$g(r,e,t[e]);if(ji)for(var e of ji(t))Lg.call(t,e)&&$g(r,e,t[e]);return r},fS=(r,t)=>dS(r,pS(t)),mS=(r,t)=>{var e={};for(var s in r)kg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&ji)for(var s of ji(r))t.indexOf(s)<0&&Lg.call(r,s)&&(e[s]=r[s]);return e};const Hg=class hx extends ne{constructor(t={}){t=hu(hu({},hx.defaultOptions),t);const e=Pt.from({vertex:{source:cu,entryPoint:"mainVertex"},fragment:{source:cu,entryPoint:"mainFragment"}}),s=Gt.from({vertex:Li,fragment:Ng,name:"noise-filter"}),i=t,{noise:n,seed:o}=i,a=mS(i,["noise","seed"]);super(fS(hu({},a),{gpuProgram:e,glProgram:s,resources:{noiseUniforms:new at({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}};Hg.defaultOptions={noise:.5};let gS=Hg;var Xg=`in vec2 vMaskCoord; in vec2 vTextureCoord; uniform sampler2D uTexture; uniform sampler2D uMaskTexture; uniform float uAlpha; uniform vec4 uMaskClamp; 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); original *= (alphaMul * masky.r * uAlpha * clip); finalColor = original; } `,zg=`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); } `,du=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct MaskUniforms { uFilterMatrix:mat3x3, uMaskClamp:vec4, 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 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 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 npmAlpha = 0.0; var alphaMul = 1.0 - npmAlpha * (1.0 - mask.a); var a = (alphaMul * mask.r) * clip; return vec4(source.rgb, source.a) * a; }`,_S=Object.defineProperty,xS=Object.defineProperties,bS=Object.getOwnPropertyDescriptors,Vi=Object.getOwnPropertySymbols,jg=Object.prototype.hasOwnProperty,Vg=Object.prototype.propertyIsEnumerable,Wg=(r,t,e)=>t in r?_S(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,vS=(r,t)=>{for(var e in t||(t={}))jg.call(t,e)&&Wg(r,e,t[e]);if(Vi)for(var e of Vi(t))Vg.call(t,e)&&Wg(r,e,t[e]);return r},yS=(r,t)=>xS(r,bS(t)),TS=(r,t)=>{var e={};for(var s in r)jg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Vi)for(var s of Vi(r))t.indexOf(s)<0&&Vg.call(r,s)&&(e[s]=r[s]);return e};class Yg extends ne{constructor(t){const e=t,{sprite:s}=e,i=TS(e,["sprite"]),n=new jn(s.texture),o=new at({uFilterMatrix:{value:new B,type:"mat3x3"},uMaskClamp:{value:n.uClampFrame,type:"vec4"},uAlpha:{value:1,type:"f32"}}),a=Pt.from({vertex:{source:du,entryPoint:"mainVertex"},fragment:{source:du,entryPoint:"mainFragment"}}),u=Gt.from({vertex:zg,fragment:Xg,name:"mask-filter"});super(yS(vS({},i),{gpuProgram:a,glProgram:u,resources:{filterUniforms:o,uMaskTexture:s.texture.source}})),this.sprite=s,this._textureMatrix=n}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 AS=`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 pu(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 Wl{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){const i=s/2,n=i*i,{x:o,x2:a,x3:u,y:l,y2:c,y3:h}=this;return qr(t,e,o,l,a,h)<=n||qr(t,e,a,c,u,h)<=n||qr(t,e,u,h,o,l)<=n}clone(){return new Wl(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 qg=class dx{constructor(t){this._tick=()=>{this.timeout=setTimeout(this._processQueue,0)},this._processQueue=()=>{const{queue:e}=this;let s=0;for(;e.length&&s{this.queue.length?(this.resolves.push(e),this.dedupeQueue(),yt.system.addOnce(this._tick,this,le.UTILITY)):e()})}dedupeQueue(){const t=Object.create(null);let e=0;for(let s=0;st in r?SS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ES=(r,t)=>{for(var e in t||(t={}))Zg.call(t,e)&&Jg(r,e,t[e]);if(Wi)for(var e of Wi(t))Qg.call(t,e)&&Jg(r,e,t[e]);return r},wS=(r,t)=>{var e={};for(var s in r)Zg.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&&Qg.call(r,s)&&(e[s]=r[s]);return e};class ms extends K{constructor(...t){var e;let s=t[0];s instanceof Ze&&(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=wS(i,["geometry","shader","texture","roundPixels","state"]);super(ES({label:"Mesh"},c)),this.renderPipeId="mesh",this.canBundle=!0,this._roundPixels=0,this.allowChildren=!1,this.shader=o,this.texture=(e=a!=null?a:o==null?void 0:o.texture)!=null?e:w.WHITE,this.state=l!=null?l:Nt.for2d(),this._geometry=n,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=u!=null?u:!1}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}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=w.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?!1:this._geometry instanceof de?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}get bounds(){return this._geometry.bounds}addBounds(t){t.addBounds(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+2=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.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(){this.stop(),super.destroy(),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?(yt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(yt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class t_{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t!=null?t:new B,this.observer=e,this.position=new nt(this,0,0),this.scale=new nt(this,1,1),this.pivot=new nt(this,0,0),this.skew=new nt(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 CS=Object.defineProperty,Yi=Object.getOwnPropertySymbols,e_=Object.prototype.hasOwnProperty,r_=Object.prototype.propertyIsEnumerable,s_=(r,t,e)=>t in r?CS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,gs=(r,t)=>{for(var e in t||(t={}))e_.call(t,e)&&s_(r,e,t[e]);if(Yi)for(var e of Yi(t))r_.call(t,e)&&s_(r,e,t[e]);return r},RS=(r,t)=>{var e={};for(var s in r)e_.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Yi)for(var s of Yi(r))t.indexOf(s)<0&&r_.call(r,s)&&(e[s]=r[s]);return e};const i_=class gn extends K{constructor(...t){let e=t[0]||{};e instanceof w&&(e={texture:e}),t.length>1&&(e.width=t[1],e.height=t[2]),e=gs(gs({},gn.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=RS(s,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(gs({label:"TilingSprite"},p)),this.renderPipeId="tilingSprite",this.canBundle=!0,this.batched=!0,this._roundPixels=0,this._bounds={minX:0,maxX:1,minY:0,maxY:0},this._boundsDirty=!0,this.allowChildren=!1,this._anchor=new nt(this),this._applyAnchorToTexture=h,this.texture=i,this._width=l!=null?l:i.width,this._height=c!=null?c:i.height,this._tileTransform=new t_({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 gn(gs({texture:q.get(t)},e)):new gn(gs({texture:t},e))}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}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}set texture(t){t||(t=w.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}_updateBounds(){const t=this._bounds,e=this._anchor,s=this._width,i=this._height;t.maxX=-e._x*s,t.minX=t.maxX+s,t.maxY=-e._y*i,t.minY=t.maxY+i}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.minX,s=this.bounds.minY,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._boundsDirty=!0,this._didTilingSpriteUpdate=!0,this._didChangeId+=4096,!this.didViewUpdate&&(this.didViewUpdate=!0,this.renderGroup&&this.renderGroup.onChildViewUpdate(this))}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}};i_.defaultOptions={texture:w.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let n_=i_;var PS=Object.defineProperty,qi=Object.getOwnPropertySymbols,o_=Object.prototype.hasOwnProperty,a_=Object.prototype.propertyIsEnumerable,u_=(r,t,e)=>t in r?PS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,DS=(r,t)=>{for(var e in t||(t={}))o_.call(t,e)&&u_(r,e,t[e]);if(qi)for(var e of qi(t))a_.call(t,e)&&u_(r,e,t[e]);return r},MS=(r,t)=>{var e={};for(var s in r)o_.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&qi)for(var s of qi(r))t.indexOf(s)<0&&a_.call(r,s)&&(e[s]=r[s]);return e};class Ki extends K{constructor(t,e){const s=t,{text:i,resolution:n,style:o,anchor:a,width:u,height:l,roundPixels:c}=s,h=MS(s,["text","resolution","style","anchor","width","height","roundPixels"]);super(DS({},h)),this.batched=!0,this.resolution=null,this._didTextUpdate=!0,this._roundPixels=0,this._bounds=new pt,this._boundsDirty=!0,this._styleClass=e,this.text=i!=null?i:"",this.style=o,this.resolution=n!=null?n:null,this.allowChildren=!1,this._anchor=new nt({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c!=null?c:!1,u&&(this.width=u),l&&(this.height=l)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}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 bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}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;let i,n;typeof t!="object"?(i=t,n=e!=null?e:t):(i=t.width,n=(s=t.height)!=null?s:t.width),i!==void 0&&this._setWidth(i,this.bounds.width),n!==void 0&&this._setHeight(n,this.bounds.height)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.maxX,s=this.bounds.maxY,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._didChangeId+=4096,this._boundsDirty=!0,!this.didViewUpdate&&(this.didViewUpdate=!0,this._didTextUpdate=!0,this.renderGroup&&this.renderGroup.onChildViewUpdate(this))}_getKey(){return`${this.text}:${this._style.styleKey}`}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 Zi(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 fu extends Ki{constructor(...t){const e=Zi(t,"Text");super(e,Lt),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._style.padding,s=this._anchor,i=Ht.measureText(this._text,this._style),{width:n,height:o}=i;t.minX=-s._x*n-e,t.maxX=t.minX+n,t.minY=-s._y*o-e,t.maxY=t.minY+o}}class l_ extends Kg{resolveQueueItem(t,e){return t instanceof K?this.resolveContainerQueueItem(t,e):t instanceof st||t instanceof w?e.push(t.source):t instanceof kt&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof Xt||t instanceof n_||t instanceof ms?e.push(t.texture.source):t instanceof fu?e.push(t):t instanceof xr?e.push(t.context):t instanceof As&&t.textures.forEach(s=>{s.source?e.push(s.source):e.push(s.texture.source)})}resolveGraphicsContextQueueItem(t){this.renderer.graphicsContext.getContextRenderData(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 c_ extends Ki{constructor(...t){var e,s,i;const n=Zi(t,"BitmapText");(e=n.style)!=null||(n.style=n.style||{}),(i=(s=n.style).fill)!=null||(s.fill=16777215),super(n,Lt),this.renderPipeId="bitmapText"}_updateBounds(){const t=this._bounds,e=this._style.padding,s=this._anchor,i=es.measureText(this.text,this._style),n=i.scale,o=i.offsetY*n,a=i.width*n,u=i.height*n;t.minX=-s._x*a-e,t.maxX=t.minX+a,t.minY=-s._y*(u+o)-e,t.maxY=t.minY+u}}class h_ extends Ki{constructor(...t){const e=Zi(t,"HtmlText");super(e,ke),this.renderPipeId="htmlText"}_updateBounds(){const t=this._bounds,e=this._style.padding,s=this._anchor,i=Pa(this.text,this._style),{width:n,height:o}=i;t.minX=-s._x*n-e,t.maxX=t.minX+n,t.minY=-s._y*o-e,t.maxY=t.minY+o}}class d_ extends l_{uploadQueueItem(t){t instanceof st?this.uploadTextureSource(t):t instanceof fu?this.uploadText(t):t instanceof h_?this.uploadHTMLText(t):t instanceof c_?this.uploadBitmapText(t):t instanceof kt&&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.getContextRenderData(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 p_ extends d_{destroy(){clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}p_.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"prepare"};class mu{constructor(){this._didUpload=!1,this._tempState=Nt.for2d()}init(t){const e=ir({name:"batch",bits:[vi,Ti(Bt),or]});this._shader=new Dt({glProgram:e,resources:{batchSamplers:Ai}}),t.renderer.runners.contextChange.add(this)}contextChange(){this._didUpload=!1}start(t,e){const s=t.renderer;s.shader.bind(this._shader,this._didUpload),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(e,this._shader.glProgram)}execute(t,e){const s=t.renderer;this._didUpload=!0,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 f_={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); `}},m_={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); `}};function g_(r,t){const e=r.root,s=r.instructionSet;s.reset(),t.batch.buildStart(s),t.blendMode.buildStart(),t.colorMask.buildStart(),e.sortableChildren&&e.sortChildren(),__(e,s,t,!0),t.batch.buildEnd(s),t.blendMode.buildEnd(s)}function _s(r,t,e){r.globalDisplayStatus<7||!r.includeInBuild||(r.sortableChildren&&r.sortChildren(),r.isSimple?IS(r,t,e):__(r,t,e,!1))}function IS(r,t,e){if(r.renderPipeId&&(e.blendMode.setBlendMode(r,r.groupBlendMode,t),r.didViewUpdate=!1,e[r.renderPipeId].addRenderable(r,t)),!r.isRenderGroupRoot){const s=r.children,i=s.length;for(let n=0;n=0;o--){const a=r.effects[o];e[a.pipe].pop(a,r,t)}}}const FS=new pt;class US extends zs{constructor(){super({filters:[new Yg({sprite:new Xt(w.EMPTY)})]})}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}}class xu{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,canBundle:!1,maskedContainer:e}),t.renderMaskToTexture){const n=t.mask;n.includeInBuild=!0,_s(n,s,i.renderPipes),n.includeInBuild=!1}i.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,canBundle:!1})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,canBundle:!1})}execute(t){const e=this._renderer,s=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const i=z.get(US);if(s){t.mask.mask.measurable=!0;const n=kr(t.mask.mask,!0,FS);t.mask.mask.measurable=!1,n.ceil();const o=dt.getOptimalTexture(n.width,n.height,1,!1);e.renderTarget.push(o,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});const a=i.sprite;a.texture=o,a.worldTransform.tx=n.minX,a.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer,filterTexture:o})}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.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&&dt.returnTexture(i.filterTexture),z.return(i.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}xu.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"alphaMask"};class bu{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}}bu.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"colorMask"};class NS{constructor(t){this.priority=0,this.pipe="scissorMask",this.mask=t,this.mask.renderable=!1,this.mask.measurable=!1}addBounds(t,e){Ks(this.mask,t,e)}addLocalBounds(t,e){Zs(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 vu{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,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,_s(u,s,a.renderPipes),u.includeInBuild=!1,a.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,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",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))(xs||{});class x_{constructor(t,e){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class yu{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._renderer=t}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gpuBuffers=Object.create(null),this._gl=this._renderer.gl}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;if(this._boundBufferBases[e]!==t){const i=this.getGlBuffer(t);this._boundBufferBases[e]=t,s.bindBufferBase(s.UNIFORM_BUFFER,e,i.buffer)}}bindBufferRange(t,e,s){const{_gl:i}=this;s=s||0;const n=this.getGlBuffer(t);i.bindBufferRange(i.UNIFORM_BUFFER,e||0,n.buffer,s*256,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;if(s.byteLength>=t.data.byteLength)e.bufferSubData(s.type,0,i,0,t._updateSize/i.BYTES_PER_ELEMENT);else{const n=t.descriptor.usage&$.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=i.byteLength,e.bufferData(s.type,i,n)}return 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=xs.ARRAY_BUFFER;t.descriptor.usage&$.INDEX?s=xs.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&$.UNIFORM&&(s=xs.UNIFORM_BUFFER);const i=new x_(e.createBuffer(),s);return this._gpuBuffers[t.uid]=i,t.on("destroy",this.onBufferDestroy,this),i}}yu.extension={type:[v.WebGLSystem],name:"buffer"};var kS=Object.defineProperty,LS=Object.defineProperties,$S=Object.getOwnPropertyDescriptors,b_=Object.getOwnPropertySymbols,HS=Object.prototype.hasOwnProperty,XS=Object.prototype.propertyIsEnumerable,v_=(r,t,e)=>t in r?kS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ji=(r,t)=>{for(var e in t||(t={}))HS.call(t,e)&&v_(r,e,t[e]);if(b_)for(var e of b_(t))XS.call(t,e)&&v_(r,e,t[e]);return r},y_=(r,t)=>LS(r,$S(t));const Tu=class px{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;if(t=Ji(Ji({},px.defaultOptions),t),t.context)this.initFromContext(t.context);else{const i=this._renderer.background.alpha<1,n=(e=t.premultipliedAlpha)!=null?e:!0,o=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:i,premultipliedAlpha:n,antialias:o,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:(s=t.powerPreference)!=null?s:"default"})}}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof X.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let s;const i=this._renderer.view.canvas;if(t===2&&(s=i.getContext("webgl2",e)),!s&&(s=i.getContext("webgl",e),!s))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=s,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions=y_(Ji({},e),{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:t.getExtension("ANGLE_instanced_arrays"),srgb:t.getExtension("EXT_sRGB")});else{this.extensions=y_(Ji({},e),{colorBufferFloat:t.getExtension("EXT_color_buffer_float")});const s=t.getExtension("WEBGL_provoking_vertex");s&&s.provokingVertexWEBGL(s.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var e;this.gl.isContextLost()&&((e=this.extensions.loseContext)==null||e.restoreContext())},0))}handleContextRestored(){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}};Tu.extension={type:[v.WebGLSystem],name:"context"},Tu.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2};let T_=Tu,Au=0;const A_=500;function tn(...r){Au!==A_&&(Au++,Au===A_?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}function Su(r,t){var e,s,i,n;for(const o in r.attributes){const a=r.attributes[o],u=t[o];u?((e=a.location)!=null||(a.location=u.location),(s=a.format)!=null||(a.format=u.format),(i=a.offset)!=null||(a.offset=u.offset),(n=a.instance)!=null||(a.instance=u.instance)):tn(`Attribute ${o} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}zS(r)}function zS(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]+=er(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]+=er(u.format).stride}}var en=(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))(en||{}),Eu=(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))(Eu||{}),S_=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(S_||{}),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 E_={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 w_(r){var t;return(t=E_[r])!=null?t:E_.float32}const jS={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class wu{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0}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()}reset(){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}}wu.extension={type:[v.WebGLSystem],name:"geometry"};var VS=Object.defineProperty,C_=Object.getOwnPropertySymbols,WS=Object.prototype.hasOwnProperty,YS=Object.prototype.propertyIsEnumerable,R_=(r,t,e)=>t in r?VS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,P_=(r,t)=>{for(var e in t||(t={}))WS.call(t,e)&&R_(r,e,t[e]);if(C_)for(var e of C_(t))YS.call(t,e)&&R_(r,e,t[e]);return r};const qS=new Ze({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),Cu=class fx{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:s}=P_(P_({},fx.defaultOptions),t);this.useBackBuffer=e,this._antialias=s,this._renderer.context.supports.msaa||(tn("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Nt.for2d();const i=new Gt({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 Dt({glProgram:i,resources:{uTexture:w.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:qS,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new w({source:new st({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)}};Cu.extension={type:[v.WebGLSystem],name:"backBuffer",priority:1},Cu.defaultOptions={useBackBuffer:!1};let D_=Cu;class Ru{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)))}}Ru.extension={type:[v.WebGLSystem],name:"colorMask"};class Pu{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}}Pu.extension={type:[v.WebGLSystem],name:"encoder"};class M_{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const me=[];me[ot.NONE]=void 0,me[ot.DISABLED]={stencilWriteMask:0,stencilReadMask:0},me[ot.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},me[ot.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},me[ot.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};class Du{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:ot.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._stencilCache.enabled=!1,this._stencilCache.stencilMode=ot.NONE,this._stencilCache.stencilReference=0}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:ot.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const s=this._renderTargetStencilState[this._activeRenderTarget.uid],i=this._gl,n=me[t],o=this._stencilCache;if(s.stencilMode=t,s.stencilReference=e,t===ot.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]))}}Du.extension={type:[v.WebGLSystem],name:"stencil"};class Mu{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!ka())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 St({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);return t.buffer||(t.buffer=new St({data:new Float32Array(i.layout.size/4),usage:$.UNIFORM|$.COPY_DST})),e||(e=t.buffer.data),s||(s=0),i.syncFunction(t.uniforms,e,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 Ou={f32:4,"vec2":8,"vec3":12,"vec4":16,"mat2x2":32,"mat3x3":48,"mat4x4":64};function O_(r){const t=r.map(n=>({data:n,offset:0,size:0}));let e=0,s=0,i=0;for(let n=0;n1&&(e=Math.max(e,16)*o.data.size),o.size=e,s%e!==0&&s<16){const a=s%e%16;s+=a,i+=a}s+e>16?(i=Math.ceil(i/16)*16,o.offset=i,i+=e,s=e):(o.offset=i,s+=e,i+=e)}return i=Math.ceil(i/16)*16,{uboElements:t,size:i}}const ge=[{type:"mat3x3",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 Bu(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","offset",o)}var KS=Object.defineProperty,ZS=Object.defineProperties,QS=Object.getOwnPropertyDescriptors,B_=Object.getOwnPropertySymbols,JS=Object.prototype.hasOwnProperty,tE=Object.prototype.propertyIsEnumerable,G_=(r,t,e)=>t in r?KS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,eE=(r,t)=>{for(var e in t||(t={}))JS.call(t,e)&&G_(r,e,t[e]);if(B_)for(var e of B_(t))tE.call(t,e)&&G_(r,e,t[e]);return r},rE=(r,t)=>ZS(r,QS(t));function dr(r,t){return` for (let i = 0; i < ${r*t}; i++) { data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i]; } `}const Gu={f32:` data[offset] = v;`,i32:` data[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];`,"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":dr(3,2),"mat4x2":dr(4,2),"mat2x3":dr(2,3),"mat4x3":dr(4,3),"mat2x4":dr(2,4),"mat3x4":dr(3,4)},I_=rE(eE({},Gu),{"mat2x2":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2]; data[offset + 3] = v[3]; `});function F_(r,t){const e=Math.max(Ou[r.data.type]/16,1),s=r.data.value.length/r.data.size,i=(4-s%4)%4;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++) { data[arrayOffset++] = v[t++]; } ${i!==0?`arrayOffset += ${i};`:""} } `}function U_(r){return Bu(r,"uboStd40",F_,Gu)}class Iu extends Mu{constructor(){super({createUboElements:O_,generateUboSync:U_})}}Iu.extension={type:[v.WebGLSystem],name:"ubo"};class N_{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,s=e.gl,i=new M_;return t.colorTexture.resource===e.gl.canvas?(i.framebuffer=null,i):(this._initColor(t,i),s.bindFramebuffer(s.FRAMEBUFFER,null),i)}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?bt.ALL:bt.NONE);const n=this._renderer.gl;if(e&bt.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&&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:tn("[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)}}function k_(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 sE=Object.defineProperty,L_=Object.getOwnPropertySymbols,iE=Object.prototype.hasOwnProperty,nE=Object.prototype.propertyIsEnumerable,$_=(r,t,e)=>t in r?sE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,oE=(r,t)=>{for(var e in t||(t={}))iE.call(t,e)&&$_(r,e,t[e]);if(L_)for(var e of L_(t))nE.call(t,e)&&$_(r,e,t[e]);return r};const pr=new Map;function Fu(r,t){if(!pr.has(r)){const e=new w({source:new Pe(oE({resource:r},t))}),s=()=>{pr.get(r)===e&&pr.delete(r)};e.once("destroy",s),e.source.once("destroy",s),pr.set(r,e)}return pr.get(r)}function aE(r){return pr.has(r)}function H_(r){const t=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var uE=Object.defineProperty,X_=Object.getOwnPropertySymbols,lE=Object.prototype.hasOwnProperty,cE=Object.prototype.propertyIsEnumerable,z_=(r,t,e)=>t in r?uE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,j_=(r,t)=>{for(var e in t||(t={}))lE.call(t,e)&&z_(r,e,t[e]);if(X_)for(var e of X_(t))cE.call(t,e)&&z_(r,e,t[e]);return r};const V_=class mx{constructor(t={}){if(this.uid=J("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t=j_(j_({},mx.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 w||t.depthStencilTexture instanceof st?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 st({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)}};V_.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let rn=V_;class Uu{constructor(t){this.rootViewPort=new j,this.viewport=new j,this.onRenderTargetChange=new La("onRenderTargetChange"),this.projectionMatrix=new B,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:s,frame:i}){this._renderTargetStack.length=0,this.push(t,e,s,i),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=H_(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 w&&(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 k_(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=bt.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=bt.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 Pe.test(t)&&(t=Fu(t)),t instanceof rn?e=t:t instanceof st&&(e=new rn({colorTextures:[t]}),Pe.test(t.source.resource)&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy();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))}}class Nu extends Uu{constructor(t){super(t),this.adaptor=new N_,this.adaptor.init(t,this)}}Nu.extension={type:[v.WebGLSystem],name:"renderTarget"};class sn extends At{constructor({buffer:t,offset:e,size:s}){super(),this.uid=J("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=J("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=J("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}function W_(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,o=0;const a=t._getProgramData(r.glProgram);for(const l in r.groups){const c=r.groups[l];e.push(` resources = g[${l}].resources; `);for(const h in c.resources){const d=c.resources[h];if(d instanceof at)d.ubo?e.push(` sS.bindUniformBlock( resources[${h}], sS._uniformBindMap[${l}[${h}], ${n++} ); `):e.push(` ugS.updateUniformGroup(resources[${h}], p, sD); `);else if(d instanceof sn)e.push(` sS.bindUniformBlock( resources[${h}], sS._uniformBindMap[${l}[${h}], ${n++} ); `);else if(d instanceof st){const p=r._uniformBindMap[l][h],f=a.uniformData[p];f&&(i||(i=!0,s.push(` var tS = r.texture; `)),t._gl.uniform1i(f.location,o),e.push(` tS.bind(resources[${h}], ${o}); `),o++)}}}const u=[...s,...e].join(` `);return new Function("r","s","sD",u)}class hE{}class Y_{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 ku(r,t,e){const s=r.createShader(t);return r.shaderSource(s,e),r.compileShader(s),s}function Lu(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 e0(r,t,e,s){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||t0(r,e),r.getShaderParameter(s,r.COMPILE_STATUS)||t0(r,s),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function r0(r,t){const e=ku(r,r.VERTEX_SHADER,t.vertex),s=ku(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)||e0(r,i,e,s),t._attributeData=Z_(i,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=J_(i,r),t._uniformBlockData=Q_(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:$u(u.type,u.size)}}return new Y_(i,o)}const on={textureCount:0,blockIndex:0};class Xu{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._nextIndex=0,this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t}contextChange(t){this._gl=t,this._maxBindings=t.MAX_UNIFORM_BUFFER_BINDINGS?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0,this._programDataHash=Object.create(null),this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;on.textureCount=0,on.blockIndex=0;let s=this._shaderSyncFunctions[t.glProgram._key];s||(s=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),s(this._renderer,t,on)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,on)}bindUniformBlock(t,e,s=0){const i=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource;o&&this._renderer.ubo.updateUniformGroup(t),i.updateBuffer(t.buffer);let a=this._boundUniformsIdsToIndexHash[t.uid];if(a===void 0){const c=this._nextIndex++%this._maxBindings,h=this._boundIndexToUniformsHash[c];h&&(this._boundUniformsIdsToIndexHash[h.uid]=void 0),a=this._boundUniformsIdsToIndexHash[t.uid]=c,this._boundIndexToUniformsHash[c]=t,o?i.bindBufferRange(t.buffer,c,t.offset):i.bindBufferBase(t.buffer,c)}const u=this._gl,l=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[s]!==a&&(n.uniformBlockBindings[s]=a,u.uniformBlockBinding(n.program,l,a))}_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]=r0(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,this._boundUniformsIdsToIndexHash=null}_generateShaderSync(t,e){return W_(t,e)}}Xu.extension={type:[v.WebGLSystem],name:"shader"};const s0={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);"},i0={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 n0(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 at?r.uniforms[s].ubo?e.push(` renderer.shader.bindUniformBlock(uv.${s}, "${s}"); `):e.push(` renderer.shader.updateUniformGroup(uv.${s}); `):r.uniforms[s]instanceof sn&&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)}}},ju={id:"image",upload(r,t,e,s){const i=r.alphaMode==="premultiply-alpha-on-upload";e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i);const n=t.width,o=t.height,a=r.pixelWidth,u=r.pixelHeight,l=r.resourceWidth,c=r.resourceHeight;l1){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,f0[r.compare])}function m0(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 AE=Object.defineProperty,SE=Object.defineProperties,EE=Object.getOwnPropertyDescriptors,g0=Object.getOwnPropertySymbols,wE=Object.prototype.hasOwnProperty,CE=Object.prototype.propertyIsEnumerable,_0=(r,t,e)=>t in r?AE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ne=(r,t)=>{for(var e in t||(t={}))wE.call(t,e)&&_0(r,e,t[e]);if(g0)for(var e of g0(t))CE.call(t,e)&&_0(r,e,t[e]);return r},RE=(r,t)=>SE(r,EE(t));function x0(r,t){let e={},s=r.RGBA;return r instanceof X.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),Ne(Ne(Ne(Ne(Ne(Ne(RE(Ne({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 b0(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 PE(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,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,Wu(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=X.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(DE*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}}Yu.extension={type:[v.WebGLSystem],name:"texture"};class qu{init(){const t=new at({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new B,type:"mat3x3"},uRound:{value:0,type:"f32"}}),e=ir({name:"graphics",bits:[vi,Ti(Bt),wi,or]});this.shader=new Dt({glProgram:e,resources:{localUniforms:t,batchSamplers:Ai}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{geometry: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,i.glProgram);const l=u.instructions;for(let c=0;c",value:new B}}}})}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}}Ku.extension={type:[v.WebGLPipesAdaptor],name:"mesh"};class Zu{constructor(t){this._renderer=t}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}Zu.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"customRender"};function Qu(r,t){const e=r.instructionSet,s=e.instructions;for(let i=0;i>16&255,i=r>>8&255,n=r&255,o=t>>16&255,a=t>>8&255,u=t&255,l=s+(o-s)*e,c=i+(a-i)*e,h=n+(u-n)*e;return(l<<16)+(c<<8)+h}const fr=16777215;function rl(r,t){return r===fr||t===fr?r+t-fr:el(r,t,.5)}function ME(r,t,e){const s=(e>>24&255)/255,i=t*s*255,n=((r&255)<<16)+(r&65280)+(r>>16&255),o=e&16777215;let a;return n===fr||o===fr?a=n+o-fr:a=el(n,o,.5),a+(i<<24)}const OE=new K;function sl(r,t=!1){v0(r);const e=r.childrenToUpdate,s=r.updateTick;r.updateTick++;for(const i in e){const n=e[i],o=n.list,a=n.index;for(let u=0;u1?1:e,r.worldAlpha=e,r.worldColorAlpha=r.worldColor+((e*255|0)<<24)}function il(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.isRenderGroupRoot?(e=e|r._updateFlags,r.relativeGroupTransform.appendFrom(s,i.relativeGroupTransform),e&&y0(r,i,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(s),e&&y0(r,OE,e)),!r.isRenderGroupRoot){const n=r.children,o=n.length;for(let u=0;u1?1:s,r.groupAlpha=s,r.groupColorAlpha=r.groupColor+((s*255|0)<<24)}e&so&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&$r&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function T0(r,t){const{list:e,index:s}=r.childrenRenderablesToUpdate;let i=!1;for(let n=0;n{this.destroyRenderable(t)}),e}destroy(){for(const t in this._gpuSpriteHash)z.return(this._gpuSpriteHash[t]);this._gpuSpriteHash=null,this._renderer=null}}ol.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"sprite"};var IE=Object.defineProperty,A0=Object.getOwnPropertySymbols,FE=Object.prototype.hasOwnProperty,UE=Object.prototype.propertyIsEnumerable,S0=(r,t,e)=>t in r?IE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,E0=(r,t)=>{for(var e in t||(t={}))FE.call(t,e)&&S0(r,e,t[e]);if(A0)for(var e of A0(t))UE.call(t,e)&&S0(r,e,t[e]);return r};const al=class gx{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Y(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=E0(E0({},gx.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(){}};al.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"background",priority:0},al.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let w0=al;const bs={};L.handle(v.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");bs[r.name]=r.ref},r=>{delete bs[r.name]});class ul{constructor(t){this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t}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=!!bs[e],this._isAdvanced&&(this._beginAdvancedBlendMode(s),this._renderableList.push(t))}_beginAdvancedBlendMode(t){this._renderer.renderPipes.batch.break(t);const e=this._activeBlendMode;if(!bs[e])return;this._filterHash[e]||(this._filterHash[e]=new zs({filters:[new bs[e]]}));const s={renderPipeId:"filter",action:"pushFilter",renderables:[],filterEffect:this._filterHash[e],canBundle:!1};this._renderableList=s.renderables,t.add(s)}_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}}ul.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"blendMode"};var NE=Object.defineProperty,C0=Object.getOwnPropertySymbols,kE=Object.prototype.hasOwnProperty,LE=Object.prototype.propertyIsEnumerable,R0=(r,t,e)=>t in r?NE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ll=(r,t)=>{for(var e in t||(t={}))kE.call(t,e)&&R0(r,e,t[e]);if(C0)for(var e of C0(t))LE.call(t,e)&&R0(r,e,t[e]);return r};const cl={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},hl=class _x{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof K||t instanceof w?ll({target:t},e):ll(ll({},e),t)}async image(t){const e=new Image;return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,_x.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)},cl[e],s)});if(i.toDataURL!==void 0)return i.toDataURL(cl[e],s);if(i.convertToBlob!==void 0){const n=await i.convertToBlob({type:cl[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 w)return s.texture.generateCanvas(e);const i=s.textureGenerator.generateTexture(t),n=s.texture.generateCanvas(i);return i.destroy(),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,s=this._renderer,i=e instanceof w?e:s.textureGenerator.generateTexture(t),n=s.texture.getPixels(i);return e instanceof K&&i.destroy(),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof w?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}};hl.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"extract"},hl.defaultImageOptions={format:"png",quality:1};let P0=hl;class D0 extends w{static create(t){return new w({source:new st(t)})}resize(t,e,s){return this.source.resize(t,e,s),this}}var $E=Object.defineProperty,HE=Object.defineProperties,XE=Object.getOwnPropertyDescriptors,M0=Object.getOwnPropertySymbols,zE=Object.prototype.hasOwnProperty,jE=Object.prototype.propertyIsEnumerable,O0=(r,t,e)=>t in r?$E(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,VE=(r,t)=>{for(var e in t||(t={}))zE.call(t,e)&&O0(r,e,t[e]);if(M0)for(var e of M0(t))jE.call(t,e)&&O0(r,e,t[e]);return r},WE=(r,t)=>HE(r,XE(t));const YE=new j,qE=new pt,KE=[0,0,0,0];class dl{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof K&&(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:Y.shared.setValue(o).toArray():o=KE;const a=((e=t.frame)==null?void 0:e.copyTo(YE))||Ws(n,qE).rectangle;a.width=Math.max(a.width,1/s)|0,a.height=Math.max(a.height,1/s)|0;const u=D0.create(WE(VE({},t.textureSourceOptions),{width:a.width,height:a.height,resolution:s,antialias:i})),l=B.shared.translate(-a.x,-a.y);return this._renderer.render({container:n,transform:l,target:u,clearColor:o}),u}destroy(){this._renderer=null}}dl.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"textureGenerator"};class pl{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 B,type:"mat3x3"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4"},uResolution:{value:[0,0],type:"vec2"}},{isStatic:!0})}destroy(){this._renderer=null}}pl.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"globalUniforms"};let B0=!1;const fl="8.1.1";function G0(r){if(!B0){if(X.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${fl} (${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 ${fl} - ${r} - http://www.pixijs.com/`);B0=!0}}class un{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===Et.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),G0(e)}}}un.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"hello",priority:-2},un.defaultOptions={hello:!1};var ZE=Object.defineProperty,I0=Object.getOwnPropertySymbols,QE=Object.prototype.hasOwnProperty,JE=Object.prototype.propertyIsEnumerable,F0=(r,t,e)=>t in r?ZE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,U0=(r,t)=>{for(var e in t||(t={}))QE.call(t,e)&&F0(r,e,t[e]);if(I0)for(var e of I0(t))JE.call(t,e)&&F0(r,e,t[e]);return r};const ml=class xx{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(t){t=U0(U0({},xx.defaultOptions),t),this.checkCountMax=t.textureGCCheckCountMax,this.maxIdle=t.textureGCAMaxIdle,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}};ml.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"textureGC"},ml.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:60*60,textureGCCheckCountMax:600};let gl=ml;L.add(gl);var t3=Object.defineProperty,N0=Object.getOwnPropertySymbols,e3=Object.prototype.hasOwnProperty,r3=Object.prototype.propertyIsEnumerable,k0=(r,t,e)=>t in r?t3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,L0=(r,t)=>{for(var e in t||(t={}))e3.call(t,e)&&k0(r,e,t[e]);if(N0)for(var e of N0(t))r3.call(t,e)&&k0(r,e,t[e]);return r};const _l=class bx{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=L0(L0({},bx.defaultOptions),t),t.view&&(t.canvas=t.view),this.screen=new j(0,0,t.width,t.height),this.canvas=t.canvas||X.get().createCanvas(),this.antialias=!!t.antialias,this.texture=Fu(this.canvas,t),this.renderTarget=new rn({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.multiView=!!t.multiView,this.autoDensity&&(this.canvas.style.width=`${this.texture.width}px`,this.canvas.style.height=`${this.texture.height}px`),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,this.autoDensity&&(this.canvas.style.width=`${t}px`,this.canvas.style.height=`${e}px`)}destroy(t=!1){(typeof t=="boolean"?t:t!=null&&t.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}};_l.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"view",priority:0},_l.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let $0=_l;const xl=[w0,pl,un,$0,nl,gl,dl,P0],bl=[ul,_u,ol,Ju,xu,vu,bu,Zu],s3=[...xl,Iu,D_,T_,yu,Yu,Nu,wu,zu,Xu,Pu,u0,Du,Ru],i3=[...bl],n3=[mu,Ku,qu],H0=[],X0=[],z0=[];L.handleByNamedList(v.WebGLSystem,H0),L.handleByNamedList(v.WebGLPipes,X0),L.handleByNamedList(v.WebGLPipesAdaptor,z0),L.add(...s3,...i3,...n3);class j0 extends ns{constructor(){const t={name:"webgl",type:Et.WEBGL,systems:H0,renderPipes:X0,renderPipeAdaptors:z0};super(t)}}var o3={__proto__:null,WebGLRenderer:j0};class vl{constructor(t){this._hash=Object.create(null),this._renderer=t}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}}vl.extension={type:[v.WebGPUSystem],name:"bindGroup"};class yl{constructor(){this._gpuBuffers=Object.create(null),this._managedBuffers=[]}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));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(ti(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,this._managedBuffers.push(t),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}}yl.extension={type:[v.WebGPUSystem],name:"buffer"};function a3(r,t){const e=r.descriptor.size,s=t.gpu.device,i=new St({data:new Float32Array(24e5),usage:$.MAP_READ|$.COPY_DST}),n=t.buffer.createGPUBuffer(i),o=s.createCommandEncoder();o.copyBufferToBuffer(t.buffer.getGPUBuffer(r),0,n,0,e),s.queue.submit([o.finish()]),n.mapAsync(GPUMapMode.READ,0,e).then(()=>{n.getMappedRange(0,e),n.unmap()})}class V0{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 navigator.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}}ln.extension={type:[v.WebGPUSystem],name:"device"},ln.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var u3=Object.defineProperty,W0=Object.getOwnPropertySymbols,l3=Object.prototype.hasOwnProperty,c3=Object.prototype.propertyIsEnumerable,Y0=(r,t,e)=>t in r?u3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,q0=(r,t)=>{for(var e in t||(t={}))l3.call(t,e)&&Y0(r,e,t[e]);if(W0)for(var e of W0(t))c3.call(t,e)&&Y0(r,e,t[e]);return r};class Al{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){for(const e in t.attributes){const s=t.attributes[e];this._setVertexBuffer(s.location,s.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),this._setShaderBindGroups(s,l),e.indexBuffer?this.renderPassEncoder.drawIndexed(o||e.indexBuffer.data.length,u||e.instanceCount,a||0):this.renderPassEncoder.draw(o||e.getSize(),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=q0({},this._boundVertexBuffer),i=this._boundIndexBuffer,n=q0({},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}}Al.extension={type:[v.WebGPUSystem],name:"encoder",priority:1};class Sl{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:ot.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}}Sl.extension={type:[v.WebGPUSystem],name:"stencil"};const vs={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 K0(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 Z0(r,t){const{size:e,align:s}=vs[r.data.type],i=(s-e)/4;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++) { data[arrayOffset++] = v[t++]; } ${i!==0?`arrayOffset += ${i};`:""} } `}function Q0(r){return Bu(r,"uboWgsl",Z0,I_)}class El extends Mu{constructor(){super({createUboElements:K0,generateUboSync:Q0})}}El.extension={type:[v.WebGPUSystem],name:"ubo"};const _e=128;class wl{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new V0({minUniformOffsetAlignment:_e});const e=256/_e;for(let s=0;st in r?h3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,g3=(r,t)=>{for(var e in t||(t={}))f3.call(t,e)&&t2(r,e,t[e]);if(J0)for(var e of J0(t))m3.call(t,e)&&t2(r,e,t[e]);return r},_3=(r,t)=>d3(r,p3(t));const x3={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function b3(r,t,e,s,i){return r<<24|t<<16|e<<10|s<<5|i}function v3(r,t,e,s){return e<<6|r<<3|s<<1|t}class Cl{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=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(ot.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=me[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||(Su(t,e.attributeData),this._generateBufferKey(t)),i=i||t.topology;const n=b3(t._layoutKey,e._layoutKey,s.data,s._blendModeId,x3[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),a=this._renderer.state.getColorTargets(s);a[0].writeMask=this._stencilMode===ot.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=_3(g3({},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{const i={arrayStride:0,stepMode:"vertex",attributes:[]},n=i.attributes;for(const o in t.attributes){const a=t.attributes[o];a.buffer===s&&(i.arrayStride=a.stride,i.stepMode=a.instance?"instance":"vertex",n.push({shaderLocation:a.location,offset:a.offset,format:a.format}))}n.length&&e.push(i)}),this._bufferLayoutsCache[t._layoutKey]=e,e}_updatePipeHash(){const t=v3(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}}Cl.extension={type:[v.WebGPUSystem],name:"pipeline"};class e2{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class r2{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?bt.ALL:bt.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&bt.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&bt.STENCIL?"clear":"load",l=e&bt.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 e2;return t.colorTextures.forEach((s,i)=>{if(Pe.test(s.resource)){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 st({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 Rl extends Uu{constructor(t){super(t),this.adaptor=new r2,this.adaptor.init(t,this)}}Rl.extension={type:[v.WebGPUSystem],name:"renderTarget"};class Pl{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}}Pl.extension={type:[v.WebGPUSystem],name:"shader"};const Ct={};Ct.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},Ct.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},Ct.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},Ct.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Ct.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Ct.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},Ct["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},Ct["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},Ct["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},Ct.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}};class Dl{constructor(){this.defaultState=new Nt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:Ct[t.blendMode]||Ct.normal}]}destroy(){this.gpu=null}}Dl.extension={type:[v.WebGPUSystem],name:"state"};const s2={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})}},Ml={"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}},y3={blockBytes:4,blockWidth:1,blockHeight:1},i2={type:"compressed",upload(r,t,e){let s=r.pixelWidth,i=r.pixelHeight;const n=Ml[r.format]||y3;for(let o=0;o>1,1),i=Math.max(i>>1,1)}}},Ol={type:"image",upload(r,t,e){const s=r.resource;if(!s)return;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})}},n2={type:"video",upload(r,t,e){Ol.upload(r,t,e)}};class o2{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 o2(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,s=e.uid;return this._bindGroupHash[s]=new qt({0:e,1:e.style}),this._bindGroupHash[s]}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=X.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:navigator.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=Kt.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 Kt.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}}Bl.extension={type:[v.WebGPUSystem],name:"texture"};class Gl{init(){const t=new at({uTransformMatrix:{value:new B,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),e=sr({name:"graphics",bits:[bi,yi(Bt),Sf,nr]});this.shader=new Dt({gpuProgram:e,resources:{localUniforms:t}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{geometry:a,instructions:u}=o.getContextRenderData(s),l=n.encoder;l.setPipelineFromGeometryProgramAndState(a,i.gpuProgram,t.state),l.setGeometry(a);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;for(let p=0;p",value:new B}}}})}execute(t,e){const s=t.renderer;let i=e._shader;if(!i)i=this._shader,i.resources.uTexture=e.texture.source,i.resources.uSampler=e.texture.source.style,i.resources.textureUniforms.uniforms.uTextureMatrix=e.texture.textureMatrix.mapCoord;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}}Il.extension={type:[v.WebGPUPipesAdaptor],name:"mesh"};const T3=[...xl,El,Al,ln,yl,Bl,Rl,Pl,Dl,Cl,Tl,Sl,vl],A3=[...bl,wl],S3=[gu,Il,Gl],a2=[],u2=[],l2=[];L.handleByNamedList(v.WebGPUSystem,a2),L.handleByNamedList(v.WebGPUPipes,u2),L.handleByNamedList(v.WebGPUPipesAdaptor,l2),L.add(...T3,...A3,...S3);class c2 extends ns{constructor(){const t={name:"webgpu",type:Et.WEBGPU,systems:a2,renderPipes:u2,renderPipeAdaptors:l2};super(t)}}var E3={__proto__:null,WebGPURenderer:c2};const w3={POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},C3=new Proxy(w3,{get(r,t){return r[t]}}),R3=new j(0,0,1,1);function P3(r,t,e){e||(e=R3);const s=t.pixelWidth,i=t.pixelHeight;return r.x=e.x*s|0,r.y=e.y*i|0,r.width=e.width*s|0,r.height=e.height*i|0,r}var h2=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(h2||{}),Fl=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))(Fl||{});const D3=new Proxy(Fl,{get(r,t){return r[t]}});var Ul=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))(Ul||{});const M3=new Proxy(Ul,{get(r,t){return r[t]}});class O3{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}}let B3=0;function G3(){return B3++}function I3(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()}var F3=Object.defineProperty,cn=Object.getOwnPropertySymbols,d2=Object.prototype.hasOwnProperty,p2=Object.prototype.propertyIsEnumerable,f2=(r,t,e)=>t in r?F3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,U3=(r,t)=>{for(var e in t||(t={}))d2.call(t,e)&&f2(r,e,t[e]);if(cn)for(var e of cn(t))p2.call(t,e)&&f2(r,e,t[e]);return r},N3=(r,t)=>{var e={};for(var s in r)d2.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&&p2.call(r,s)&&(e[s]=r[s]);return e};class k3 extends K{constructor(t){var e,s;typeof t=="function"&&(t={render:t});const i=t,{render:n}=i,o=N3(i,["render"]);super(U3({label:"RenderContainer"},o)),this.batched=!1,this.bounds=new pt,this.canBundle=!1,this.renderPipeId="customRender",n&&(this.render=n),this.containsPoint=(e=t.containsPoint)!=null?e:()=>!1,this.addBounds=(s=t.addBounds)!=null?s:()=>!1}render(t){}}function L3(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 $3(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}const H3={rectangle:Ro,polygon:Co,triangle:Po,circle:Me,ellipse:Me,roundedRectangle:Me};function X3(r){r instanceof xe&&(r={path:r,textureMatrix:null,out:null});const t=[],e=[],s=[],i=r.path.shapePath,n=r.textureMatrix;i.shapePrimitives.forEach(({shape:a,transform:u})=>{const l=s.length,c=t.length/2,h=[],d=H3[a.type];d.build(a,h),u&&ei(h,u),d.triangulate(h,t,2,c,s,l);const p=e.length/2;n?(u&&n.append(u.clone().invert()),vo(t,2,c,e,p,2,t.length/2-c,n)):yo(e,p,2,t.length/2-c)});const o=r.out;return o?(o.positions=new Float32Array(t),o.uvs=new Float32Array(e),o.indices=new Uint32Array(s),o):new de({positions:new Float32Array(t),uvs:new Float32Array(e),indices:new Uint32Array(s)})}var z3=Object.defineProperty,j3=Object.defineProperties,V3=Object.getOwnPropertyDescriptors,hn=Object.getOwnPropertySymbols,m2=Object.prototype.hasOwnProperty,g2=Object.prototype.propertyIsEnumerable,_2=(r,t,e)=>t in r?z3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,W3=(r,t)=>{for(var e in t||(t={}))m2.call(t,e)&&_2(r,e,t[e]);if(hn)for(var e of hn(t))g2.call(t,e)&&_2(r,e,t[e]);return r},Y3=(r,t)=>j3(r,V3(t)),q3=(r,t)=>{var e={};for(var s in r)m2.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&&g2.call(r,s)&&(e[s]=r[s]);return e};class K3 extends ms{constructor(t){const e=t,{texture:s,verticesX:i,verticesY:n}=e,o=q3(e,["texture","verticesX","verticesY"]),a=new Ba(he({width:s.width,height:s.height,verticesX:i,verticesY:n}));super(he(Y3(W3({},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 Z3=Object.defineProperty,x2=Object.getOwnPropertySymbols,Q3=Object.prototype.hasOwnProperty,J3=Object.prototype.propertyIsEnumerable,b2=(r,t,e)=>t in r?Z3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,v2=(r,t)=>{for(var e in t||(t={}))Q3.call(t,e)&&b2(r,e,t[e]);if(x2)for(var e of x2(t))J3.call(t,e)&&b2(r,e,t[e]);return r};const y2=class vx extends de{constructor(t){const{width:e,points:s,textureScale:i}=v2(v2({},vx.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()}};y2.defaultOptions={width:200,points:[],textureScale:0};let T2=y2;var tw=Object.defineProperty,ew=Object.defineProperties,rw=Object.getOwnPropertyDescriptors,dn=Object.getOwnPropertySymbols,A2=Object.prototype.hasOwnProperty,S2=Object.prototype.propertyIsEnumerable,E2=(r,t,e)=>t in r?tw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nl=(r,t)=>{for(var e in t||(t={}))A2.call(t,e)&&E2(r,e,t[e]);if(dn)for(var e of dn(t))S2.call(t,e)&&E2(r,e,t[e]);return r},sw=(r,t)=>ew(r,rw(t)),iw=(r,t)=>{var e={};for(var s in r)A2.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&&S2.call(r,s)&&(e[s]=r[s]);return e};const w2=class yx extends ms{constructor(t){const e=Nl(Nl({},yx.defaultOptions),t),{texture:s,points:i,textureScale:n}=e,o=iw(e,["texture","points","textureScale"]),a=new T2(he({width:s.height,points:i,textureScale:n}));n>0&&(s.source.style.addressMode="repeat"),super(he(sw(Nl({},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())}};w2.defaultOptions={textureScale:0};let nw=w2;var ow=Object.defineProperty,aw=Object.defineProperties,uw=Object.getOwnPropertyDescriptors,pn=Object.getOwnPropertySymbols,C2=Object.prototype.hasOwnProperty,R2=Object.prototype.propertyIsEnumerable,P2=(r,t,e)=>t in r?ow(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,lw=(r,t)=>{for(var e in t||(t={}))C2.call(t,e)&&P2(r,e,t[e]);if(pn)for(var e of pn(t))R2.call(t,e)&&P2(r,e,t[e]);return r},cw=(r,t)=>aw(r,uw(t)),hw=(r,t)=>{var e={};for(var s in r)C2.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&&R2.call(r,s)&&(e[s]=r[s]);return e};class dw extends ms{constructor(t){const e=t,{texture:s,vertices:i,uvs:n,indices:o,topology:a}=e,u=hw(e,["texture","vertices","uvs","indices","topology"]),l=new de(he({positions:i,uvs:n,indices:o,topology:a}));super(he(cw(lw({},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 pw(r,t){const{width:e,height:s}=r.frame;return t.scale(1/e,1/s),t}var fw=Object.defineProperty,fn=Object.getOwnPropertySymbols,D2=Object.prototype.hasOwnProperty,M2=Object.prototype.propertyIsEnumerable,O2=(r,t,e)=>t in r?fw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mw=(r,t)=>{for(var e in t||(t={}))D2.call(t,e)&&O2(r,e,t[e]);if(fn)for(var e of fn(t))M2.call(t,e)&&O2(r,e,t[e]);return r},gw=(r,t)=>{var e={};for(var s in r)D2.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&&M2.call(r,s)&&(e[s]=r[s]);return e};const B2=class Tx extends K{constructor(t){var e,s,i,n,o,a,u,l,c,h;t instanceof w&&(t={texture:t});const d=t,{width:p,height:f,leftWidth:g,rightWidth:m,topHeight:_,bottomHeight:b,texture:x,roundPixels:y}=d,A=gw(d,["width","height","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]);super(mw({label:"NineSliceSprite"},A)),this._roundPixels=0,this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this.bounds={minX:0,minY:0,maxX:0,maxY:0},this._leftWidth=(s=g!=null?g:(e=x==null?void 0:x.defaultBorders)==null?void 0:e.left)!=null?s:pe.defaultOptions.leftWidth,this._topHeight=(n=_!=null?_:(i=x==null?void 0:x.defaultBorders)==null?void 0:i.top)!=null?n:pe.defaultOptions.topHeight,this._rightWidth=(a=m!=null?m:(o=x==null?void 0:x.defaultBorders)==null?void 0:o.right)!=null?a:pe.defaultOptions.rightWidth,this._bottomHeight=(l=b!=null?b:(u=x==null?void 0:x.defaultBorders)==null?void 0:u.bottom)!=null?l:pe.defaultOptions.bottomHeight,this.bounds.maxX=this._width=(c=p!=null?p:x.width)!=null?c:pe.defaultOptions.width,this.bounds.maxY=this._height=(h=f!=null?f:x.height)!=null?h:pe.defaultOptions.height,this.allowChildren=!1,this.texture=x!=null?x:Tx.defaultOptions.texture,this.roundPixels=y!=null?y:!1}get width(){return this._width}set width(t){this.bounds.maxX=this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this.bounds.maxY=this._height=t,this.onViewUpdate()}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=w.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 roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}onViewUpdate(){this._didChangeId+=4096,this._didSpriteUpdate=!0,!this.didViewUpdate&&(this.didViewUpdate=!0,this.renderGroup&&this.renderGroup.onChildViewUpdate(this))}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds;return t.x>=e.minX&&t.x<=e.maxX&&t.y>=e.minY&&t.y<=e.maxY}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,this.bounds=null}};B2.defaultOptions={texture:w.EMPTY};let G2=B2;class _w extends G2{constructor(...t){let e=t[0];e instanceof w&&(e={texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}),super(e)}}function xw(r,t){return t instanceof Lt||t instanceof ke?t:r==="html"?new ke(t):new Lt(t)}var kl=/iPhone/i,I2=/iPod/i,F2=/iPad/i,U2=/\biOS-universal(?:.+)Mac\b/i,Ll=/\bAndroid(?:.+)Mobile\b/i,N2=/Android/i,mr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,mn=/Silk/i,oe=/Windows Phone/i,k2=/\bWindows(?:.+)ARM\b/i,L2=/BlackBerry/i,$2=/BB10/i,H2=/Opera Mini/i,X2=/\b(CriOS|Chrome)(?:.+)Mobile/i,z2=/Mobile(?:.+)Firefox\b/i,j2=function(r){return typeof r!="undefined"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream=="undefined"};function bw(r){return function(t){return t.test(r)}}function V2(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=bw(e),n={apple:{phone:i(kl)&&!i(oe),ipod:i(I2),tablet:!i(kl)&&(i(F2)||j2(t))&&!i(oe),universal:i(U2),device:(i(kl)||i(I2)||i(F2)||i(U2)||j2(t))&&!i(oe)},amazon:{phone:i(mr),tablet:!i(mr)&&i(mn),device:i(mr)||i(mn)},android:{phone:!i(oe)&&i(mr)||!i(oe)&&i(Ll),tablet:!i(oe)&&!i(mr)&&!i(Ll)&&(i(mn)||i(N2)),device:!i(oe)&&(i(mr)||i(mn)||i(Ll)||i(N2))||i(/\bokhttp\b/i)},windows:{phone:i(oe),tablet:i(k2),device:i(oe)||i(k2)},other:{blackberry:i(L2),blackberry10:i($2),opera:i(H2),firefox:i(z2),chrome:i(X2),device:i(L2)||i($2)||i(H2)||i(z2)||i(X2)},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 W2;const vw=(W2=V2.default)!=null?W2:V2,yw=vw(globalThis.navigator),Tw=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;async function Aw(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 Sw=Object.defineProperty,Ew=Object.defineProperties,ww=Object.getOwnPropertyDescriptors,Y2=Object.getOwnPropertySymbols,Cw=Object.prototype.hasOwnProperty,Rw=Object.prototype.propertyIsEnumerable,q2=(r,t,e)=>t in r?Sw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,K2=(r,t)=>{for(var e in t||(t={}))Cw.call(t,e)&&q2(r,e,t[e]);if(Y2)for(var e of Y2(t))Rw.call(t,e)&&q2(r,e,t[e]);return r},Pw=(r,t)=>Ew(r,ww(t));const Dw=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let Mw=0;function Z2(r,t=0,e={color:"#000000"}){r.isRenderGroupRoot&&(e.color=Dw[Mw++]);let s="";for(let o=0;o