1
0
wiki/postscript.js

946 lines
603 KiB
JavaScript
Raw Normal View History

2024-09-06 17:53:58 +08:00
(function(){var gt='<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg>',Pt='<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true"><path fill-rule="evenodd" fill="rgb(63, 185, 80)" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg>';document.addEventListener("nav",()=>{let jt=document.getElementsByTagName("pre");for(let Et=0;Et<jt.length;Et++){let Bt=jt[Et].getElementsByTagName("code")[0];if(Bt){let v=function(){navigator.clipboard.writeText(Ue).then(()=>{ze.blur(),ze.innerHTML=Pt,setTimeout(()=>{ze.innerHTML=gt,ze.style.borderColor=""},2e3)},Rt=>console.error(Rt))};var it=v;let Ue=Bt.innerText.replace(/\n\n/g,`
`),ze=document.createElement("button");ze.className="clipboard-button",ze.type="button",ze.innerHTML=gt,ze.ariaLabel="Copy source",ze.addEventListener("click",v),window.addCleanup(()=>ze.removeEventListener("click",v)),jt[Et].prepend(ze)}}})})(),function(){var gt=Object.create,Pt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,it=Object.getOwnPropertyNames,Et=Object.getPrototypeOf,Bt=Object.prototype.hasOwnProperty,v=(c,g)=>()=>(g||c((g={exports:{}}).exports,g),g.exports),Ue=(c,g,m,x)=>{if(g&&typeof g=="object"||typeof g=="function")for(let w of it(g))!Bt.call(c,w)&&w!==m&&Pt(c,w,{get:()=>g[w],enumerable:!(x=jt(g,w))||x.enumerable});return c},ze=(c,g,m)=>(m=c!=null?gt(Et(c)):{},Ue(g||!c||!c.__esModule?Pt(m,"default",{value:c,enumerable:!0}):m,c)),Rt=v(()=>{}),ht=v((c,g)=>{"use strict";g.exports=x;function m(S){return S instanceof Buffer?Buffer.from(S):new S.constructor(S.buffer.slice(),S.byteOffset,S.length)}function x(S){if(S=S||{},S.circles)return w(S);let k=new Map;if(k.set(Date,V=>new Date(V)),k.set(Map,(V,L)=>new Map(N(Array.from(V),L))),k.set(Set,(V,L)=>new Set(N(Array.from(V),L))),S.constructorHandlers)for(let V of S.constructorHandlers)k.set(V[0],V[1]);let B=null;return S.proto?F:X;function N(V,L){let I=Object.keys(V),D=new Array(I.length);for(let $=0;$<I.length;$++){let se=I[$],xe=V[se];typeof xe!="object"||xe===null?D[se]=xe:xe.constructor!==Object&&(B=k.get(xe.constructor))?D[se]=B(xe,L):ArrayBuffer.isView(xe)?D[se]=m(xe):D[se]=L(xe)}return D}function X(V){if(typeof V!="object"||V===null)return V;if(Array.isArray(V))return N(V,X);if(V.constructor!==Object&&(B=k.get(V.constructor)))return B(V,X);let L={};for(let I in V){if(Object.hasOwnProperty.call(V,I)===!1)continue;let D=V[I];typeof D!="object"||D===null?L[I]=D:D.constructor!==Object&&(B=k.get(D.constructor))?L[I]=B(D,X):ArrayBuffer.isView(D)?L[I]=m(D):L[I]=X(D)}return L}function F(V){if(typeof V!="object"||V===null)return V;if(Array.isArray(V))return N(V,F);if(V.constructor!==Object&&(B=k.get(V.constructor)))return B(V,F);let L={};for(let I in V){let D=V[I];typeof D!="object"||D===null?L[I]=D:D.constructor!==Object&&(B=k.get(D.constructor))?L[I]=B(D,F):ArrayBuffer.isView(D)?L[I]=m(D):L[I]=F(D)}return L}}function w(S){let k=[],B=[],N=new Map;if(N.set(Date,I=>new Date(I)),N.set(Map,(I,D)=>new Map(F(Array.from(I),D))),N.set(Set,(I,D)=>new Set(F(Array.from(I),D))),S.constructorHandlers)for(let I of S.constructorHandlers)N.set(I[0],I[1]);let X=null;return S.proto?L:V;function F(I,D){let $=Object.keys(I),se=new Array($.length);for(let xe=0;xe<$.length;xe++){let Me=$[xe],Ge=I[Me];if(typeof Ge!="object"||Ge===null)se[Me]=Ge;else if(Ge.constructor!==Object&&(X=N.get(Ge.constructor)))se[Me]=X(Ge,D);else if(ArrayBuffer.isView(Ge))se[Me]=m(Ge);else{let ct=k.indexOf(Ge);ct!==-1?se[Me]=B[ct]:se[Me]=D(Ge)}}return se}function V(I){if(typeof I!="object"||I===null)return I;if(Array.isArray(I))return F(I,V);if(I.constructor!==Object&&(X=N.get(I.constructor)))return X(I,V);let D={};k.push(I),B.push(D);for(let $ in I){if(Object.hasOwnProperty.call(I,$)===!1)continue;let se=I[$];if(typeof se!="object"||se===null)D[$]=se;else if(se.constructor!==Object&&(X=N.get(se.constructor)))D[$]=X(se,V);else if(ArrayBuffer.isView(se))D[$]=m(se);else{let xe=k.indexOf(se);xe!==-1?D[$]=B[xe]:D[$]=V(se)}}return k.pop(),B.pop(),D}function L(I){if(typeof I!="object"||I===null)return I;if(Array.isArray(I))return F(I,L);if(I.constructor!==Object&&(X=N.get(I.constructor)))return X(I,L);let D={};k.push(I),B.push(D);for(let $ in I){let se=I[$];if(typeof se!="object"||se===null)D[$]=se;else if(se.constructor!==Object&&(X=N.get(se.constructor)))D[$]=X(se,L);else if(ArrayBuffer.isView(se))D[$]=m(se);else{let xe=k.indexOf(se);xe!==-1?D[$]=B[xe]:D[$]=L(se)}}return k.pop(),B.pop(),D}}}),G;function kt(c){return typeof c<"u"?c:!0}function je(c){let g=Array(c);for(let m=0;m<c;m++)g[m]=pe();return g}function pe(){return Object.create(null)}function te(c,g){return g.length-c.length}function dt(c){return typeof c=="string"}function Nt(c){return typeof c=="object"}function Je(c){return typeof c=="function
<h3>No results.</h3>
<p>Try another search term?</p>
</a>`:I.append(...Ae.map(Qt)),Ae.length===0&&V)bt(V);else{let Be=I.firstElementChild;Be.classList.add("focus"),se=Be,await di(Be)}}async function qt(Ae){if(en.has(Ae))return en.get(Ae);let Be=ct(Ae).toString(),He=await fetch(Be).then(ft=>ft.text()).then(ft=>{if(ft===void 0)throw new Error(`Could not fetch ${Be}`);let et=pr.parseFromString(ft??"","text/html");return Kr(et,Be),[...et.getElementsByClassName("popover-hint")]});return en.set(Ae,He),He}async function di(Ae){if(!B||!F||!Ae||!V)return;let Be=Ae.id,He=await qt(Be).then(ft=>ft.flatMap(et=>[...ot(Ct,et).children]));L=document.createElement("div"),L.classList.add("preview-inner"),L.append(...He),V.replaceChildren(L),[...V.querySelectorAll(".highlight")].sort((ft,et)=>et.innerHTML.length-ft.innerHTML.length)[0]?.scrollIntoView({block:"start"})}async function Ut(Ae){if(!B||!Ni)return;Ct=Ae.target.value,B.classList.toggle("display-results",Ct!==""),xi=Ct.startsWith("#")?"tags":"basic";let Be;if(xi==="tags"){Ct=Ct.substring(1).trim();let et=Ct.indexOf(" ");if(et!=-1){let lt=Ct.substring(0,et),zt=Ct.substring(et+1).trim();Be=await Ni.searchAsync({query:zt,limit:Math.max(Gr,1e4),index:["title","content"],tag:lt});for(let Ci of Be)Ci.result=Ci.result.slice(0,Gr);xi="basic",Ct=zt}else Be=await Ni.searchAsync({query:Ct,limit:Gr,index:["tags"]})}else xi==="basic"&&(Be=await Ni.searchAsync({query:Ct,limit:Gr,index:["title","content"]}));let He=et=>{let lt=Be.filter(zt=>zt.field===et);return lt.length===0?[]:[...lt[0].result]},ft=[...new Set([...He("title"),...He("content"),...He("tags")])].map(et=>Me(Ct,et));await ei(ft)}document.addEventListener("keydown",xe),window.addCleanup(()=>document.removeEventListener("keydown",xe)),S?.addEventListener("click",()=>$("basic")),window.addCleanup(()=>S?.removeEventListener("click",()=>$("basic"))),k?.addEventListener("input",Ut),window.addCleanup(()=>k?.removeEventListener("input",Ut)),dr(x,D),await E(m)});async function E(c){let g=0,m=[];for(let[x,w]of Object.entries(c))m.push(Ni.addAsync(g++,{id:g,slug:x,title:w.title,content:w.content,tags:w.tags}));return await Promise.all(m)}}(),function(){var gt,Pt=new IntersectionObserver(Ue=>{let ze=document.getElementById("explorer-ul");if(ze)for(let Rt of Ue)Rt.isIntersecting?ze.classList.add("no-background"):ze.classList.remove("no-background")});function jt(){this.classList.toggle("collapsed"),this.setAttribute("aria-expanded",this.getAttribute("aria-expanded")==="true"?"false":"true");let Ue=this.nextElementSibling;Ue&&(Ue.classList.toggle("collapsed"),Ue.style.maxHeight=Ue.style.maxHeight==="0px"?Ue.scrollHeight+"px":"0px")}function it(Ue){Ue.stopPropagation();let ze=Ue.target;if(!ze)return;let Rt=ze.nodeName==="svg",ht=Rt?ze.parentElement?.nextSibling:ze.parentElement?.parentElement?.nextElementSibling,G=Rt?ze.nextElementSibling:ze.parentElement;if(!(ht&&G))return;ht.classList.toggle("open");let kt=ht.classList.contains("open");Bt(ht,!kt);let je=G.dataset.folderpath;v(gt,je);let pe=JSON.stringify(gt);localStorage.setItem("fileTree",pe)}function Et(){let Ue=document.getElementById("explorer");if(!Ue)return;if(Ue.dataset.behavior==="collapse")for(let je of document.getElementsByClassName("folder-button"))je.addEventListener("click",it),window.addCleanup(()=>je.removeEventListener("click",it));Ue.addEventListener("click",jt),window.addCleanup(()=>Ue.removeEventListener("click",jt));for(let je of document.getElementsByClassName("folder-icon"))je.addEventListener("click",it),window.addCleanup(()=>je.removeEventListener("click",it));let ze=localStorage.getItem("fileTree"),Rt=Ue?.dataset.savestate==="true",ht=ze&&Rt?JSON.parse(ze):[],G=new Map(ht.map(je=>[je.path,je.collapsed])),kt=Ue.dataset.tree?JSON.parse(Ue.dataset.tree):[];gt=[];for(let{path:je,collapsed:pe}of kt)gt.push({path:je,collapsed:G.get(je)??pe});gt.map(je=>{let pe=document.querySelector(`[data-folderpath='${je.path}']`)?.parentElement?.nextElementSibling;pe&&Bt(pe,je.collapsed)})}window.addEventListener("resize",Et),document.addEventListener("nav",()=>{Et(),Pt.disconnect();let Ue=document.getElementById("explorer-end");Ue&&P
Deprecated since v${e}`):(r=r.split(`
`).splice(i).join(`
`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
Deprecated since v${e}`),console.warn(r),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
Deprecated since v${e}`),console.warn(r))),fr[t]=!0}var fr,Ve,wt=v(()=>{"use strict";fr={},Ve="8.0.0"}),tr,Kr=v(()=>{"use strict";tr=class{constructor(e,t){this._pool=[],this._count=0,this._index=0,this._classType=e,t&&this.prepopulate(t)}prepopulate(e){for(let t=0;t<e;t++)this._pool[this._index++]=new this._classType;this._count+=e}get(e){let t;return this._index>0?t=this._pool[--this._index]:t=new this._classType,t.init?.(e),t}return(e){e.reset?.(),this._pool[this._index++]=e}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}}),Zr,Le,Ht=v(()=>{Kr(),Zr=class{constructor(){this._poolsByClass=new Map}prepopulate(e,t){this.getPool(e).prepopulate(t)}get(e,t){return this.getPool(e).get(t)}return(e){this.getPool(e.constructor).return(e)}getPool(e){return this._poolsByClass.has(e)||this._poolsByClass.set(e,new tr(e)),this._poolsByClass.get(e)}stats(){let e={};return this._poolsByClass.forEach(t=>{let i=e[t._classType.name]?t._classType.name+t._classType.ID:t._classType.name;e[i]={free:t.totalFree,used:t.totalUsed,size:t.totalSize}}),e}},Le=new Zr});function Br(e,t,i){let r=e.length,n;if(t>=r||i===0)return;i=t+i>r?r-t:i;let s=r-i;for(n=t;n<s;++n)e[n]=e[n+i];e.length=s}var Jr=v(()=>{"use strict"}),Qr,xi=v(()=>{Jr(),wt(),Qr={allowChildren:!0,removeChildren(e=0,t){let i=t??this.children.length,r=i-e,n=[];if(r>0&&r<=i){for(let a=i-1;a>=e;a--){let o=this.children[a];o&&(n.push(o),o.parent=null)}Br(this.children,e,i);let s=this.renderGroup||this.parentRenderGroup;s&&s.removeChildren(n);for(let a=0;a<n.length;++a)this.emit("childRemoved",n[a],this,a),n[a].emit("removed",this);return n}else if(r===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(e){let t=this.getChildAt(e);return this.removeChild(t)},getChildAt(e){if(e<0||e>=this.children.length)throw new Error(`getChildAt: Index (${e}) does not exist.`);return this.children[e]},setChildIndex(e,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(e),this.addChildAt(e,t)},getChildIndex(e){let t=this.children.indexOf(e);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(e,t){this.allowChildren||Xe(Ve,"addChildAt: Only Containers will be allowed to add children in v8.0.0");let{children:i}=this;if(t<0||t>i.length)throw new Error(`${e}addChildAt: The index ${t} supplied is out of bounds ${i.length}`);if(e.parent){let n=e.parent.children.indexOf(e);if(e.parent===this&&n===t)return e;n!==-1&&e.parent.children.splice(n,1)}t===i.length?i.push(e):i.splice(t,0,e),e.parent=this,e.didChange=!0,e.didViewUpdate=!1,e._updateFlags=15;let r=this.renderGroup||this.parentRenderGroup;return r&&r.addChild(e),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",e,this,t),e.emit("added",this),e},swapChildren(e,t){if(e===t)return;let i=this.getChildIndex(e),r=this.getChildIndex(t);this.children[i]=t,this.children[r]=e;let n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...e){return e.length===1?this.reparentChildAt(e[0],this.children.length):(e.forEach(t=>this.reparentChildAt(t,this.children.length)),e[0])},reparentChildAt(e,t){if(e.parent===this)return this.setChildIndex(e,t),e;let i=e.worldTransform.clone();e.removeFromParent(),this.addChildAt(e,t);let r=this.worldTransform.clone();return r.invert(),i.prepend(r),e.setFromMatrix(i),e}}}),Ct,Ir=v(()=>{"use strict";Ct=class{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let e=0;e<this.filters.length;e++)this.filters[e].destroy();this.filters=null,this.filterArea=null}}}),Ni,pr,en=v(()=>{te(),Ht(),Ni=class{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(e=>{this.add({test:e.test,mas
else `),i<e-1&&(t+=`if(test == ${i}.0){}`);return t}function dy(e,t){if(e===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");let i=t.createShader(t.FRAGMENT_SHADER);try{for(;;){let r=Td.replace(/%forloop%/gi,cy(e));if(t.shaderSource(i,r),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS))e=e/2|0;else break}}finally{t.deleteShader(i)}return e}var Td,fy=v(()=>{"use strict";Td=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
`)});function yr(){if(Hr)return Hr;let e=bd();return Hr=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),Hr=dy(Hr,e),e.getExtension("WEBGL_lose_context")?.loseContext(),Hr}var Hr,xr=v(()=>{wd(),fy(),Hr=null});function wl(e,t){let i=2166136261;for(let r=0;r<t;r++)i^=e[r].uid,i=Math.imul(i,16777619),i>>>=0;return Tl[i]||py(e,t,i)}function py(e,t,i){let r={},n=0;Ys||(Ys=yr());for(let a=0;a<Ys;a++){let o=a<t?e[a]:Re.EMPTY.source;r[n++]=o.source,r[n++]=o.style}let s=new Vi(r);return Tl[i]=s,s}var Tl,Ys,Sl=v(()=>{Nr(),pt(),xr(),Tl={},Ys=0}),El,gy=v(()=>{"use strict";El=class{constructor(e){typeof e=="number"?this.rawBinaryData=new ArrayBuffer(e):e instanceof Uint8Array?this.rawBinaryData=e.buffer:this.rawBinaryData=e,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(e){return this[`${e}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this.uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${e} isn't a valid view type`)}}}});function Al(e,t){let i=e.byteLength/8|0,r=new Float64Array(e,0,i);new Float64Array(t,0,i).set(r);let n=e.byteLength-i*8;if(n>0){let s=new Uint8Array(e,i*8,n);new Uint8Array(t,i*8,n).set(s)}}var Sd=v(()=>{"use strict"}),Ed,Lt,ln=v(()=>{"use strict";Ed={normal:"normal-npm",add:"add-npm",screen:"screen-npm"},Lt=(e=>(e[e.DISABLED=0]="DISABLED",e[e.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",e[e.MASK_ACTIVE=2]="MASK_ACTIVE",e[e.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",e[e.NONE=4]="NONE",e))(Lt||{})});function qs(e,t){return t.alphaMode==="no-premultiply-alpha"&&Ed[e]||e}var Cl=v(()=>{ln()}),Ad,my=v(()=>{"use strict";Ad=class{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let e=0;e<this.count;e++){let t=this.textures[e];this.textures[e]=null,this.ids[t.uid]=null}this.count=0}}});function Cd(){return Ks>0?Ml[--Ks]:new Pd}function Md(e){Ml[Ks++]=e}var Pd,Ml,Ks,hn,Pl,Rl,Rd=v(()=>{bt(),gy(),Sd(),Cl(),xr(),my(),Pd=class{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Ad,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}},Ml=[],Ks=0,hn=0,Pl=class Ro{constructor(t={}){this.uid=at("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._vertexSize=6,this._elements=[],Ro.defaultOptions.maxTextures=Ro.defaultOptions.maxTextures??yr(),t={...Ro.defaultOptions,...t};let{vertexSize:i,indexSize:r,maxTextures:n}=t;this.attributeBuffer=new El(i*this._vertexSize*4),this.indexBuffer=new Uint16Array(r),this.maxTextures=n}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)Md(this.batches[t]);this.batchIndex=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,i){let r=t.batch.textures.ids[i._source.uid];return!r&&r!==0?!1:(t.textureId=r,t.tex
`:t,t}static _getFromCache(t,i,r,n){let s=r[t];return typeof s!="number"&&(s=Ee._measureText(t,i,n)+i,r[t]=s),s}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 i=t.length-1;i>=0;i--){let r=t[i];if(!Ee.isBreakingSpace(r))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:Ee._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,i){return typeof t!="string"?!1:Ee._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){let i=[],r="";if(typeof t!="string")return i;for(let n=0;n<t.length;n++){let s=t[n],a=t[n+1];if(Ee.isBreakingSpace(s,a)||Ee._isNewline(s)){r!==""&&(i.push(r),r=""),i.push(s);continue}r+=s}return r!==""&&i.push(r),i}static canBreakWords(t,i){return i}static canBreakChars(t,i,r,n,s){return!0}static wordWrapSplit(t){return Ee.graphemeSegmenter(t)}static measureFont(t){if(Ee._fonts[t])return Ee._fonts[t];let i=Ee._context;i.font=t;let r=i.measureText(Ee.METRICS_STRING+Ee.BASELINE_SYMBOL),n={ascent:r.actualBoundingBoxAscent,descent:r.actualBoundingBoxDescent,fontSize:r.actualBoundingBoxAscent+r.actualBoundingBoxDescent};return Ee._fonts[t]=n,n}static clearMetrics(t=""){t?delete Ee._fonts[t]:Ee._fonts={}}static get _canvas(){if(!Ee.__canvas){let t;try{let i=new OffscreenCanvas(0,0);if(i.getContext("2d",Ta)?.measureText)return Ee.__canvas=i,i;t=vt.get().createCanvas()}catch{t=vt.get().createCanvas()}t.width=t.height=10,Ee.__canvas=t}return Ee.__canvas}static get _context(){return Ee.__context||(Ee.__context=Ee._canvas.getContext("2d",Ta)),Ee.__context}},Si.METRICS_STRING="|\xC9q\xC5",Si.BASELINE_SYMBOL="M",Si.BASELINE_MULTIPLIER=1.4,Si.HEIGHT_MULTIPLIER=2,Si.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){let e=new Intl.Segmenter;return t=>[...e.segment(t)].map(i=>i.segment)}return e=>[...e]})(),Si.experimentalLetterSpacing=!1,Si._fonts={},Si._newlines=[10,13],Si._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Si._measurementCache={},Ri=Si});function Ea(e,t){if(e.texture===Re.WHITE&&!e.fill)return ue.shared.setValue(e.color).setAlpha(e.alpha??1).toHexa();if(e.fill){if(e.fill instanceof Nn){let i=e.fill,r=t.createPattern(i.texture.source.resource,"repeat"),n=i.transform.copyTo(ke.shared);return n.scale(i.texture.frame.width,i.texture.frame.height),r.setTransform(n),r}else if(e.fill instanceof dn){let i=e.fill;if(i.type==="linear"){let r=t.createLinearGradient(i.x0,i.y0,i.x1,i.y1);return i.gradientStops.forEach(n=>{r.addColorStop(n.offset,ue.shared.setValue(n.color).toHex())}),r}}}else{let i=t.createPattern(e.texture.source.resource,"repeat"),r=e.matrix.copyTo(ke.shared);return r.scale(e.texture.frame.width,e.texture.frame.height),i.setTransform(r),i}return F("FillStyle not recognised",e),"red"}var Hf=v(()=>{Ie(),We(),pt(),I(),zl(),Vl()}),Ql,Tx=v(()=>{Ie(),te(),Ls(),pa(),Ln(),$y(),wt(),jn(),Lf(),Sa(),Jl(),Hf(),Ql=class{constructor(e){this._activeTextures={},this._renderer=e}getTextureSize(e,t,i){let r=Ri.measureText(e||" ",i),n=Math.ceil(Math.ceil(Math.max(1,r.width)+i.padding*2)*t),s=Math.ceil(Math.ceil(Math.max(1,r.height)+i.padding*2)*t);return n=Math.ceil(n-1e-6),s=Math.ceil(s-1e-6),n=on(n),s=on(s),{width:n,height:s}}getTexture(e,t,i,r){typeof e=="string"&&(Xe("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),e={text:e,style:i,resolution:t}),e.style instanceof Xi||(e.style=new Xi(e.style));let{texture:n,canvasAndContext:s}=this.createTextureAndCanvas(e);return this._renderer.texture.initSource(n._source),$i.returnCanvasAndContext(s),n}createTextureAndCanvas(e){let{text:t,style:i}=e,r=e.resolution??this._renderer.resolution,n=Ri.measureText(t||" ",i),s=Math.ceil(Math.ceil(Math.max(1,n.width)+i.padding*2)*r),a=Math.ceil(Math.ceil(Math.max(1,n.height)+i.padding*2)*r),o=$i.getOptimalCanvasAndContext(s,a),{canvas:l}=o;this.renderTextToCanvas(t,i,r,o);let h=Ff(l,s,a,r);if(i.trim){let u=jy(l,r);h.frame.copyFrom(u),h.updateUvs()}return{texture:h,canvasAndContext:o}}ge
#ifdef GL_ES // This checks if it is WebGL1
#define in varying
#define finalColor gl_FragColor
#define texture texture2D
#endif
${e}
`):`
#ifdef GL_ES // This checks if it is WebGL1
#define in attribute
#define out varying
#endif
${e}
`}var Cx=v(()=>{"use strict"});function Mx(e,t,i){let r=i?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(e.substring(0,9)!=="precision"){let n=i?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&r!=="highp"&&(n="mediump"),`precision ${n} float;
${e}`}else if(r!=="highp"&&e.substring(0,15)==="precision highp")return e.replace("precision highp","precision mediump");return e}var Px=v(()=>{"use strict"});function Rx(e,t){return t?`#version 300 es
${e}`:e}var kx=v(()=>{"use strict"});function Bx(e,{name:t="pixi-program"},i=!0){t=t.replace(/\s+/g,"-"),t+=i?"-fragment":"-vertex";let r=i?Vf:jf;return r[t]?(r[t]++,t+=`-${r[t]}`):r[t]=1,e.indexOf("#define SHADER_NAME")!==-1?e:`${`#define SHADER_NAME ${t}`}
${e}`}var Vf,jf,Ix=v(()=>{"use strict";Vf={},jf={}});function Gx(e,t){return t?e.replace("#version 300 es",""):e}var Ox=v(()=>{"use strict"}),Ma,Pa,eh,pn,$n=v(()=>{ca(),Ex(),Cx(),Px(),kx(),Ix(),Ox(),Ma={stripVersion:Gx,ensurePrecision:Mx,addProgramDefines:Ax,setProgramName:Bx,insertVersion:Rx},Pa=Object.create(null),eh=class Ac{constructor(t){t={...Ac.defaultOptions,...t};let i=t.fragment.indexOf("#version 300 es")!==-1,r={stripVersion:i,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Sx()},setProgramName:{name:t.name},addProgramDefines:i,insertVersion:i},n=t.fragment,s=t.vertex;Object.keys(Ma).forEach(a=>{let o=r[a];n=Ma[a](n,o,!0),s=Ma[a](s,o,!1)}),this.fragment=n,this.vertex=s,this._key=Dn(`${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){let i=`${t.vertex}:${t.fragment}`;return Pa[i]||(Pa[i]=new Ac(t)),Pa[i]}},eh.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"},pn=eh});function Xn(e){return th[e]??th.float32}var th,Ra=v(()=>{"use strict";th={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 Ux({source:e,entryPoint:t}){let i={},r=e.indexOf(`fn ${t}`);if(r!==-1){let n=e.indexOf("->",r);if(n!==-1){let s=e.substring(r,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g,o;for(;(o=a.exec(s))!==null;){let l=$f[o[3]]??"float32";i[o[2]]={location:parseInt(o[1],10),format:l,stride:Xn(l).stride,offset:0,instance:!1,start:0}}}}return i}var $f,Fx=v(()=>{Ra(),$f={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"}});function ih(e){let t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,i=/@group\((\d+)\)/,r=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,s=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,l=/struct\s+(\w+)/,h=e.match(t)?.map(d=>({group:parseInt(d.match(i)[1],10),binding:parseInt(d.match(r)[1],10),name:d.match(n)[2],isUniform:d.match(n)[1]==="<uniform>",type:d.match(s)[1]}));if(!h)return{groups:[],structs:[]};let u=e.match(a)?.map(d=>{let p=d.match(l)[1],f=d.match(o).reduce((y,b)=>{let[_,T]=b.split(":");return y[_.trim()]=T.trim(),y},{});return f?{name:p,members:f}:null}).filter(({name:d})=>h.some(p=>p.type===d))??[];return{groups:h,structs:u}}var Dx=v(()=>{"use strict"}),gn,Lx=v(()=>{"use strict";gn=(e=>(e[e.VERTEX=1]="VERTE
`),a=t.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",`
${s}
`),a}var Yx=v(()=>{"use strict"});function Jf(e,t){let i,r=/@out\s+([^;]+);/g;for(;(i=r.exec(e))!==null;)t.push(i[1])}function qx(e){let t=/\b(\w+)\s*:/g.exec(e);return t?t[1]:""}function Kx(e){let t=/@.*?\s+/g;return e.replace(t,"")}function Zx(e,t){let i=[];Jf(t,i),e.forEach(l=>{l.header&&Jf(l.header,i)});let r=0,n=i.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${r++}) ${l}`).join(`,
`),s=i.sort().map(l=>` var ${Kx(l)};`).join(`
`),a=`return VSOutput(
${i.sort().map(l=>` ${qx(l)}`).join(`,
`)});`,o=t.replace(/@out\s+[^;]+;\s*/g,"");return o=o.replace("{{struct}}",`
${n}
`),o=o.replace("{{start}}",`
${s}
`),o=o.replace("{{return}}",`
${a}
`),o}var Jx=v(()=>{"use strict"});function Qf(e,t){let i=e;for(let r in t){let n=t[r];n.join(`
`).length?i=i.replace(`{{${r}}}`,`//-----${r} START-----//
${n.join(`
`)}
//----${r} FINISH----//`):i=i.replace(`{{${r}}}`,"")}return i}var Qx=v(()=>{"use strict"});function e0({template:e,bits:t}){let i=ep(e,t);if(wr[i])return wr[i];let{vertex:r,fragment:n}=i0(e,t);return wr[i]=tp(r,n,t),wr[i]}function t0({template:e,bits:t}){let i=ep(e,t);return wr[i]||(wr[i]=tp(e.vertex,e.fragment,t)),wr[i]}function i0(e,t){let i=t.map(a=>a.vertex).filter(a=>!!a),r=t.map(a=>a.fragment).filter(a=>!!a),n=Zf(i,e.vertex,!0);n=Zx(i,n);let s=Zf(r,e.fragment,!0);return{vertex:n,fragment:s}}function ep(e,t){return t.map(i=>(Ia.has(i)||Ia.set(i,ip++),Ia.get(i))).sort((i,r)=>i-r).join("-")+e.vertex+e.fragment}function tp(e,t,i){let r=Yf(e),n=Yf(t);return i.forEach(s=>{Xf(s.vertex,r,s.name),Xf(s.fragment,n,s.name)}),{vertex:Qf(e,r),fragment:Qf(t,n)}}var wr,Ia,ip,r0=v(()=>{$x(),Xx(),Yx(),Jx(),Qx(),wr=Object.create(null),Ia=new Map,ip=0}),rp,np,sp,ap,n0=v(()=>{"use strict";rp=`
@in aPosition: vec2<f32>;
@in aUV: vec2<f32>;
@out @builtin(position) vPosition: vec4<f32>;
@out vUV : vec2<f32>;
@out vColor : vec4<f32>;
{{header}}
struct VSOutput {
{{struct}}
};
@vertex
fn main( {{in}} ) -> VSOutput {
var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
var modelMatrix = mat3x3<f32>(
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<f32>(1., 1., 1., 1.);
{{main}}
vUV = uv;
var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
vColor *= globalUniforms.uWorldColorAlpha;
{{end}}
{{return}}
};
`,np=`
@in vUV : vec2<f32>;
@in vColor : vec4<f32>;
{{header}}
@fragment
fn main(
{{in}}
) -> @location(0) vec4<f32> {
{{start}}
var outColor:vec4<f32>;
{{main}}
return outColor * vColor;
};
`,sp=`
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}}
}
`,ap=`
in vec4 vColor;
in vec2 vUV;
out vec4 finalColor;
{{header}}
void main(void) {
{{start}}
vec4 outColor;
{{main}}
finalColor = outColor * vColor;
}
`}),op,lp,s0=v(()=>{"use strict";op={name:"global-uniforms-bit",vertex:{header:`
struct GlobalUniforms {
uProjectionMatrix:mat3x3<f32>,
uWorldTransformMatrix:mat3x3<f32>,
uWorldColorAlpha: vec4<f32>,
uResolution: vec2<f32>,
}
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
`}},lp={name:"global-uniforms-bit",vertex:{header:`
uniform mat3 uProjectionMatrix;
uniform mat3 uWorldTransformMatrix;
uniform vec4 uWorldColorAlpha;
uniform vec2 uResolution;
`}}});function qn({bits:e,name:t}){let i=e0({template:{fragment:np,vertex:rp},bits:[op,...e]});return Yn.from({name:t,vertex:{source:i.vertex,entryPoint:"main"},fragment:{source:i.fragment,entryPoint:"main"}})}function Kn({bits:e,name:t}){return new pn({name:t,...t0({template:{vertex:sp,fragment:ap},bits:[lp,...e]})})}var Tr=v(()=>{$n(),Ba(),r0(),n0(),s0()}),Ga,Oa,Zn=v(()=>{"use strict";Ga={name:"color-bit",vertex:{header:`
@in aColor: vec4<f32>;
`,main:`
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
`}},Oa={name:"color-bit",vertex:{header:`
in vec4 aColor;
`,main:`
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
`}}});function a0(e){let t=[];if(e===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let i=0;for(let r=0;r<e;r++)t.push(`@group(1) @binding(${i++}) var textureSource${r+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${i++}) var textureSampler${r+1}: sampler;`)}return t.join(`
`)}function o0(e){let t=[];if(e===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let i=0;i<e;i++)i===e-1?t.push(" default:{"):t.push(` case ${i}:{`),t.push(` outColor = textureSampleGrad(textureSource${i+1}, textureSampler${i+1}, vUV, uvDx, uvDy);`),t.push(" break;}");t.push("}")}return t.join(`
`)}function rh(e){return Ua[e]||(Ua[e]={name:"texture-batch-bit",vertex:{header:`
@in aTextureIdAndRound: vec2<u32>;
@out @interpolate(flat) vTextureId : u32;
`,main:`
vTextureId = aTextureIdAndRound.y;
`,end:`
if(aTextureIdAndRound.x == 1)
{
vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
}
`},fragment:{header:`
@in @interpolate(flat) vTextureId: u32;
${a0(e)}
`,main:`
var uvDx = dpdx(vUV);
var uvDy = dpdy(vUV);
${o0(e)}
`}}),Ua[e]}function l0(e){let t=[];for(let i=0;i<e;i++)i>0&&t.push("else"),i<e-1&&t.push(`if(vTextureId < ${i}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${i}], vUV);`),t.push("}");return t.join(`
`)}function nh(e){return Fa[e]||(Fa[e]={name:"texture-batch-bit",vertex:{header:`
in vec2 aTextureIdAndRound;
out float vTextureId;
`,main:`
vTextureId = aTextureIdAndRound.y;
`,end:`
if(aTextureIdAndRound.x == 1.)
{
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
}
`},fragment:{header:`
in float vTextureId;
uniform sampler2D uTextures[${e}];
`,main:`
${l0(e)}
`}}),Fa[e]}var Ua,Fa,Jn=v(()=>{"use strict";Ua={},Fa={}}),mn,_n,Sr=v(()=>{"use strict";mn={name:"round-pixels-bit",vertex:{header:`
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
{
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
}
`}},_n={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;
}
`}}});function sh(e){let t=ah[e];if(t)return t;let i=new Int32Array(e);for(let r=0;r<e;r++)i[r]=r;return t=ah[e]=new ti({uTextures:{value:i,type:"i32",size:e}},{isStatic:!0}),t}var ah,oh=v(()=>{pi(),ah={}}),Ei,sr=v(()=>{"use strict";Ei=(e=>(e[e.WEBGL=1]="WEBGL",e[e.WEBGPU=2]="WEBGPU",e[e.BOTH=3]="BOTH",e))(Ei||{})}),ki,Yi=v(()=>{xt(),$n(),Nr(),Ba(),sr(),pi(),ki=class hv extends Je{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:i,glProgram:r,groups:n,resources:s,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=i,this.glProgram=r,a===void 0&&(a=0,i&&(a|=Ei.WEBGPU),r&&(a|=Ei.WEBGL)),this.compatibleRenderers=a;let l={};if(!s&&!n&&(s={}),s&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!i&&n&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!i&&n&&o)for(let h in o)for(let u in o[h]){let d=o[h][u];l[d]={group:h,binding:u,name:d}}else if(i&&n&&!o){let h=i.structsAndGroups.groups;o={},h.forEach(u=>{o[u.group]=o[u.group]||{},o[u.group][u.binding]=u.name,l[u.name]=u})}else if(s){n={},o={},i&&i.structsAndGroups.groups.forEach(u=>{o[u.group]=o[u.group]||{},o[u.group][u.binding]=u.name,l[u.name]=u});let h=0;for(let u in s)l[u]||(n[99]||(n[99]=new Vi,this._ownedBindGroups.push(n[99])),l[u]={group:99,binding:h,name:u},o[99]=o[99]||{},o[99][h]=u,h++);for(let u in s){let d=u,p=s[u];!p.source&&!p._resourceType&&(p=new ti(p));let f=l[d];f&&(n[f.group]||(n[f.group]=new Vi,this._ownedBindGroups.push(n[f.group])),n[f.group].setResource(p,f.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,l)}addResource(t,i,r){var n,s;(n=this._uniformBindMap)[i]||(n[i]={}),(s=this._uniformBindMap[i])[r]||(s[r]=t),this.groups[i]||(this.groups[i]=new Vi,this._ownedBindGroups.push(this.groups[i]))}_buildResourceAccessor(t,i){let r={};for(let n in i){let s=i[n];Object.defineProperty(r,s.name,{get(){return t[s.group].getResource(s.binding)},set(a){t[s.group].setResource(a,s.binding)}})}return r}destroy(t=!1){this.emit("destroy",this),t&&(this.gpuProgram?.destroy(),this.glProgram?.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){let{gpu:i,gl:r,...n}=t,s,a;return i&&(s=Yn.from(i)),r&&(a=pn.from(r)),new hv({gpuProgram:s,glProgram:a,...n})}}}),hp,up,h0=v(()=>{"use strict";hp={name:"local-uniform-msdf-bit",vertex:{header:`
struct LocalUniforms {
uColor:vec4<f32>,
uTransformMatrix:mat3x3<f32>,
uDistance: f32,
uRound:f32,
}
@group(2) @binding(0) var<uniform> 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<f32>,
uTransformMatrix:mat3x3<f32>,
uDistance: f32
}
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
`,main:`
outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));
`}},up={name:"local-uniform-msdf-bit",vertex:{header:`
uniform mat3 uTransformMatrix;
uniform vec4 uColor;
uniform float uRound;
`,main:`
vColor *= uColor;
modelMatrix *= uTransformMatrix;
`,end:`
if(uRound == 1.)
{
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
}
`},fragment:{header:`
uniform float uDistance;
`,main:`
outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));
`}}}),cp,dp,u0=v(()=>{"use strict";cp={name:"msdf-bit",fragment:{header:`
fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {
// MSDF
var median = msdfColor.r + msdfColor.g + msdfColor.b -
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
// SDF
median = min(median, msdfColor.a);
var screenPxDistance = distance * (median - 0.5);
var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
if (median < 0.01) {
alpha = 0.0;
} else if (median > 0.99) {
alpha = 1.0;
}
// Gamma correction for coverage-like alpha
var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));
var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);
var coverage: f32 = pow(shapeColor.a * alpha, gamma);
return coverage;
}
`}},dp={name:"msdf-bit",fragment:{header:`
float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {
// MSDF
float median = msdfColor.r + msdfColor.g + msdfColor.b -
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
// SDF
median = min(median, msdfColor.a);
float screenPxDistance = distance * (median - 0.5);
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
if (median < 0.01) {
alpha = 0.0;
} else if (median > 0.99) {
alpha = 1.0;
}
// Gamma correction for coverage-like alpha
float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));
float gamma = mix(1.0, 1.0 / 2.2, luma);
float coverage = pow(shapeColor.a * alpha, gamma);
return coverage;
}
`}}}),lh,hh,fp,c0=v(()=>{We(),xr(),Tr(),Zn(),Jn(),Sr(),oh(),Yi(),pi(),h0(),u0(),fp=class extends ki{constructor(){let e=new ti({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new ke,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}}),t=yr();lh??(lh=qn({name:"sdf-shader",bits:[Ga,rh(t),hp,cp,mn]})),hh??(hh=Kn({name:"sdf-shader",bits:[Oa,nh(t),up,dp,_n]})),super({glProgram:hh,gpuProgram:lh,resources:{localUniforms:e,batchSamplers:sh(t)}})}}}),pp,d0=v(()=>{xt(),wt(),pp=class extends Je{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return Xe(Ve,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return Xe(Ve,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return Xe(Ve,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return Xe(Ve,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return Xe(Ve,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(e=!1){this.emit("destroy",this),this.removeAllListeners();for(let t in this.chars)this.chars[t].texture?.destroy();this.chars=null,e&&(this.pages.forEach(t=>t.texture.destroy(!0)),this.pages=null)}}});function gp(e){if(e==="")return[];typeof e=="string"&&(e=[e]);let t=[];for(let i=0,r=e.length;i<r;i++){let n=e[i];if(Array.isArray(n)){if(n.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);if(n[0].length===0||n[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");let s=n[0].charCodeAt(0),a=n[1].charCodeAt(0);if(a<s)throw new Error("[BitmapFont]: Invalid character range.");for(let o=s,l=a;o<=l;o++)t.push(String.fromCharCode(o))}else t.push(...Array.from(n))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}var mp=v(()=>{"use strict"}),uh,ch,f0=v(()=>{Ie(),E(),pa(),yl(),pt(),wt(),Sa(),Jl(),Hf(),jn(),d0(),mp(),uh=class uv extends pp{constructor(t){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentPageIndex=-1,this._skipKerning=!1;let i={...uv.defaultOptions,...t};this._textureSize=i.textureSize,this._mipmap=i.mipmap;let r=i.style.clone();i.overrideFill&&(r._fill.color=16777215,r._fill.alpha=1,r._fill.texture=Re.WHITE,r._fill.fill=null),this.applyFillAsTint=i.overrideFill;let n=r.fontSize;r.fontSize=this.baseMeasurementFontSize;let s=wa(r);i.overrideSize?r._stroke&&(r._stroke.width*=this.baseRenderedFontSize/n):r.fontSize=this.baseRenderedFontSize=n,this._style=r,this._skipKerning=i.skipKerning??!1,this.resolution=i.resolution??1,this._padding=i.padding??4,this.fontMetrics=Ri.measureFont(s),this.lineHeight=r.lineHeight||this.fontMetrics.fontSize||r.fontSize}ensureCharacters(t){let i=gp(t).filter(b=>!this._currentChars.includes(b)).filter((b,_,T)=>T.indexOf(b)===_);if(!i.length)return;this._currentChars=[...this._currentChars,...i];let r;this._currentPageIndex===-1?r=this._nextPage():r=this.pages[this._currentPageIndex];let{canvas:n,context:s}=r.canvasAndContext,a=r.texture.source,o=this._style,l=this._currentX,h=this._currentY,u=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*u,p=o.fontStyle==="italic"?2:1,f=0,y=!1;for(let b=0;b<i.length;b++){let _=i[b],T=Ri.measureText(_,o,n,!1);T.lineHeight=T.height;let C=p*T.width*u,O=T.height*u,R=C+d*2,z=O+d*2;if(y=!1,_!==`
`&&_!=="\r"&&_!==" "&&_!==" "&&(y=!0,f=Math.ceil(Math.max(z,f))),l+R>this._textureSize&&(h+=f,f=z,l=0,h+f>this._textureSize)){a.update();let ne=this._nextPage();n=ne.canvasAndContext.canvas,s=ne.canvasAndContext.context,a=ne.texture.source,h=0}let ee=C/u-(o.dropShadow?.distance??0)-(o._stroke?.width??0);if(this.chars[_]={id:_.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:ee,kerning:{}},y){this._drawGlyph(s,T,l+d,h+d,u,o);let ne=a.width*u,Q=a.height*u,Y=new ot(l/ne*a.width,h/Q*a.height,R/ne*a.width,z/Q*a.height);this.chars[_].texture=new Re({source:a,frame:Y}),l+=Math.ceil(R)}}a.update(),this._currentX=l,this._currentY=h,this._skipKerning&&this._applyKerning(i,s)}get pageTextures(){return Xe(Ve,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,i){let r=this._measureCache;for(let n=0;n<t.length;n++){let s=t[n];for(let a=0;a<this._currentChars.length;a++){let o=this._currentChars[a],l=r[s];l||(l=r[s]=i.measureText(s).width);let h=r[o];h||(h=r[o]=i.measureText(o).width);let u=i.measureText(s+o).width,d=u-(l+h);d&&(this.chars[s].kerning[o]=d),u=i.measureText(s+o).width,d=u-(l+h),d&&(this.chars[o].kerning[s]=d)}}}_nextPage(){this._currentPageIndex++;let t=this.resolution,i=$i.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(i.context,this._style,t);let r=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),n=new Re({source:new Gn({resource:i.canvas,resolution:r,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})}),s={canvasAndContext:i,texture:n};return this.pages[this._currentPageIndex]=s,s}_setupContext(t,i,r){i.fontSize=this.baseRenderedFontSize,t.scale(r,r),t.font=wa(i),i.fontSize=this.baseMeasurementFontSize,t.textBaseline=i.textBaseline;let n=i._stroke,s=n?.width??0;if(n&&(t.lineWidth=s,t.lineJoin=n.join,t.miterLimit=n.miterLimit,t.strokeStyle=Ea(n,t)),i._fill&&(t.fillStyle=Ea(i._fill,t)),i.dropShadow){let a=i.dropShadow,o=ue.shared.setValue(a.color).toArray(),l=a.blur*r,h=a.distance*r;t.shadowColor=`rgba(${o[0]*255},${o[1]*255},${o[2]*255},${a.alpha})`,t.shadowBlur=l,t.shadowOffsetX=Math.cos(a.angle)*h,t.shadowOffsetY=Math.sin(a.angle)*h}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,i,r,n,s,a){let o=i.text,l=i.fontProperties,h=(a._stroke?.width??0)*s,u=r+h/2,d=n-h/2,p=l.descent*s,f=i.lineHeight*s;a.stroke&&h&&t.strokeText(o,u,d+f-p),a._fill&&t.fillText(o,u,d+f-p)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){let{canvasAndContext:i,texture:r}=this.pages[t];i.canvas.width=i.canvas.width,$i.returnCanvasAndContext(i),r.destroy(!0)}this.pages=null}},uh.defaultOptions={textureSize:512,style:new Xi,mipmap:!0},ch=uh});function _p(e,t,i){let r={width:0,height:0,offsetY:0,scale:t.fontSize/i.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};r.offsetY=i.baseLineOffset;let n=r.lines[0],s=null,a=!0,o={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},l=f=>{let y=n.width;for(let b=0;b<o.index;b++){let _=f.positions[b];n.chars.push(f.chars[b]),n.charPositions.push(_+y)}n.width+=f.width,a=!1,o.width=0,o.index=0,o.chars.length=0},h=()=>{let f=n.chars.length-1,y=n.chars[f];for(;y===" ";)n.width-=i.chars[y].xAdvance,y=n.chars[--f];r.width=Math.max(r.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,r.lines.push(n),r.height+=i.lineHeight},u=i.baseMeasurementFontSize/t.fontSize,d=t.letterSpacing*u,p=t.wordWrapWidth*u;for(let f=0;f<e.length+1;f++){let y,b=f===e.length;b||(y=e[f]);let _=i.chars[y]||i.chars[" "];if(/(?:\s)/.test(y)||y==="\r"||y===`
`||b){if(!a&&t.wordWrap&&n.width+o.width-d>p?(h(),l(o),b||n.charPositions.push(0)):(o.start=n.width,l(o),b||n.charPositions.push(0)),y==="\r"||y===`
`)n.width!==0&&h();else if(!b){let T=_.xAdvance+(_.kerning[s]||0)+d;n.width+=T,n.spaceWidth=T,n.spacesIndex.push(n.charPositions.length),n.chars.push(y)}}else{let T=_.kerning[s]||0,C=_.xAdvance+T+d;o.positions[o.index++]=o.width+T,o.chars.push(y),o.width+=C}s=y}return h(),t.align==="center"?p0(r):t.align==="right"?g0(r):t.align==="justify"&&m0(r),r}function p0(e){for(let t=0;t<e.lines.length;t++){let i=e.lines[t],r=e.width/2-i.width/2;for(let n=0;n<i.charPositions.length;n++)i.charPositions[n]+=r}}function g0(e){for(let t=0;t<e.lines.length;t++){let i=e.lines[t],r=e.width-i.width;for(let n=0;n<i.charPositions.length;n++)i.charPositions[n]+=r}}function m0(e){let t=e.width;for(let i=0;i<e.lines.length;i++){let r=e.lines[i],n=0,s=r.spacesIndex[n++],a=0,o=r.spacesIndex.length,l=(t-r.width)/o;for(let h=0;h<r.charPositions.length;h++)h===s&&(s=r.spacesIndex[n++],a+=l),r.charPositions[h]+=a}}var vp=v(()=>{"use strict"}),Qn,yp,xp,_0=v(()=>{js(),wt(),I(),jn(),f0(),vp(),mp(),Qn=0,yp=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(e,t){let i=`${t.fontFamily}-bitmap`,r=!0;if(t._fill.fill&&!t._stroke)i+=t._fill.fill.styleKey,r=!1;else if(t._stroke||t.dropShadow){let s=t.styleKey;s=s.substring(0,s.lastIndexOf("-")),i=`${s}-bitmap`,r=!1}if(!Wt.has(i)){let s=new ch({style:t,overrideFill:r,overrideSize:!0,...this.defaultOptions});Qn++,Qn>50&&F("BitmapText",`You have dynamically created ${Qn} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),s.once("destroy",()=>{Qn--,Wt.remove(i)}),Wt.set(i,s)}let n=Wt.get(i);return n.ensureCharacters?.(e),n}getLayout(e,t){let i=this.getFont(e,t);return _p([...e],t,i)}measureText(e,t){return this.getLayout(e,t)}install(...e){let t=e[0];typeof t=="string"&&(t={name:t,style:e[1],chars:e[2]?.chars,resolution:e[2]?.resolution,padding:e[2]?.padding,skipKerning:e[2]?.skipKerning},Xe(Ve,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));let i=t?.name;if(!i)throw new Error("[BitmapFontManager] Property `name` is required.");t={...this.defaultOptions,...t};let r=t.style,n=r instanceof Xi?r:new Xi(r),s=n._fill.fill!==null&&n._fill.fill!==void 0,a=new ch({style:n,overrideFill:s,skipKerning:t.skipKerning,padding:t.padding,resolution:t.resolution,overrideSize:!1}),o=gp(t.chars);return a.ensureCharacters(o.join("")),Wt.set(`${i}-bitmap`,a),a.once("destroy",()=>Wt.remove(`${i}-bitmap`)),a}uninstall(e){let t=`${e}-bitmap`,i=Wt.get(t);i&&(Wt.remove(t),i.destroy())}},xp=new yp});function bp(e,t){t.groupTransform=e.groupTransform,t.groupColorAlpha=e.groupColorAlpha,t.groupColor=e.groupColor,t.groupBlendMode=e.groupBlendMode,t.globalDisplayStatus=e.globalDisplayStatus,t.groupTransform=e.groupTransform,t.localDisplayStatus=e.localDisplayStatus,t.groupAlpha=e.groupAlpha,t._roundPixels=e._roundPixels}var dh,v0=v(()=>{js(),te(),Ht(),Wf(),c0(),_0(),vp(),dh=class{constructor(e){this._gpuBitmapText={},this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e}validateRenderable(e){let t=this._getGpuBitmapText(e);return e._didTextUpdate&&(e._didTextUpdate=!1,this._updateContext(e,t)),this._renderer.renderPipes.graphics.validateRenderable(t)}addRenderable(e,t){let i=this._getGpuBitmapText(e);bp(e,i),e._didTextUpdate&&(e._didTextUpdate=!1,this._updateContext(e,i)),this._renderer.renderPipes.graphics.addRenderable(i,t),i.context.customShader&&this._updateDistanceField(e)}destroyRenderable(e){e.off("destroyed",this._destroyRenderableBound),this._destroyRenderableByUid(e.uid)}_destroyRenderableByUid(e){let t=this._gpuBitmapText[e].context;t.customShader&&(Le.return(t.customShader),t.customShader=null),Le.return(this._gpuBitmapText[e]),this._gpuBitmapText[e]=null}updateRenderable(e){let t=this._getGpuBitmapText(e);bp(e,t),this._renderer.renderPipes.graphics.updateRen
font-family: "${e.fontFamily}";
src: url('${i}');
font-weight: ${e.fontWeight};
font-style: ${e.fontStyle};
}`}var R0=v(()=>{P0()});async function k0(e,t,i){let r=e.filter(n=>Wt.has(`${n}-and-url`)).map((n,s)=>{if(!es.has(n)){let{url:a}=Wt.get(`${n}-and-url`);s===0?es.set(n,Cp({fontWeight:t.fontWeight,fontStyle:t.fontStyle,fontFamily:n},a)):es.set(n,Cp({fontWeight:i.fontWeight,fontStyle:i.fontStyle,fontFamily:n},a))}return es.get(n)});return(await Promise.all(r)).join(`
`)}var es,B0=v(()=>{js(),R0(),es=new Map});function I0(e,t,i,r,n){let{domElement:s,styleElement:a,svgRoot:o}=n;s.innerHTML=`<style>${t.cssStyle}</style><div style='padding:0;'>${e}</div>`,s.setAttribute("style",`transform: scale(${i});transform-origin: top left; display: inline-block`),a.textContent=r;let{width:l,height:h}=n.image;return o.setAttribute("width",l.toString()),o.setAttribute("height",h.toString()),new XMLSerializer().serializeToString(o)}var G0=v(()=>{"use strict"});function O0(e,t){let i=$i.getOptimalCanvasAndContext(e.width,e.height,t),{context:r}=i;return r.clearRect(0,0,e.width,e.height),r.drawImage(e,0,0),$i.returnCanvasAndContext(i),i.canvas}var U0=v(()=>{pa()});function F0(e,t,i){return new Promise(async r=>{i&&await new Promise(n=>setTimeout(n,100)),e.onload=()=>{r()},e.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,e.crossOrigin="anonymous"})}var D0=v(()=>{"use strict"});function L0(e,t,i,r){r=r||Mp||(Mp=new mh);let{domElement:n,styleElement:s,svgRoot:a}=r;n.innerHTML=`<style>${t.cssStyle};</style><div style='padding:0'>${e}</div>`,n.setAttribute("style","transform-origin: top left; display: inline-block"),i&&(s.textContent=i),document.body.appendChild(a);let o=n.getBoundingClientRect();a.remove();let l=Ri.measureFont(t.fontStyle).descent,h=t.padding*2;return{width:o.width-h,height:o.height+l-h}}var Mp,N0=v(()=>{Sa(),Tp()}),Da,H0=v(()=>{te(),Ln(),sr(),b0(),I(),Ht(),Lf(),Tp(),E0(),C0(),B0(),G0(),U0(),D0(),N0(),Da=class{constructor(e){this._activeTextures={},this._renderer=e,this._createCanvas=e.type===Ei.WEBGPU}getTexture(e){return this._buildTexturePromise(e.text,e.resolution,e.style)}getManagedTexture(e,t,i,r){if(this._activeTextures[r])return this._increaseReferenceCount(r),this._activeTextures[r].promise;let n=this._buildTexturePromise(e,t,i).then(s=>(this._activeTextures[r].texture=s,s));return this._activeTextures[r]={texture:null,promise:n,usageCount:1},n}async _buildTexturePromise(e,t,i){let r=Le.get(mh),n=A0(e,i),s=await k0(n,i,Ap.defaultTextStyle),a=L0(e,i,s,r),o=Math.ceil(Math.ceil(Math.max(1,a.width)+i.padding*2)*t),l=Math.ceil(Math.ceil(Math.max(1,a.height)+i.padding*2)*t),h=r.image,u=2;h.width=(o|0)+u,h.height=(l|0)+u;let d=I0(e,i,t,s,r);await F0(h,d,x0()&&n.length>0);let p=h;this._createCanvas&&(p=O0(h,t));let f=Ff(p,h.width-u,h.height-u,t);return this._createCanvas&&this._renderer.texture.initSource(f.source),Le.return(r),f}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}decreaseReferenceCount(e){let t=this._activeTextures[e];t&&(t.usageCount--,t.usageCount===0&&(t.texture?this._cleanUp(t):t.promise.then(i=>{t.texture=i,this._cleanUp(t)}).catch(()=>{F("HTMLTextSystem: Failed to clean texture")}),this._activeTextures[e]=null))}_cleanUp(e){gi.returnTexture(e.texture),e.texture.source.resource=null,e.texture.source.uploadMethodId="unknown"}getReferenceCount(e){return this._activeTextures[e].usageCount}destroy(){this._activeTextures=null}},Da.extension={type:[G.WebGLSystem,G.WebGPUSystem,G.CanvasSystem],name:"htmlText"},Da.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"}}),Pp=v(()=>{te(),y0(),H0(),pe.add(Da),pe.add(fh)}),yh,La,xh=v(()=>{un(),zr(),Zs(),wt(),yh=class dv extends Un{constructor(...t){let i=t[0]??{};i instanceof Float32Array&&(Xe(Ve,"use new MeshGeometry({ positions, uvs, indices }) instead"),i={positions:i,uvs:t[1],indices:t[2]}),i={...dv.defaultOptions,...i};let r=i.positions||new Float32Array([0,0,1,0,1,1,0,1]),n=i.uvs||new Float32Array([0,0,1,0,1,1,0,1]),s=i.indices||new Uint32Array([0,1,2,0,2,3]),a=i.shrinkBuffersToFit,o=new wi({data:r,label:"attribute-mesh-positions",shrinkToFit:a,usage:tt.VERTEX|tt.COPY_DST}),l=new wi({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:tt.VERTEX|tt.COPY_DST}),h=new wi({data:s,label:"index-mesh-buffer",shrinkToFit:a,usage:tt.INDEX|tt.COPY_DST});super({attributes:{aPosition:{buffer:o,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:l,format:"float32x2",stride:2*4,offset:0}},indexBuffer:h,topology:i.topology}),this.batchMode="auto"}get positions(){return this.attributes.
struct LocalUniforms {
uTransformMatrix:mat3x3<f32>,
uColor:vec4<f32>,
uRound:f32,
}
@group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
`,main:`
vColor *= localUniforms.uColor;
modelMatrix *= localUniforms.uTransformMatrix;
`,end:`
if(localUniforms.uRound == 1)
{
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
}
`}},Rp={...vn,vertex:{...vn.vertex,header:vn.vertex.header.replace("group(1)","group(2)")}},Na={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);
}
`}}}),kp,Bp,z0=v(()=>{"use strict";kp={name:"tiling-bit",vertex:{header:`
struct TilingUniforms {
uMapCoord:mat3x3<f32>,
uClampFrame:vec4<f32>,
uClampOffset:vec2<f32>,
uTextureTransform:mat3x3<f32>,
uSizeAnchor:vec4<f32>
};
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
@group(2) @binding(1) var uTexture: texture_2d<f32>;
@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<f32>,
uClampFrame:vec4<f32>,
uClampOffset:vec2<f32>,
uTextureTransform:mat3x3<f32>,
uSizeAnchor:vec4<f32>
};
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
@group(2) @binding(1) var uTexture: texture_2d<f32>;
@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);
`}},Bp={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
`}}}),bh,wh,Ip,W0=v(()=>{We(),Tr(),ts(),Sr(),Yi(),pi(),pt(),z0(),Ip=class extends ki{constructor(){bh??(bh=qn({name:"tiling-sprite-shader",bits:[vn,kp,mn]})),wh??(wh=Kn({name:"tiling-sprite-shader",bits:[Na,Bp,_n]}));let e=new ti({uMapCoord:{value:new ke,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new ke,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:wh,gpuProgram:bh,resources:{localUniforms:new ti({uTransformMatrix:{value:new ke,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:e,uTexture:Re.EMPTY.source,uSampler:Re.EMPTY.source.style}})}updateUniforms(e,t,i,r,n,s){let a=this.resources.tilingUniforms,o=s.width,l=s.height,h=s.textureMatrix,u=a.uniforms.uTextureTransform;u.set(i.a*o/e,i.b*o/t,i.c*l/e,i.d*l/t,i.tx/e,i.ty/t),u.invert(),a.uniforms.uMapCoord=h.mapCoord,a.uniforms.uClampFrame=h.uClampFrame,a.uniforms.uClampOffset=h.uClampOffset,a.uniforms.uTextureTransform=u,a.uniforms.uSizeAnchor[0]=e,a.uniforms.uSizeAnchor[1]=t,a.uniforms.uSizeAnchor[2]=r,a.uniforms.uSizeAnchor[3]=n,s&&(this.resources.uTexture=s.source,this.resources.uSampler=s.source.style)}}}),Gp,V0=v(()=>{xh(),Gp=class extends La{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 j0(e,t){let i=e.anchor.x,r=e.anchor.y;t[0]=-i*e.width,t[1]=-r*e.height,t[2]=(1-i)*e.width,t[3]=-r*e.height,t[4]=(1-i)*e.width,t[5]=(1-r)*e.height,t[6]=-i*e.width,t[7]=(1-r)*e.height}var $0=v(()=>{"use strict"});function X0(e,t,i,r){let n=0,s=e.length/(t||2),a=r.a,o=r.b,l=r.c,h=r.d,u=r.tx,d=r.ty;for(i*=t;n<s;){let p=e[i],f=e[i+1];e[i]=a*p+l*f+u,e[i+1]=o*p+h*f+d,i+=t,n++}}var Y0=v(()=>{"use strict"});function q0(e,t){let i=e.texture,r=i.frame.width,n=i.frame.height,s=0,a=0;e._applyAnchorToTexture&&(s=e.anchor.x,a=e.anchor.y),t[0]=t[6]=-s,t[2]=t[4]=1-s,t[1]=t[3]=-a,t[5]=t[7]=1-a;let o=ke.shared;o.copyFrom(e._tileTransform.matrix),o.tx/=e.width,o.ty/=e.height,o.invert(),o.scale(e.width/r,e.height/n),X0(t,2,0,o)}var K0=v(()=>{We(),Y0()}),is,Th,Z0=v(()=>{te(),Cl(),nr(),sr(),ha(),Fl(),xh(),W0(),V0(),$0(),K0(),is=new Gp,Th=class{constructor(e){this._state=ji.default2d,this._tilingSpriteDataHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e}validateRenderable(e){let t=this._getTilingSpriteData(e),i=t.canBatch;this._updateCanBatch(e);let r=t.canBatch;if(r&&r===i){let{batchableMesh:n}=t;if(n&&n.texture._source!==e.texture._source)return!n.batcher.checkAndUpdateTexture(n,e.texture)}return i!==r}addRenderable(e,t){let i=this._renderer.renderPipes.batch;this._updateCanBatch(e);let r=this._getTilingSpriteData(e),{geometry:n,canBatch:s}=r;if(s){r.batchableMesh||(r.batchableMesh=new da);let a=r.batchableMesh;e._didTilingSpriteUpdate&&(e._didTilingSpriteUpdate=!1,this._updateBatchableMesh(e),a.geometry=n,a.mesh=e,a.texture=e._texture),a.roundPixels=this._renderer._roundPixels|e._roundPixels,i.addToBatch(a)}else i.break(t),r.shader||(r.shader=new Ip),this.updateRenderable(e),t.add(e)}execute(e){let{shader:t}=this._tilingSpriteDataHash[e.uid];t.groups[0]=this._renderer.globalUniforms.bindGroup;let i=t.resources.localUniforms.uniforms;i.uTransformMatrix=e.groupTransform,i.uRound=this._renderer._roundPixels|e._roundPixels,la(e.groupColorAlpha,i.uColor,0),this._state.blendMode=qs(e.groupBlendMode,e.texture._source),this._renderer.encoder.draw({geometry:is,shader:t,state:this._state})}updateRenderable(e){let t=this._getTilingSpriteData(e),{canBatch:i}=t;if(i){let{batchableMesh:r}=t;e._didTilingSpriteUpdate&&this._updateBatchableMesh(e),r.batcher.updateElement(r)}else if(e._didTilingSpriteUpdate){let{shader:r}=t;r.updateUniforms(e.width,e.height,e._tileTransform.matrix,e.anchor.x,e.anchor.y,e.texture)}e._didTilingSpriteUpdate=!1}destroyRenderable(e){let t=this._getTilingSpr
struct TextureUniforms {
uTextureMatrix:mat3x3<f32>,
}
@group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
`,main:`
uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
`},fragment:{header:`
@group(2) @binding(0) var uTexture: texture_2d<f32>;
@group(2) @binding(1) var uSampler: sampler;
`,main:`
outColor = textureSample(uTexture, uSampler, vUV);
`}},qp={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);
`}}}),Ih,gb=v(()=>{te(),We(),Tr(),ts(),Sr(),Kp(),Yi(),pt(),I(),Ih=class{init(){let e=qn({name:"mesh",bits:[vn,Yp,mn]});this._shader=new ki({gpuProgram:e,resources:{uTexture:Re.EMPTY._source,uSampler:Re.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new ke}}}})}execute(e,t){let i=e.renderer,r=t._shader;if(!r)r=this._shader,r.groups[2]=i.texture.getTextureBindGroup(t.texture);else if(!r.gpuProgram){F("Mesh shader has no gpuProgram",t.shader);return}let n=r.gpuProgram;if(n.autoAssignGlobalUniforms&&(r.groups[0]=i.globalUniforms.bindGroup),n.autoAssignLocalUniforms){let s=e.localUniforms;r.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(s,!0)}i.encoder.draw({geometry:t._geometry,shader:r,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}},Ih.extension={type:[G.WebGPUPipesAdaptor],name:"mesh"}}),as,Gh,mb=v(()=>{te(),Tr(),Zn(),Jn(),Sr(),Yi(),nr(),xr(),Sl(),as=ji.for2d(),Gh=class{init(){let e=qn({name:"batch",bits:[Ga,rh(yr()),mn]});this._shader=new ki({gpuProgram:e,groups:{}})}start(e,t){let i=e.renderer,r=i.encoder,n=this._shader.gpuProgram;this._geometry=t,r.setGeometry(t,n),as.blendMode="normal",i.pipeline.getPipeline(t,n,as);let s=i.globalUniforms.bindGroup;r.resetBindGroup(1),r.setBindGroup(0,s,n)}execute(e,t){let i=this._shader.gpuProgram,r=e.renderer,n=r.encoder;if(!t.bindGroup){let o=t.textures;t.bindGroup=wl(o.textures,o.count)}as.blendMode=t.blendMode;let s=r.bindGroup.getBindGroup(t.bindGroup,i,1),a=r.pipeline.getPipeline(this._geometry,i,as);t.bindGroup._touch(r.textureGC.count),n.setPipeline(a),n.renderPassEncoder.setBindGroup(1,s),n.renderPassEncoder.drawIndexed(t.size,1,t.start)}destroy(){this._shader.destroy(!0),this._shader=null}},Gh.extension={type:[G.WebGPUPipesAdaptor],name:"batch"}}),Oh,_b=v(()=>{te(),Oh=class{constructor(e){this._renderer=e}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&e.render(this._renderer)}destroy(){this._renderer=null}},Oh.extension={type:[G.WebGLPipes,G.WebGPUPipes,G.CanvasPipes],name:"customRender"}});function Zp(e,t){let i=e.instructionSet,r=i.instructions;for(let n=0;n<i.instructionSize;n++){let s=r[n];t[s.renderPipeId].execute(s)}}var Jp=v(()=>{"use strict"}),Uh,vb=v(()=>{te(),Jp(),Uh=class{constructor(e){this._renderer=e}addRenderGroup(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&(this._renderer.globalUniforms.push({worldTransformMatrix:e.worldTransform,worldColor:e.worldColorAlpha}),Zp(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop())}destroy(){this._renderer=null}},Uh.extension={type:[G.WebGLPipes,G.WebGPUPipes,G.CanvasPipes],name:"renderGroup"}});function yb(e,t){let i=e.root,r=e.instructionSet;r.reset();let n=t.renderPipes?t:t.batch.renderer,s=n.renderPipes;s.batch.buildStart(r),s.blendMode.buildStart(),s.colorMask.buildStart(),i.sortableChildren&&i.sortChildren(),Qp(i,r,n,!0),s.batch.buildEnd(r),s.blendMode.buildEnd(r)}function Wa(e,t,i){let r=i.renderPipes?i:i.batch.renderer;e.globalDisplayStatus<7||!e.includeInBuild||(e.sortableChildren&&e.sortChildren(),e.isSimple?xb(e,t,r):Qp(e,t,r,!1))}function xb(e,t,i){if(e.renderPipeId){let{renderPipes:r,renderableGC:n}=i;r.blendMode.setBlendMode(e,e.groupBlendMode,t),e.didViewUpdate=!1,r[e.renderPipeId].addRenderable(e,t),n.addRenderable(e,t)}if(!e.renderGroup){let r=e.children,n=r.length;for(let s=0;s<n;s++)Wa(r[s],t,i)}}function Qp(e,t,i,r){let{renderPipes:n,renderableGC:s}=i;if(!r&&e.renderGroup)n.renderGroup.addRenderGroup(e.renderGroup,t);else{for(let l=0;l<e.effects.length;l++){let h=e.effects[l];n[h.pipe].push(h,e,t)}let a=e.renderPipeId;a&&(n.blendMode.setBlendMode(e,e.groupBlendMode,t),e.didViewUpdate=!1,n[a].addRenderable(e,t),s.addRenderable(e,t));let o=e.children;if(o.length)for(let l=0;l<o.length;l++)Wa(o[l],t,i);for(let l=e.effects.length-1;l>=0;l--){let h=e.effects[l];n[h.pipe].pop(h,e,t)}}}var Fh=v(()=>{"use strict"});function Dh(e,t){t||(t=0);for(let i=t;i<e.length&&e[i];i++)e[i]=null}var eg=v(()=>{"use strict"});function tg(e,t=[]){t.push(e);
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;
}
`}),ug,Gb=v(()=>{ug=`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);
}
`}),jh,Ob=v(()=>{jh=`struct GlobalFilterUniforms {
uInputSize:vec4<f32>,
uInputPixel:vec4<f32>,
uInputClamp:vec4<f32>,
uOutputFrame:vec4<f32>,
uGlobalFrame:vec4<f32>,
uOutputTexture:vec4<f32>,
};
struct MaskUniforms {
uFilterMatrix:mat3x3<f32>,
uMaskClamp:vec4<f32>,
uAlpha:f32,
};
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
@group(0) @binding(1) var uTexture: texture_2d<f32>;
@group(0) @binding(2) var uSampler : sampler;
@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
struct VSOutput {
@builtin(position) position: vec4<f32>,
@location(0) uv : vec2<f32>,
@location(1) filterUv : vec2<f32>,
};
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
{
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<f32> ) -> vec2<f32>
{
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
}
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
{
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
}
fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
{
return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
}
fn getSize() -> vec2<f32>
{
return gfu.uGlobalFrame.zw;
}
@vertex
fn mainVertex(
@location(0) aPosition : vec2<f32>,
) -> VSOutput {
return VSOutput(
filterVertexPosition(aPosition),
filterTextureCoord(aPosition),
getFilterCoord(aPosition)
);
}
@fragment
fn mainFragment(
@location(0) uv: vec2<f32>,
@location(1) filterUv: vec2<f32>,
@builtin(position) position: vec4<f32>
) -> @location(0) vec4<f32> {
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;
}`}),cg,Ub=v(()=>{We(),$n(),Ba(),pi(),ad(),cb(),Ib(),Gb(),Ob(),cg=class extends Wp{constructor(e){let{sprite:t,...i}=e,r=new ul(t.texture),n=new ti({uFilterMatrix:{value:new ke,type:"mat3x3<f32>"},uMaskClamp:{value:r.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"}}),s=Yn.from({vertex:{source:jh,entryPoint:"mainVertex"},fragment:{source:jh,entryPoint:"mainFragment"}}),a=pn.from({vertex:ug,fragment:hg,name:"mask-filter"});super({...i,gpuProgram:s,glProgram:a,resources:{filterUniforms:n,uMaskTexture:t.texture.source}}),this.sprite=t,this._textureMatrix=r}apply(e,t,i,r){this._textureMatrix.texture=this.sprite.texture,e.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,e.applyFilter(this,t,i,r)}}}),dg,fg,$h,Fb=v(()=>{te(),Ir(),Ub(),m(),X(),Fh(),ud(),Ht(),pt(),Ln(),sr(),dg=new g,fg=class extends Ct{constructor(){super(),this.filters=[new cg({sprite:new Ws(Re.EMPTY),resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].sprite=e}},$h=class{constructor(e){this._activeMaskStage=[],this._renderer=e}push(e,t,i){let r=this._renderer;if(r.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:e,canBundle:!1,maskedContainer:t}),e.renderMaskToTexture){let n=e.mask;n.includeInBuild=!0,Wa(n,i,r),n.includeInBuild=!1}r.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:e,maskedContainer:t,canBundle:!1})}pop(e,t,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:e,canBundle:!1})}execute(e){let t=this._renderer,i=e.mask.renderMaskToTexture;if(e.action==="pushMaskBegin"){let r=Le.get(fg);if(i){e.mask.mask.measurable=!0;let n=k(e.mask.mask,!0,dg);e.mask.mask.measurable=!1,n.ceil();let s=t.renderTarget.renderTarget.colorTexture.source,a=gi.getOptimalTexture(n.width,n.height,s._resolution,s.antialias);t.renderTarget.push(a,!0),t.globalUniforms.push({offset:n,worldColor:4294967295});let o=r.sprite;o.texture=a,o.worldTransform.tx=n.minX,o.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:r,maskedContainer:e.maskedContainer,filterTexture:a})}else r.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:r,maskedContainer:e.maskedContainer})}else if(e.action==="pushMaskEnd"){let r=this._activeMaskStage[this._activeMaskStage.length-1];i&&(t.type===Ei.WEBGL&&t.renderTarget.finishRenderPass(),t.renderTarget.pop(),t.globalUniforms.pop()),t.filter.push({renderPipeId:"filter",action:"pushFilter",container:r.maskedContainer,filterEffect:r.filterEffect,canBundle:!1})}else if(e.action==="popMaskEnd"){t.filter.pop();let r=this._activeMaskStage.pop();i&&gi.returnTexture(r.filterTexture),Le.return(r.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}},$h.extension={type:[G.WebGLPipes,G.WebGPUPipes,G.CanvasPipes],name:"alphaMask"}}),Xh,Db=v(()=>{te(),Xh=class{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,i){this._renderer.renderPipes.batch.break(i);let r=this._colorStack;r[this._colorStackIndex]=r[this._colorStackIndex-1]&e.mask;let n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(e,t,i){this._renderer.renderPipes.batch.break(i);let r=this._colorStack;this._colorStackIndex--;let n=r[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._colorStack=null}},Xh.extension={type:[G.WebGLPipes,G.WebGPUPipes,G.CanvasPipes],name:"colorMask"}}),Yh,Lb=v(()=>{te(),Fh(),ns(),ln(),Yh=class{constructor(e){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=e}push(e,t,i){var r;let n=e,s=this._rendere
`,"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 ${eu} - ${e} - http://www.pixijs.com/`);Qh=!0}}var Qh,eu,Yb=v(()=>{Ft(),Qh=!1,eu="8.3.3"}),Ya,qb=v(()=>{te(),Yb(),sr(),Ya=class{constructor(e){this._renderer=e}init(e){if(e.hello){let t=this._renderer.name;this._renderer.type===Ei.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),Xb(t)}}},Ya.extension={type:[G.WebGLSystem,G.WebGPUSystem,G.CanvasSystem],name:"hello",priority:-2},Ya.defaultOptions={hello:!1}}),qa,bg,Kb=v(()=>{te(),qa=class yv{constructor(t){this._managedRenderables=[],this._renderer=t}init(t){t={...yv.defaultOptions,...t},this.maxUnusedTime=t.renderableGCMaxUnusedTime,this._frequency=t.renderableGCFrequency,this.enabled=t.renderableGCActive}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency):this._renderer.scheduler.cancel(this._handler))}prerender(){this._now=performance.now()}addRenderable(t,i){t._lastUsed=this._now,t._lastInstructionTick===-1&&this._managedRenderables.push(t),t._lastInstructionTick=i.tick}run(){let t=performance.now(),i=this._managedRenderables,r=this._renderer.renderPipes,n=0;for(let s=0;s<i.length;s++){let a=i[s],o=(a.renderGroup??a.parentRenderGroup)?.instructionSet?.tick??-1;a._lastInstructionTick!==o&&t-a._lastUsed>this.maxUnusedTime?(a.destroyed||r[a.renderPipeId].destroyRenderable(a),a._lastInstructionTick=-1,n++):i[s-n]=a}i.length=i.length-n}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0}},qa.extension={type:[G.WebGLSystem,G.WebGPUSystem],name:"renderableGC"},qa.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4},bg=qa}),Ka,wg,Zb=v(()=>{te(),Ka=class xv{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(t){t={...xv.defaultOptions,...t},this.checkCountMax=t.textureGCCheckCountMax,this.maxIdle=t.textureGCAMaxIdle??t.textureGCMaxIdle,this.active=t.textureGCActive}postrender(){this._renderer.renderingToScreen&&(this.count++,this.active&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){let t=this._renderer.texture.managedTextures;for(let i=0;i<t.length;i++){let r=t[i];r.autoGarbageCollect&&r.resource&&r._touched>-1&&this.count-r._touched>this.maxIdle&&(r._touched=-1,r.unload())}}destroy(){this._renderer=null}},Ka.extension={type:[G.WebGLSystem,G.WebGPUSystem],name:"textureGC"},Ka.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:60*60,textureGCCheckCountMax:600},wg=Ka}),tu,Za,Tg=v(()=>{bt(),fi(),pt(),tu=class bv{constructor(t={}){if(this.uid=at("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t={...bv.defaultOptions,...t},this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures=="number"){this._managedColorTextures=!0;for(let i=0;i<t.colorTextures;i++)this.colorTextures.push(new Dt({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map(r=>r.source)];let i=this.colorTexture.source;this.resize(i.width,i.height,i._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof Re||t.depthStencilTexture instanceof Dt?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){let 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
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<f32>",test:e=>e.type==="vec4<f32>"&&e.size===1&&e.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<f32>",test:e=>e.type==="vec2<f32>"&&e.size===1&&e.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<f32>",test:e=>e.type==="vec4<f32>"&&e.size===1&&e.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<f32>",test:e=>e.type==="vec3<f32>"&&e.size===1&&e.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 kg(e,t,i,r){let n=[`
var v = null;
var v2 = null;
var t = 0;
var index = 0;
var name = null;
var arrayOffset = null;
`],s=0;for(let o=0;o<e.length;o++){let l=e[o],h=l.data.name,u=!1,d=0;for(let p=0;p<Er.length;p++)if(Er[p].test(l.data)){d=l.offset/4,n.push(`name = "${h}";`,`offset += ${d-s};`,Er[p][t]||Er[p].ubo),u=!0;break}if(!u)if(l.data.size>1)d=l.offset/4,n.push(i(l,d-s));else{let p=r[l.data.type];d=l.offset/4,n.push(`
v = uv.${h};
offset += ${d-s};
${p};
`)}s=d}let a=n.join(`
`);return new Function("uv","data","offset",a)}var Bg=v(()=>{Rg()});function bn(e,t){return`
for (let i = 0; i < ${e*t}; i++) {
data[offset + (((i / ${e})|0) * 4) + (i % ${e})] = v[i];
}
`}var uu,Ig,Gg=v(()=>{"use strict";uu={f32:`
data[offset] = v;`,i32:`
data[offset] = v;`,"vec2<f32>":`
data[offset] = v[0];
data[offset + 1] = v[1];`,"vec3<f32>":`
data[offset] = v[0];
data[offset + 1] = v[1];
data[offset + 2] = v[2];`,"vec4<f32>":`
data[offset] = v[0];
data[offset + 1] = v[1];
data[offset + 2] = v[2];
data[offset + 3] = v[3];`,"mat2x2<f32>":`
data[offset] = v[0];
data[offset + 1] = v[1];
data[offset + 4] = v[2];
data[offset + 5] = v[3];`,"mat3x3<f32>":`
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<f32>":`
for (let i = 0; i < 16; i++) {
data[offset + i] = v[i];
}`,"mat3x2<f32>":bn(3,2),"mat4x2<f32>":bn(4,2),"mat2x3<f32>":bn(2,3),"mat4x3<f32>":bn(4,3),"mat2x4<f32>":bn(2,4),"mat3x4<f32>":bn(3,4)},Ig={...uu,"mat2x2<f32>":`
data[offset] = v[0];
data[offset + 1] = v[1];
data[offset + 2] = v[2];
data[offset + 3] = v[3];
`}});function a1(e,t){let{size:i,align:r}=os[e.data.type],n=(r-i)/4;return`
v = uv.${e.data.name};
${t!==0?`offset += ${t};`:""}
arrayOffset = offset;
t = 0;
for(var i=0; i < ${e.data.size*(i/4)}; i++)
{
for(var j = 0; j < ${i/4}; j++)
{
data[arrayOffset++] = v[t++];
}
${n!==0?`arrayOffset += ${n};`:""}
}
`}var o1=v(()=>{Pg()});function l1(e){return kg(e,"uboWgsl",a1,Ig)}var h1=v(()=>{Bg(),Gg(),o1()}),cu,u1=v(()=>{te(),Mg(),Pg(),h1(),cu=class extends hu{constructor(){super({createUboElements:s1,generateUboSync:l1})}},cu.extension={type:[G.WebGPUSystem],name:"ubo"}}),eo,du=v(()=>{xt(),bt(),eo=class extends Je{constructor({buffer:e,offset:t,size:i}){super(),this.uid=at("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=at("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=e,this.offset=t|0,this.size=i,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=at("resource"),this.emit("change",this)}destroy(e=!1){this.destroyed=!0,e&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}}),Og,c1=v(()=>{"use strict";Og=class{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${e*4}`);let t=this.byteIndex,i=t+e*4;if(i=Math.ceil(i/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,i>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=i,t}addGroup(e){let t=this.addEmptyGroup(e.length);for(let i=0;i<e.length;i++)this.data[t/4+i]=e[i];return t}destroy(){this._buffer.destroy(),this._buffer=null,this.data=null}}}),ar,fu,d1=v(()=>{te(),un(),du(),zr(),c1(),Nr(),ar=128,fu=class{constructor(e){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=e,this._batchBuffer=new Og({minUniformOffsetAlignment:ar});let t=256/ar;for(let i=0;i<t;i++){let r=tt.UNIFORM|tt.COPY_DST;i===0&&(r|=tt.COPY_SRC),this._buffers.push(new wi({data:this._batchBuffer.data,usage:r}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){for(let e in this._bindGroupHash)this._bindGroupHash[e]=null;this._batchBuffer.clear()}getUniformBindGroup(e,t){if(!t&&this._bindGroupHash[e.uid])return this._bindGroupHash[e.uid];this._renderer.ubo.ensureUniformGroup(e);let i=e.buffer.data,r=this._batchBuffer.addEmptyGroup(i.length);return this._renderer.ubo.syncUniformGroup(e,this._batchBuffer.data,r/4),this._bindGroupHash[e.uid]=this._getBindGroup(r/ar),this._bindGroupHash[e.uid]}getUboResource(e){this._renderer.ubo.updateUniformGroup(e);let t=e.buffer.data,i=this._batchBuffer.addGroup(t);return this._getBufferResource(i/ar)}getArrayBindGroup(e){let t=this._batchBuffer.addGroup(e);return this._getBindGroup(t/ar)}getArrayBufferResource(e){let t=this._batchBuffer.addGroup(e)/ar;return this._getBufferResource(t)}_getBufferResource(e){if(!this._bufferResources[e]){let t=this._buffers[e%2];this._bufferResources[e]=new eo({buffer:t,offset:(e/2|0)*256,size:ar})}return this._bufferResources[e]}_getBindGroup(e){if(!this._bindGroups[e]){let t=new Vi({0:this._getBufferResource(e)});this._bindGroups[e]=t}return this._bindGroups[e]}_uploadBindGroups(){let e=this._renderer.buffer,t=this._buffers[0];t.update(this._batchBuffer.byteIndex),e.updateBuffer(t);let i=this._renderer.gpu.device.createCommandEncoder();for(let r=1;r<this._buffers.length;r++){let n=this._buffers[r];i.copyBufferToBuffer(e.getGPUBuffer(t),ar,e.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([i.finish()])}destroy(){for(let e=0;e<this._bindGroups.length;e++)this._bindGroups[e].destroy();this._bindGroups=null,this._bindGroupHash=null;for(let e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers=null;for(let e=0;e<this._bufferResources.length;e++)this._bufferResources[e].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._bindGroupHash=null,this._renderer=null}},fu.extension={type:[G.WebGPUPipes],name:"uniformBatch"}});function Ug(e,t){for(let i in e.attributes){let r=e.attributes[i],n=t[i];n?(r.format??(r.format=n.format),r.offset??(r.offset=n.offset),r.instance??(r.instance
var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
struct VertexOutput {
@builtin(position) position : vec4<f32>,
@location(0) texCoord : vec2<f32>,
};
@vertex
fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
var output : VertexOutput;
output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
return output;
}
@group(0) @binding(0) var imgSampler : sampler;
@group(0) @binding(1) var img : texture_2d<f32>;
@fragment
fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
return textureSample(img, imgSampler, texCoord);
}
`})),t=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:e}]}}),this.pipelines[e]=t),t}generateMipmap(e){let t=this._getMipmapPipeline(e.format);if(e.dimension==="3d"||e.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let i=e,r=e.depthOrArrayLayers||1,n=e.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){let o={size:{width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:r},format:e.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:e.mipLevelCount-1};i=this.device.createTexture(o)}let s=this.device.createCommandEncoder({}),a=t.getBindGroupLayout(0);for(let o=0;o<r;++o){let l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:o,arrayLayerCount:1}),h=n?1:0;for(let u=1;u<e.mipLevelCount;++u){let d=i.createView({baseMipLevel:h++,mipLevelCount:1,dimension:"2d",baseArrayLayer:o,arrayLayerCount:1}),p=s.beginRenderPass({colorAttachments:[{view:d,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),f=this.device.createBindGroup({layout:a,entries:[{binding:0,resource:this.sampler},{binding:1,resource:l}]});p.setPipeline(t),p.setBindGroup(0,f),p.draw(3,1,0,0),p.end(),l=d}}if(!n){let o={width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:r};for(let l=1;l<e.mipLevelCount;++l)s.copyTextureToTexture({texture:i,mipLevel:l-1},{texture:e,mipLevel:l},o),o.width=Math.ceil(o.width/2),o.height=Math.ceil(o.height/2)}return this.device.queue.submit([s.finish()]),n||i.destroy(),e}}}),bu,k1=v(()=>{Ft(),te(),pi(),pa(),Nr(),C1(),M1(),$g(),P1(),R1(),bu=class{constructor(e){this.managedTextures=[],this._gpuSources=Object.create(null),this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._textureViewHash=Object.create(null),this._uploads={image:xu,buffer:Wg,video:Xg,compressed:jg},this._renderer=e}contextChange(e){this._gpu=e}initSource(e){if(e.autoGenerateMipmaps){let o=Math.max(e.pixelWidth,e.pixelHeight);e.mipLevelCount=Math.floor(Math.log2(o))+1}let t=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;e.uploadMethodId!=="compressed"&&(t|=GPUTextureUsage.RENDER_ATTACHMENT,t|=GPUTextureUsage.COPY_SRC);let i=yu[e.format]||{blockBytes:4,blockWidth:1,blockHeight:1},r=Math.ceil(e.pixelWidth/i.blockWidth)*i.blockWidth,n=Math.ceil(e.pixelHeight/i.blockHeight)*i.blockHeight,s={label:e.label,size:{width:r,height:n},format:e.format,sampleCount:e.sampleCount,mipLevelCount:e.mipLevelCount,dimension:e.dimension,usage:t},a=this._gpu.device.createTexture(s);return this._gpuSources[e.uid]=a,this.managedTextures.includes(e)||(e.on("update",this.onSourceUpdate,this),e.on("resize",this.onSourceResize,this),e.on("destroy",this.onSourceDestroy,this),e.on("unload",this.onSourceUnload,this),e.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(e)),this.onSourceUpdate(e),a}onSourceUpdate(e){let t=this.getGpuSource(e);t&&(this._uploads[e.uploadMethodId]&&this._uploads[e.uploadMethodId].upload(e,t,this._gpu),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e))}onSourceUnload(e){let t=this._gpuSources[e.uid];t&&(this._gpuSources[e.uid]=null,t.destroy())}onUpdateMipmaps(e){this._mipmapGenerator||(this._mipmapGenerator=new Yg(this._gpu.device));let t=this.getGpuSource(e);this._mipmapGenerator.generateMipmap(t)}onSourceDestroy(e){e.off("update",this.onSourceUpdate,this),e.off("unload",this.onSourceUnload,this),e.off("destroy",this.onSourceDestroy,this),e.off("resize",this.onSourceResize,this),e.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(e),1),this.onSourceUnload(e)}onSourceResize(e){let t=this._gpuSources[e.uid];t?(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(this._textureViewHash[e.uid]=null,this._bindGroupHash[e.uid]=null,this.onSourceUnload(e),this.initSource(e)):this.initSource(e)}_i
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 ki({glProgram:n,resources:{uTexture:Re.WHITE.source}})}renderStart(t){let i=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!i.isRoot,this._useBackBufferThisRender){let r=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=r.colorTexture,t.target=this._getBackBufferTexture(r.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){let 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:nm,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new Re({source:new Dt({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)}},ro.extension={type:[G.WebGLSystem],name:"backBuffer",priority:1},ro.defaultOptions={useBackBuffer:!1},sm=ro}),Bu,V1=v(()=>{te(),Bu=class{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.gl.colorMask(!!(e&8),!!(e&4),!!(e&2),!!(e&1)))}},Bu.extension={type:[G.WebGLSystem],name:"colorMask"}}),Iu,j1=v(()=>{te(),Iu=class{constructor(e){this.commandFinished=Promise.resolve(),this._renderer=e}setGeometry(e,t){this._renderer.geometry.bind(e,t.glProgram)}finishRenderPass(){}draw(e){let t=this._renderer,{geometry:i,shader:r,state:n,skipSync:s,topology:a,size:o,start:l,instanceCount:h}=e;t.shader.bind(r,s),t.geometry.bind(i,t.shader._activeProgram),n&&t.state.set(n),t.geometry.draw(a,o,l,h??i.instanceCount)}destroy(){this._renderer=null}},Iu.extension={type:[G.WebGLSystem],name:"encoder"}}),Gu,$1=v(()=>{te(),Dg(),ln(),Gu=class{constructor(e){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:Lt.NONE},this._renderTargetStencilState=Object.create(null),e.renderTarget.onRenderTargetChange.add(this)}contextChange(e){this._gl=e,this._comparisonFuncMapping={always:e.ALWAYS,never:e.NEVER,equal:e.EQUAL,"not-equal":e.NOTEQUAL,less:e.LESS,"less-equal":e.LEQUAL,greater:e.GREATER,"greater-equal":e.GEQUAL},this._stencilOpsMapping={keep:e.KEEP,zero:e.ZERO,replace:e.REPLACE,invert:e.INVERT,"increment-clamp":e.INCR,"decrement-clamp":e.DECR,"increment-wrap":e.INCR_WRAP,"decrement-wrap":e.DECR_WRAP},this._stencilCache.enabled=!1,this._stencilCache.stencilMode=Lt.NONE,this._stencilCache.stencilReference=0}onRenderTargetChange(e){if(this._activeRenderTarget===e)return;this._activeRenderTarget=e;let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:Lt.DISABLED,stencilReference:0}),this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){let i=this._renderTargetStencilState[this._activeRenderTarget.uid],r=this._gl,n=Ar[e],s=this._stencilCache;if(i.stencilMode=e,i.stencilReference=t,e===Lt.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,r.disable(r.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,r.enable(r.STENCIL_TEST)),(e!==s.stencilMode||s.stencilReference!==t)&&(s.stencilMode=e,s.stencilReference=t,r.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],t,255),r.stencilOp(r.KEEP,r.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}},Gu.extension={type:[G.WebGLSystem],name:"stencil"}});function X1(e){let t=e.map(s=>({data:s,offset:0,size:0})),i=0,r=0,n=0;for(let s=0;s<t.length;s++){let a=t[s];if(i=Ou[a.data.type],!i)throw new Error(`Unknown type ${a.data.type}`);if(a.data.size>1&&(i=Math.max(i,16)*a.data.size),a.size=i,r%i!==0&&r<16){let o=r%i%16;r+=o,n+=o}r+i>16?(n=Math.ceil(n/16)*16,a.offset=n,n+=i,r=i):(a.offset=n,r+=i,n+=i)}return n=Math.ceil(n/16)*16,{uboElements:t,size:n}}var Ou
v = uv.${e.data.name};
offset += ${t};
arrayOffset = offset;
t = 0;
for(var i=0; i < ${e.data.size*i}; i++)
{
for(var j = 0; j < ${r}; j++)
{
data[arrayOffset++] = v[t++];
}
${n!==0?`arrayOffset += ${n};`:""}
}
`}var q1=v(()=>{am()});function K1(e){return kg(e,"uboStd40",Y1,uu)}var Z1=v(()=>{Bg(),Gg(),q1()}),Uu,J1=v(()=>{te(),Mg(),am(),Z1(),Uu=class extends hu{constructor(){super({createUboElements:X1,generateUboSync:K1})}},Uu.extension={type:[G.WebGLSystem],name:"ubo"}}),om,Q1=v(()=>{"use strict";om=class{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}}),lm,ew=v(()=>{E(),I(),ns(),Q1(),lm=class{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ot}init(e,t){this._renderer=e,this._renderTargetSystem=t,e.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ot}copyToTexture(e,t,i,r,n){let s=this._renderTargetSystem,a=this._renderer,o=s.getGpuRenderTarget(e),l=a.gl;return this.finishRenderPass(e),l.bindFramebuffer(l.FRAMEBUFFER,o.resolveTargetFramebuffer),a.texture.bind(t,0),l.copyTexSubImage2D(l.TEXTURE_2D,0,n.x,n.y,i.x,i.y,r.width,r.height),t}startRenderPass(e,t=!0,i,r){let n=this._renderTargetSystem,s=e.colorTexture,a=n.getGpuRenderTarget(e),o=r.y;e.isRoot&&(o=s.pixelHeight-r.height),e.colorTextures.forEach(u=>{this._renderer.texture.unbind(u)});let l=this._renderer.gl;l.bindFramebuffer(l.FRAMEBUFFER,a.framebuffer);let h=this._viewPortCache;(h.x!==r.x||h.y!==o||h.width!==r.width||h.height!==r.height)&&(h.x=r.x,h.y=o,h.width=r.width,h.height=r.height,l.viewport(r.x,o,r.width,r.height)),!a.depthStencilRenderBuffer&&(e.stencil||e.depth)&&this._initStencil(a),this.clear(e,t,i)}finishRenderPass(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);if(!t.msaa)return;let i=this._renderer.gl;i.bindFramebuffer(i.FRAMEBUFFER,t.resolveTargetFramebuffer),i.bindFramebuffer(i.READ_FRAMEBUFFER,t.framebuffer),i.blitFramebuffer(0,0,t.width,t.height,0,0,t.width,t.height,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,t.framebuffer)}initGpuRenderTarget(e){let t=this._renderer,i=t.gl,r=new om;return e.colorTexture.resource===t.gl.canvas?(r.framebuffer=null,r):(this._initColor(e,r),i.bindFramebuffer(i.FRAMEBUFFER,null),r)}destroyGpuRenderTarget(e){let t=this._renderer.gl;e.framebuffer&&(t.deleteFramebuffer(e.framebuffer),e.framebuffer=null),e.resolveTargetFramebuffer&&(t.deleteFramebuffer(e.resolveTargetFramebuffer),e.resolveTargetFramebuffer=null),e.depthStencilRenderBuffer&&(t.deleteRenderbuffer(e.depthStencilRenderBuffer),e.depthStencilRenderBuffer=null),e.msaaRenderBuffer.forEach(i=>{t.deleteRenderbuffer(i)}),e.msaaRenderBuffer=null}clear(e,t,i){if(!t)return;let r=this._renderTargetSystem;typeof t=="boolean"&&(t=t?li.ALL:li.NONE);let n=this._renderer.gl;if(t&li.COLOR){i??(i=r.defaultClearColor);let s=this._clearColorCache,a=i;(s[0]!==a[0]||s[1]!==a[1]||s[2]!==a[2]||s[3]!==a[3])&&(s[0]=a[0],s[1]=a[1],s[2]=a[2],s[3]=a[3],n.clearColor(a[0],a[1],a[2],a[3]))}n.clear(t)}resizeGpuRenderTarget(e){if(e.isRoot)return;let t=this._renderTargetSystem.getGpuRenderTarget(e);this._resizeColor(e,t),(e.stencil||e.depth)&&this._resizeStencil(t)}_initColor(e,t){let i=this._renderer,r=i.gl,n=r.createFramebuffer();if(t.resolveTargetFramebuffer=n,r.bindFramebuffer(r.FRAMEBUFFER,n),t.width=e.colorTexture.source.pixelWidth,t.height=e.colorTexture.source.pixelHeight,e.colorTextures.forEach((s,a)=>{let o=s.source;o.antialias&&(i.context.supports.msaa?t.msaa=!0:F("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),i.texture.bindSource(o,0);let l=i.texture.getGlSource(o).texture;r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+a,3553,l,0)}),t.msaa){let s=r.createFramebuffer();t.framebuffer=s,r.bindFramebuffer(r.FRAMEBUFFER,s),e.colorTextures.forEach((a,o)=>{let l=r.createRenderbuffer();t.msaaRenderBuffer[o]=l})}else t.framebuffer=n;this._resizeColor(e,t)}_resizeColor(e,t){let i=e.colorTexture.source;if(t.width=i.pixelWidth,t.height=i.pixelHeight,e.colorTextures.forEach((r,n)=>{n!==0&&r.source.resize(i.width,i.height,i._resolution)}),t.msaa){let r=this._renderer,n=r.gl,s=t.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,s),e.colorTextures.forEach((a,o)=>{let l=a.source;r.texture.bindSource(l,0);let h=r.texture.getGlSource(l).in
var g = s.groups;
var sS = r.shader;
var p = s.glProgram;
var ugS = r.uniformGroup;
var resources;
`],n=!1,s=0,a=0,o=t._getProgramData(e.glProgram);for(let h in e.groups){let u=e.groups[h];i.push(`
resources = g[${h}].resources;
`);for(let d in u.resources){let p=u.resources[d];if(p instanceof ti)p.ubo?i.push(`
sS.bindUniformBlock(
resources[${d}],
sS._uniformBindMap[${h}[${d}],
${s++}
);
`):i.push(`
ugS.updateUniformGroup(resources[${d}], p, sD);
`);else if(p instanceof eo)i.push(`
sS.bindUniformBlock(
resources[${d}],
sS._uniformBindMap[${h}[${d}],
${s++}
);
`);else if(p instanceof Dt){let f=e._uniformBindMap[h][d],y=o.uniformData[f];y&&(n||(n=!0,r.push(`
var tS = r.texture;
`)),t._gl.uniform1i(y.location,a),i.push(`
tS.bind(resources[${d}], ${a});
`),a++)}}}let l=[...r,...i].join(`
`);return new Function("r","s","sD",l)}var rw=v(()=>{du(),pi(),fi()}),hm,nw=v(()=>{"use strict";hm=class{constructor(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}});function um(e,t,i){let r=e.createShader(t);return e.shaderSource(r,i),e.compileShader(r),r}var sw=v(()=>{"use strict"});function Du(e){let t=new Array(e);for(let i=0;i<t.length;i++)t[i]=!1;return t}function cm(e,t){switch(e){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Du(2*t);case"bvec3":return Du(3*t);case"bvec4":return Du(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var dm=v(()=>{"use strict"});function fm(e,t){if(!hs){let i=Object.keys(Lu);hs={};for(let r=0;r<i.length;++r){let n=i[r];hs[e[n]]=Lu[n]}}return hs[t]}function aw(e,t){let i=fm(e,t);return pm[i]||"float32"}var hs,Lu,pm,gm=v(()=>{"use strict";hs=null,Lu={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"},pm={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"}});function ow(e,t,i=!1){let r={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let a=0;a<n;a++){let o=t.getActiveAttrib(e,a);if(o.name.startsWith("gl_"))continue;let l=aw(t,o.type);r[o.name]={location:0,format:l,stride:Xn(l).stride,offset:0,instance:!1,start:0}}let s=Object.keys(r);if(i){s.sort((a,o)=>a>o?1:-1);for(let a=0;a<s.length;a++)r[s[a]].location=a,t.bindAttribLocation(e,a,s[a]);t.linkProgram(e)}else for(let a=0;a<s.length;a++)r[s[a]].location=t.getAttribLocation(e,s[a]);return r}var lw=v(()=>{Ra(),gm()});function hw(e,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};let i={},r=t.getProgramParameter(e,t.ACTIVE_UNIFORM_BLOCKS);for(let n=0;n<r;n++){let s=t.getActiveUniformBlockName(e,n),a=t.getUniformBlockIndex(e,s),o=t.getActiveUniformBlockParameter(e,n,t.UNIFORM_BLOCK_DATA_SIZE);i[s]={name:s,index:a,size:o}}return i}var uw=v(()=>{"use strict"});function cw(e,t){let i={},r=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let n=0;n<r;n++){let s=t.getActiveUniform(e,n),a=s.name.replace(/\[.*?\]$/,""),o=!!s.name.match(/\[.*?\]$/),l=fm(t,s.type);i[a]={name:a,index:n,type:l,size:s.size,isArray:o,value:cm(l,s.size)}}return i}var dw=v(()=>{dm(),gm()});function mm(e,t){let i=e.getShaderSource(t).split(`
`).map((h,u)=>`${u}: ${h}`),r=e.getShaderInfoLog(t),n=r.split(`
`),s={},a=n.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!s[h]?(s[h]=!0,!0):!1),o=[""];a.forEach(h=>{i[h-1]=`%c${i[h-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});let l=i.join(`
`);o[0]=l,console.error(r),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}function fw(e,t,i,r){e.getProgramParameter(t,e.LINK_STATUS)||(e.getShaderParameter(i,e.COMPILE_STATUS)||mm(e,i),e.getShaderParameter(r,e.COMPILE_STATUS)||mm(e,r),console.error("PixiJS Error: Could not initialize shader."),e.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",e.getProgramInfoLog(t)))}var pw=v(()=>{"use strict"});function gw(e,t){let i=um(e,e.VERTEX_SHADER,t.vertex),r=um(e,e.FRAGMENT_SHADER,t.fragment),n=e.createProgram();e.attachShader(n,i),e.attachShader(n,r);let s=t.transformFeedbackVaryings;s&&(typeof e.transformFeedbackVaryings!="function"?F("TransformFeedback is not supported but TransformFeedbackVaryings are given."):e.transformFeedbackVaryings(n,s.names,s.bufferMode==="separate"?e.SEPARATE_ATTRIBS:e.INTERLEAVED_ATTRIBS)),e.linkProgram(n),e.getProgramParameter(n,e.LINK_STATUS)||fw(e,n,i,r),t._attributeData=ow(n,e,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=cw(n,e),t._uniformBlockData=hw(n,e),e.deleteShader(i),e.deleteShader(r);let a={};for(let o in t._uniformData){let l=t._uniformData[o];a[o]={location:e.getUniformLocation(n,o),value:cm(l.type,l.size)}}return new hm(n,a)}var mw=v(()=>{I(),nw(),sw(),dm(),lw(),uw(),dw(),pw()}),us,Nu,_w=v(()=>{te(),xr(),rw(),mw(),us={textureCount:0,blockIndex:0},Nu=class{constructor(e){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=e}contextChange(e){this._gl=e,this._maxBindings=e.MAX_UNIFORM_BUFFER_BINDINGS?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0,this._programDataHash=Object.create(null),this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null,this.maxTextures=yr()}bind(e,t){if(this._setProgram(e.glProgram),t)return;us.textureCount=0,us.blockIndex=0;let i=this._shaderSyncFunctions[e.glProgram._key];i||(i=this._shaderSyncFunctions[e.glProgram._key]=this._generateShaderSync(e,this)),i(this._renderer,e,us)}updateUniformGroup(e){this._renderer.uniformGroup.updateUniformGroup(e,this._activeProgram,us)}bindUniformBlock(e,t,i=0){let r=this._renderer.buffer,n=this._getProgramData(this._activeProgram),s=e._bufferResource;s&&this._renderer.ubo.updateUniformGroup(e),r.updateBuffer(e.buffer);let a=this._boundUniformsIdsToIndexHash[e.uid];if(a===void 0){let h=this._nextIndex++%this._maxBindings,u=this._boundIndexToUniformsHash[h];u&&(this._boundUniformsIdsToIndexHash[u.uid]=void 0),a=this._boundUniformsIdsToIndexHash[e.uid]=h,this._boundIndexToUniformsHash[h]=e,s?r.bindBufferRange(e.buffer,h,e.offset):r.bindBufferBase(e.buffer,h)}let o=this._gl,l=this._activeProgram._uniformBlockData[t].index;n.uniformBlockBindings[i]!==a&&(n.uniformBlockBindings[i]=a,o.uniformBlockBinding(n.program,l,a))}_setProgram(e){if(this._activeProgram===e)return;this._activeProgram=e;let t=this._getProgramData(e);this._gl.useProgram(t.program)}_getProgramData(e){return this._programDataHash[e._key]||this._createProgramData(e)}_createProgramData(e){let t=e._key;return this._programDataHash[t]=gw(this._gl,e),this._programDataHash[t]}destroy(){for(let e of Object.keys(this._programDataHash))this._programDataHash[e].destroy(),this._programDataHash[e]=null;this._programDataHash=null,this._boundUniformsIdsToIndexHash=null}_generateShaderSync(e,t){return iw(e,t)}},Nu.extension={type:[G.WebGLSystem],name:"shader"}}),_m,vm,vw=v(()=>{"use strict";_m={f32:`if (cv !== v) {
cu.value = v;
gl.uniform1f(location, v);
}`,"vec2<f32>":`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<f32>":`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<f32>":`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<i32>":`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<i32>":`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<i32>":`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<u32>":`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<u32>":`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<u32>":`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<bool>":`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<bool>":`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<bool>":`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<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},vm={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"}});function yw(e,t){let i=[`
var v = null;
var cv = null;
var cu = null;
var t = 0;
var gl = renderer.gl;
var name = null;
`];for(let r in e.uniforms){if(!t[r]){e.uniforms[r]instanceof ti?e.uniforms[r].ubo?i.push(`
renderer.shader.bindUniformBlock(uv.${r}, "${r}");
`):i.push(`
renderer.shader.updateUniformGroup(uv.${r});
`):e.uniforms[r]instanceof eo&&i.push(`
renderer.shader.bindBufferResource(uv.${r}, "${r}");
`);continue}let n=e.uniformStructures[r],s=!1;for(let a=0;a<Er.length;a++){let o=Er[a];if(n.type===o.type&&o.test(n)){i.push(`name = "${r}";`,Er[a].uniform),s=!0;break}}if(!s){let a=(n.size===1?_m:vm)[n.type].replace("location",`ud["${r}"].location`);i.push(`
cu = ud["${r}"];
cv = cu.value;
v = uv["${r}"];
${a};`)}}return new Function("ud","uv","renderer","syncData",i.join(`
`))}var xw=v(()=>{du(),pi(),Rg(),vw()}),Hu,bw=v(()=>{te(),xw(),Hu=class{constructor(e){this._cache={},this._uniformGroupSyncHash={},this._renderer=e,this.gl=null,this._cache={}}contextChange(e){this.gl=e}updateUniformGroup(e,t,i){let r=this._renderer.shader._getProgramData(t);(!e.isStatic||e._dirtyId!==r.uniformDirtyGroups[e.uid])&&(r.uniformDirtyGroups[e.uid]=e._dirtyId,this._getUniformSyncFunction(e,t)(r.uniformData,e.uniforms,this._renderer,i))}_getUniformSyncFunction(e,t){return this._uniformGroupSyncHash[e._signature]?.[t._key]||this._createUniformSyncFunction(e,t)}_createUniformSyncFunction(e,t){let i=this._uniformGroupSyncHash[e._signature]||(this._uniformGroupSyncHash[e._signature]={}),r=this._getSignature(e,t._uniformData,"u");return this._cache[r]||(this._cache[r]=this._generateUniformsSync(e,t._uniformData)),i[t._key]=this._cache[r],i[t._key]}_generateUniformsSync(e,t){return yw(e,t)}_getSignature(e,t,i){let r=e.uniforms,n=[`${i}-`];for(let s in r)n.push(s),t[s]&&n.push(t[s].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}},Hu.extension={type:[G.WebGLSystem],name:"uniformGroup"}});function ww(e){let t={};if(t.normal=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t.add=[e.ONE,e.ONE],t.multiply=[e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.screen=[e.ONE,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[e.SRC_ALPHA,e.ONE,e.ONE,e.ONE],t["screen-npm"]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.erase=[e.ZERO,e.ONE_MINUS_SRC_ALPHA],!(e instanceof vt.get().getWebGLRenderingContext()))t.min=[e.ONE,e.ONE,e.ONE,e.ONE,e.MIN,e.MIN],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,e.MAX,e.MAX];else{let i=e.getExtension("EXT_blend_minmax");i&&(t.min=[e.ONE,e.ONE,e.ONE,e.ONE,i.MIN_EXT,i.MIN_EXT],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,i.MAX_EXT,i.MAX_EXT])}return t}var Tw=v(()=>{Ft()}),ym,xm,bm,wm,Tm,Sm,zu,Em,Sw=v(()=>{te(),nr(),Tw(),ym=0,xm=1,bm=2,wm=3,Tm=4,Sm=5,zu=class Mc{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[ym]=this.setBlend,this.map[xm]=this.setOffset,this.map[bm]=this.setCullFace,this.map[wm]=this.setDepthTest,this.map[Tm]=this.setFrontFace,this.map[Sm]=this.setDepthMask,this.checks=[],this.defaultState=ji.for2d()}contextChange(t){this.gl=t,this.blendModesMap=ww(t),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let i=this.stateId^t.data,r=0;for(;i;)i&1&&this.map[r].call(this,!!(t.data&1<<r)),i=i>>1,r++;this.stateId=t.data}for(let i=0;i<this.checks.length;i++)this.checks[i](this,t)}forceState(t){t=t||this.defaultState;for(let i=0;i<this.map.length;i++)this.map[i].call(this,!!(t.data&1<<i));for(let i=0;i<this.checks.length;i++)this.checks[i](this,t);this.stateId=t.data}setBlend(t){this._updateCheck(Mc._checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this._updateCheck(Mc._checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(this.blendModesMap[t]||(t="normal"),t===this.blendMode)return;this.blendMode=t;let i=this.blendModesMap[t],r=this.gl;i.length===2?r.blendFunc(i[0],i[1]):r.blendFuncSeparate(i[0],i[1],i[2],i[3]),i.length===6?(this._blendEq=!0,r.blendEquationSeparate(i[4],i[5])):this._blendEq&&(this._blendEq=!1,r.blendEquationSeparate(r.FUNC_ADD,r.FUNC_ADD))}setPolygonOffset(t,i){this.gl.polygonOffset(t,i)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(t,i){let r=this.checks.indexOf(t);i&&r===-1?this.checks.push(t):!i&&r!==-1&&this.checks.splice(r,1)}static _checkBlendMode(t,i){t.setBlendMode(i.blendMode)}static _checkPolygonOffset(t,i){t.setPolygonOffset(1,i.polygonOffse