@ivoryheart/herdr-world 0.1.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +42 -0
- package/THIRD_PARTY_NOTICES.md +52 -0
- package/UPSTREAM.md +33 -0
- package/bin/herdr-world +128 -0
- package/docs/world-assets.md +51 -0
- package/lib/bridges/linux-x64/herdr-world-bridge +0 -0
- package/lib/bridges/macos-arm64/herdr-world-bridge +0 -0
- package/lib/bridges/macos-x64/herdr-world-bridge +0 -0
- package/lib/herdr-world-launcher.sh +518 -0
- package/package.json +36 -0
- package/share/herdr-world/web/assets/BufferResource-TmONtVkO.js +311 -0
- package/share/herdr-world/web/assets/CanvasPool-C4EP4giG.js +1 -0
- package/share/herdr-world/web/assets/FederatedEventTarget-CkoT1sfc.js +1 -0
- package/share/herdr-world/web/assets/FilterSystem-Cc8XEqAi.js +173 -0
- package/share/herdr-world/web/assets/NoteMarkdownPreview-DSlfOjOc.js +29 -0
- package/share/herdr-world/web/assets/SpacesSurface-KQpjWcgW.js +1 -0
- package/share/herdr-world/web/assets/WebGLRenderer-COAVtjkI.js +1 -0
- package/share/herdr-world/web/assets/WebGPURenderer-DgfOPeWV.js +1 -0
- package/share/herdr-world/web/assets/WorldSurface-DvbdAI-_.js +197 -0
- package/share/herdr-world/web/assets/__vite-browser-external-2447137e-BvRk9kiK.js +0 -0
- package/share/herdr-world/web/assets/browserAll-B8-kqmYE.js +1 -0
- package/share/herdr-world/web/assets/chunk-QTnfLwEv.js +1 -0
- package/share/herdr-world/web/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/share/herdr-world/web/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/share/herdr-world/web/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/share/herdr-world/web/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/share/herdr-world/web/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/share/herdr-world/web/assets/getBatchSamplersUniformGroup-D-hqfegN.js +1 -0
- package/share/herdr-world/web/assets/ghostty-web-8_X1K5z2.js +13 -0
- package/share/herdr-world/web/assets/index-B1fwFDFH.css +1 -0
- package/share/herdr-world/web/assets/index-BAVYPHsj.js +17 -0
- package/share/herdr-world/web/assets/init-DeL9YIMj.js +1 -0
- package/share/herdr-world/web/assets/localUniformBit-BnogyqF-.js +264 -0
- package/share/herdr-world/web/assets/web-CkXGA1Hr.js +1 -0
- package/share/herdr-world/web/assets/web-DXrm_vsa.js +1 -0
- package/share/herdr-world/web/assets/webworkerAll-BFZtmp1G.js +1 -0
- package/share/herdr-world/web/herdr-logo-180.png +0 -0
- package/share/herdr-world/web/herdr-logo-192.png +0 -0
- package/share/herdr-world/web/herdr-logo-512.png +0 -0
- package/share/herdr-world/web/herdr-logo-maskable-192.png +0 -0
- package/share/herdr-world/web/herdr-logo-maskable-512.png +0 -0
- package/share/herdr-world/web/herdr-logo.svg +6 -0
- package/share/herdr-world/web/index.html +24 -0
- package/share/herdr-world/web/legal/Apache-2.0.txt +190 -0
- package/share/herdr-world/web/legal/LICENSE.txt +22 -0
- package/share/herdr-world/web/legal/PixiJS-MIT.txt +21 -0
- package/share/herdr-world/web/legal/THIRD_PARTY_NOTICES.md +52 -0
- package/share/herdr-world/web/legal/UPSTREAM.md +33 -0
- package/share/herdr-world/web/legal/manifest.json +33 -0
- package/share/herdr-world/web/legal/npm-licenses.txt +1381 -0
- package/share/herdr-world/web/legal/world-assets.md +51 -0
- package/share/herdr-world/web/manifest.json +42 -0
- package/share/herdr-world/web/world/LICENSE-PixiJS.txt +21 -0
- package/share/herdr-world/web/world/characters/1-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/10-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/11-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/12-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/2-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/3-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/4-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/5-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/6-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/7-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/8-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/9-D-1.png +0 -0
- package/third_party/dependencies/README.md +22 -0
- package/third_party/dependencies/cargo-licenses.html +7696 -0
- package/third_party/dependencies/npm-licenses.txt +1381 -0
- package/third_party/licenses/Apache-2.0.txt +190 -0
- package/third_party/licenses/PixiJS-MIT.txt +21 -0
- package/vendor/herdr-compat/VENDOR-MANIFEST.toml +186 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import{r as e,t}from"./chunk-QTnfLwEv.js";import{$ as n,B as r,C as i,D as a,E as o,F as s,G as c,H as l,I as u,J as d,K as f,L as p,M as m,N as h,O as g,P as _,Q as v,S as y,T as b,U as x,W as S,X as C,Y as w,Z as T,_ as E,a as D,at as O,c as k,ct as A,d as j,dt as M,et as N,f as P,ft as F,i as I,it as L,j as ee,l as te,lt as R,n as ne,o as re,ot as ie,p as ae,pt as z,q as oe,rt as B,s as se,t as ce,u as le,ut as V,v as ue,w as de,x as fe,y as H,z as pe}from"./localUniformBit-BnogyqF-.js";import{n as me,t as U}from"./CanvasPool-C4EP4giG.js";import{t as he}from"./getBatchSamplersUniformGroup-D-hqfegN.js";var ge=class{static init(e){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener(`resize`,this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener(`resize`,this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&=(cancelAnimationFrame(this._resizeId),null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,t;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,t=globalThis.innerHeight;else{let{clientWidth:n,clientHeight:r}=this._resizeTo;e=n,t=r}this.renderer.resize(e,t),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener(`resize`,this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}};ge.extension=F.Application;var _e=class{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,c.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?S.shared:new S,e.autoStart&&this.start()}static destroy(){if(this._ticker){let e=this._ticker;this.ticker=null,e.destroy()}}};_e.extension=F.Application;var ve=(e=>(e[e.Low=0]=`Low`,e[e.Normal=1]=`Normal`,e[e.High=2]=`High`,e))(ve||{});function W(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received ${JSON.stringify(e)}`)}function ye(e){return e.split(`?`)[0].split(`#`)[0]}function be(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function xe(e,t,n){return e.replace(new RegExp(be(t),`g`),n)}function Se(e,t){let n=``,r=0,i=-1,a=0,o=-1;for(let s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(!(i===s-1||a===1))if(i!==s-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){let e=n.lastIndexOf(`/`);if(e!==n.length-1){e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}}else if(n.length===2||n.length===1){n=``,r=0,i=s,a=0;continue}}t&&(n.length>0?n+=`/..`:n=`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===46&&a!==-1?++a:a=-1}return n}var Ce={toPosix(e){return xe(e,`\\`,`/`)},isUrl(e){return/^https?:/.test(this.toPosix(e))},isDataUrl(e){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(e)},isBlobUrl(e){return e.startsWith(`blob:`)},hasProtocol(e){return/^[^/:]+:/.test(this.toPosix(e))},getProtocol(e){W(e),e=this.toPosix(e);let t=/^file:\/\/\//.exec(e);if(t)return t[0];let n=/^[^/:]+:\/{0,2}/.exec(e);return n?n[0]:``},toAbsolute(e,t,n){if(W(e),this.isDataUrl(e)||this.isBlobUrl(e))return e;let r=ye(this.toPosix(t??x.get().getBaseUrl())),i=ye(this.toPosix(n??this.rootname(r)));return e=this.toPosix(e),e.startsWith(`/`)?Ce.join(i,e.slice(1)):this.isAbsolute(e)?e:this.join(r,e)},normalize(e){if(W(e),e.length===0)return`.`;if(this.isDataUrl(e)||this.isBlobUrl(e))return e;e=this.toPosix(e);let t=``,n=e.startsWith(`/`);this.hasProtocol(e)&&(t=this.rootname(e),e=e.slice(t.length));let r=e.endsWith(`/`);return e=Se(e,!1),e.length>0&&r&&(e+=`/`),n?`/${e}`:t+e},isAbsolute(e){return W(e),e=this.toPosix(e),this.hasProtocol(e)?!0:e.startsWith(`/`)},join(...e){if(e.length===0)return`.`;let t;for(let n=0;n<e.length;++n){let r=e[n];if(W(r),r.length>0)if(t===void 0)t=r;else{let i=e[n-1]??``;this.joinExtensions.includes(this.extname(i).toLowerCase())?t+=`/../${r}`:t+=`/${r}`}}return t===void 0?`.`:this.normalize(t)},dirname(e){if(W(e),e.length===0)return`.`;e=this.toPosix(e);let t=e.charCodeAt(0),n=t===47,r=-1,i=!0,a=this.getProtocol(e),o=e;e=e.slice(a.length);for(let n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!i){r=n;break}}else i=!1;return r===-1?n?`/`:this.isUrl(o)?a+e:a:n&&r===1?`//`:a+e.slice(0,r)},rootname(e){W(e),e=this.toPosix(e);let t=``;if(t=e.startsWith(`/`)?`/`:this.getProtocol(e),this.isUrl(e)){let n=e.indexOf(`/`,t.length);t=n===-1?e:e.slice(0,n),t.endsWith(`/`)||(t+=`/`)}return t},basename(e,t){W(e),t&&W(t),e=ye(this.toPosix(e));let n=0,r=-1,i=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let o=t.length-1,s=-1;for(a=e.length-1;a>=0;--a){let c=e.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else s===-1&&(i=!1,s=a+1),o>=0&&(c===t.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=s))}return n===r?r=s:r===-1&&(r=e.length),e.slice(n,r)}for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?``:e.slice(n,r)},extname(e){W(e),e=ye(this.toPosix(e));let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)},parse(e){W(e);let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;e=ye(this.toPosix(e));let n=e.charCodeAt(0),r=this.isAbsolute(e),i;t.root=this.rootname(e),i=r||this.hasProtocol(e)?1:0;let a=-1,o=0,s=-1,c=!0,l=e.length-1,u=0;for(;l>=i;--l){if(n=e.charCodeAt(l),n===47){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),n===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(o===0&&r?t.base=t.name=e.slice(1,s):t.base=t.name=e.slice(o,s)):(o===0&&r?(t.name=e.slice(1,a),t.base=e.slice(1,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s)),t.ext=e.slice(a,s)),t.dir=this.dirname(e),t},sep:`/`,delimiter:`:`,joinExtensions:[`.html`]},G=(e,t,n=!1)=>(Array.isArray(e)||(e=[e]),t?e.map(e=>typeof e==`string`||n?t(e):e):e);function we(e,t,n,r,i){let a=t[n];for(let o=0;o<a.length;o++){let s=a[o];n<t.length-1?we(e.replace(r[n],s),t,n+1,r,i):i.push(e.replace(r[n],s))}}function Te(e){let t=e.match(/\{(.*?)\}/g),n=[];if(t){let r=[];t.forEach(e=>{let t=e.substring(1,e.length-1).split(`,`);r.push(t)}),we(e,r,0,t,n)}else n.push(e);return n}var Ee=e=>!Array.isArray(e),De=class{constructor(){this._defaultBundleIdentifierOptions={connector:`-`,createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,``)},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle(`foo`,this._createBundleAssetId(`foo`,`bar`))!==`bar`)throw Error(`[Resolver] GenerateBundleAssetId are not working correctly`)}prefer(...e){e.forEach(e=>{this._preferredOrder.push(e),e.priority||=Object.keys(e.params)}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e==`string`)this._defaultSearchParams=e;else{let t=e;this._defaultSearchParams=Object.keys(t).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`).join(`&`)}}getAlias(e){let{alias:t,src:n}=e;return G(t||n,e=>typeof e==`string`?e:Array.isArray(e)?e.map(e=>e?.src??e):e?.src?e.src:e,!0)}addManifest(e){this._manifest&&w(`[Resolver] Manifest already exists, this will be overwritten`),this._manifest=e,e.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(e,t){let n=[],r=t;Array.isArray(t)||(r=Object.entries(t).map(([e,t])=>typeof t==`string`||Array.isArray(t)?{alias:e,src:t}:{alias:e,...t})),r.forEach(t=>{let r=t.src,i=t.alias,a;if(typeof i==`string`){let t=this._createBundleAssetId(e,i);n.push(t),a=[i,t]}else{let t=i.map(t=>this._createBundleAssetId(e,t));n.push(...t),a=[...i,...t]}this.add({...t,alias:a,src:r})}),this._bundles[e]=n}add(e){let t=[];Array.isArray(e)?t.push(...e):t.push(e);let n=e=>{this.hasKey(e)&&w(`[Resolver] already has key: ${e} overwriting`)};G(t).forEach(e=>{let{src:t}=e,{data:r,format:i,loadParser:a}=e,o=G(t).map(e=>typeof e==`string`?Te(e):Array.isArray(e)?e:[e]),s=this.getAlias(e);Array.isArray(s)?s.forEach(n):n(s);let c=[];o.forEach(e=>{e.forEach(e=>{let t={};if(typeof e!=`object`){t.src=e;for(let n=0;n<this._parsers.length;n++){let r=this._parsers[n];if(r.test(e)){t=r.parse(e);break}}}else r=e.data??r,i=e.format??i,a=e.loadParser??a,t={...t,...e};if(!s)throw Error(`[Resolver] alias is undefined for this asset: ${t.src}`);t=this._buildResolvedAsset(t,{aliases:s,data:r,format:i,loadParser:a}),c.push(t)})}),s.forEach(e=>{this._assetMap[e]=c})})}resolveBundle(e){let t=Ee(e);e=G(e);let n={};return e.forEach(e=>{let t=this._bundles[e];if(t){let r=this.resolve(t),i={};for(let t in r){let n=r[t];i[this._extractAssetIdFromBundle(e,t)]=n}n[e]=i}}),t?n[e[0]]:n}resolveUrl(e){let t=this.resolve(e);if(typeof e!=`string`){let e={};for(let n in t)e[n]=t[n].src;return e}return t.src}resolve(e){let t=Ee(e);e=G(e);let n={};return e.forEach(e=>{if(!this._resolverHash[e])if(this._assetMap[e]){let t=this._assetMap[e],n=this._getPreferredOrder(t);n?.priority.forEach(e=>{n.params[e].forEach(n=>{let r=t.filter(t=>t[e]?t[e]===n:!1);r.length&&(t=r)})}),this._resolverHash[e]=t[0]}else this._resolverHash[e]=this._buildResolvedAsset({alias:[e],src:e},{});n[e]=this._resolverHash[e]}),t?n[e[0]]:n}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){let t=e[0],n=this._preferredOrder.find(e=>e.params.format.includes(t.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(e){return this._defaultSearchParams?`${e}${/\?/.test(e)?`&`:`?`}${this._defaultSearchParams}`:e}_buildResolvedAsset(e,t){let{aliases:n,data:r,loadParser:i,format:a}=t;return(this._basePath||this._rootPath)&&(e.src=Ce.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=n??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...r||{},...e.data},e.loadParser=i??e.loadParser,e.format=a??e.format??Oe(e.src),e}};De.RETINA_PREFIX=/@([0-9\.]+)x/;function Oe(e){return e.split(`.`).pop().split(`?`).shift().split(`#`).shift()}var ke=(e,t)=>{let n=t.split(`?`)[1];return n&&(e+=`?${n}`),e},Ae=class e{constructor(e,t){this.linkedSheets=[],this._texture=e instanceof p?e:null,this.textureSource=e.source,this.textures={},this.animations={},this.data=t;let n=parseFloat(t.meta.scale);n?(this.resolution=n,e.source.resolution=this.resolution):this.resolution=e.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=e.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let n=t,r=e.BATCH_SIZE;for(;n-t<r&&n<this._frameKeys.length;){let e=this._frameKeys[n],t=this._frames[e],r=t.frame;if(r){let n=null,i=null,a=t.trimmed!==!1&&t.sourceSize?t.sourceSize:t.frame,o=new N(0,0,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution);n=t.rotated?new N(Math.floor(r.x)/this.resolution,Math.floor(r.y)/this.resolution,Math.floor(r.h)/this.resolution,Math.floor(r.w)/this.resolution):new N(Math.floor(r.x)/this.resolution,Math.floor(r.y)/this.resolution,Math.floor(r.w)/this.resolution,Math.floor(r.h)/this.resolution),t.trimmed!==!1&&t.spriteSourceSize&&(i=new N(Math.floor(t.spriteSourceSize.x)/this.resolution,Math.floor(t.spriteSourceSize.y)/this.resolution,Math.floor(r.w)/this.resolution,Math.floor(r.h)/this.resolution)),this.textures[e]=new p({source:this.textureSource,frame:n,orig:o,trim:i,rotate:t.rotated?2:0,defaultAnchor:t.anchor,defaultBorders:t.borders,label:e.toString()})}n++}}_processAnimations(){let e=this.data.animations||{};for(let t in e){this.animations[t]=[];for(let n=0;n<e[t].length;n++){let r=e[t][n];this.animations[t].push(this.textures[r])}}}_parseComplete(){let e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*e.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*e.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){for(let e in this.textures)this.textures[e].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};Ae.BATCH_SIZE=1e3;var je=Ae,Me=[`jpg`,`png`,`jpeg`,`avif`,`webp`,`basis`,`etc2`,`bc7`,`bc6h`,`bc5`,`bc4`,`bc3`,`bc2`,`bc1`,`eac`,`astc`];function Ne(e,t,n){let r={};if(e.forEach(e=>{r[e]=t}),Object.keys(t.textures).forEach(e=>{r[e]=t.textures[e]}),!n){let n=Ce.dirname(e[0]);t.linkedSheets.forEach((e,i)=>{let a=Ne([`${n}/${t.data.meta.related_multi_packs[i]}`],e,!0);Object.assign(r,a)})}return r}var Pe={extension:F.Asset,cache:{test:e=>e instanceof je,getCacheableAssets:(e,t)=>Ne(e,t,!1)},resolver:{extension:{type:F.ResolveParser,name:`resolveSpritesheet`},test:e=>{let t=e.split(`?`)[0].split(`.`),n=t.pop(),r=t.pop();return n===`json`&&Me.includes(r)},parse:e=>{let t=e.split(`.`);return{resolution:parseFloat(De.RETINA_PREFIX.exec(e)?.[1]??`1`),format:t[t.length-2],src:e}}},loader:{name:`spritesheetLoader`,extension:{type:F.LoadParser,priority:ve.Normal,name:`spritesheetLoader`},async testParse(e,t){return Ce.extname(t.src).toLowerCase()===`.json`&&!!e.frames},async parse(e,t,n){let{texture:r,imageFilename:i}=t?.data??{},a=Ce.dirname(t.src);a&&a.lastIndexOf(`/`)!==a.length-1&&(a+=`/`);let o;if(r instanceof p)o=r;else{let r=ke(a+(i??e.meta.image),t.src);o=(await n.load([r]))[r]}let s=new je(o.source,e);await s.parse();let c=e?.meta?.related_multi_packs;if(Array.isArray(c)){let e=[];for(let r of c){if(typeof r!=`string`)continue;let i=a+r;t.data?.ignoreMultiPack||(i=ke(i,t.src),e.push(n.load({src:i,data:{ignoreMultiPack:!0}})))}let r=await Promise.all(e);s.linkedSheets=r,r.forEach(e=>{e.linkedSheets=[s].concat(s.linkedSheets.filter(t=>t!==e))})}return s},async unload(e,t,n){await n.unload(e.textureSource._sourceOrigin),e.destroy(!1)}}};z.add(Pe);var Fe=new n;function Ie(e,t,n){let r=Fe;e.measurable=!0,C(e,n,r),t.addBoundsMask(r),e.measurable=!1}function Le(e,t,n){let r=T.get();e.measurable=!0;let i=v.get().identity();d(e,r,Re(e,n,i)),e.measurable=!1,t.addBoundsMask(r),v.return(i),T.return(r)}function Re(e,t,n){return e?(e!==t&&(Re(e.parent,t,n),e.updateLocalTransform(),n.append(e.localTransform)),n):(w(`Mask bounds, renderable is not inside the root container`),n)}var ze=class{constructor(e){this.priority=0,this.pipe=`alphaMask`,e?.mask&&this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof _),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(e,t){Ie(this.mask,e,t)}addLocalBounds(e,t){Le(this.mask,e,t)}containsPoint(e,t){let n=this.mask;return t(n,e)}destroy(){this.reset()}static test(e){return e instanceof _}};ze.extension=F.MaskEffect;var Be=class{constructor(e){this.priority=0,this.pipe=`colorMask`,e?.mask&&this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e==`number`}};Be.extension=F.MaskEffect;var Ve=class{constructor(e){this.priority=0,this.pipe=`stencilMask`,e?.mask&&this.init(e.mask)}init(e){this.mask=e,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(e,t){Ie(this.mask,e,t)}addLocalBounds(e,t){Le(this.mask,e,t)}containsPoint(e,t){let n=this.mask;return t(n,e)}destroy(){this.reset()}static test(e){return e instanceof f}};Ve.extension=F.MaskEffect;var He=class extends r{constructor(e){if(e.resource&&globalThis.HTMLImageElement&&e.resource instanceof HTMLImageElement){let t=x.get().createCanvas(e.resource.width,e.resource.height);t.getContext(`2d`).drawImage(e.resource,0,0,e.resource.width,e.resource.height),e.resource=t,w(`ImageSource: Image element passed, converting to canvas. Use CanvasSource instead.`)}super(e),this.uploadMethodId=`image`,this.autoGarbageCollect=!0}static test(e){return globalThis.HTMLImageElement&&e instanceof HTMLImageElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||globalThis.VideoFrame&&e instanceof VideoFrame}};He.extension=F.TextureSource;var Ue;async function We(){return Ue??=(async()=>{let e=document.createElement(`canvas`).getContext(`webgl`);if(!e)return`premultiply-alpha-on-upload`;let t=await new Promise(e=>{let t=document.createElement(`video`);t.onloadeddata=()=>e(t),t.onerror=()=>e(null),t.autoplay=!1,t.crossOrigin=`anonymous`,t.preload=`auto`,t.src=`data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=`,t.load()});if(!t)return`premultiply-alpha-on-upload`;let n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);let r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t);let i=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,i),e.deleteFramebuffer(r),e.deleteTexture(n),e.getExtension(`WEBGL_lose_context`)?.loseContext(),i[0]<=i[3]?`premultiplied-alpha`:`premultiply-alpha-on-upload`})(),Ue}var Ge=class e extends r{constructor(t){super(t),this.isReady=!1,this.uploadMethodId=`video`,t={...e.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??`premultiply-alpha-on-upload`,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){let e=S.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;let e=this.resource,t=this.options;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener(`play`,this._onPlayStart),e.addEventListener(`pause`,this._onPlayStop),e.addEventListener(`seeked`,this._onSeeked),this._isSourceReady()?this._mediaReady():(t.preload||e.addEventListener(`canplay`,this._onCanPlay),e.addEventListener(`canplaythrough`,this._onCanPlayThrough),e.addEventListener(`error`,this._onError,!0)),this.alphaMode=await We(),this._load=new Promise((n,r)=>{this.isValid?n(this):(this._resolve=n,this._reject=r,t.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${t.preloadTimeoutMs}ms`))})),e.load())}),this._load}_onError(e){this.resource.removeEventListener(`error`,this._onError,!0),this.emit(`error`,e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){let e=this.resource;return!e.paused&&!e.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener(`canplay`,this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener(`canplaythrough`,this._onCanPlay),this._preloadTimeout&&=(clearTimeout(this._preloadTimeout),void 0),this._mediaReady()}_mediaReady(){let e=this.resource;this.isValid&&(this.isReady=!0,this.resize(e.videoWidth,e.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();let e=this.resource;e&&(e.removeEventListener(`play`,this._onPlayStart),e.removeEventListener(`pause`,this._onPlayStop),e.removeEventListener(`seeked`,this._onSeeked),e.removeEventListener(`canplay`,this._onCanPlay),e.removeEventListener(`canplaythrough`,this._onCanPlayThrough),e.removeEventListener(`error`,this._onError,!0),e.pause(),e.src=``,e.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(S.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(S.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(S.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};Ge.extension=F.TextureSource,Ge.defaultOptions={...r.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},Ge.MIME_TYPES={ogv:`video/ogg`,mov:`video/quicktime`,m4v:`video/mp4`};var Ke=Ge,K=new class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){let t=this._cache.get(e);return t||w(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){let n=G(e),r;for(let e=0;e<this.parsers.length;e++){let i=this.parsers[e];if(i.test(t)){r=i.getCacheableAssets(n,t);break}}let i=new Map(Object.entries(r||{}));r||n.forEach(e=>{i.set(e,t)});let a=[...i.keys()],o={cacheKeys:a,keys:n};n.forEach(e=>{this._cacheMap.set(e,o)}),a.forEach(e=>{let n=r?r[e]:t;this._cache.has(e)&&this._cache.get(e)!==n&&w(`[Cache] already has key:`,e),this._cache.set(e,i.get(e))})}remove(e){if(!this._cacheMap.has(e)){w(`[Assets] Asset id ${e} was not found in the Cache`);return}let t=this._cacheMap.get(e);t.cacheKeys.forEach(e=>{this._cache.delete(e)}),t.keys.forEach(e=>{this._cacheMap.delete(e)})}get parsers(){return this._parsers}},qe=[];z.handleByList(F.TextureSource,qe);function Je(e={}){let t=e&&e.resource,n=t?e.resource:e,r=t?e:{resource:e};for(let e=0;e<qe.length;e++){let t=qe[e];if(t.test(n))return new t(r)}throw Error(`Could not find a source type for resource: ${r.resource}`)}function Ye(e={},t=!1){let n=e&&e.resource,r=n?e.resource:e,i=n?e:{resource:e};if(!t&&K.has(r))return K.get(r);let a=new p({source:Je(i)});return a.on(`destroy`,()=>{K.has(r)&&K.remove(r)}),t||K.set(r,a),a}function Xe(e,t=!1){return typeof e==`string`?K.get(e):e instanceof r?new p({source:e}):Ye(e,t)}p.from=Xe,r.from=Je,z.add(ze,Be,Ve,Ke,He,h,pe);function Ze(e,t,n,r,i,a,o,s=null){let c=0;n*=t,i*=a;let l=s.a,u=s.b,d=s.c,f=s.d,p=s.tx,m=s.ty;for(;c<o;){let o=e[n],s=e[n+1];r[i]=l*o+d*s+p,r[i+1]=u*o+f*s+m,i+=a,n+=t,c++}}function Qe(e,t,n,r){let i=0;for(t*=n;i<r;)e[t]=0,e[t+1]=0,t+=n,i++}function $e(e,t,n,r,i){let a=t.a,o=t.b,s=t.c,c=t.d,l=t.tx,u=t.ty;n||=0,r||=2,i||=e.length/r-n;let d=n*r;for(let t=0;t<i;t++){let t=e[d],n=e[d+1];e[d]=a*t+s*n+l,e[d+1]=o*t+c*n+u,d+=r}}function et(e,t){if(e===16777215||!t)return t;if(t===16777215||!e)return e;let n=e>>16&255,r=e>>8&255,i=e&255,a=t>>16&255,o=t>>8&255,s=t&255,c=n*a/255,l=r*o/255,u=i*s/255;return(c<<16)+(l<<8)+u}var tt=class{constructor(){this.batcher=null,this.batch=null,this.applyTransform=!0,this.roundPixels=0}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:`normal`}packIndex(e,t,n){let r=this.geometryData.indices;for(let i=0;i<this.indexSize;i++)e[t++]=r[i+this.indexOffset]+n-this.vertexOffset}packAttributes(e,t,n,r){let i=this.geometryData,a=this.renderable,o=i.vertices,s=i.uvs,c=this.vertexOffset*2,l=(this.vertexOffset+this.vertexSize)*2,u=this.color,d=u>>16|u&65280|(u&255)<<16;if(this.applyTransform){let i=et(d,a.groupColor)+(this.alpha*a.groupAlpha*255<<24),u=a.groupTransform,f=r<<16|this.roundPixels&65535,p=u.a,m=u.b,h=u.c,g=u.d,_=u.tx,v=u.ty;for(let r=c;r<l;r+=2){let a=o[r],c=o[r+1];e[n]=p*a+h*c+_,e[n+1]=m*a+g*c+v,e[n+2]=s[r],e[n+3]=s[r+1],t[n+4]=i,t[n+5]=f,n+=6}}else{let i=d+(this.alpha*255<<24);for(let a=c;a<l;a+=2)e[n]=o[a],e[n+1]=o[a+1],e[n+2]=s[a],e[n+3]=s[a+1],t[n+4]=i,t[n+5]=r<<16,n+=6}}get vertSize(){return this.vertexSize}copyTo(e){e.indexOffset=this.indexOffset,e.indexSize=this.indexSize,e.vertexOffset=this.vertexOffset,e.vertexSize=this.vertexSize,e.color=this.color,e.alpha=this.alpha,e.texture=this.texture,e.geometryData=this.geometryData}reset(){this.applyTransform=!0}},nt={extension:{type:F.ShapeBuilder,name:`circle`},build(e,t){let n,r,i,a,o,s;if(e.type===`circle`){let t=e;n=t.x,r=t.y,o=s=t.radius,i=a=0}else if(e.type===`ellipse`){let t=e;n=t.x,r=t.y,o=t.halfWidth,s=t.halfHeight,i=a=0}else{let t=e,c=t.width/2,l=t.height/2;n=t.x+c,r=t.y+l,o=s=Math.max(0,Math.min(t.radius,Math.min(c,l))),i=c-o,a=l-s}if(!(o>=0&&s>=0&&i>=0&&a>=0))return t;let c=Math.ceil(2.3*Math.sqrt(o+s)),l=c*8+(i?4:0)+(a?4:0);if(l===0)return t;if(c===0)return t[0]=t[6]=n+i,t[1]=t[3]=r+a,t[2]=t[4]=n-i,t[5]=t[7]=r-a,t;let u=0,d=c*4+(i?2:0)+2,f=d,p=l,m=i+o,h=a,g=n+m,_=n-m,v=r+h;if(t[u++]=g,t[u++]=v,t[--d]=v,t[--d]=_,a){let e=r-h;t[f++]=_,t[f++]=e,t[--p]=e,t[--p]=g}for(let e=1;e<c;e++){let l=Math.PI/2*(e/c),m=i+Math.cos(l)*o,h=a+Math.sin(l)*s,g=n+m,_=n-m,v=r+h,y=r-h;t[u++]=g,t[u++]=v,t[--d]=v,t[--d]=_,t[f++]=_,t[f++]=y,t[--p]=y,t[--p]=g}m=i,h=a+s,g=n+m,_=n-m,v=r+h;let y=r-h;return t[u++]=g,t[u++]=v,t[--p]=y,t[--p]=g,i&&(t[u++]=_,t[u++]=v,t[--p]=y,t[--p]=_),t},triangulate(e,t,n,r,i,a){if(e.length===0)return;let o=0,s=0;for(let t=0;t<e.length;t+=2)o+=e[t],s+=e[t+1];o/=e.length/2,s/=e.length/2;let c=r;t[c*n]=o,t[c*n+1]=s;let l=c++;for(let r=0;r<e.length;r+=2)t[c*n]=e[r],t[c*n+1]=e[r+1],r>0&&(i[a++]=c,i[a++]=l,i[a++]=c-1),c++;i[a++]=l+1,i[a++]=l,i[a++]=c-1}},rt={...nt,extension:{...nt.extension,name:`ellipse`}},it={...nt,extension:{...nt.extension,name:`roundedRectangle`}},at=1e-4,ot=1e-4;function st(e){let t=e.length;if(t<6)return 1;let n=0;for(let r=0,i=e[t-2],a=e[t-1];r<t;r+=2){let t=e[r],o=e[r+1];n+=(t-i)*(o+a),i=t,a=o}return n<0?-1:1}function ct(e,t,n,r,i,a,o,s){let c=e-n*i,l=t-r*i,u=e+n*a,d=t+r*a,f,p;o?(f=r,p=-n):(f=-r,p=n);let m=c+f,h=l+p,g=u+f,_=d+p;return s.push(m,h),s.push(g,_),2}function q(e,t,n,r,i,a,o,s){let c=n-e,l=r-t,u=Math.atan2(c,l),d=Math.atan2(i-e,a-t);s&&u<d?u+=Math.PI*2:!s&&u>d&&(d+=Math.PI*2);let f=u,p=d-u,m=Math.abs(p),h=Math.sqrt(c*c+l*l),g=(15*m*Math.sqrt(h)/Math.PI>>0)+1,_=p/g;if(f+=_,s){o.push(e,t),o.push(n,r);for(let n=1,r=f;n<g;n++,r+=_)o.push(e,t),o.push(e+Math.sin(r)*h,t+Math.cos(r)*h);o.push(e,t),o.push(i,a)}else{o.push(n,r),o.push(e,t);for(let n=1,r=f;n<g;n++,r+=_)o.push(e+Math.sin(r)*h,t+Math.cos(r)*h),o.push(e,t);o.push(i,a),o.push(e,t)}return g*2}function lt(e,t,n,r,i,a,o,s,c){let l=at;if(e.length===0)return;let u=t,d=u.alignment;if(t.alignment!==.5){let t=st(e);n&&(t*=-1),d=(d-.5)*t+.5}let f=new R(e[0],e[1]),p=new R(e[e.length-2],e[e.length-1]),m=r,h=Math.abs(f.x-p.x)<l&&Math.abs(f.y-p.y)<l;if(m){e=e.slice(),h&&(e.pop(),e.pop(),p.set(e[e.length-2],e[e.length-1]));let t=(f.x+p.x)*.5,n=(p.y+f.y)*.5;e.unshift(t,n),e.push(t,n)}let g=i,_=e.length/2,v=e.length,y=g.length/2,b=u.width/2,x=b*b,S=u.miterLimit*u.miterLimit,C=e[0],w=e[1],T=e[2],E=e[3],D=0,O=0,k=-(w-E),A=C-T,j=0,M=0,N=Math.sqrt(k*k+A*A);k/=N,A/=N,k*=b,A*=b;let P=d,F=(1-P)*2,I=P*2;m||(u.cap===`round`?v+=q(C-k*(F-I)*.5,w-A*(F-I)*.5,C-k*F,w-A*F,C+k*I,w+A*I,g,!0)+2:u.cap===`square`&&(v+=ct(C,w,k,A,F,I,!0,g))),g.push(C-k*F,w-A*F),g.push(C+k*I,w+A*I);for(let t=1;t<_-1;++t){C=e[(t-1)*2],w=e[(t-1)*2+1],T=e[t*2],E=e[t*2+1],D=e[(t+1)*2],O=e[(t+1)*2+1],k=-(w-E),A=C-T,N=Math.sqrt(k*k+A*A),k/=N,A/=N,k*=b,A*=b,j=-(E-O),M=T-D,N=Math.sqrt(j*j+M*M),j/=N,M/=N,j*=b,M*=b;let n=T-C,r=w-E,i=T-D,a=O-E,o=n*i+r*a,s=r*i-a*n,c=s<0;if(Math.abs(s)<.001*Math.abs(o)){g.push(T-k*F,E-A*F),g.push(T+k*I,E+A*I),o>=0&&(u.join===`round`?v+=q(T,E,T-k*F,E-A*F,T-j*F,E-M*F,g,!1)+4:v+=2,g.push(T-j*I,E-M*I),g.push(T+j*F,E+M*F));continue}let l=(-k+C)*(-A+E)-(-k+T)*(-A+w),d=(-j+D)*(-M+E)-(-j+T)*(-M+O),f=(n*d-i*l)/s,p=(a*l-r*d)/s,m=(f-T)*(f-T)+(p-E)*(p-E),h=T+(f-T)*F,_=E+(p-E)*F,y=T-(f-T)*I,P=E-(p-E)*I,L=Math.min(n*n+r*r,i*i+a*a),ee=c?F:I;m<=L+ee*ee*x?u.join===`bevel`||m/x>S?(c?(g.push(h,_),g.push(T+k*I,E+A*I),g.push(h,_),g.push(T+j*I,E+M*I)):(g.push(T-k*F,E-A*F),g.push(y,P),g.push(T-j*F,E-M*F),g.push(y,P)),v+=2):u.join===`round`?c?(g.push(h,_),g.push(T+k*I,E+A*I),v+=q(T,E,T+k*I,E+A*I,T+j*I,E+M*I,g,!0)+4,g.push(h,_),g.push(T+j*I,E+M*I)):(g.push(T-k*F,E-A*F),g.push(y,P),v+=q(T,E,T-k*F,E-A*F,T-j*F,E-M*F,g,!1)+4,g.push(T-j*F,E-M*F),g.push(y,P)):(g.push(h,_),g.push(y,P)):(g.push(T-k*F,E-A*F),g.push(T+k*I,E+A*I),u.join===`round`?c?v+=q(T,E,T+k*I,E+A*I,T+j*I,E+M*I,g,!0)+2:v+=q(T,E,T-k*F,E-A*F,T-j*F,E-M*F,g,!1)+2:u.join===`miter`&&m/x<=S&&(c?(g.push(y,P),g.push(y,P)):(g.push(h,_),g.push(h,_)),v+=2),g.push(T-j*F,E-M*F),g.push(T+j*I,E+M*I),v+=2)}C=e[(_-2)*2],w=e[(_-2)*2+1],T=e[(_-1)*2],E=e[(_-1)*2+1],k=-(w-E),A=C-T,N=Math.sqrt(k*k+A*A),k/=N,A/=N,k*=b,A*=b,g.push(T-k*F,E-A*F),g.push(T+k*I,E+A*I),m||(u.cap===`round`?v+=q(T-k*(F-I)*.5,E-A*(F-I)*.5,T-k*F,E-A*F,T+k*I,E+A*I,g,!1)+2:u.cap===`square`&&(v+=ct(T,E,k,A,F,I,!1,g)));let L=ot*ot;for(let e=y;e<v+y-2;++e)C=g[e*2],w=g[e*2+1],T=g[(e+1)*2],E=g[(e+1)*2+1],D=g[(e+2)*2],O=g[(e+2)*2+1],!(Math.abs(C*(E-O)+T*(O-w)+D*(w-E))<L)&&s.push(e,e+1,e+2)}var ut=t(((e,t)=>{t.exports=n,t.exports.default=n;function n(e,t,n){n||=2;var i=t&&t.length,o=i?t[0]*n:e.length,s=r(e,0,o,n,!0),c=[];if(!s||s.next===s.prev)return c;var l,d,f,p,m,h,g;if(i&&(s=u(e,t,s,n)),e.length>80*n){l=f=e[0],d=p=e[1];for(var _=n;_<o;_+=n)m=e[_],h=e[_+1],m<l&&(l=m),h<d&&(d=h),m>f&&(f=m),h>p&&(p=h);g=Math.max(f-l,p-d),g=g===0?0:32767/g}return a(s,c,n,l,d,g,0),c}function r(e,t,n,r,i){var a,o;if(i===N(e,t,n,r)>0)for(a=t;a<n;a+=r)o=A(a,e[a],e[a+1],o);else for(a=n-r;a>=t;a-=r)o=A(a,e[a],e[a+1],o);return o&&S(o,o.next)&&(j(o),o=o.next),o}function i(e,t){if(!e)return e;t||=e;var n=e,r;do if(r=!1,!n.steiner&&(S(n,n.next)||x(n.prev,n,n.next)===0)){if(j(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function a(e,t,n,r,u,d,f){if(e){!f&&d&&h(e,r,u,d);for(var p=e,m,g;e.prev!==e.next;){if(m=e.prev,g=e.next,d?s(e,r,u,d):o(e)){t.push(m.i/n|0),t.push(e.i/n|0),t.push(g.i/n|0),j(e),e=g.next,p=g.next;continue}if(e=g,e===p){f?f===1?(e=c(i(e),t,n),a(e,t,n,r,u,d,2)):f===2&&l(e,t,n,r,u,d):a(i(e),t,n,r,u,d,1);break}}}}function o(e){var t=e.prev,n=e,r=e.next;if(x(t,n,r)>=0)return!1;for(var i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=i<a?i<o?i:o:a<o?a:o,d=s<c?s<l?s:l:c<l?c:l,f=i>a?i>o?i:o:a>o?a:o,p=s>c?s>l?s:l:c>l?c:l,m=r.next;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&y(i,s,a,c,o,l,m.x,m.y)&&x(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function s(e,t,n,r){var i=e.prev,a=e,o=e.next;if(x(i,a,o)>=0)return!1;for(var s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=s<c?s<l?s:l:c<l?c:l,m=u<d?u<f?u:f:d<f?d:f,h=s>c?s>l?s:l:c>l?c:l,g=u>d?u>f?u:f:d>f?d:f,v=_(p,m,t,n,r),b=_(h,g,t,n,r),S=e.prevZ,C=e.nextZ;S&&S.z>=v&&C&&C.z<=b;){if(S.x>=p&&S.x<=h&&S.y>=m&&S.y<=g&&S!==i&&S!==o&&y(s,u,c,d,l,f,S.x,S.y)&&x(S.prev,S,S.next)>=0||(S=S.prevZ,C.x>=p&&C.x<=h&&C.y>=m&&C.y<=g&&C!==i&&C!==o&&y(s,u,c,d,l,f,C.x,C.y)&&x(C.prev,C,C.next)>=0))return!1;C=C.nextZ}for(;S&&S.z>=v;){if(S.x>=p&&S.x<=h&&S.y>=m&&S.y<=g&&S!==i&&S!==o&&y(s,u,c,d,l,f,S.x,S.y)&&x(S.prev,S,S.next)>=0)return!1;S=S.prevZ}for(;C&&C.z<=b;){if(C.x>=p&&C.x<=h&&C.y>=m&&C.y<=g&&C!==i&&C!==o&&y(s,u,c,d,l,f,C.x,C.y)&&x(C.prev,C,C.next)>=0)return!1;C=C.nextZ}return!0}function c(e,t,n){var r=e;do{var a=r.prev,o=r.next.next;!S(a,o)&&C(a,r,r.next,o)&&D(a,o)&&D(o,a)&&(t.push(a.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),j(r),j(r.next),r=e=o),r=r.next}while(r!==e);return i(r)}function l(e,t,n,r,o,s){var c=e;do{for(var l=c.next.next;l!==c.prev;){if(c.i!==l.i&&b(c,l)){var u=k(c,l);c=i(c,c.next),u=i(u,u.next),a(c,t,n,r,o,s,0),a(u,t,n,r,o,s,0);return}l=l.next}c=c.next}while(c!==e)}function u(e,t,n,i){var a=[],o,s,c,l,u;for(o=0,s=t.length;o<s;o++)c=t[o]*i,l=o<s-1?t[o+1]*i:e.length,u=r(e,c,l,i,!1),u===u.next&&(u.steiner=!0),a.push(v(u));for(a.sort(d),o=0;o<a.length;o++)n=f(a[o],n);return n}function d(e,t){return e.x-t.x}function f(e,t){var n=p(e,t);if(!n)return t;var r=k(n,e);return i(r,r.next),i(n,n.next)}function p(e,t){var n=t,r=e.x,i=e.y,a=-1/0,o;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){var s=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=r&&s>a&&(a=s,o=n.x<n.next.x?n:n.next,s===r))return o}n=n.next}while(n!==t);if(!o)return null;var c=o,l=o.x,u=o.y,d=1/0,f;n=o;do r>=n.x&&n.x>=l&&r!==n.x&&y(i<u?r:a,i,l,u,i<u?a:r,i,n.x,n.y)&&(f=Math.abs(i-n.y)/(r-n.x),D(n,e)&&(f<d||f===d&&(n.x>o.x||n.x===o.x&&m(o,n)))&&(o=n,d=f)),n=n.next;while(n!==c);return o}function m(e,t){return x(e.prev,e,t.prev)<0&&x(t.next,e,e.next)<0}function h(e,t,n,r){var i=e;do i.z===0&&(i.z=_(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,g(i)}function g(e){var t,n,r,i,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,s=0,t=0;t<l&&(s++,r=r.nextZ,r);t++);for(c=l;s>0||c>0&&r;)s!==0&&(c===0||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1);return e}function _(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function v(e){var t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function y(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function b(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!E(e,t)&&(D(e,t)&&D(t,e)&&O(e,t)&&(x(e.prev,e,t.prev)||x(e,t.prev,t))||S(e,t)&&x(e.prev,e,e.next)>0&&x(t.prev,t,t.next)>0)}function x(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function S(e,t){return e.x===t.x&&e.y===t.y}function C(e,t,n,r){var i=T(x(e,t,n)),a=T(x(e,t,r)),o=T(x(n,r,e)),s=T(x(n,r,t));return!!(i!==a&&o!==s||i===0&&w(e,n,t)||a===0&&w(e,r,t)||o===0&&w(n,e,r)||s===0&&w(n,t,r))}function w(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function T(e){return e>0?1:e<0?-1:0}function E(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&C(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function D(e,t){return x(e.prev,e,e.next)<0?x(e,t,e.next)>=0&&x(e,e.prev,t)>=0:x(e,t,e.prev)<0||x(e,e.next,t)<0}function O(e,t){var n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function k(e,t){var n=new M(e.i,e.x,e.y),r=new M(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function A(e,t,n,r){var i=new M(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function j(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function M(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}n.deviation=function(e,t,n,r){var i=t&&t.length,a=i?t[0]*n:e.length,o=Math.abs(N(e,0,a,n));if(i)for(var s=0,c=t.length;s<c;s++){var l=t[s]*n,u=s<c-1?t[s+1]*n:e.length;o-=Math.abs(N(e,l,u,n))}var d=0;for(s=0;s<r.length;s+=3){var f=r[s]*n,p=r[s+1]*n,m=r[s+2]*n;d+=Math.abs((e[f]-e[m])*(e[p+1]-e[f+1])-(e[f]-e[p])*(e[m+1]-e[f+1]))}return o===0&&d===0?0:Math.abs((d-o)/o)};function N(e,t,n,r){for(var i=0,a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}n.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,i=0;i<e.length;i++){for(var a=0;a<e[i].length;a++)for(var o=0;o<t;o++)n.vertices.push(e[i][a][o]);i>0&&(r+=e[i-1].length,n.holes.push(r))}return n}})),dt=e(ut(),1);function ft(e,t,n,r,i,a,o){let s=(0,dt.default)(e,t,2);if(!s)return;for(let e=0;e<s.length;e+=3)a[o++]=s[e]+i,a[o++]=s[e+1]+i,a[o++]=s[e+2]+i;let c=i*r;for(let t=0;t<e.length;t+=2)n[c]=e[t],n[c+1]=e[t+1],c+=r}var pt=[],mt={extension:{type:F.ShapeBuilder,name:`polygon`},build(e,t){for(let n=0;n<e.points.length;n++)t[n]=e.points[n];return t},triangulate(e,t,n,r,i,a){ft(e,pt,t,n,r,i,a)}},ht={extension:{type:F.ShapeBuilder,name:`rectangle`},build(e,t){let n=e,r=n.x,i=n.y,a=n.width,o=n.height;return a>=0&&o>=0?(t[0]=r,t[1]=i,t[2]=r+a,t[3]=i,t[4]=r+a,t[5]=i+o,t[6]=r,t[7]=i+o,t):t},triangulate(e,t,n,r,i,a){let o=0;r*=n,t[r+o]=e[0],t[r+o+1]=e[1],o+=n,t[r+o]=e[2],t[r+o+1]=e[3],o+=n,t[r+o]=e[6],t[r+o+1]=e[7],o+=n,t[r+o]=e[4],t[r+o+1]=e[5],o+=n;let s=r/n;i[a++]=s,i[a++]=s+1,i[a++]=s+2,i[a++]=s+1,i[a++]=s+3,i[a++]=s+2}},gt={extension:{type:F.ShapeBuilder,name:`triangle`},build(e,t){return t[0]=e.x,t[1]=e.y,t[2]=e.x2,t[3]=e.y2,t[4]=e.x3,t[5]=e.y3,t},triangulate(e,t,n,r,i,a){let o=0;r*=n,t[r+o]=e[0],t[r+o+1]=e[1],o+=n,t[r+o]=e[2],t[r+o+1]=e[3],o+=n,t[r+o]=e[4],t[r+o+1]=e[5];let s=r/n;i[a++]=s,i[a++]=s+1,i[a++]=s+2}},_t={};z.handleByMap(F.ShapeBuilder,_t),z.add(ht,mt,gt,nt,rt,it);var vt=new N;function yt(e,t){let{geometryData:n,batches:r}=t;r.length=0,n.indices.length=0,n.vertices.length=0,n.uvs.length=0;for(let t=0;t<e.instructions.length;t++){let i=e.instructions[t];if(i.action===`texture`)bt(i.data,r,n);else if(i.action===`fill`||i.action===`stroke`){let e=i.action===`stroke`,t=i.data.path.shapePath,a=i.data.style,o=i.data.hole;e&&o&&xt(o.shapePath,a,null,!0,r,n),xt(t,a,o,e,r,n)}}}function bt(e,t,n){let{vertices:r,uvs:i,indices:a}=n,o=a.length,s=r.length/2,c=[],l=_t.rectangle,u=vt,d=e.image;u.x=e.dx,u.y=e.dy,u.width=e.dw,u.height=e.dh;let f=e.transform;l.build(u,c),f&&$e(c,f),l.triangulate(c,r,2,s,a,o);let p=d.uvs;i.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);let m=B.get(tt);m.indexOffset=o,m.indexSize=a.length-o,m.vertexOffset=s,m.vertexSize=r.length/2-s,m.color=e.style,m.alpha=e.alpha,m.texture=d,m.geometryData=n,t.push(m)}function xt(e,t,n,r,i,a){let{vertices:o,uvs:s,indices:c}=a,l=e.shapePrimitives.length-1;e.shapePrimitives.forEach(({shape:e,transform:u},d)=>{let f=c.length,m=o.length/2,h=[],g=_t[e.type];if(g.build(e,h),u&&$e(h,u),r)lt(h,t,!1,e.closePath??!0,o,2,m,c,f);else if(n&&l===d){l!==0&&console.warn(`[Pixi Graphics] only the last shape have be cut out`);let e=[],t=h.slice();St(n.shapePath).forEach(n=>{e.push(t.length/2),t.push(...n)}),ft(t,e,o,2,m,c,f)}else g.triangulate(h,o,2,m,c,f);let _=s.length/2,v=t.texture;if(v!==p.WHITE){let e=t.matrix;e&&(u&&e.append(u.clone().invert()),Ze(o,2,m,s,_,2,o.length/2-m,e))}else Qe(s,_,2,o.length/2-m);let y=B.get(tt);y.indexOffset=f,y.indexSize=c.length-f,y.vertexOffset=m,y.vertexSize=o.length/2-m,y.color=t.color,y.alpha=t.alpha,y.texture=v,y.geometryData=a,i.push(y)})}function St(e){if(!e)return[];let t=e.shapePrimitives,n=[];for(let e=0;e<t.length;e++){let r=t[e].shape,i=[];_t[r.type].build(r,i),n.push(i)}return n}var Ct=class{constructor(){this.batcher=new a,this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}},wt=class{constructor(){this.geometry=new i,this.instructions=new oe}init(){this.instructions.reset()}},Tt=class e{constructor(){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null)}init(t){e.defaultOptions.bezierSmoothness=t?.bezierSmoothness??e.defaultOptions.bezierSmoothness}getContextRenderData(e){return this._graphicsDataContextHash[e.uid]||this._initContextRenderData(e)}updateGpuContext(e){let t=this._gpuContextHash[e.uid]||this._initContext(e);if(e.dirty){t?this._cleanGraphicsContextData(e):t=this._initContext(e),yt(e,t);let n=e.batchMode;e.customShader||n===`no-batch`?t.isBatchable=!1:n===`auto`&&(t.isBatchable=t.geometryData.vertices.length<400),e.dirty=!1}return t}getGpuContext(e){return this._gpuContextHash[e.uid]||this._initContext(e)}_initContextRenderData(e){let t=B.get(wt),{batches:n,geometryData:r,batcher:i}=this._gpuContextHash[e.uid],a=r.vertices.length,o=r.indices.length;for(let e=0;e<n.length;e++)n[e].applyTransform=!1;i.ensureAttributeBuffer(a),i.ensureIndexBuffer(o),i.begin();for(let e=0;e<n.length;e++){let t=n[e];i.add(t)}i.finish(t.instructions);let s=t.geometry;s.indexBuffer.setDataWithSize(i.indexBuffer,i.indexSize,!0),s.buffers[0].setDataWithSize(i.attributeBuffer.float32View,i.attributeSize,!0);let c=i.batches;for(let e=0;e<c.length;e++){let t=c[e];t.bindGroup=me(t.textures.textures,t.textures.count)}return this._graphicsDataContextHash[e.uid]=t,t}_initContext(e){let t=new Ct;return t.context=e,this._gpuContextHash[e.uid]=t,e.on(`destroy`,this.onGraphicsContextDestroy,this),this._gpuContextHash[e.uid]}onGraphicsContextDestroy(e){this._cleanGraphicsContextData(e),e.off(`destroy`,this.onGraphicsContextDestroy,this),this._gpuContextHash[e.uid]=null}_cleanGraphicsContextData(e){let t=this._gpuContextHash[e.uid];t.isBatchable||this._graphicsDataContextHash[e.uid]&&(B.return(this.getContextRenderData(e)),this._graphicsDataContextHash[e.uid]=null),t.batches&&t.batches.forEach(e=>{B.return(e)})}destroy(){for(let e in this._gpuContextHash)this._gpuContextHash[e]&&this.onGraphicsContextDestroy(this._gpuContextHash[e].context)}};Tt.extension={type:[F.WebGLSystem,F.WebGPUSystem,F.CanvasSystem],name:`graphicsContext`},Tt.defaultOptions={bezierSmoothness:.5};var Et=Tt,Dt=class{constructor(e,t){this.state=y.for2d(),this._graphicsBatchesHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){let t=e.context,n=!!this._graphicsBatchesHash[e.uid],r=this.renderer.graphicsContext.updateGpuContext(t);return!!(r.isBatchable||n!==r.isBatchable)}addRenderable(e,t){let n=this.renderer.graphicsContext.updateGpuContext(e.context);e._didGraphicsUpdate&&(e._didGraphicsUpdate=!1,this._rebuild(e)),n.isBatchable?this._addToBatcher(e):(this.renderer.renderPipes.batch.break(t),t.add(e))}updateRenderable(e){let t=this._graphicsBatchesHash[e.uid];if(t)for(let e=0;e<t.length;e++){let n=t[e];n.batcher.updateElement(n)}}destroyRenderable(e){this._graphicsBatchesHash[e.uid]&&this._removeBatchForRenderable(e.uid),e.off(`destroyed`,this._destroyRenderableBound)}execute(e){if(!e.isRenderable)return;let t=this.renderer,n=e.context;if(!t.graphicsContext.getGpuContext(n).batches.length)return;let r=n.customShader||this._adaptor.shader;this.state.blendMode=e.groupBlendMode;let i=r.resources.localUniforms.uniforms;i.uTransformMatrix=e.groupTransform,i.uRound=t._roundPixels|e._roundPixels,fe(e.groupColorAlpha,i.uColor,0),this._adaptor.execute(this,e)}_rebuild(e){let t=!!this._graphicsBatchesHash[e.uid],n=this.renderer.graphicsContext.updateGpuContext(e.context);t&&this._removeBatchForRenderable(e.uid),n.isBatchable&&this._initBatchesForRenderable(e),e.batched=n.isBatchable}_addToBatcher(e){let t=this.renderer.renderPipes.batch,n=this._getBatchesForRenderable(e);for(let e=0;e<n.length;e++){let r=n[e];t.addToBatch(r)}}_getBatchesForRenderable(e){return this._graphicsBatchesHash[e.uid]||this._initBatchesForRenderable(e)}_initBatchesForRenderable(e){let t=e.context,n=this.renderer.graphicsContext.getGpuContext(t),r=this.renderer._roundPixels|e._roundPixels,i=n.batches.map(t=>{let n=B.get(tt);return t.copyTo(n),n.renderable=e,n.roundPixels=r,n});return this._graphicsBatchesHash[e.uid]===void 0&&e.on(`destroyed`,this._destroyRenderableBound),this._graphicsBatchesHash[e.uid]=i,i}_removeBatchForRenderable(e){this._graphicsBatchesHash[e].forEach(e=>{B.return(e)}),this._graphicsBatchesHash[e]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(let e in this._graphicsBatchesHash)this._removeBatchForRenderable(e);this._graphicsBatchesHash=null}};Dt.extension={type:[F.WebGLPipes,F.WebGPUPipes,F.CanvasPipes],name:`graphics`};var Ot=class{constructor(){this.batcher=null,this.batch=null,this.roundPixels=0,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get blendMode(){return this.mesh.groupBlendMode}reset(){this.mesh=null,this.texture=null,this.batcher=null,this.batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}packIndex(e,t,n){let r=this.geometry.indices;for(let i=0;i<r.length;i++)e[t++]=r[i]+n}packAttributes(e,t,n,r){let i=this.mesh,a=this.geometry,o=i.groupTransform,s=r<<16|this.roundPixels&65535,c=o.a,l=o.b,u=o.c,d=o.d,f=o.tx,p=o.ty,m=a.positions,h=a.getBuffer(`aUV`),g=h.data,_=g,v=this.texture.textureMatrix;v.isSimple||(_=this._transformedUvs,(this._textureMatrixUpdateId!==v._updateID||this._uvUpdateId!==h._updateID)&&((!_||_.length<g.length)&&(_=this._transformedUvs=new Float32Array(g.length)),this._textureMatrixUpdateId=v._updateID,this._uvUpdateId=h._updateID,v.multiplyUvs(g,_)));let y=i.groupColorAlpha;for(let r=0;r<m.length;r+=2){let i=m[r],a=m[r+1];e[n]=c*i+u*a+f,e[n+1]=l*i+d*a+p,e[n+2]=_[r],e[n+3]=_[r+1],t[n+4]=y,t[n+5]=s,n+=6}}get vertexSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}},kt=class{constructor(e,t){this.localUniforms=new H({uTransformMatrix:{value:new A,type:`mat3x3<f32>`},uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uRound:{value:0,type:`f32`}}),this.localUniformsBindGroup=new m({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){let t=this._getMeshData(e),n=t.batched,r=e.batched;if(t.batched=r,n!==r)return!0;if(r){let n=e._geometry;if(n.indices.length!==t.indexSize||n.positions.length!==t.vertexSize)return t.indexSize=n.indices.length,t.vertexSize=n.positions.length,!0;let r=this._getBatchableMesh(e),i=e.texture;if(r.texture._source!==i._source&&r.texture._source!==i._source)return!r.batcher.checkAndUpdateTexture(r,i)}return!1}addRenderable(e,t){let n=this.renderer.renderPipes.batch,{batched:r}=this._getMeshData(e);if(r){let t=this._getBatchableMesh(e);t.texture=e._texture,t.geometry=e._geometry,n.addToBatch(t)}else n.break(t),t.add(e)}updateRenderable(e){if(e.batched){let t=this._gpuBatchableMeshHash[e.uid];t.texture=e._texture,t.geometry=e._geometry,t.batcher.updateElement(t)}}destroyRenderable(e){this._meshDataHash[e.uid]=null;let t=this._gpuBatchableMeshHash[e.uid];t&&(B.return(t),this._gpuBatchableMeshHash[e.uid]=null),e.off(`destroyed`,this._destroyRenderableBound)}execute(e){if(!e.isRenderable)return;e.state.blendMode=g(e.groupBlendMode,e.texture._source);let t=this.localUniforms;t.uniforms.uTransformMatrix=e.groupTransform,t.uniforms.uRound=this.renderer._roundPixels|e._roundPixels,t.update(),fe(e.groupColorAlpha,t.uniforms.uColor,0),this._adaptor.execute(this,e)}_getMeshData(e){return this._meshDataHash[e.uid]||this._initMeshData(e)}_initMeshData(e){return this._meshDataHash[e.uid]={batched:e.batched,indexSize:e._geometry.indices?.length,vertexSize:e._geometry.positions?.length},e.on(`destroyed`,this._destroyRenderableBound),this._meshDataHash[e.uid]}_getBatchableMesh(e){return this._gpuBatchableMeshHash[e.uid]||this._initBatchableMesh(e)}_initBatchableMesh(e){let t=B.get(Ot);return t.mesh=e,t.texture=e._texture,t.roundPixels=this.renderer._roundPixels|e._roundPixels,this._gpuBatchableMeshHash[e.uid]=t,t.mesh=e,t}destroy(){for(let e in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[e]&&B.return(this._gpuBatchableMeshHash[e]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}};kt.extension={type:[F.WebGLPipes,F.WebGPUPipes,F.CanvasPipes],name:`mesh`};var At=class{constructor(e){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e,this._renderer.runners.resolutionChange.add(this)}resolutionChange(){for(let e in this._gpuText){let t=this._gpuText[e].batchableSprite.renderable;t._autoResolution&&(t._resolution=this._renderer.resolution,t.onViewUpdate())}}validateRenderable(e){let t=this._getGpuText(e),n=e._getKey();if(t.currentKey!==n){let{width:n,height:r}=this._renderer.canvasText.getTextureSize(e.text,e.resolution,e._style);return!(this._renderer.canvasText.getReferenceCount(t.currentKey)===1&&n===t.texture._source.width&&r===t.texture._source.height)}return!1}addRenderable(e,t){let n=this._getGpuText(e).batchableSprite;e._didTextUpdate&&this._updateText(e),this._renderer.renderPipes.batch.addToBatch(n)}updateRenderable(e){let t=this._getGpuText(e).batchableSprite;e._didTextUpdate&&this._updateText(e),t.batcher.updateElement(t)}destroyRenderable(e){e.off(`destroyed`,this._destroyRenderableBound),this._destroyRenderableById(e.uid)}_destroyRenderableById(e){let t=this._gpuText[e];this._renderer.canvasText.decreaseReferenceCount(t.currentKey),B.return(t.batchableSprite),this._gpuText[e]=null}_updateText(e){let t=e._getKey(),n=this._getGpuText(e),r=n.batchableSprite;n.currentKey!==t&&this._updateGpuText(e),e._didTextUpdate=!1;let i=e._style.padding;u(r.bounds,e._anchor,r.texture,i)}_updateGpuText(e){let t=this._getGpuText(e),n=t.batchableSprite;t.texture&&this._renderer.canvasText.decreaseReferenceCount(t.currentKey),t.texture=n.texture=this._renderer.canvasText.getManagedTexture(e),t.currentKey=e._getKey(),n.texture=t.texture}_getGpuText(e){return this._gpuText[e.uid]||this.initGpuText(e)}initGpuText(e){let t={texture:null,currentKey:`--`,batchableSprite:B.get(ue)};return t.batchableSprite.renderable=e,t.batchableSprite.bounds={minX:0,maxX:1,minY:0,maxY:0},t.batchableSprite.roundPixels=this._renderer._roundPixels|e._roundPixels,this._gpuText[e.uid]=t,e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,this._updateText(e),e.on(`destroyed`,this._destroyRenderableBound),t}destroy(){for(let e in this._gpuText)this._destroyRenderableById(e);this._gpuText=null,this._renderer=null}};At.extension={type:[F.WebGLPipes,F.WebGPUPipes,F.CanvasPipes],name:`text`};function jt(e,t,n){for(let r=0,i=4*n*t;r<t;++r,i+=4)if(e[i+3]!==0)return!1;return!0}function Mt(e,t,n,r,i){let a=4*t;for(let t=r,o=r*a+4*n;t<=i;++t,o+=a)if(e[o+3]!==0)return!1;return!0}function Nt(e,t=1){let{width:n,height:r}=e,i=e.getContext(`2d`,{willReadFrequently:!0});if(i===null)throw TypeError(`Failed to get canvas 2D context`);let a=i.getImageData(0,0,n,r).data,o=0,s=0,c=n-1,l=r-1;for(;s<r&&jt(a,n,s);)++s;if(s===r)return N.EMPTY;for(;jt(a,n,l);)--l;for(;Mt(a,n,o,s,l);)++o;for(;Mt(a,n,c,s,l);)--c;return++c,++l,new N(o/t,s/t,(c-o)/t,(l-s)/t)}var Pt=class e{constructor(e,t,n,r){this.uid=ie(`fillGradient`),this.type=`linear`,this.gradientStops=[],this._styleKey=null,this.x0=e,this.y0=t,this.x1=n,this.y1=r}addColorStop(e,t){return this.gradientStops.push({offset:e,color:V.shared.setValue(t).toHexa()}),this._styleKey=null,this}buildLinearGradient(){let t=e.defaultTextureSize,{gradientStops:n}=this,r=x.get().createCanvas();r.width=t,r.height=t;let i=r.getContext(`2d`),a=i.createLinearGradient(0,0,e.defaultTextureSize,1);for(let e=0;e<n.length;e++){let t=n[e];a.addColorStop(t.offset,t.color)}i.fillStyle=a,i.fillRect(0,0,t,t),this.texture=new p({source:new He({resource:r,addressModeU:`clamp-to-edge`,addressModeV:`repeat`})});let{x0:o,y0:s,x1:c,y1:l}=this,u=new A,d=c-o,f=l-s,m=Math.sqrt(d*d+f*f),h=Math.atan2(f,d);u.translate(-o,-s),u.scale(1/t,1/t),u.rotate(-h),u.scale(256/m,1),this.transform=u,this._styleKey=null}get styleKey(){if(this._styleKey)return this._styleKey;let e=this.gradientStops.map(e=>`${e.offset}-${e.color}`).join(`-`),t=this.texture.uid,n=this.transform.toArray().join(`-`);return`fill-gradient-${this.uid}-${e}-${t}-${n}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Pt.defaultTextureSize=256;var Ft=Pt,It={repeat:{addressModeU:`repeat`,addressModeV:`repeat`},"repeat-x":{addressModeU:`repeat`,addressModeV:`clamp-to-edge`},"repeat-y":{addressModeU:`clamp-to-edge`,addressModeV:`repeat`},"no-repeat":{addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`}},Lt=class{constructor(e,t){this.uid=ie(`fillPattern`),this.transform=new A,this._styleKey=null,this.texture=e,this.transform.scale(1/e.frame.width,1/e.frame.height),t&&(e.source.style.addressModeU=It[t].addressModeU,e.source.style.addressModeV=It[t].addressModeV)}setTransform(e){let t=this.texture;this.transform.copyFrom(e),this.transform.invert(),this.transform.scale(1/t.frame.width,1/t.frame.height),this._styleKey=null}get styleKey(){return this._styleKey||=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join(`-`)}`,this._styleKey}},Rt=e(t(((e,t)=>{t.exports=i;var n={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},r=/([astvzqmhlc])([^astvzqmhlc]*)/gi;function i(e){var t=[];return e.replace(r,function(e,r,i){var a=r.toLowerCase();for(i=o(i),a==`m`&&i.length>2&&(t.push([r].concat(i.splice(0,2))),a=`l`,r=r==`m`?`l`:`L`);;){if(i.length==n[a])return i.unshift(r),t.push(i);if(i.length<n[a])throw Error(`malformed path data`);t.push([r].concat(i.splice(0,n[a])))}}),t}var a=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;function o(e){var t=e.match(a);return t?t.map(Number):[]}}))(),1);function zt(e,t){let n=(0,Rt.default)(e),r=[],i=null,a=0,o=0;for(let e=0;e<n.length;e++){let s=n[e],c=s[0],l=s;switch(c){case`M`:a=l[1],o=l[2],t.moveTo(a,o);break;case`m`:a+=l[1],o+=l[2],t.moveTo(a,o);break;case`H`:a=l[1],t.lineTo(a,o);break;case`h`:a+=l[1],t.lineTo(a,o);break;case`V`:o=l[1],t.lineTo(a,o);break;case`v`:o+=l[1],t.lineTo(a,o);break;case`L`:a=l[1],o=l[2],t.lineTo(a,o);break;case`l`:a+=l[1],o+=l[2],t.lineTo(a,o);break;case`C`:a=l[5],o=l[6],t.bezierCurveTo(l[1],l[2],l[3],l[4],a,o);break;case`c`:t.bezierCurveTo(a+l[1],o+l[2],a+l[3],o+l[4],a+l[5],o+l[6]),a+=l[5],o+=l[6];break;case`S`:a=l[3],o=l[4],t.bezierCurveToShort(l[1],l[2],a,o);break;case`s`:t.bezierCurveToShort(a+l[1],o+l[2],a+l[3],o+l[4]),a+=l[3],o+=l[4];break;case`Q`:a=l[3],o=l[4],t.quadraticCurveTo(l[1],l[2],a,o);break;case`q`:t.quadraticCurveTo(a+l[1],o+l[2],a+l[3],o+l[4]),a+=l[3],o+=l[4];break;case`T`:a=l[1],o=l[2],t.quadraticCurveToShort(a,o);break;case`t`:a+=l[1],o+=l[2],t.quadraticCurveToShort(a,o);break;case`A`:a=l[6],o=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],a,o);break;case`a`:a+=l[6],o+=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],a,o);break;case`Z`:case`z`:t.closePath(),r.length>0&&(i=r.pop(),i?(a=i.startX,o=i.startY):(a=0,o=0)),i=null;break;default:w(`Unknown SVG path command: ${c}`)}c!==`Z`&&c!==`z`&&i===null&&(i={startX:a,startY:o},r.push(i))}return t}var Bt=class e{constructor(e=0,t=0,n=0){this.type=`circle`,this.x=e,this.y=t,this.radius=n}clone(){return new e(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;let n=this.radius*this.radius,r=this.x-e,i=this.y-t;return r*=r,i*=i,r+i<=n}strokeContains(e,t,n){if(this.radius===0)return!1;let r=this.x-e,i=this.y-t,a=this.radius,o=n/2,s=Math.sqrt(r*r+i*i);return s<a+o&&s>a-o}getBounds(e){return e||=new N,e.x=this.x-this.radius,e.y=this.y-this.radius,e.width=this.radius*2,e.height=this.radius*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}},Vt=class e{constructor(e=0,t=0,n=0,r=0){this.type=`ellipse`,this.x=e,this.y=t,this.halfWidth=n,this.halfHeight=r}clone(){return new e(this.x,this.y,this.halfWidth,this.halfHeight)}contains(e,t){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let n=(e-this.x)/this.halfWidth,r=(t-this.y)/this.halfHeight;return n*=n,r*=r,n+r<=1}strokeContains(e,t,n){let{halfWidth:r,halfHeight:i}=this;if(r<=0||i<=0)return!1;let a=n/2,o=r-a,s=i-a,c=r+a,l=i+a,u=e-this.x,d=t-this.y,f=u*u/(o*o)+d*d/(s*s),p=u*u/(c*c)+d*d/(l*l);return f>1&&p<=1}getBounds(e){return e||=new N,e.x=this.x-this.halfWidth,e.y=this.y-this.halfHeight,e.width=this.halfWidth*2,e.height=this.halfHeight*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.halfWidth=e.halfWidth,this.halfHeight=e.halfHeight,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}};function Ht(e,t,n,r,i,a){let o=e-n,s=t-r,c=i-n,l=a-r,u=o*c+s*l,d=c*c+l*l,f=-1;d!==0&&(f=u/d);let p,m;f<0?(p=n,m=r):f>1?(p=i,m=a):(p=n+f*c,m=r+f*l);let h=e-p,g=t-m;return h*h+g*g}var Ut=class e{constructor(...e){this.type=`polygon`;let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!=`number`){let e=[];for(let n=0,r=t.length;n<r;n++)e.push(t[n].x,t[n].y);t=e}this.points=t,this.closePath=!0}clone(){let t=new e(this.points.slice());return t.closePath=this.closePath,t}contains(e,t){let n=!1,r=this.points.length/2;for(let i=0,a=r-1;i<r;a=i++){let r=this.points[i*2],o=this.points[i*2+1],s=this.points[a*2],c=this.points[a*2+1];o>t!=c>t&&e<(s-r)*((t-o)/(c-o))+r&&(n=!n)}return n}strokeContains(e,t,n){let r=n/2,i=r*r,{points:a}=this,o=a.length-(this.closePath?0:2);for(let n=0;n<o;n+=2){let r=a[n],o=a[n+1],s=a[(n+2)%a.length],c=a[(n+3)%a.length];if(Ht(e,t,r,o,s,c)<=i)return!0}return!1}getBounds(e){e||=new N;let t=this.points,n=1/0,r=-1/0,i=1/0,a=-1/0;for(let e=0,o=t.length;e<o;e+=2){let o=t[e],s=t[e+1];n=o<n?o:n,r=o>r?o:r,i=s<i?s:i,a=s>a?s:a}return e.x=n,e.width=r-n,e.y=i,e.height=a-i,e}copyFrom(e){return this.points=e.points.slice(),this.closePath=e.closePath,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((e,t)=>`${e}, ${t}`,``)}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}},Wt=(e,t,n,r,i,a)=>{let o=e-n,s=t-r,c=Math.sqrt(o*o+s*s);return c>=i-a&&c<=i+a},Gt=class e{constructor(e=0,t=0,n=0,r=0,i=20){this.type=`roundedRectangle`,this.x=e,this.y=t,this.width=n,this.height=r,this.radius=i}getBounds(e){return e||=new N,e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new e(this.x,this.y,this.width,this.height,this.radius)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){let n=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+n&&t<=this.y+this.height-n||e>=this.x+n&&e<=this.x+this.width-n)return!0;let r=e-(this.x+n),i=t-(this.y+n),a=n*n;if(r*r+i*i<=a||(r=e-(this.x+this.width-n),r*r+i*i<=a)||(i=t-(this.y+this.height-n),r*r+i*i<=a)||(r=e-(this.x+n),r*r+i*i<=a))return!0}return!1}strokeContains(e,t,n){let{x:r,y:i,width:a,height:o,radius:s}=this,c=n/2,l=r+s,u=i+s,d=a-s*2,f=o-s*2,p=r+a,m=i+o;return(e>=r-c&&e<=r+c||e>=p-c&&e<=p+c)&&t>=u&&t<=u+f||(t>=i-c&&t<=i+c||t>=m-c&&t<=m+c)&&e>=l&&e<=l+d?!0:e<l&&t<u&&Wt(e,t,l,u,s,c)||e>p-s&&t<u&&Wt(e,t,p-s,u,s,c)||e>p-s&&t>m-s&&Wt(e,t,p-s,m-s,s,c)||e<l&&t>m-s&&Wt(e,t,l,m-s,s,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}},Kt=8,qt=1.1920929e-7,Jt=1;function Yt(e,t,n,r,i,a,o,s,c,l){let u=(Jt-Math.min(.99,Math.max(0,l??Et.defaultOptions.bezierSmoothness)))/1;return u*=u,Xt(t,n,r,i,a,o,s,c,e,u),e}function Xt(e,t,n,r,i,a,o,s,c,l){Zt(e,t,n,r,i,a,o,s,c,l,0),c.push(o,s)}function Zt(e,t,n,r,i,a,o,s,c,l,u){if(u>Kt)return;let d=(e+n)/2,f=(t+r)/2,p=(n+i)/2,m=(r+a)/2,h=(i+o)/2,g=(a+s)/2,_=(d+p)/2,v=(f+m)/2,y=(p+h)/2,b=(m+g)/2,x=(_+y)/2,S=(v+b)/2;if(u>0){let u=o-e,d=s-t,f=Math.abs((n-o)*d-(r-s)*u),p=Math.abs((i-o)*d-(a-s)*u);if(f>qt&&p>qt){if((f+p)*(f+p)<=l*(u*u+d*d)){c.push(x,S);return}}else if(f>qt){if(f*f<=l*(u*u+d*d)){c.push(x,S);return}}else if(p>qt){if(p*p<=l*(u*u+d*d)){c.push(x,S);return}}else if(u=x-(e+o)/2,d=S-(t+s)/2,u*u+d*d<=l){c.push(x,S);return}}Zt(e,t,d,f,_,v,x,S,c,l,u+1),Zt(x,S,y,b,h,g,o,s,c,l,u+1)}var Qt=8,$t=1.1920929e-7,en=1;function tn(e,t,n,r,i,a,o,s){let c=(en-Math.min(.99,Math.max(0,s??Et.defaultOptions.bezierSmoothness)))/1;return c*=c,nn(t,n,r,i,a,o,e,c),e}function nn(e,t,n,r,i,a,o,s){rn(o,e,t,n,r,i,a,s,0),o.push(i,a)}function rn(e,t,n,r,i,a,o,s,c){if(c>Qt)return;let l=(t+r)/2,u=(n+i)/2,d=(r+a)/2,f=(i+o)/2,p=(l+d)/2,m=(u+f)/2,h=a-t,g=o-n,_=Math.abs((r-a)*g-(i-o)*h);if(_>$t){if(_*_<=s*(h*h+g*g)){e.push(p,m);return}}else if(h=p-(t+a)/2,g=m-(n+o)/2,h*h+g*g<=s){e.push(p,m);return}rn(e,t,n,l,u,p,m,s,c+1),rn(e,p,m,d,f,a,o,s,c+1)}function an(e,t,n,r,i,a,o,s){let c=Math.abs(i-a);(!o&&i>a||o&&a>i)&&(c=2*Math.PI-c),s||=Math.max(6,Math.floor(6*r**(1/3)*(c/Math.PI))),s=Math.max(s,3);let l=c/s,u=i;l*=o?-1:1;for(let i=0;i<s+1;i++){let i=Math.cos(u),a=Math.sin(u),o=t+i*r,s=n+a*r;e.push(o,s),u+=l}}function on(e,t,n,r,i,a){let o=e[e.length-2],s=e[e.length-1]-n,c=o-t,l=i-n,u=r-t,d=Math.abs(s*u-c*l);if(d<1e-8||a===0){(e[e.length-2]!==t||e[e.length-1]!==n)&&e.push(t,n);return}let f=s*s+c*c,p=l*l+u*u,m=s*l+c*u,h=a*Math.sqrt(f)/d,g=a*Math.sqrt(p)/d,_=h*m/f,v=g*m/p,y=h*u+g*c,b=h*l+g*s,x=c*(g+_),S=s*(g+_),C=u*(h+v),w=l*(h+v),T=Math.atan2(S-b,x-y),E=Math.atan2(w-b,C-y);an(e,y+t,b+n,a,T,E,c*l>u*s)}var sn=Math.PI*2,cn={centerX:0,centerY:0,ang1:0,ang2:0},ln=({x:e,y:t},n,r,i,a,o,s,c)=>{e*=n,t*=r;let l=i*e-a*t,u=a*e+i*t;return c.x=l+o,c.y=u+s,c};function un(e,t){let n=t===-1.5707963267948966?-.551915024494:4/3*Math.tan(t/4),r=t===1.5707963267948966?.551915024494:n,i=Math.cos(e),a=Math.sin(e),o=Math.cos(e+t),s=Math.sin(e+t);return[{x:i-a*r,y:a+i*r},{x:o+s*r,y:s-o*r},{x:o,y:s}]}var dn=(e,t,n,r)=>{let i=e*r-t*n<0?-1:1,a=e*n+t*r;return a>1&&(a=1),a<-1&&(a=-1),i*Math.acos(a)},fn=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=i**2,m=a**2,h=u**2,g=d**2,_=p*m-p*g-m*h;_<0&&(_=0),_/=p*g+m*h,_=Math.sqrt(_)*(o===s?-1:1);let v=_*i/a*d,y=_*-a/i*u,b=l*v-c*y+(e+n)/2,x=c*v+l*y+(t+r)/2,S=(u-v)/i,C=(d-y)/a,w=(-u-v)/i,T=(-d-y)/a,E=dn(1,0,S,C),D=dn(S,C,w,T);s===0&&D>0&&(D-=sn),s===1&&D<0&&(D+=sn),f.centerX=b,f.centerY=x,f.ang1=E,f.ang2=D};function pn(e,t,n,r,i,a,o,s=0,c=0,l=0){if(a===0||o===0)return;let u=Math.sin(s*sn/360),d=Math.cos(s*sn/360),f=d*(t-r)/2+u*(n-i)/2,p=-u*(t-r)/2+d*(n-i)/2;if(f===0&&p===0)return;a=Math.abs(a),o=Math.abs(o);let m=f**2/a**2+p**2/o**2;m>1&&(a*=Math.sqrt(m),o*=Math.sqrt(m)),fn(t,n,r,i,a,o,c,l,u,d,f,p,cn);let{ang1:h,ang2:g}=cn,{centerX:_,centerY:v}=cn,y=Math.abs(g)/(sn/4);Math.abs(1-y)<1e-7&&(y=1);let b=Math.max(Math.ceil(y),1);g/=b;let x=e[e.length-2],S=e[e.length-1],C={x:0,y:0};for(let t=0;t<b;t++){let t=un(h,g),{x:n,y:r}=ln(t[0],a,o,d,u,_,v,C),{x:i,y:s}=ln(t[1],a,o,d,u,_,v,C),{x:c,y:l}=ln(t[2],a,o,d,u,_,v,C);Yt(e,x,S,n,r,i,s,c,l),x=c,S=l,h+=g}}function mn(e,t,n){let r=(e,t)=>{let n=t.x-e.x,r=t.y-e.y,i=Math.sqrt(n*n+r*r);return{len:i,nx:n/i,ny:r/i}},i=(t,n)=>{t===0?e.moveTo(n.x,n.y):e.lineTo(n.x,n.y)},a=t[t.length-1];for(let o=0;o<t.length;o++){let s=t[o%t.length],c=s.radius??n;if(c<=0){i(o,s),a=s;continue}let l=t[(o+1)%t.length],u=r(s,a),d=r(s,l);if(u.len<1e-4||d.len<1e-4){i(o,s),a=s;continue}let f=Math.asin(u.nx*d.ny-u.ny*d.nx),p=1,m=!1;u.nx*d.nx-u.ny*-d.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,p=-1,m=!0):f>0&&(p=-1,m=!0);let h=f/2,g,_=Math.abs(Math.cos(h)*c/Math.sin(h));_>Math.min(u.len/2,d.len/2)?(_=Math.min(u.len/2,d.len/2),g=Math.abs(_*Math.sin(h)/Math.cos(h))):g=c;let v=s.x+d.nx*_+-d.ny*g*p,y=s.y+d.ny*_+d.nx*g*p,b=Math.atan2(u.ny,u.nx)+Math.PI/2*p,x=Math.atan2(d.ny,d.nx)-Math.PI/2*p;o===0&&e.moveTo(v+Math.cos(b)*g,y+Math.sin(b)*g),e.arc(v,y,g,b,x,m),a=s}}function hn(e,t,n,r){let i=(e,t)=>Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2),a=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),o=t.length;for(let s=0;s<o;s++){let c=t[(s+1)%o],l=c.radius??n;if(l<=0){s===0?e.moveTo(c.x,c.y):e.lineTo(c.x,c.y);continue}let u=t[s],d=t[(s+2)%o],f=i(u,c),p;p=f<1e-4?c:a(c,u,Math.min(f/2,l)/f);let m=i(d,c),h;h=m<1e-4?c:a(c,d,Math.min(m/2,l)/m),s===0?e.moveTo(p.x,p.y):e.lineTo(p.x,p.y),e.quadraticCurveTo(c.x,c.y,h.x,h.y,r)}}var gn=new N,_n=class{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new n,this._graphicsPath2D=e}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();let n=this._currentPoly.points,r=n[n.length-2],i=n[n.length-1];return(r!==e||i!==t)&&n.push(e,t),this}arc(e,t,n,r,i,a){this._ensurePoly(!1);let o=this._currentPoly.points;return an(o,e,t,n,r,i,a),this}arcTo(e,t,n,r,i){this._ensurePoly();let a=this._currentPoly.points;return on(a,e,t,n,r,i),this}arcToSvg(e,t,n,r,i,a,o){let s=this._currentPoly.points;return pn(s,this._currentPoly.lastX,this._currentPoly.lastY,a,o,e,t,n,r,i),this}bezierCurveTo(e,t,n,r,i,a,o){this._ensurePoly();let s=this._currentPoly;return Yt(this._currentPoly.points,s.lastX,s.lastY,e,t,n,r,i,a,o),this}quadraticCurveTo(e,t,n,r,i){this._ensurePoly();let a=this._currentPoly;return tn(this._currentPoly.points,a.lastX,a.lastY,e,t,n,r,i),this}closePath(){return this.endPoly(!0),this}addPath(e,t){this.endPoly(),t&&!t.isIdentity()&&(e=e.clone(!0),e.transform(t));for(let t=0;t<e.instructions.length;t++){let n=e.instructions[t];this[n.action](...n.data)}return this}finish(e=!1){this.endPoly(e)}rect(e,t,n,r,i){return this.drawShape(new N(e,t,n,r),i),this}circle(e,t,n,r){return this.drawShape(new Bt(e,t,n),r),this}poly(e,t,n){let r=new Ut(e);return r.closePath=t,this.drawShape(r,n),this}regularPoly(e,t,n,r,i=0,a){r=Math.max(r|0,3);let o=-1*Math.PI/2+i,s=Math.PI*2/r,c=[];for(let i=0;i<r;i++){let r=i*s+o;c.push(e+n*Math.cos(r),t+n*Math.sin(r))}return this.poly(c,!0,a),this}roundPoly(e,t,n,r,i,a=0,o){if(r=Math.max(r|0,3),i<=0)return this.regularPoly(e,t,n,r,a);let s=n*Math.sin(Math.PI/r)-.001;i=Math.min(i,s);let c=-1*Math.PI/2+a,l=Math.PI*2/r,u=(r-2)*Math.PI/r/2;for(let a=0;a<r;a++){let r=a*l+c,s=e+n*Math.cos(r),d=t+n*Math.sin(r),f=r+Math.PI+u,p=r-Math.PI-u,m=s+i*Math.cos(f),h=d+i*Math.sin(f),g=s+i*Math.cos(p),_=d+i*Math.sin(p);a===0?this.moveTo(m,h):this.lineTo(m,h),this.quadraticCurveTo(s,d,g,_,o)}return this.closePath()}roundShape(e,t,n=!1,r){return e.length<3?this:(n?hn(this,e,t,r):mn(this,e,t),this.closePath())}filletRect(e,t,n,r,i){if(i===0)return this.rect(e,t,n,r);let a=Math.min(n,r)/2,o=Math.min(a,Math.max(-a,i)),s=e+n,c=t+r,l=o<0?-o:0,u=Math.abs(o);return this.moveTo(e,t+u).arcTo(e+l,t+l,e+u,t,u).lineTo(s-u,t).arcTo(s-l,t+l,s,t+u,u).lineTo(s,c-u).arcTo(s-l,c-l,e+n-u,c,u).lineTo(e+u,c).arcTo(e+l,c-l,e,c-u,u).closePath()}chamferRect(e,t,n,r,i,a){if(i<=0)return this.rect(e,t,n,r);let o=Math.min(i,Math.min(n,r)/2),s=e+n,c=t+r,l=[e+o,t,s-o,t,s,t+o,s,c-o,s-o,c,e+o,c,e,c-o,e,t+o];for(let e=l.length-1;e>=2;e-=2)l[e]===l[e-2]&&l[e-1]===l[e-3]&&l.splice(e-1,2);return this.poly(l,!0,a)}ellipse(e,t,n,r,i){return this.drawShape(new Vt(e,t,n,r),i),this}roundRect(e,t,n,r,i,a){return this.drawShape(new Gt(e,t,n,r,i),a),this}drawShape(e,t){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:t}),this}startPoly(e,t){let n=this._currentPoly;return n&&this.endPoly(),n=new Ut,n.points.push(e,t),this._currentPoly=n,this}endPoly(e=!1){let t=this._currentPoly;return t&&t.points.length>2&&(t.closePath=e,this.shapePrimitives.push({shape:t})),this._currentPoly=null,this}_ensurePoly(e=!0){if(!this._currentPoly&&(this._currentPoly=new Ut,e)){let e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let t=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){let r=e.transform,i=t;t=r.a*t+r.c*n+r.tx,n=r.b*i+r.d*n+r.ty}this._currentPoly.points.push(t,n)}else this._currentPoly.points.push(0,0)}}buildPath(){let e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let t=0;t<e.instructions.length;t++){let n=e.instructions[t];this[n.action](...n.data)}this.finish()}get bounds(){let e=this._bounds;e.clear();let t=this.shapePrimitives;for(let n=0;n<t.length;n++){let r=t[n],i=r.shape.getBounds(gn);r.transform?e.addRect(i,r.transform):e.addRect(i)}return e}},vn=class e{constructor(e){this.instructions=[],this.uid=ie(`graphicsPath`),this._dirty=!0,typeof e==`string`?zt(e,this):this.instructions=e?.slice()??[]}get shapePath(){return this._shapePath||=new _n(this),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(e,t){return e=e.clone(),this.instructions.push({action:`addPath`,data:[e,t]}),this._dirty=!0,this}arc(...e){return this.instructions.push({action:`arc`,data:e}),this._dirty=!0,this}arcTo(...e){return this.instructions.push({action:`arcTo`,data:e}),this._dirty=!0,this}arcToSvg(...e){return this.instructions.push({action:`arcToSvg`,data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:`bezierCurveTo`,data:e}),this._dirty=!0,this}bezierCurveToShort(e,t,n,r,i){let a=this.instructions[this.instructions.length-1],o=this.getLastPoint(R.shared),s=0,c=0;if(!a||a.action!==`bezierCurveTo`)s=o.x,c=o.y;else{s=a.data[2],c=a.data[3];let e=o.x,t=o.y;s=e+(e-s),c=t+(t-c)}return this.instructions.push({action:`bezierCurveTo`,data:[s,c,e,t,n,r,i]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:`closePath`,data:[]}),this._dirty=!0,this}ellipse(...e){return this.instructions.push({action:`ellipse`,data:e}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:`lineTo`,data:e}),this._dirty=!0,this}moveTo(...e){return this.instructions.push({action:`moveTo`,data:e}),this}quadraticCurveTo(...e){return this.instructions.push({action:`quadraticCurveTo`,data:e}),this._dirty=!0,this}quadraticCurveToShort(e,t,n){let r=this.instructions[this.instructions.length-1],i=this.getLastPoint(R.shared),a=0,o=0;if(!r||r.action!==`quadraticCurveTo`)a=i.x,o=i.y;else{a=r.data[0],o=r.data[1];let e=i.x,t=i.y;a=e+(e-a),o=t+(t-o)}return this.instructions.push({action:`quadraticCurveTo`,data:[a,o,e,t,n]}),this._dirty=!0,this}rect(e,t,n,r,i){return this.instructions.push({action:`rect`,data:[e,t,n,r,i]}),this._dirty=!0,this}circle(e,t,n,r){return this.instructions.push({action:`circle`,data:[e,t,n,r]}),this._dirty=!0,this}roundRect(...e){return this.instructions.push({action:`roundRect`,data:e}),this._dirty=!0,this}poly(...e){return this.instructions.push({action:`poly`,data:e}),this._dirty=!0,this}regularPoly(...e){return this.instructions.push({action:`regularPoly`,data:e}),this._dirty=!0,this}roundPoly(...e){return this.instructions.push({action:`roundPoly`,data:e}),this._dirty=!0,this}roundShape(...e){return this.instructions.push({action:`roundShape`,data:e}),this._dirty=!0,this}filletRect(...e){return this.instructions.push({action:`filletRect`,data:e}),this._dirty=!0,this}chamferRect(...e){return this.instructions.push({action:`chamferRect`,data:e}),this._dirty=!0,this}star(e,t,n,r,i,a,o){i||=r/2;let s=-1*Math.PI/2+a,c=n*2,l=Math.PI*2/c,u=[];for(let n=0;n<c;n++){let a=n%2?i:r,o=n*l+s;u.push(e+a*Math.cos(o),t+a*Math.sin(o))}return this.poly(u,!0,o),this}clone(t=!1){let n=new e;if(!t)n.instructions=this.instructions.slice();else for(let e=0;e<this.instructions.length;e++){let t=this.instructions[e];n.instructions.push({action:t.action,data:t.data.slice()})}return n}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(e){if(e.isIdentity())return this;let t=e.a,n=e.b,r=e.c,i=e.d,a=e.tx,o=e.ty,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0;for(let h=0;h<this.instructions.length;h++){let g=this.instructions[h],_=g.data;switch(g.action){case`moveTo`:case`lineTo`:s=_[0],c=_[1],_[0]=t*s+r*c+a,_[1]=n*s+i*c+o;break;case`bezierCurveTo`:l=_[0],u=_[1],d=_[2],f=_[3],s=_[4],c=_[5],_[0]=t*l+r*u+a,_[1]=n*l+i*u+o,_[2]=t*d+r*f+a,_[3]=n*d+i*f+o,_[4]=t*s+r*c+a,_[5]=n*s+i*c+o;break;case`quadraticCurveTo`:l=_[0],u=_[1],s=_[2],c=_[3],_[0]=t*l+r*u+a,_[1]=n*l+i*u+o,_[2]=t*s+r*c+a,_[3]=n*s+i*c+o;break;case`arcToSvg`:s=_[5],c=_[6],p=_[0],m=_[1],_[0]=t*p+r*m,_[1]=n*p+i*m,_[5]=t*s+r*c+a,_[6]=n*s+i*c+o;break;case`circle`:_[4]=yn(_[3],e);break;case`rect`:_[4]=yn(_[4],e);break;case`ellipse`:_[8]=yn(_[8],e);break;case`roundRect`:_[5]=yn(_[5],e);break;case`addPath`:_[0].transform(e);break;case`poly`:_[2]=yn(_[2],e);break;default:w(`unknown transform action`,g.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(e){let t=this.instructions.length-1,n=this.instructions[t];if(!n)return e.x=0,e.y=0,e;for(;n.action===`closePath`;){if(t--,t<0)return e.x=0,e.y=0,e;n=this.instructions[t]}switch(n.action){case`moveTo`:case`lineTo`:e.x=n.data[0],e.y=n.data[1];break;case`quadraticCurveTo`:e.x=n.data[2],e.y=n.data[3];break;case`bezierCurveTo`:e.x=n.data[4],e.y=n.data[5];break;case`arc`:case`arcToSvg`:e.x=n.data[5],e.y=n.data[6];break;case`addPath`:n.data[0].getLastPoint(e);break}return e}};function yn(e,t){return e?e.prepend(t):t.clone()}function bn(e,t){if(typeof e==`string`){let t=document.createElement(`div`);t.innerHTML=e.trim(),e=t.querySelector(`svg`)}let n={context:t,path:new vn};return xn(e,n,null,null),t}function xn(e,t,n,r){let i=e.children,{fillStyle:a,strokeStyle:o}=Sn(e);a&&n?n={...n,...a}:a&&(n=a),o&&r?r={...r,...o}:o&&(r=o),t.context.fillStyle=n,t.context.strokeStyle=r;let s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C;switch(e.nodeName.toLowerCase()){case`path`:b=e.getAttribute(`d`),x=new vn(b),t.context.path(x),n&&t.context.fill(),r&&t.context.stroke();break;case`circle`:p=J(e,`cx`,0),m=J(e,`cy`,0),h=J(e,`r`,0),t.context.ellipse(p,m,h,h),n&&t.context.fill(),r&&t.context.stroke();break;case`rect`:s=J(e,`x`,0),c=J(e,`y`,0),S=J(e,`width`,0),C=J(e,`height`,0),g=J(e,`rx`,0),_=J(e,`ry`,0),g||_?t.context.roundRect(s,c,S,C,g||_):t.context.rect(s,c,S,C),n&&t.context.fill(),r&&t.context.stroke();break;case`ellipse`:p=J(e,`cx`,0),m=J(e,`cy`,0),g=J(e,`rx`,0),_=J(e,`ry`,0),t.context.beginPath(),t.context.ellipse(p,m,g,_),n&&t.context.fill(),r&&t.context.stroke();break;case`line`:l=J(e,`x1`,0),u=J(e,`y1`,0),d=J(e,`x2`,0),f=J(e,`y2`,0),t.context.beginPath(),t.context.moveTo(l,u),t.context.lineTo(d,f),r&&t.context.stroke();break;case`polygon`:y=e.getAttribute(`points`),v=y.match(/\d+/g).map(e=>parseInt(e,10)),t.context.poly(v,!0),n&&t.context.fill(),r&&t.context.stroke();break;case`polyline`:y=e.getAttribute(`points`),v=y.match(/\d+/g).map(e=>parseInt(e,10)),t.context.poly(v,!1),r&&t.context.stroke();break;case`g`:case`svg`:break;default:console.info(`[SVG parser] <${e.nodeName}> elements unsupported`);break}for(let e=0;e<i.length;e++)xn(i[e],t,n,r)}function J(e,t,n){let r=e.getAttribute(t);return r?Number(r):n}function Sn(e){let t=e.getAttribute(`style`),n={},r={},i=!1,a=!1;if(t){let e=t.split(`;`);for(let t=0;t<e.length;t++){let[o,s]=e[t].split(`:`);switch(o){case`stroke`:s!==`none`&&(n.color=V.shared.setValue(s).toNumber(),a=!0);break;case`stroke-width`:n.width=Number(s);break;case`fill`:s!==`none`&&(i=!0,r.color=V.shared.setValue(s).toNumber());break;case`fill-opacity`:r.alpha=Number(s);break;case`stroke-opacity`:n.alpha=Number(s);break;case`opacity`:r.alpha=Number(s),n.alpha=Number(s);break}}}else{let t=e.getAttribute(`stroke`);t&&t!==`none`&&(a=!0,n.color=V.shared.setValue(t).toNumber(),n.width=J(e,`stroke-width`,1));let o=e.getAttribute(`fill`);o&&o!==`none`&&(i=!0,r.color=V.shared.setValue(o).toNumber())}return{strokeStyle:a?n:null,fillStyle:i?r:null}}function Cn(e){return V.isColorLike(e)}function wn(e){return e instanceof Lt}function Tn(e){return e instanceof Ft}function En(e,t,n){let r=V.shared.setValue(t??0);return e.color=r.toNumber(),e.alpha=r.alpha===1?n.alpha:r.alpha,e.texture=p.WHITE,{...n,...e}}function Dn(e,t,n){return e.fill=t,e.color=16777215,e.texture=t.texture,e.matrix=t.transform,{...n,...e}}function On(e,t,n){return t.buildLinearGradient(),e.fill=t,e.color=16777215,e.texture=t.texture,e.matrix=t.transform,{...n,...e}}function kn(e,t){let n={...t,...e};if(n.texture){if(n.texture!==p.WHITE){let e=n.matrix?.invert()||new A;e.translate(n.texture.frame.x,n.texture.frame.y),e.scale(1/n.texture.source.width,1/n.texture.source.height),n.matrix=e}let e=n.texture.source.style;e.addressMode===`clamp-to-edge`&&(e.addressMode=`repeat`,e.update())}let r=V.shared.setValue(n.color);return n.alpha*=r.alpha,n.color=r.toNumber(),n.matrix=n.matrix?n.matrix.clone():null,n}function Y(e,t){if(e==null)return null;let n={},r=e;return Cn(e)?En(n,e,t):wn(e)?Dn(n,e,t):Tn(e)?On(n,e,t):r.fill&&wn(r.fill)?Dn(r,r.fill,t):r.fill&&Tn(r.fill)?On(r,r.fill,t):kn(r,t)}function An(e,t){let{width:n,alignment:r,miterLimit:i,cap:a,join:o,...s}=t,c=Y(e,s);return c?{width:n,alignment:r,miterLimit:i,cap:a,join:o,...c}:null}var jn=new R,Mn=new A,Nn=class e extends M{constructor(){super(...arguments),this.uid=ie(`graphicsContext`),this.dirty=!0,this.batchMode=`auto`,this.instructions=[],this._activePath=new vn,this._transform=new A,this._fillStyle={...e.defaultFillStyle},this._strokeStyle={...e.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new n,this._boundsDirty=!0}clone(){let t=new e;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=Y(t,e.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=An(t,e.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Y(t,e.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Y(t,e.defaultStrokeStyle),this}texture(e,t,n,r,i,a){return this.instructions.push({action:`texture`,data:{image:e,dx:n||0,dy:r||0,dw:i||e.frame.width,dh:a||e.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:t?V.shared.setValue(t).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new vn,this}fill(t,n){let r,i=this.instructions[this.instructions.length-1];return r=this._tick===0&&i&&i.action===`stroke`?i.data.path:this._activePath.clone(),r?(t!=null&&(n!==void 0&&typeof t==`number`&&(L(O,`GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead`),t={color:t,alpha:n}),this._fillStyle=Y(t,e.defaultFillStyle)),this.instructions.push({action:`fill`,data:{style:this.fillStyle,path:r}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){let{x:e,y:t}=this._activePath.getLastPoint(R.shared);this._activePath.clear(),this._activePath.moveTo(e,t)}stroke(t){let n,r=this.instructions[this.instructions.length-1];return n=this._tick===0&&r&&r.action===`fill`?r.data.path:this._activePath.clone(),n?(t!=null&&(this._strokeStyle=An(t,e.defaultStrokeStyle)),this.instructions.push({action:`stroke`,data:{style:this.strokeStyle,path:n}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let e=0;e<2;e++){let t=this.instructions[this.instructions.length-1-e],n=this._activePath.clone();if(t&&(t.action===`stroke`||t.action===`fill`))if(t.data.hole)t.data.hole.addPath(n);else{t.data.hole=n;break}}return this._initNextPathLocation(),this}arc(e,t,n,r,i,a){this._tick++;let o=this._transform;return this._activePath.arc(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,n,r,i,a),this}arcTo(e,t,n,r,i){this._tick++;let a=this._transform;return this._activePath.arcTo(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,a.a*n+a.c*r+a.tx,a.b*n+a.d*r+a.ty,i),this}arcToSvg(e,t,n,r,i,a,o){this._tick++;let s=this._transform;return this._activePath.arcToSvg(e,t,n,r,i,s.a*a+s.c*o+s.tx,s.b*a+s.d*o+s.ty),this}bezierCurveTo(e,t,n,r,i,a,o){this._tick++;let s=this._transform;return this._activePath.bezierCurveTo(s.a*e+s.c*t+s.tx,s.b*e+s.d*t+s.ty,s.a*n+s.c*r+s.tx,s.b*n+s.d*r+s.ty,s.a*i+s.c*a+s.tx,s.b*i+s.d*a+s.ty,o),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(e,t,n,r){return this._tick++,this._activePath.ellipse(e,t,n,r,this._transform.clone()),this}circle(e,t,n){return this._tick++,this._activePath.circle(e,t,n,this._transform.clone()),this}path(e){return this._tick++,this._activePath.addPath(e,this._transform.clone()),this}lineTo(e,t){this._tick++;let n=this._transform;return this._activePath.lineTo(n.a*e+n.c*t+n.tx,n.b*e+n.d*t+n.ty),this}moveTo(e,t){this._tick++;let n=this._transform,r=this._activePath.instructions,i=n.a*e+n.c*t+n.tx,a=n.b*e+n.d*t+n.ty;return r.length===1&&r[0].action===`moveTo`?(r[0].data[0]=i,r[0].data[1]=a,this):(this._activePath.moveTo(i,a),this)}quadraticCurveTo(e,t,n,r,i){this._tick++;let a=this._transform;return this._activePath.quadraticCurveTo(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,a.a*n+a.c*r+a.tx,a.b*n+a.d*r+a.ty,i),this}rect(e,t,n,r){return this._tick++,this._activePath.rect(e,t,n,r,this._transform.clone()),this}roundRect(e,t,n,r,i){return this._tick++,this._activePath.roundRect(e,t,n,r,i,this._transform.clone()),this}poly(e,t){return this._tick++,this._activePath.poly(e,t,this._transform.clone()),this}regularPoly(e,t,n,r,i=0,a){return this._tick++,this._activePath.regularPoly(e,t,n,r,i,a),this}roundPoly(e,t,n,r,i,a){return this._tick++,this._activePath.roundPoly(e,t,n,r,i,a),this}roundShape(e,t,n,r){return this._tick++,this._activePath.roundShape(e,t,n,r),this}filletRect(e,t,n,r,i){return this._tick++,this._activePath.filletRect(e,t,n,r,i),this}chamferRect(e,t,n,r,i,a){return this._tick++,this._activePath.chamferRect(e,t,n,r,i,a),this}star(e,t,n,r,i=0,a=0){return this._tick++,this._activePath.star(e,t,n,r,i,a,this._transform.clone()),this}svg(e){return this._tick++,bn(e,this),this}restore(){let e=this._stateStack.pop();return e&&(this._transform=e.transform,this._fillStyle=e.fillStyle,this._strokeStyle=e.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(e){return this._transform.rotate(e),this}scale(e,t=e){return this._transform.scale(e,t),this}setTransform(e,t,n,r,i,a){return e instanceof A?(this._transform.set(e.a,e.b,e.c,e.d,e.tx,e.ty),this):(this._transform.set(e,t,n,r,i,a),this)}transform(e,t,n,r,i,a){return e instanceof A?(this._transform.append(e),this):(Mn.set(e,t,n,r,i,a),this._transform.append(Mn),this)}translate(e,t=e){return this._transform.translate(e,t),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit(`update`,this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;let e=this._bounds;e.clear();for(let t=0;t<this.instructions.length;t++){let n=this.instructions[t],r=n.action;if(r===`fill`){let t=n.data;e.addBounds(t.path.bounds)}else if(r===`texture`){let t=n.data;e.addFrame(t.dx,t.dy,t.dx+t.dw,t.dy+t.dh,t.transform)}if(r===`stroke`){let t=n.data,r=t.style.width/2,i=t.path.bounds;e.addFrame(i.minX-r,i.minY-r,i.maxX+r,i.maxY+r)}}return e}containsPoint(e){if(!this.bounds.containsPoint(e.x,e.y))return!1;let t=this.instructions,n=!1;for(let r=0;r<t.length;r++){let i=t[r],a=i.data,o=a.path;if(!i.action||!o)continue;let s=a.style,c=o.shapePath.shapePrimitives;for(let t=0;t<c.length;t++){let r=c[t].shape;if(!s||!r)continue;let o=c[t].transform,l=o?o.applyInverse(e,jn):e;n=i.action===`fill`?r.contains(l.x,l.y):r.strokeContains(l.x,l.y,s.width);let u=a.hole;if(u){let e=u.shapePath?.shapePrimitives;if(e)for(let t=0;t<e.length;t++)e[t].shape.contains(l.x,l.y)&&(n=!1)}if(n)return!0}}return n}destroy(e=!1){if(this._stateStack.length=0,this._transform=null,this.emit(`destroy`,this),this.removeAllListeners(),typeof e==`boolean`?e:e?.texture){let t=typeof e==`boolean`?e:e?.textureSource;this._fillStyle.texture&&this._fillStyle.texture.destroy(t),this._strokeStyle.texture&&this._strokeStyle.texture.destroy(t)}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Nn.defaultFillStyle={color:16777215,alpha:1,texture:p.WHITE,matrix:null,fill:null},Nn.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:`butt`,join:`miter`,texture:p.WHITE,matrix:null,fill:null};var X=Nn,Pn=[`align`,`breakWords`,`cssOverrides`,`fontVariant`,`fontWeight`,`leading`,`letterSpacing`,`lineHeight`,`padding`,`textBaseline`,`trim`,`whiteSpace`,`wordWrap`,`wordWrapWidth`,`fontFamily`,`fontStyle`,`fontSize`];function Fn(e){let t=[],n=0;for(let r=0;r<Pn.length;r++){let i=`_${Pn[r]}`;t[n++]=e[i]}return n=In(e._fill,t,n),n=Ln(e._stroke,t,n),n=Rn(e.dropShadow,t,n),t.join(`-`)}function In(e,t,n){return e?(t[n++]=e.color,t[n++]=e.alpha,t[n++]=e.fill?.styleKey,n):n}function Ln(e,t,n){return e?(n=In(e,t,n),t[n++]=e.width,t[n++]=e.alignment,t[n++]=e.cap,t[n++]=e.join,t[n++]=e.miterLimit,n):n}function Rn(e,t,n){return e?(t[n++]=e.alpha,t[n++]=e.angle,t[n++]=e.blur,t[n++]=e.distance,t[n++]=V.shared.setValue(e.color).toNumber(),n):n}var zn=class e extends M{constructor(t={}){super(),Bn(t);let n={...e.defaultTextStyle,...t};for(let e in n){let t=e;this[t]=n[e]}this.update()}get align(){return this._align}set align(e){this._align=e,this.update()}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords=e,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(t){typeof t==`object`&&t?this._dropShadow=this._createProxy({...e.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...e.defaultDropShadow}):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily=e,this.update()}get fontSize(){return this._fontSize}set fontSize(e){typeof e==`string`?this._fontSize=parseInt(e,10):this._fontSize=e,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle=e,this.update()}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant=e,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight=e,this.update()}get leading(){return this._leading}set leading(e){this._leading=e,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing=e,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight=e,this.update()}get padding(){return this._padding}set padding(e){this._padding=e,this.update()}get trim(){return this._trim}set trim(e){this._trim=e,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline=e,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace=e,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap=e,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth=e,this.update()}get fill(){return this._originalFill}set fill(e){e!==this._originalFill&&(this._originalFill=e,this._isFillStyle(e)&&(this._originalFill=this._createProxy({...X.defaultFillStyle,...e},()=>{this._fill=Y({...this._originalFill},X.defaultFillStyle)})),this._fill=Y(e===0?`black`:e,X.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...X.defaultStrokeStyle,...e},()=>{this._stroke=An({...this._originalStroke},X.defaultStrokeStyle)})),this._stroke=An(e,X.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=Fn(this),this._styleKey}update(){this._styleKey=null,this.emit(`update`,this)}reset(){let t=e.defaultTextStyle;for(let e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new e({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(e=!1){if(this.removeAllListeners(),typeof e==`boolean`?e:e?.texture){let t=typeof e==`boolean`?e:e?.textureSource;this._fill?.texture&&this._fill.texture.destroy(t),this._originalFill?.texture&&this._originalFill.texture.destroy(t),this._stroke?.texture&&this._stroke.texture.destroy(t),this._originalStroke?.texture&&this._originalStroke.texture.destroy(t)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(e,t){return new Proxy(e,{set:(e,n,r)=>(e[n]=r,t?.(n,r),this.update(),!0)})}_isFillStyle(e){return(e??null)!==null&&!(V.isColorLike(e)||e instanceof Ft||e instanceof Lt)}};zn.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:`black`,distance:5},zn.defaultTextStyle={align:`left`,breakWords:!1,dropShadow:null,fill:`black`,fontFamily:`Arial`,fontSize:26,fontStyle:`normal`,fontVariant:`normal`,fontWeight:`normal`,leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:`alphabetic`,trim:!1,whiteSpace:`pre`,wordWrap:!1,wordWrapWidth:100};var Z=zn;function Bn(e){let t=e;if(typeof t.dropShadow==`boolean`&&t.dropShadow){let n=Z.defaultDropShadow;e.dropShadow={alpha:t.dropShadowAlpha??n.alpha,angle:t.dropShadowAngle??n.angle,blur:t.dropShadowBlur??n.blur,color:t.dropShadowColor??n.color,distance:t.dropShadowDistance??n.distance}}if(t.strokeThickness!==void 0){L(O,`strokeThickness is now a part of stroke`);let n=t.stroke,r={};if(V.isColorLike(n))r.color=n;else if(n instanceof Ft||n instanceof Lt)r.fill=n;else if(Object.hasOwnProperty.call(n,`color`)||Object.hasOwnProperty.call(n,`fill`))r=n;else throw Error(`Invalid stroke value.`);e.stroke={...r,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){L(O,"gradient fill is now a fill pattern: `new FillGradient(...)`");let n;e.fontSize==null?e.fontSize=Z.defaultTextStyle.fontSize:n=typeof e.fontSize==`string`?parseInt(e.fontSize,10):e.fontSize;let r=new Ft(0,0,0,n*1.7),i=t.fillGradientStops.map(e=>V.shared.setValue(e).toNumber());i.forEach((e,t)=>{let n=t/(i.length-1);r.addColorStop(n,e)}),e.fill={fill:r}}}var Vn=new n;function Hn(e,t,n,r){let i=Vn;i.minX=0,i.minY=0,i.maxX=e.width/r|0,i.maxY=e.height/r|0;let a=E.getOptimalTexture(i.width,i.height,r,!1);return a.source.uploadMethodId=`image`,a.source.resource=e,a.source.alphaMode=`premultiply-alpha-on-upload`,a.frame.width=t/r,a.frame.height=n/r,a.source.emit(`update`,a.source),a.updateUvs(),a}var Un=[`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`];function Wn(e){let t=typeof e.fontSize==`number`?`${e.fontSize}px`:e.fontSize,n=e.fontFamily;Array.isArray(e.fontFamily)||(n=e.fontFamily.split(`,`));for(let e=n.length-1;e>=0;e--){let t=n[e].trim();!/([\"\'])[^\'\"]+\1/.test(t)&&!Un.includes(t)&&(t=`"${t}"`),n[e]=t}return`${e.fontStyle} ${e.fontVariant} ${e.fontWeight} ${t} ${n.join(`,`)}`}var Gn={willReadFrequently:!0},Q=class e{static get experimentalLetterSpacingSupported(){let t=e._experimentalLetterSpacingSupported;if(t!==void 0){let n=x.get().getCanvasRenderingContext2D().prototype;t=e._experimentalLetterSpacingSupported=`letterSpacing`in n||`textLetterSpacing`in n}return t}constructor(e,t,n,r,i,a,o,s,c){this.text=e,this.style=t,this.width=n,this.height=r,this.lines=i,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=s,this.fontProperties=c}static measureText(t=` `,n,r=e._canvas,i=n.wordWrap){let a=`${t}:${n.styleKey}`;if(e._measurementCache[a])return e._measurementCache[a];let o=Wn(n),s=e.measureFont(o);s.fontSize===0&&(s.fontSize=n.fontSize,s.ascent=n.fontSize);let c=e.__context;c.font=o;let l=(i?e._wordWrap(t,n,r):t).split(/(?:\r\n|\r|\n)/),u=Array(l.length),d=0;for(let t=0;t<l.length;t++){let r=e._measureText(l[t],n.letterSpacing,c);u[t]=r,d=Math.max(d,r)}let f=n._stroke?.width||0,p=d+f;n.dropShadow&&(p+=n.dropShadow.distance);let m=n.lineHeight||s.fontSize,h=Math.max(m,s.fontSize+f)+(l.length-1)*(m+n.leading);return n.dropShadow&&(h+=n.dropShadow.distance),new e(t,n,p,h,l,u,m+n.leading,d,s)}static _measureText(t,n,r){let i=!1;e.experimentalLetterSpacingSupported&&(e.experimentalLetterSpacing?(r.letterSpacing=`${n}px`,r.textLetterSpacing=`${n}px`,i=!0):(r.letterSpacing=`0px`,r.textLetterSpacing=`0px`));let a=r.measureText(t).width;return a>0&&(i?a-=n:a+=(e.graphemeSegmenter(t).length-1)*n),a}static _wordWrap(t,n,r=e._canvas){let i=r.getContext(`2d`,Gn),a=0,o=``,s=``,c=Object.create(null),{letterSpacing:l,whiteSpace:u}=n,d=e._collapseSpaces(u),f=e._collapseNewlines(u),p=!d,m=n.wordWrapWidth+l,h=e._tokenize(t);for(let t=0;t<h.length;t++){let r=h[t];if(e._isNewline(r)){if(!f){s+=e._addLine(o),p=!d,o=``,a=0;continue}r=` `}if(d){let t=e.isBreakingSpace(r),n=e.isBreakingSpace(o[o.length-1]);if(t&&n)continue}let u=e._getFromCache(r,l,c,i);if(u>m)if(o!==``&&(s+=e._addLine(o),o=``,a=0),e.canBreakWords(r,n.breakWords)){let t=e.wordWrapSplit(r);for(let u=0;u<t.length;u++){let d=t[u],f=d,h=1;for(;t[u+h];){let i=t[u+h];if(!e.canBreakChars(f,i,r,u,n.breakWords))d+=i;else break;f=i,h++}u+=h-1;let g=e._getFromCache(d,l,c,i);g+a>m&&(s+=e._addLine(o),p=!1,o=``,a=0),o+=d,a+=g}}else{o.length>0&&(s+=e._addLine(o),o=``,a=0);let n=t===h.length-1;s+=e._addLine(r,!n),p=!1,o=``,a=0}else u+a>m&&(p=!1,s+=e._addLine(o),o=``,a=0),(o.length>0||!e.isBreakingSpace(r)||p)&&(o+=r,a+=u)}return s+=e._addLine(o,!1),s}static _addLine(t,n=!0){return t=e._trimRight(t),t=n?`${t}
|
|
2
|
+
`:t,t}static _getFromCache(t,n,r,i){let a=r[t];return typeof a!=`number`&&(a=e._measureText(t,n,i)+n,r[t]=a),a}static _collapseSpaces(e){return e===`normal`||e===`pre-line`}static _collapseNewlines(e){return e===`normal`}static _trimRight(t){if(typeof t!=`string`)return``;for(let n=t.length-1;n>=0;n--){let r=t[n];if(!e.isBreakingSpace(r))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t==`string`?e._newlines.includes(t.charCodeAt(0)):!1}static isBreakingSpace(t,n){return typeof t==`string`?e._breakingSpaces.includes(t.charCodeAt(0)):!1}static _tokenize(t){let n=[],r=``;if(typeof t!=`string`)return n;for(let i=0;i<t.length;i++){let a=t[i],o=t[i+1];if(e.isBreakingSpace(a,o)||e._isNewline(a)){r!==``&&(n.push(r),r=``),n.push(a);continue}r+=a}return r!==``&&n.push(r),n}static canBreakWords(e,t){return t}static canBreakChars(e,t,n,r,i){return!0}static wordWrapSplit(t){return e.graphemeSegmenter(t)}static measureFont(t){if(e._fonts[t])return e._fonts[t];let n=e._context;n.font=t;let r=n.measureText(e.METRICS_STRING+e.BASELINE_SYMBOL),i={ascent:r.actualBoundingBoxAscent,descent:r.actualBoundingBoxDescent,fontSize:r.actualBoundingBoxAscent+r.actualBoundingBoxDescent};return e._fonts[t]=i,i}static clearMetrics(t=``){t?delete e._fonts[t]:e._fonts={}}static get _canvas(){if(!e.__canvas){let t;try{let n=new OffscreenCanvas(0,0);if(n.getContext(`2d`,Gn)?.measureText)return e.__canvas=n,n;t=x.get().createCanvas()}catch{t=x.get().createCanvas()}t.width=t.height=10,e.__canvas=t}return e.__canvas}static get _context(){return e.__context||=e._canvas.getContext(`2d`,Gn),e.__context}};Q.METRICS_STRING=`|ÉqÅ`,Q.BASELINE_SYMBOL=`M`,Q.BASELINE_MULTIPLIER=1.4,Q.HEIGHT_MULTIPLIER=2,Q.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter==`function`){let e=new Intl.Segmenter;return t=>[...e.segment(t)].map(e=>e.segment)}return e=>[...e]})(),Q.experimentalLetterSpacing=!1,Q._fonts={},Q._newlines=[10,13],Q._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Q._measurementCache={};var $=Q;function Kn(e,t){if(e.texture===p.WHITE&&!e.fill)return V.shared.setValue(e.color).setAlpha(e.alpha??1).toHexa();if(!e.fill){let n=t.createPattern(e.texture.source.resource,`repeat`),r=e.matrix.copyTo(A.shared);return r.scale(e.texture.frame.width,e.texture.frame.height),n.setTransform(r),n}else if(e.fill instanceof Lt){let n=e.fill,r=t.createPattern(n.texture.source.resource,`repeat`),i=n.transform.copyTo(A.shared);return i.scale(n.texture.frame.width,n.texture.frame.height),r.setTransform(i),r}else if(e.fill instanceof Ft){let n=e.fill;if(n.type===`linear`){let e=t.createLinearGradient(n.x0,n.y0,n.x1,n.y1);return n.gradientStops.forEach(t=>{e.addColorStop(t.offset,V.shared.setValue(t.color).toHex())}),e}}return w(`FillStyle not recognised`,e),`red`}var qn=class{constructor(e){this._activeTextures={},this._renderer=e}getTextureSize(e,t,n){let r=$.measureText(e||` `,n),i=Math.ceil(Math.ceil(Math.max(1,r.width)+n.padding*2)*t),a=Math.ceil(Math.ceil(Math.max(1,r.height)+n.padding*2)*t);return i=Math.ceil(i-1e-6),a=Math.ceil(a-1e-6),i=l(i),a=l(a),{width:i,height:a}}getTexture(e,t,n,r){typeof e==`string`&&(L(`8.0.0`,`CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments`),e={text:e,style:n,resolution:t}),e.style instanceof Z||(e.style=new Z(e.style));let{texture:i,canvasAndContext:a}=this.createTextureAndCanvas(e);return this._renderer.texture.initSource(i._source),U.returnCanvasAndContext(a),i}createTextureAndCanvas(e){let{text:t,style:n}=e,r=e.resolution??this._renderer.resolution,i=$.measureText(t||` `,n),a=Math.ceil(Math.ceil(Math.max(1,i.width)+n.padding*2)*r),o=Math.ceil(Math.ceil(Math.max(1,i.height)+n.padding*2)*r),s=U.getOptimalCanvasAndContext(a,o),{canvas:c}=s;this.renderTextToCanvas(t,n,r,s);let l=Hn(c,a,o,r);if(n.trim){let e=Nt(c,r);l.frame.copyFrom(e),l.updateUvs()}return{texture:l,canvasAndContext:s}}getManagedTexture(e){e._resolution=e._autoResolution?this._renderer.resolution:e.resolution;let t=e._getKey();if(this._activeTextures[t])return this._increaseReferenceCount(t),this._activeTextures[t].texture;let{texture:n,canvasAndContext:r}=this.createTextureAndCanvas(e);return this._activeTextures[t]={canvasAndContext:r,texture:n,usageCount:1},n}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}decreaseReferenceCount(e){let t=this._activeTextures[e];if(t.usageCount--,t.usageCount===0){U.returnCanvasAndContext(t.canvasAndContext),E.returnTexture(t.texture);let n=t.texture.source;n.resource=null,n.uploadMethodId=`unknown`,n.alphaMode=`no-premultiply-alpha`,this._activeTextures[e]=null}}getReferenceCount(e){return this._activeTextures[e].usageCount}renderTextToCanvas(e,t,n,r){let{canvas:i,context:a}=r,o=Wn(t),s=$.measureText(e||` `,t),c=s.lines,l=s.lineHeight,u=s.lineWidths,d=s.maxLineWidth,f=s.fontProperties,p=i.height;a.resetTransform(),a.scale(n,n);let m=t.padding*2;if(a.clearRect(0,0,s.width+4+m,s.height+4+m),t._stroke?.width){let e=t._stroke;a.lineWidth=e.width,a.miterLimit=e.miterLimit,a.lineJoin=e.join,a.lineCap=e.cap}a.font=o;let h,g,_=t.dropShadow?2:1;for(let e=0;e<_;++e){let i=t.dropShadow&&e===0,o=i?Math.ceil(Math.max(1,p)+t.padding*2):0,s=o*n;if(i){a.fillStyle=`black`,a.strokeStyle=`black`;let e=t.dropShadow,r=e.color,i=e.alpha;a.shadowColor=V.shared.setValue(r).setAlpha(i).toRgbaString();let o=e.blur*n,c=e.distance*n;a.shadowBlur=o,a.shadowOffsetX=Math.cos(e.angle)*c,a.shadowOffsetY=Math.sin(e.angle)*c+s}else a.globalAlpha=t._fill?.alpha??1,a.fillStyle=t._fill?Kn(t._fill,a):null,t._stroke?.width&&(a.strokeStyle=Kn(t._stroke,a)),a.shadowColor=`black`;let m=(l-f.fontSize)/2;l-f.fontSize<0&&(m=0);let _=t._stroke?.width??0;for(let e=0;e<c.length;e++)h=_/2,g=_/2+e*l+f.ascent+m,t.align===`right`?h+=d-u[e]:t.align===`center`&&(h+=(d-u[e])/2),t._stroke?.width&&this._drawLetterSpacing(c[e],t,r,h+t.padding,g+t.padding-o,!0),t._fill!==void 0&&this._drawLetterSpacing(c[e],t,r,h+t.padding,g+t.padding-o)}}_drawLetterSpacing(e,t,n,r,i,a=!1){let{context:o}=n,s=t.letterSpacing,c=!1;if($.experimentalLetterSpacingSupported&&($.experimentalLetterSpacing?(o.letterSpacing=`${s}px`,o.textLetterSpacing=`${s}px`,c=!0):(o.letterSpacing=`0px`,o.textLetterSpacing=`0px`)),s===0||c){a?o.strokeText(e,r,i):o.fillText(e,r,i);return}let l=r,u=$.graphemeSegmenter(e),d=o.measureText(e).width,f=0;for(let e=0;e<u.length;++e){let t=u[e];a?o.strokeText(t,l,i):o.fillText(t,l,i);let n=``;for(let t=e+1;t<u.length;++t)n+=u[t];f=o.measureText(n).width,l+=d-f+s,d=f}}destroy(){this._activeTextures=null}};qn.extension={type:[F.WebGLSystem,F.WebGPUSystem,F.CanvasSystem],name:`canvasText`};var Jn=class e extends s{constructor(e){e instanceof X&&(e={context:e});let{context:t,roundPixels:n,...r}=e||{};super({label:`Graphics`,...r}),this.renderPipeId=`graphics`,t?this._context=t:this._context=this._ownedContext=new X,this._context.on(`update`,this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=n??!1}set context(e){e!==this._context&&(this._context.off(`update`,this.onViewUpdate,this),this._context=e,this._context.on(`update`,this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(e){e.addBounds(this._context.bounds)}containsPoint(e){return this._context.containsPoint(e)}onViewUpdate(){if(this._didViewChangeTick++,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;let e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}destroy(e){this._ownedContext&&!e?this._ownedContext.destroy(e):(e===!0||e?.context===!0)&&this._context.destroy(e),this._ownedContext=null,this._context=null,super.destroy(e)}_callContextMethod(e,t){return this.context[e](...t),this}setFillStyle(...e){return this._callContextMethod(`setFillStyle`,e)}setStrokeStyle(...e){return this._callContextMethod(`setStrokeStyle`,e)}fill(...e){return this._callContextMethod(`fill`,e)}stroke(...e){return this._callContextMethod(`stroke`,e)}texture(...e){return this._callContextMethod(`texture`,e)}beginPath(){return this._callContextMethod(`beginPath`,[])}cut(){return this._callContextMethod(`cut`,[])}arc(...e){return this._callContextMethod(`arc`,e)}arcTo(...e){return this._callContextMethod(`arcTo`,e)}arcToSvg(...e){return this._callContextMethod(`arcToSvg`,e)}bezierCurveTo(...e){return this._callContextMethod(`bezierCurveTo`,e)}closePath(){return this._callContextMethod(`closePath`,[])}ellipse(...e){return this._callContextMethod(`ellipse`,e)}circle(...e){return this._callContextMethod(`circle`,e)}path(...e){return this._callContextMethod(`path`,e)}lineTo(...e){return this._callContextMethod(`lineTo`,e)}moveTo(...e){return this._callContextMethod(`moveTo`,e)}quadraticCurveTo(...e){return this._callContextMethod(`quadraticCurveTo`,e)}rect(...e){return this._callContextMethod(`rect`,e)}roundRect(...e){return this._callContextMethod(`roundRect`,e)}poly(...e){return this._callContextMethod(`poly`,e)}regularPoly(...e){return this._callContextMethod(`regularPoly`,e)}roundPoly(...e){return this._callContextMethod(`roundPoly`,e)}roundShape(...e){return this._callContextMethod(`roundShape`,e)}filletRect(...e){return this._callContextMethod(`filletRect`,e)}chamferRect(...e){return this._callContextMethod(`chamferRect`,e)}star(...e){return this._callContextMethod(`star`,e)}svg(...e){return this._callContextMethod(`svg`,e)}restore(...e){return this._callContextMethod(`restore`,e)}save(){return this._callContextMethod(`save`,[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod(`resetTransform`,[])}rotateTransform(...e){return this._callContextMethod(`rotate`,e)}scaleTransform(...e){return this._callContextMethod(`scale`,e)}setTransform(...e){return this._callContextMethod(`setTransform`,e)}transform(...e){return this._callContextMethod(`transform`,e)}translateTransform(...e){return this._callContextMethod(`translate`,e)}clear(){return this._callContextMethod(`clear`,[])}get fillStyle(){return this._context.fillStyle}set fillStyle(e){this._context.fillStyle=e}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(e){this._context.strokeStyle=e}clone(t=!1){return t?new e(this._context.clone()):(this._ownedContext=null,new e(this._context))}lineStyle(e,t,n){L(O,`Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.`);let r={};return e&&(r.width=e),t&&(r.color=t),n&&(r.alpha=n),this.context.strokeStyle=r,this}beginFill(e,t){L(O,`Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.`);let n={};return e&&(n.color=e),t&&(n.alpha=t),this.context.fillStyle=n,this}endFill(){L(O,`Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.`),this.context.fill();let e=this.context.strokeStyle;return(e.width!==X.defaultStrokeStyle.width||e.color!==X.defaultStrokeStyle.color||e.alpha!==X.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...e){return L(O,`Graphics#drawCircle has been renamed to Graphics#circle`),this._callContextMethod(`circle`,e)}drawEllipse(...e){return L(O,`Graphics#drawEllipse has been renamed to Graphics#ellipse`),this._callContextMethod(`ellipse`,e)}drawPolygon(...e){return L(O,`Graphics#drawPolygon has been renamed to Graphics#poly`),this._callContextMethod(`poly`,e)}drawRect(...e){return L(O,`Graphics#drawRect has been renamed to Graphics#rect`),this._callContextMethod(`rect`,e)}drawRoundedRect(...e){return L(O,`Graphics#drawRoundedRect has been renamed to Graphics#roundRect`),this._callContextMethod(`roundRect`,e)}drawStar(...e){return L(O,`Graphics#drawStar has been renamed to Graphics#star`),this._callContextMethod(`star`,e)}},Yn={name:`local-uniform-msdf-bit`,vertex:{header:`
|
|
3
|
+
struct LocalUniforms {
|
|
4
|
+
uColor:vec4<f32>,
|
|
5
|
+
uTransformMatrix:mat3x3<f32>,
|
|
6
|
+
uDistance: f32,
|
|
7
|
+
uRound:f32,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
11
|
+
`,main:`
|
|
12
|
+
vColor *= localUniforms.uColor;
|
|
13
|
+
modelMatrix *= localUniforms.uTransformMatrix;
|
|
14
|
+
`,end:`
|
|
15
|
+
if(localUniforms.uRound == 1)
|
|
16
|
+
{
|
|
17
|
+
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
18
|
+
}
|
|
19
|
+
`},fragment:{header:`
|
|
20
|
+
struct LocalUniforms {
|
|
21
|
+
uColor:vec4<f32>,
|
|
22
|
+
uTransformMatrix:mat3x3<f32>,
|
|
23
|
+
uDistance: f32
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
27
|
+
`,main:`
|
|
28
|
+
outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));
|
|
29
|
+
`}},Xn={name:`local-uniform-msdf-bit`,vertex:{header:`
|
|
30
|
+
uniform mat3 uTransformMatrix;
|
|
31
|
+
uniform vec4 uColor;
|
|
32
|
+
uniform float uRound;
|
|
33
|
+
`,main:`
|
|
34
|
+
vColor *= uColor;
|
|
35
|
+
modelMatrix *= uTransformMatrix;
|
|
36
|
+
`,end:`
|
|
37
|
+
if(uRound == 1.)
|
|
38
|
+
{
|
|
39
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
40
|
+
}
|
|
41
|
+
`},fragment:{header:`
|
|
42
|
+
uniform float uDistance;
|
|
43
|
+
`,main:`
|
|
44
|
+
outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));
|
|
45
|
+
`}},Zn={name:`msdf-bit`,fragment:{header:`
|
|
46
|
+
fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {
|
|
47
|
+
|
|
48
|
+
// MSDF
|
|
49
|
+
var median = msdfColor.r + msdfColor.g + msdfColor.b -
|
|
50
|
+
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
|
|
51
|
+
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
|
|
52
|
+
|
|
53
|
+
// SDF
|
|
54
|
+
median = min(median, msdfColor.a);
|
|
55
|
+
|
|
56
|
+
var screenPxDistance = distance * (median - 0.5);
|
|
57
|
+
var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
|
58
|
+
if (median < 0.01) {
|
|
59
|
+
alpha = 0.0;
|
|
60
|
+
} else if (median > 0.99) {
|
|
61
|
+
alpha = 1.0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Gamma correction for coverage-like alpha
|
|
65
|
+
var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));
|
|
66
|
+
var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);
|
|
67
|
+
var coverage: f32 = pow(shapeColor.a * alpha, gamma);
|
|
68
|
+
|
|
69
|
+
return coverage;
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
`}},Qn={name:`msdf-bit`,fragment:{header:`
|
|
73
|
+
float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {
|
|
74
|
+
|
|
75
|
+
// MSDF
|
|
76
|
+
float median = msdfColor.r + msdfColor.g + msdfColor.b -
|
|
77
|
+
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
|
|
78
|
+
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
|
|
79
|
+
|
|
80
|
+
// SDF
|
|
81
|
+
median = min(median, msdfColor.a);
|
|
82
|
+
|
|
83
|
+
float screenPxDistance = distance * (median - 0.5);
|
|
84
|
+
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
|
85
|
+
|
|
86
|
+
if (median < 0.01) {
|
|
87
|
+
alpha = 0.0;
|
|
88
|
+
} else if (median > 0.99) {
|
|
89
|
+
alpha = 1.0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Gamma correction for coverage-like alpha
|
|
93
|
+
float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));
|
|
94
|
+
float gamma = mix(1.0, 1.0 / 2.2, luma);
|
|
95
|
+
float coverage = pow(shapeColor.a * alpha, gamma);
|
|
96
|
+
|
|
97
|
+
return coverage;
|
|
98
|
+
}
|
|
99
|
+
`}},$n,er,tr=class extends I{constructor(){let e=new H({uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uTransformMatrix:{value:new A,type:`mat3x3<f32>`},uDistance:{value:4,type:`f32`},uRound:{value:0,type:`f32`}}),t=ee();$n??=ae({name:`sdf-shader`,bits:[le,k(t),Yn,Zn,re]}),er??=P({name:`sdf-shader`,bits:[j,te(t),Xn,Qn,se]}),super({glProgram:er,gpuProgram:$n,resources:{localUniforms:e,batchSamplers:he(t)}})}},nr=class extends M{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 L(O,`BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead.`),this.fontFamily}get pageTextures(){return L(O,`BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead.`),this.pages}get size(){return L(O,`BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead.`),this.fontMetrics.fontSize}get distanceFieldRange(){return L(O,`BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead.`),this.distanceField.range}get distanceFieldType(){return L(O,`BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead.`),this.distanceField.type}destroy(e=!1){this.emit(`destroy`,this),this.removeAllListeners();for(let e in this.chars)this.chars[e].texture?.destroy();this.chars=null,e&&(this.pages.forEach(e=>e.texture.destroy(!0)),this.pages=null)}};function rr(e){if(e===``)return[];typeof e==`string`&&(e=[e]);let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(Array.isArray(r)){if(r.length!==2)throw Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);if(r[0].length===0||r[1].length===0)throw Error(`[BitmapFont]: Invalid character delimiter.`);let e=r[0].charCodeAt(0),n=r[1].charCodeAt(0);if(n<e)throw Error(`[BitmapFont]: Invalid character range.`);for(let r=e,i=n;r<=i;r++)t.push(String.fromCharCode(r))}else t.push(...Array.from(r))}if(t.length===0)throw Error(`[BitmapFont]: Empty set when resolving characters.`);return t}var ir=class e extends nr{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 n={...e.defaultOptions,...t};this._textureSize=n.textureSize,this._mipmap=n.mipmap;let r=n.style.clone();n.overrideFill&&(r._fill.color=16777215,r._fill.alpha=1,r._fill.texture=p.WHITE,r._fill.fill=null),this.applyFillAsTint=n.overrideFill;let i=r.fontSize;r.fontSize=this.baseMeasurementFontSize;let a=Wn(r);n.overrideSize?r._stroke&&(r._stroke.width*=this.baseRenderedFontSize/i):r.fontSize=this.baseRenderedFontSize=i,this._style=r,this._skipKerning=n.skipKerning??!1,this.resolution=n.resolution??1,this._padding=n.padding??4,this.fontMetrics=$.measureFont(a),this.lineHeight=r.lineHeight||this.fontMetrics.fontSize||r.fontSize}ensureCharacters(e){let t=rr(e).filter(e=>!this._currentChars.includes(e)).filter((e,t,n)=>n.indexOf(e)===t);if(!t.length)return;this._currentChars=[...this._currentChars,...t];let n;n=this._currentPageIndex===-1?this._nextPage():this.pages[this._currentPageIndex];let{canvas:r,context:i}=n.canvasAndContext,a=n.texture.source,o=this._style,s=this._currentX,c=this._currentY,l=this.baseRenderedFontSize/this.baseMeasurementFontSize,u=this._padding*l,d=o.fontStyle===`italic`?2:1,f=0,m=!1;for(let e=0;e<t.length;e++){let n=t[e],h=$.measureText(n,o,r,!1);h.lineHeight=h.height;let g=d*h.width*l,_=h.height*l,v=g+u*2,y=_+u*2;if(m=!1,n!==`
|
|
100
|
+
`&&n!==`\r`&&n!==` `&&n!==` `&&(m=!0,f=Math.ceil(Math.max(y,f))),s+v>this._textureSize&&(c+=f,f=y,s=0,c+f>this._textureSize)){a.update();let e=this._nextPage();r=e.canvasAndContext.canvas,i=e.canvasAndContext.context,a=e.texture.source,c=0}let b=g/l-(o.dropShadow?.distance??0)-(o._stroke?.width??0);if(this.chars[n]={id:n.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:b,kerning:{}},m){this._drawGlyph(i,h,s+u,c+u,l,o);let e=a.width*l,t=a.height*l,r=new N(s/e*a.width,c/t*a.height,v/e*a.width,y/t*a.height);this.chars[n].texture=new p({source:a,frame:r}),s+=Math.ceil(v)}}a.update(),this._currentX=s,this._currentY=c,this._skipKerning&&this._applyKerning(t,i)}get pageTextures(){return L(O,`BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead.`),this.pages}_applyKerning(e,t){let n=this._measureCache;for(let r=0;r<e.length;r++){let i=e[r];for(let e=0;e<this._currentChars.length;e++){let r=this._currentChars[e],a=n[i];a||=n[i]=t.measureText(i).width;let o=n[r];o||=n[r]=t.measureText(r).width;let s=t.measureText(i+r).width,c=s-(a+o);c&&(this.chars[i].kerning[r]=c),s=t.measureText(i+r).width,c=s-(a+o),c&&(this.chars[r].kerning[i]=c)}}}_nextPage(){this._currentPageIndex++;let e=this.resolution,t=U.getOptimalCanvasAndContext(this._textureSize,this._textureSize,e);this._setupContext(t.context,this._style,e);let n=e*(this.baseRenderedFontSize/this.baseMeasurementFontSize),r={canvasAndContext:t,texture:new p({source:new He({resource:t.canvas,resolution:n,alphaMode:`premultiply-alpha-on-upload`,autoGenerateMipmaps:this._mipmap})})};return this.pages[this._currentPageIndex]=r,r}_setupContext(e,t,n){t.fontSize=this.baseRenderedFontSize,e.scale(n,n),e.font=Wn(t),t.fontSize=this.baseMeasurementFontSize,e.textBaseline=t.textBaseline;let r=t._stroke,i=r?.width??0;if(r&&(e.lineWidth=i,e.lineJoin=r.join,e.miterLimit=r.miterLimit,e.strokeStyle=Kn(r,e)),t._fill&&(e.fillStyle=Kn(t._fill,e)),t.dropShadow){let r=t.dropShadow,i=V.shared.setValue(r.color).toArray(),a=r.blur*n,o=r.distance*n;e.shadowColor=`rgba(${i[0]*255},${i[1]*255},${i[2]*255},${r.alpha})`,e.shadowBlur=a,e.shadowOffsetX=Math.cos(r.angle)*o,e.shadowOffsetY=Math.sin(r.angle)*o}else e.shadowColor=`black`,e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0}_drawGlyph(e,t,n,r,i,a){let o=t.text,s=t.fontProperties,c=(a._stroke?.width??0)*i,l=n+c/2,u=r-c/2,d=s.descent*i,f=t.lineHeight*i;a.stroke&&c&&e.strokeText(o,l,u+f-d),a._fill&&e.fillText(o,l,u+f-d)}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){let{canvasAndContext:t,texture:n}=this.pages[e];t.canvas.width=t.canvas.width,U.returnCanvasAndContext(t),n.destroy(!0)}this.pages=null}};ir.defaultOptions={textureSize:512,style:new Z,mipmap:!0};var ar=ir;function or(e,t,n){let r={width:0,height:0,offsetY:0,scale:t.fontSize/n.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};r.offsetY=n.baseLineOffset;let i=r.lines[0],a=null,o=!0,s={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},c=e=>{let t=i.width;for(let n=0;n<s.index;n++){let r=e.positions[n];i.chars.push(e.chars[n]),i.charPositions.push(r+t)}i.width+=e.width,o=!1,s.width=0,s.index=0,s.chars.length=0},l=()=>{let e=i.chars.length-1,t=i.chars[e];for(;t===` `;)i.width-=n.chars[t].xAdvance,t=i.chars[--e];r.width=Math.max(r.width,i.width),i={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,r.lines.push(i),r.height+=n.lineHeight},u=n.baseMeasurementFontSize/t.fontSize,d=t.letterSpacing*u,f=t.wordWrapWidth*u;for(let r=0;r<e.length+1;r++){let u,p=r===e.length;p||(u=e[r]);let m=n.chars[u]||n.chars[` `];if(/(?:\s)/.test(u)||u===`\r`||u===`
|
|
101
|
+
`||p){if(!o&&t.wordWrap&&i.width+s.width-d>f?(l(),c(s),p||i.charPositions.push(0)):(s.start=i.width,c(s),p||i.charPositions.push(0)),u===`\r`||u===`
|
|
102
|
+
`)i.width!==0&&l();else if(!p){let e=m.xAdvance+(m.kerning[a]||0)+d;i.width+=e,i.spaceWidth=e,i.spacesIndex.push(i.charPositions.length),i.chars.push(u)}}else{let e=m.kerning[a]||0,t=m.xAdvance+e+d;s.positions[s.index++]=s.width+e,s.chars.push(u),s.width+=t}a=u}return l(),t.align===`center`?sr(r):t.align===`right`?cr(r):t.align===`justify`&&lr(r),r}function sr(e){for(let t=0;t<e.lines.length;t++){let n=e.lines[t],r=e.width/2-n.width/2;for(let e=0;e<n.charPositions.length;e++)n.charPositions[e]+=r}}function cr(e){for(let t=0;t<e.lines.length;t++){let n=e.lines[t],r=e.width-n.width;for(let e=0;e<n.charPositions.length;e++)n.charPositions[e]+=r}}function lr(e){let t=e.width;for(let n=0;n<e.lines.length;n++){let r=e.lines[n],i=0,a=r.spacesIndex[i++],o=0,s=r.spacesIndex.length,c=(t-r.width)/s;for(let e=0;e<r.charPositions.length;e++)e===a&&(a=r.spacesIndex[i++],o+=c),r.charPositions[e]+=o}}var ur=0,dr=new 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 n=`${t.fontFamily}-bitmap`,r=!0;if(t._fill.fill&&!t._stroke)n+=t._fill.fill.styleKey,r=!1;else if(t._stroke||t.dropShadow){let e=t.styleKey;e=e.substring(0,e.lastIndexOf(`-`)),n=`${e}-bitmap`,r=!1}if(!K.has(n)){let e=new ar({style:t,overrideFill:r,overrideSize:!0,...this.defaultOptions});ur++,ur>50&&w(`BitmapText`,`You have dynamically created ${ur} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),e.once(`destroy`,()=>{ur--,K.remove(n)}),K.set(n,e)}let i=K.get(n);return i.ensureCharacters?.(e),i}getLayout(e,t){let n=this.getFont(e,t);return or([...e],t,n)}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},L(O,`BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})`));let n=t?.name;if(!n)throw Error("[BitmapFontManager] Property `name` is required.");t={...this.defaultOptions,...t};let r=t.style,i=r instanceof Z?r:new Z(r),a=new ar({style:i,overrideFill:i._fill.fill!==null&&i._fill.fill!==void 0,skipKerning:t.skipKerning,padding:t.padding,resolution:t.resolution,overrideSize:!1}),o=rr(t.chars);return a.ensureCharacters(o.join(``)),K.set(`${n}-bitmap`,a),a.once(`destroy`,()=>K.remove(`${n}-bitmap`)),a}uninstall(e){let t=`${e}-bitmap`,n=K.get(t);n&&(K.remove(t),n.destroy())}},fr=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 n=this._getGpuBitmapText(e);pr(e,n),e._didTextUpdate&&(e._didTextUpdate=!1,this._updateContext(e,n)),this._renderer.renderPipes.graphics.addRenderable(n,t),n.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&&=(B.return(t.customShader),null),B.return(this._gpuBitmapText[e]),this._gpuBitmapText[e]=null}updateRenderable(e){let t=this._getGpuBitmapText(e);pr(e,t),this._renderer.renderPipes.graphics.updateRenderable(t),t.context.customShader&&this._updateDistanceField(e)}_updateContext(e,t){let{context:n}=t,r=dr.getFont(e.text,e._style);n.clear(),r.distanceField.type!==`none`&&(n.customShader||=B.get(tr));let i=Array.from(e.text),a=e._style,o=r.baseLineOffset,s=or(i,a,r),c=0,l=a.padding,u=s.scale,d=s.width,f=s.height+s.offsetY;a._stroke&&(d+=a._stroke.width/u,f+=a._stroke.width/u),n.translate(-e._anchor._x*d-l,-e._anchor._y*f-l).scale(u,u);let p=r.applyFillAsTint?a._fill.color:16777215;for(let e=0;e<s.lines.length;e++){let t=s.lines[e];for(let e=0;e<t.charPositions.length;e++){let a=i[c++],s=r.chars[a];s?.texture&&n.texture(s.texture,p||`black`,Math.round(t.charPositions[e]+s.xOffset),Math.round(o+s.yOffset))}o+=r.lineHeight}}_getGpuBitmapText(e){return this._gpuBitmapText[e.uid]||this.initGpuText(e)}initGpuText(e){let t=B.get(Jn);return this._gpuBitmapText[e.uid]=t,this._updateContext(e,t),e.on(`destroyed`,this._destroyRenderableBound),this._gpuBitmapText[e.uid]}_updateDistanceField(e){let t=this._getGpuBitmapText(e).context,n=e._style.fontFamily,r=K.get(`${n}-bitmap`),{a:i,b:a,c:o,d:s}=e.groupTransform,c=Math.sqrt(i*i+a*a),l=Math.sqrt(o*o+s*s),u=(Math.abs(c)+Math.abs(l))/2,d=r.baseRenderedFontSize/e._style.fontSize,f=u*r.distanceField.range*(1/d);t.customShader.resources.localUniforms.uniforms.uDistance=f}destroy(){for(let e in this._gpuBitmapText)this._destroyRenderableByUid(e);this._gpuBitmapText=null,this._renderer=null}};fr.extension={type:[F.WebGLPipes,F.WebGPUPipes,F.CanvasPipes],name:`bitmapText`};function pr(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 mr=class{constructor(e){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e,this._renderer.runners.resolutionChange.add(this)}resolutionChange(){for(let e in this._gpuText){let t=this._gpuText[e].batchableSprite.renderable;t._autoResolution&&(t._resolution=this._renderer.resolution,t.onViewUpdate())}}validateRenderable(e){let t=this._getGpuText(e),n=e._getKey();return t.textureNeedsUploading?(t.textureNeedsUploading=!1,!0):t.currentKey!==n}addRenderable(e,t){let n=this._getGpuText(e).batchableSprite;e._didTextUpdate&&this._updateText(e),this._renderer.renderPipes.batch.addToBatch(n)}updateRenderable(e){let t=this._getGpuText(e).batchableSprite;e._didTextUpdate&&this._updateText(e),t.batcher.updateElement(t)}destroyRenderable(e){e.off(`destroyed`,this._destroyRenderableBound),this._destroyRenderableById(e.uid)}_destroyRenderableById(e){let t=this._gpuText[e];this._renderer.htmlText.decreaseReferenceCount(t.currentKey),B.return(t.batchableSprite),this._gpuText[e]=null}_updateText(e){let t=e._getKey(),n=this._getGpuText(e),r=n.batchableSprite;n.currentKey!==t&&this._updateGpuText(e).catch(e=>{console.error(e)}),e._didTextUpdate=!1;let i=e._style.padding;u(r.bounds,e._anchor,r.texture,i)}async _updateGpuText(e){e._didTextUpdate=!1;let t=this._getGpuText(e);if(t.generatingTexture)return;let n=e._getKey();this._renderer.htmlText.decreaseReferenceCount(t.currentKey),t.generatingTexture=!0,t.currentKey=n;let r=e.resolution??this._renderer.resolution,i=await this._renderer.htmlText.getManagedTexture(e.text,r,e._style,e._getKey()),a=t.batchableSprite;a.texture=t.texture=i,t.generatingTexture=!1,t.textureNeedsUploading=!0,e.onViewUpdate();let o=e._style.padding;u(a.bounds,e._anchor,a.texture,o)}_getGpuText(e){return this._gpuText[e.uid]||this.initGpuText(e)}initGpuText(e){let t={texture:p.EMPTY,currentKey:`--`,batchableSprite:B.get(ue),textureNeedsUploading:!1,generatingTexture:!1},n=t.batchableSprite;return n.renderable=e,n.texture=p.EMPTY,n.bounds={minX:0,maxX:1,minY:0,maxY:0},n.roundPixels=this._renderer._roundPixels|e._roundPixels,e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,this._gpuText[e.uid]=t,e.on(`destroyed`,this._destroyRenderableBound),t}destroy(){for(let e in this._gpuText)this._destroyRenderableById(e);this._gpuText=null,this._renderer=null}};mr.extension={type:[F.WebGLPipes,F.WebGPUPipes,F.CanvasPipes],name:`htmlText`};function hr(){let{userAgent:e}=x.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(e)}var gr=`http://www.w3.org/2000/svg`,_r=`http://www.w3.org/1999/xhtml`,vr=class{constructor(){this.svgRoot=document.createElementNS(gr,`svg`),this.foreignObject=document.createElementNS(gr,`foreignObject`),this.domElement=document.createElementNS(_r,`div`),this.styleElement=document.createElementNS(_r,`style`),this.image=new Image;let{foreignObject:e,svgRoot:t,styleElement:n,domElement:r}=this;e.setAttribute(`width`,`10000`),e.setAttribute(`height`,`10000`),e.style.overflow=`hidden`,t.appendChild(e),e.appendChild(n),e.appendChild(r)}};function yr(e){let t=e._stroke,n=e._fill,r=[`div { ${[`color: ${V.shared.setValue(n.color).toHex()}`,`font-size: ${e.fontSize}px`,`font-family: ${e.fontFamily}`,`font-weight: ${e.fontWeight}`,`font-style: ${e.fontStyle}`,`font-variant: ${e.fontVariant}`,`letter-spacing: ${e.letterSpacing}px`,`text-align: ${e.align}`,`padding: ${e.padding}px`,`white-space: ${e.whiteSpace===`pre`&&e.wordWrap?`pre-wrap`:e.whiteSpace}`,...e.lineHeight?[`line-height: ${e.lineHeight}px`]:[],...e.wordWrap?[`word-wrap: ${e.breakWords?`break-all`:`break-word`}`,`max-width: ${e.wordWrapWidth}px`]:[],...t?[xr(t)]:[],...e.dropShadow?[br(e.dropShadow)]:[],...e.cssOverrides].join(`;`)} }`];return wr(e.tagStyles,r),r.join(` `)}function br(e){let t=V.shared.setValue(e.color).setAlpha(e.alpha).toHexa(),n=`${Math.round(Math.cos(e.angle)*e.distance)}px ${Math.round(Math.sin(e.angle)*e.distance)}px`;return e.blur>0?`text-shadow: ${n} ${e.blur}px ${t}`:`text-shadow: ${n} ${t}`}function xr(e){return[`-webkit-text-stroke-width: ${e.width}px`,`-webkit-text-stroke-color: ${V.shared.setValue(e.color).toHex()}`,`text-stroke-width: ${e.width}px`,`text-stroke-color: ${V.shared.setValue(e.color).toHex()}`,`paint-order: stroke`].join(`;`)}var Sr={fontSize:`font-size: {{VALUE}}px`,fontFamily:`font-family: {{VALUE}}`,fontWeight:`font-weight: {{VALUE}}`,fontStyle:`font-style: {{VALUE}}`,fontVariant:`font-variant: {{VALUE}}`,letterSpacing:`letter-spacing: {{VALUE}}px`,align:`text-align: {{VALUE}}`,padding:`padding: {{VALUE}}px`,whiteSpace:`white-space: {{VALUE}}`,lineHeight:`line-height: {{VALUE}}px`,wordWrapWidth:`max-width: {{VALUE}}px`},Cr={fill:e=>`color: ${V.shared.setValue(e).toHex()}`,breakWords:e=>`word-wrap: ${e?`break-all`:`break-word`}`,stroke:xr,dropShadow:br};function wr(e,t){for(let n in e){let r=e[n],i=[];for(let e in r)Cr[e]?i.push(Cr[e](r[e])):Sr[e]&&i.push(Sr[e].replace(`{{VALUE}}`,r[e]));t.push(`${n} { ${i.join(`;`)} }`)}}var Tr=class e extends Z{constructor(e={}){super(e),this._cssOverrides=[],this.cssOverrides??=e.cssOverrides,this.tagStyles=e.tagStyles??{}}set cssOverrides(e){this._cssOverrides=e instanceof Array?e:[e],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=Fn(this)+this._cssOverrides.join(`-`),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new e({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?{...this.dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides})}get cssStyle(){return this._cssStyle||=yr(this),this._cssStyle}addOverride(...e){let t=e.filter(e=>!this.cssOverrides.includes(e));t.length>0&&(this.cssOverrides.push(...t),this.update())}removeOverride(...e){let t=e.filter(e=>this.cssOverrides.includes(e));t.length>0&&(this.cssOverrides=this.cssOverrides.filter(e=>!t.includes(e)),this.update())}set fill(e){typeof e!=`string`&&typeof e!=`number`&&w(`[HTMLTextStyle] only color fill is not supported by HTMLText`),super.fill=e}set stroke(e){e&&typeof e!=`string`&&typeof e!=`number`&&w(`[HTMLTextStyle] only color stroke is not supported by HTMLText`),super.stroke=e}};function Er(e,t){let n=t.fontFamily,r=[],i={},a=e.match(/font-family:([^;"\s]+)/g);function o(e){i[e]||(r.push(e),i[e]=!0)}if(Array.isArray(n))for(let e=0;e<n.length;e++)o(n[e]);else o(n);a&&a.forEach(e=>{o(e.split(`:`)[1].trim())});for(let e in t.tagStyles){let n=t.tagStyles[e].fontFamily;o(n)}return r}async function Dr(e){let t=await(await x.get().fetch(e)).blob(),n=new FileReader;return await new Promise((e,r)=>{n.onloadend=()=>e(n.result),n.onerror=r,n.readAsDataURL(t)})}async function Or(e,t){let n=await Dr(t);return`@font-face {
|
|
103
|
+
font-family: "${e.fontFamily}";
|
|
104
|
+
src: url('${n}');
|
|
105
|
+
font-weight: ${e.fontWeight};
|
|
106
|
+
font-style: ${e.fontStyle};
|
|
107
|
+
}`}var kr=new Map;async function Ar(e,t,n){let r=e.filter(e=>K.has(`${e}-and-url`)).map((e,r)=>{if(!kr.has(e)){let{url:i}=K.get(`${e}-and-url`);r===0?kr.set(e,Or({fontWeight:t.fontWeight,fontStyle:t.fontStyle,fontFamily:e},i)):kr.set(e,Or({fontWeight:n.fontWeight,fontStyle:n.fontStyle,fontFamily:e},i))}return kr.get(e)});return(await Promise.all(r)).join(`
|
|
108
|
+
`)}function jr(e,t,n,r,i){let{domElement:a,styleElement:o,svgRoot:s}=i;a.innerHTML=`<style>${t.cssStyle}</style><div style='padding:0;'>${e}</div>`,a.setAttribute(`style`,`transform: scale(${n});transform-origin: top left; display: inline-block`),o.textContent=r;let{width:c,height:l}=i.image;return s.setAttribute(`width`,c.toString()),s.setAttribute(`height`,l.toString()),new XMLSerializer().serializeToString(s)}function Mr(e,t){let n=U.getOptimalCanvasAndContext(e.width,e.height,t),{context:r}=n;return r.clearRect(0,0,e.width,e.height),r.drawImage(e,0,0),U.returnCanvasAndContext(n),n.canvas}function Nr(e,t,n){return new Promise(async r=>{n&&await new Promise(e=>setTimeout(e,100)),e.onload=()=>{r()},e.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,e.crossOrigin=`anonymous`})}var Pr;function Fr(e,t,n,r){r=r||Pr||(Pr=new vr);let{domElement:i,styleElement:a,svgRoot:o}=r;i.innerHTML=`<style>${t.cssStyle};</style><div style='padding:0'>${e}</div>`,i.setAttribute(`style`,`transform-origin: top left; display: inline-block`),n&&(a.textContent=n),document.body.appendChild(o);let s=i.getBoundingClientRect();o.remove();let c=$.measureFont(t.fontStyle).descent,l=t.padding*2;return{width:s.width-l,height:s.height+c-l}}var Ir=class{constructor(e){this._activeTextures={},this._renderer=e,this._createCanvas=e.type===D.WEBGPU}getTexture(e){return this._buildTexturePromise(e.text,e.resolution,e.style)}getManagedTexture(e,t,n,r){if(this._activeTextures[r])return this._increaseReferenceCount(r),this._activeTextures[r].promise;let i=this._buildTexturePromise(e,t,n).then(e=>(this._activeTextures[r].texture=e,e));return this._activeTextures[r]={texture:null,promise:i,usageCount:1},i}async _buildTexturePromise(e,t,n){let r=B.get(vr),i=Er(e,n),a=await Ar(i,n,Tr.defaultTextStyle),o=Fr(e,n,a,r),s=Math.ceil(Math.ceil(Math.max(1,o.width)+n.padding*2)*t),c=Math.ceil(Math.ceil(Math.max(1,o.height)+n.padding*2)*t),l=r.image;l.width=(s|0)+2,l.height=(c|0)+2,await Nr(l,jr(e,n,t,a,r),hr()&&i.length>0);let u=l;this._createCanvas&&(u=Mr(l,t));let d=Hn(u,l.width-2,l.height-2,t);return this._createCanvas&&this._renderer.texture.initSource(d.source),B.return(r),d}_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(e=>{t.texture=e,this._cleanUp(t)}).catch(()=>{w(`HTMLTextSystem: Failed to clean texture`)}),this._activeTextures[e]=null))}_cleanUp(e){E.returnTexture(e.texture),e.texture.source.resource=null,e.texture.source.uploadMethodId=`unknown`}getReferenceCount(e){return this._activeTextures[e].usageCount}destroy(){this._activeTextures=null}};Ir.extension={type:[F.WebGLSystem,F.WebGPUSystem,F.CanvasSystem],name:`htmlText`},Ir.defaultFontOptions={fontFamily:`Arial`,fontStyle:`normal`,fontWeight:`normal`};var Lr=class e extends de{constructor(...t){let n=t[0]??{};n instanceof Float32Array&&(L(O,`use new MeshGeometry({ positions, uvs, indices }) instead`),n={positions:n,uvs:t[1],indices:t[2]}),n={...e.defaultOptions,...n};let r=n.positions||new Float32Array([0,0,1,0,1,1,0,1]),i=n.uvs||new Float32Array([0,0,1,0,1,1,0,1]),a=n.indices||new Uint32Array([0,1,2,0,2,3]),s=n.shrinkBuffersToFit,c=new b({data:r,label:`attribute-mesh-positions`,shrinkToFit:s,usage:o.VERTEX|o.COPY_DST}),l=new b({data:i,label:`attribute-mesh-uvs`,shrinkToFit:s,usage:o.VERTEX|o.COPY_DST}),u=new b({data:a,label:`index-mesh-buffer`,shrinkToFit:s,usage:o.INDEX|o.COPY_DST});super({attributes:{aPosition:{buffer:c,format:`float32x2`,stride:8,offset:0},aUV:{buffer:l,format:`float32x2`,stride:8,offset:0}},indexBuffer:u,topology:n.topology}),this.batchMode=`auto`}get positions(){return this.attributes.aPosition.buffer.data}set positions(e){this.attributes.aPosition.buffer.data=e}get uvs(){return this.attributes.aUV.buffer.data}set uvs(e){this.attributes.aUV.buffer.data=e}get indices(){return this.indexBuffer.data}set indices(e){this.indexBuffer.data=e}};Lr.defaultOptions={topology:`triangle-list`,shrinkBuffersToFit:!1};var Rr=Lr,zr={name:`tiling-bit`,vertex:{header:`
|
|
109
|
+
struct TilingUniforms {
|
|
110
|
+
uMapCoord:mat3x3<f32>,
|
|
111
|
+
uClampFrame:vec4<f32>,
|
|
112
|
+
uClampOffset:vec2<f32>,
|
|
113
|
+
uTextureTransform:mat3x3<f32>,
|
|
114
|
+
uSizeAnchor:vec4<f32>
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
118
|
+
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
119
|
+
@group(2) @binding(2) var uSampler: sampler;
|
|
120
|
+
`,main:`
|
|
121
|
+
uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;
|
|
122
|
+
|
|
123
|
+
position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
|
|
124
|
+
`},fragment:{header:`
|
|
125
|
+
struct TilingUniforms {
|
|
126
|
+
uMapCoord:mat3x3<f32>,
|
|
127
|
+
uClampFrame:vec4<f32>,
|
|
128
|
+
uClampOffset:vec2<f32>,
|
|
129
|
+
uTextureTransform:mat3x3<f32>,
|
|
130
|
+
uSizeAnchor:vec4<f32>
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
134
|
+
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
135
|
+
@group(2) @binding(2) var uSampler: sampler;
|
|
136
|
+
`,main:`
|
|
137
|
+
|
|
138
|
+
var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
|
|
139
|
+
coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
|
|
140
|
+
var unclamped = coord;
|
|
141
|
+
coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);
|
|
142
|
+
|
|
143
|
+
var bias = 0.;
|
|
144
|
+
|
|
145
|
+
if(unclamped.x == coord.x && unclamped.y == coord.y)
|
|
146
|
+
{
|
|
147
|
+
bias = -32.;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
outColor = textureSampleBias(uTexture, uSampler, coord, bias);
|
|
151
|
+
`}},Br={name:`tiling-bit`,vertex:{header:`
|
|
152
|
+
uniform mat3 uTextureTransform;
|
|
153
|
+
uniform vec4 uSizeAnchor;
|
|
154
|
+
|
|
155
|
+
`,main:`
|
|
156
|
+
uv = (uTextureTransform * vec3(aUV, 1.0)).xy;
|
|
157
|
+
|
|
158
|
+
position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
|
|
159
|
+
`},fragment:{header:`
|
|
160
|
+
uniform sampler2D uTexture;
|
|
161
|
+
uniform mat3 uMapCoord;
|
|
162
|
+
uniform vec4 uClampFrame;
|
|
163
|
+
uniform vec2 uClampOffset;
|
|
164
|
+
`,main:`
|
|
165
|
+
|
|
166
|
+
vec2 coord = vUV + ceil(uClampOffset - vUV);
|
|
167
|
+
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
|
168
|
+
vec2 unclamped = coord;
|
|
169
|
+
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
|
170
|
+
|
|
171
|
+
outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
|
|
172
|
+
|
|
173
|
+
`}},Vr,Hr,Ur=class extends I{constructor(){Vr??=ae({name:`tiling-sprite-shader`,bits:[ce,zr,re]}),Hr??=P({name:`tiling-sprite-shader`,bits:[ne,Br,se]});let e=new H({uMapCoord:{value:new A,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 A,type:`mat3x3<f32>`},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:`vec4<f32>`}});super({glProgram:Hr,gpuProgram:Vr,resources:{localUniforms:new H({uTransformMatrix:{value:new A,type:`mat3x3<f32>`},uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uRound:{value:0,type:`f32`}}),tilingUniforms:e,uTexture:p.EMPTY.source,uSampler:p.EMPTY.source.style}})}updateUniforms(e,t,n,r,i,a){let o=this.resources.tilingUniforms,s=a.width,c=a.height,l=a.textureMatrix,u=o.uniforms.uTextureTransform;u.set(n.a*s/e,n.b*s/t,n.c*c/e,n.d*c/t,n.tx/e,n.ty/t),u.invert(),o.uniforms.uMapCoord=l.mapCoord,o.uniforms.uClampFrame=l.uClampFrame,o.uniforms.uClampOffset=l.uClampOffset,o.uniforms.uTextureTransform=u,o.uniforms.uSizeAnchor[0]=e,o.uniforms.uSizeAnchor[1]=t,o.uniforms.uSizeAnchor[2]=r,o.uniforms.uSizeAnchor[3]=i,a&&(this.resources.uTexture=a.source,this.resources.uSampler=a.source.style)}},Wr=class extends Rr{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 Gr(e,t){let n=e.anchor.x,r=e.anchor.y;t[0]=-n*e.width,t[1]=-r*e.height,t[2]=(1-n)*e.width,t[3]=-r*e.height,t[4]=(1-n)*e.width,t[5]=(1-r)*e.height,t[6]=-n*e.width,t[7]=(1-r)*e.height}function Kr(e,t,n,r){let i=0,a=e.length/(t||2),o=r.a,s=r.b,c=r.c,l=r.d,u=r.tx,d=r.ty;for(n*=t;i<a;){let r=e[n],a=e[n+1];e[n]=o*r+c*a+u,e[n+1]=s*r+l*a+d,n+=t,i++}}function qr(e,t){let n=e.texture,r=n.frame.width,i=n.frame.height,a=0,o=0;e._applyAnchorToTexture&&(a=e.anchor.x,o=e.anchor.y),t[0]=t[6]=-a,t[2]=t[4]=1-a,t[1]=t[3]=-o,t[5]=t[7]=1-o;let s=A.shared;s.copyFrom(e._tileTransform.matrix),s.tx/=e.width,s.ty/=e.height,s.invert(),s.scale(e.width/r,e.height/i),Kr(t,2,0,s)}var Jr=new Wr,Yr=class{constructor(e){this._state=y.default2d,this._tilingSpriteDataHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e}validateRenderable(e){let t=this._getTilingSpriteData(e),n=t.canBatch;this._updateCanBatch(e);let r=t.canBatch;if(r&&r===n){let{batchableMesh:n}=t;if(n&&n.texture._source!==e.texture._source)return!n.batcher.checkAndUpdateTexture(n,e.texture)}return n!==r}addRenderable(e,t){let n=this._renderer.renderPipes.batch;this._updateCanBatch(e);let r=this._getTilingSpriteData(e),{geometry:i,canBatch:a}=r;if(a){r.batchableMesh||=new Ot;let t=r.batchableMesh;e._didTilingSpriteUpdate&&(e._didTilingSpriteUpdate=!1,this._updateBatchableMesh(e),t.geometry=i,t.mesh=e,t.texture=e._texture),t.roundPixels=this._renderer._roundPixels|e._roundPixels,n.addToBatch(t)}else n.break(t),r.shader||=new Ur,this.updateRenderable(e),t.add(e)}execute(e){let{shader:t}=this._tilingSpriteDataHash[e.uid];t.groups[0]=this._renderer.globalUniforms.bindGroup;let n=t.resources.localUniforms.uniforms;n.uTransformMatrix=e.groupTransform,n.uRound=this._renderer._roundPixels|e._roundPixels,fe(e.groupColorAlpha,n.uColor,0),this._state.blendMode=g(e.groupBlendMode,e.texture._source),this._renderer.encoder.draw({geometry:Jr,shader:t,state:this._state})}updateRenderable(e){let t=this._getTilingSpriteData(e),{canBatch:n}=t;if(n){let{batchableMesh:n}=t;e._didTilingSpriteUpdate&&this._updateBatchableMesh(e),n.batcher.updateElement(n)}else if(e._didTilingSpriteUpdate){let{shader:n}=t;n.updateUniforms(e.width,e.height,e._tileTransform.matrix,e.anchor.x,e.anchor.y,e.texture)}e._didTilingSpriteUpdate=!1}destroyRenderable(e){let t=this._getTilingSpriteData(e);t.batchableMesh=null,t.shader?.destroy(),this._tilingSpriteDataHash[e.uid]=null,e.off(`destroyed`,this._destroyRenderableBound)}_getTilingSpriteData(e){return this._tilingSpriteDataHash[e.uid]||this._initTilingSpriteData(e)}_initTilingSpriteData(e){let t=new Rr({indices:Jr.indices,positions:Jr.positions.slice(),uvs:Jr.uvs.slice()});return this._tilingSpriteDataHash[e.uid]={canBatch:!0,renderable:e,geometry:t},e.on(`destroyed`,this._destroyRenderableBound),this._tilingSpriteDataHash[e.uid]}_updateBatchableMesh(e){let{geometry:t}=this._getTilingSpriteData(e),n=e.texture.source.style;n.addressMode!==`repeat`&&(n.addressMode=`repeat`,n.update()),qr(e,t.uvs),Gr(e,t.positions)}destroy(){for(let e in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[e].renderable);this._tilingSpriteDataHash=null,this._renderer=null}_updateCanBatch(e){let t=this._getTilingSpriteData(e),n=e.texture,r=!0;return this._renderer.type===D.WEBGL&&(r=this._renderer.context.supports.nonPowOf2wrapping),t.canBatch=n.textureMatrix.isSimple&&(r||n.source.isPowerOfTwo),t.canBatch}};Yr.extension={type:[F.WebGLPipes,F.WebGPUPipes,F.CanvasPipes],name:`tilingSprite`};var Xr=class e extends Rr{constructor(...e){super({});let t=e[0]??{};typeof t==`number`&&(L(O,`PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead`),t={width:t,height:e[1],verticesX:e[2],verticesY:e[3]}),this.build(t)}build(t){t={...e.defaultOptions,...t},this.verticesX=this.verticesX??t.verticesX,this.verticesY=this.verticesY??t.verticesY,this.width=this.width??t.width,this.height=this.height??t.height;let n=this.verticesX*this.verticesY,r=[],i=[],a=[],o=this.verticesX-1,s=this.verticesY-1,c=this.width/o,l=this.height/s;for(let e=0;e<n;e++){let t=e%this.verticesX,n=e/this.verticesX|0;r.push(t*c,n*l),i.push(t/o,n/s)}let u=o*s;for(let e=0;e<u;e++){let t=e%o,n=e/o|0,r=n*this.verticesX+t,i=n*this.verticesX+t+1,s=(n+1)*this.verticesX+t,c=(n+1)*this.verticesX+t+1;a.push(r,i,s,i,c,s)}this.buffers[0].data=new Float32Array(r),this.buffers[1].data=new Float32Array(i),this.indexBuffer.data=new Uint32Array(a),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};Xr.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};var Zr=Xr,Qr=class e extends Zr{constructor(t={}){t={...e.defaultOptions,...t},super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(e){this.width=e.width??this.width,this.height=e.height??this.height,this._originalWidth=e.originalWidth??this._originalWidth,this._originalHeight=e.originalHeight??this._originalHeight,this._leftWidth=e.leftWidth??this._leftWidth,this._rightWidth=e.rightWidth??this._rightWidth,this._topHeight=e.topHeight??this._topHeight,this._bottomHeight=e.bottomHeight??this._bottomHeight,this.updateUvs(),this.updatePositions()}updatePositions(){let e=this.positions,t=this._leftWidth+this._rightWidth,n=this.width>t?1:this.width/t,r=this._topHeight+this._bottomHeight,i=this.height>r?1:this.height/r,a=Math.min(n,i);e[9]=e[11]=e[13]=e[15]=this._topHeight*a,e[17]=e[19]=e[21]=e[23]=this.height-this._bottomHeight*a,e[25]=e[27]=e[29]=e[31]=this.height,e[2]=e[10]=e[18]=e[26]=this._leftWidth*a,e[4]=e[12]=e[20]=e[28]=this.width-this._rightWidth*a,e[6]=e[14]=e[22]=e[30]=this.width,this.getBuffer(`aPosition`).update()}updateUvs(){let e=this.uvs;e[0]=e[8]=e[16]=e[24]=0,e[1]=e[3]=e[5]=e[7]=0,e[6]=e[14]=e[22]=e[30]=1,e[25]=e[27]=e[29]=e[31]=1;let t=1/this._originalWidth,n=1/this._originalHeight;e[2]=e[10]=e[18]=e[26]=t*this._leftWidth,e[9]=e[11]=e[13]=e[15]=n*this._topHeight,e[4]=e[12]=e[20]=e[28]=1-t*this._rightWidth,e[17]=e[19]=e[21]=e[23]=1-n*this._bottomHeight,this.getBuffer(`aUV`).update()}};Qr.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};var $r=Qr,ei=class{constructor(e){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e}addRenderable(e,t){let n=this._getGpuSprite(e);e._didSpriteUpdate&&this._updateBatchableSprite(e,n),this._renderer.renderPipes.batch.addToBatch(n)}updateRenderable(e){let t=this._gpuSpriteHash[e.uid];e._didSpriteUpdate&&this._updateBatchableSprite(e,t),t.batcher.updateElement(t)}validateRenderable(e){let t=e._texture,n=this._getGpuSprite(e);return n.texture._source===t._source?!1:!n.batcher.checkAndUpdateTexture(n,t)}destroyRenderable(e){let t=this._gpuSpriteHash[e.uid];B.return(t.geometry),B.return(t),this._gpuSpriteHash[e.uid]=null,e.off(`destroyed`,this._destroyRenderableBound)}_updateBatchableSprite(e,t){e._didSpriteUpdate=!1,t.geometry.update(e),t.texture=e._texture}_getGpuSprite(e){return this._gpuSpriteHash[e.uid]||this._initGPUSprite(e)}_initGPUSprite(e){let t=B.get(Ot);return t.geometry=B.get($r),t.mesh=e,t.texture=e._texture,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._didSpriteUpdate=!0,this._gpuSpriteHash[e.uid]=t,e.on(`destroyed`,this._destroyRenderableBound),t}destroy(){for(let e in this._gpuSpriteHash)this._gpuSpriteHash[e].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null}};ei.extension={type:[F.WebGLPipes,F.WebGPUPipes,F.CanvasPipes],name:`nineSliceSprite`};var ti=class{constructor(e){this._renderer=e}push(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:`filter`,canBundle:!1,action:`pushFilter`,container:t,filterEffect:e})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:`filter`,action:`popFilter`,canBundle:!1})}execute(e){e.action===`pushFilter`?this._renderer.filter.push(e):e.action===`popFilter`&&this._renderer.filter.pop()}destroy(){this._renderer=null}};ti.extension={type:[F.WebGLPipes,F.WebGPUPipes,F.CanvasPipes],name:`filter`};var ni=new A;function ri(e,t){return t.clear(),ii(e,t),t.isValid||t.set(0,0,0,0),e.renderGroup?t.applyMatrix(e.renderGroup.localTransform):t.applyMatrix(e.parentRenderGroup.worldTransform),t}function ii(e,t){if(e.localDisplayStatus!==7||!e.measurable)return;let n=!!e.effects.length,r=t;if((e.renderGroup||n)&&(r=T.get().clear()),e.boundsArea)t.addRect(e.boundsArea,e.worldTransform);else{if(e.renderPipeId){let t=e.bounds;r.addFrame(t.minX,t.minY,t.maxX,t.maxY,e.groupTransform)}let t=e.children;for(let e=0;e<t.length;e++)ii(t[e],r)}if(n){let n=!1;for(let t=0;t<e.effects.length;t++)e.effects[t].addBounds&&(n||(n=!0,r.applyMatrix(e.parentRenderGroup.worldTransform)),e.effects[t].addBounds(r,!0));n&&(r.applyMatrix(e.parentRenderGroup.worldTransform.copyTo(ni).invert()),t.addBounds(r,e.relativeGroupTransform)),t.addBounds(r),T.return(r)}else e.renderGroup&&(t.addBounds(r,e.relativeGroupTransform),T.return(r))}function ai(e,t){t.clear();let n=t.matrix;for(let n=0;n<e.length;n++){let r=e[n];r.globalDisplayStatus<7||(t.matrix=r.worldTransform,r.addBounds(t))}return t.matrix=n,t}var oi=new de({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:`float32x2`,stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])}),si=class{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new H({uInputSize:{value:new Float32Array(4),type:`vec4<f32>`},uInputPixel:{value:new Float32Array(4),type:`vec4<f32>`},uInputClamp:{value:new Float32Array(4),type:`vec4<f32>`},uOutputFrame:{value:new Float32Array(4),type:`vec4<f32>`},uGlobalFrame:{value:new Float32Array(4),type:`vec4<f32>`},uOutputTexture:{value:new Float32Array(4),type:`vec4<f32>`}}),this._globalFilterBindGroup=new m({}),this.renderer=e}get activeBackTexture(){return this._activeFilterData?.backTexture}push(e){let t=this.renderer,n=e.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());let r=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,n.length===0){r.skip=!0;return}let i=r.bounds;e.renderables?ai(e.renderables,i):e.filterEffect.filterArea?(i.clear(),i.addRect(e.filterEffect.filterArea),i.applyMatrix(e.container.worldTransform)):ri(e.container,i);let a=t.renderTarget.renderTarget.colorTexture.source,o=1/0,s=0,c=!0,l=!1,u=!1;for(let e=0;e<n.length;e++){let r=n[e];if(o=Math.min(o,r.resolution===`inherit`?a._resolution:r.resolution),s+=r.padding,r.antialias===`off`?c=!1:r.antialias===`inherit`&&(c&&=a.antialias),!(r.compatibleRenderers&t.type)){u=!1;break}if(r.blendRequired&&!(t.backBuffer?.useBackBuffer??!0)){w("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),u=!1;break}u=r.enabled||u,l||=r.blendRequired}if(!u){r.skip=!0;return}let d=t.renderTarget.rootViewPort;if(i.scale(o).fitBounds(0,d.width,0,d.height).ceil().scale(1/o).pad(s|0),!i.isPositive){r.skip=!0;return}r.skip=!1,r.bounds=i,r.blendRequired=l,r.container=e.container,r.filterEffect=e.filterEffect,r.previousRenderSurface=t.renderTarget.renderSurface,r.inputTexture=E.getOptimalTexture(i.width,i.height,o,c),t.renderTarget.bind(r.inputTexture,!0),t.globalUniforms.push({offset:i})}pop(){let e=this.renderer;this._filterStackIndex--;let t=this._filterStack[this._filterStackIndex];if(t.skip)return;this._activeFilterData=t;let n=t.inputTexture,r=t.bounds,i=p.EMPTY;if(e.renderTarget.finishRenderPass(),t.blendRequired){let n=this._filterStackIndex>0?this._filterStack[this._filterStackIndex-1].bounds:null,a=e.renderTarget.getRenderTarget(t.previousRenderSurface);i=this.getBackTexture(a,r,n)}t.backTexture=i;let a=t.filterEffect.filters;if(this._globalFilterBindGroup.setResource(n.source.style,2),this._globalFilterBindGroup.setResource(i.source,3),e.globalUniforms.pop(),a.length===1)a[0].apply(this,n,t.previousRenderSurface,!1),E.returnTexture(n);else{let e=t.inputTexture,n=E.getOptimalTexture(r.width,r.height,e.source._resolution,!1),i=0;for(i=0;i<a.length-1;++i){a[i].apply(this,e,n,!0);let t=e;e=n,n=t}a[i].apply(this,e,t.previousRenderSurface,!1),E.returnTexture(e),E.returnTexture(n)}t.blendRequired&&E.returnTexture(i)}getBackTexture(e,t,n){let r=e.colorTexture.source._resolution,i=E.getOptimalTexture(t.width,t.height,r,!1),a=t.minX,o=t.minY;n&&(a-=n.minX,o-=n.minY),a=Math.floor(a*r),o=Math.floor(o*r);let s=Math.ceil(t.width*r),c=Math.ceil(t.height*r);return this.renderer.renderTarget.copyToTexture(e,i,{x:a,y:o},{width:s,height:c},{x:0,y:0}),i}applyFilter(e,t,n,r){let i=this.renderer,a=this._filterStack[this._filterStackIndex],o=a.bounds,s=R.shared,c=a.previousRenderSurface===n,l=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,u=this._filterStackIndex-1;for(;u>0&&this._filterStack[u].skip;)--u;u>0&&(l=this._filterStack[u].inputTexture.source._resolution);let d=this._filterGlobalUniforms,f=d.uniforms,m=f.uOutputFrame,h=f.uInputSize,g=f.uInputPixel,_=f.uInputClamp,v=f.uGlobalFrame,y=f.uOutputTexture;if(c){let e=this._filterStackIndex;for(;e>0;){e--;let t=this._filterStack[this._filterStackIndex-1];if(!t.skip){s.x=t.bounds.minX,s.y=t.bounds.minY;break}}m[0]=o.minX-s.x,m[1]=o.minY-s.y}else m[0]=0,m[1]=0;m[2]=t.frame.width,m[3]=t.frame.height,h[0]=t.source.width,h[1]=t.source.height,h[2]=1/h[0],h[3]=1/h[1],g[0]=t.source.pixelWidth,g[1]=t.source.pixelHeight,g[2]=1/g[0],g[3]=1/g[1],_[0]=.5*g[2],_[1]=.5*g[3],_[2]=t.frame.width*h[2]-.5*g[2],_[3]=t.frame.height*h[3]-.5*g[3];let b=this.renderer.renderTarget.rootRenderTarget.colorTexture;v[0]=s.x*l,v[1]=s.y*l,v[2]=b.source.width*l,v[3]=b.source.height*l;let x=this.renderer.renderTarget.getRenderTarget(n);if(i.renderTarget.bind(n,!!r),n instanceof p?(y[0]=n.frame.width,y[1]=n.frame.height):(y[0]=x.width,y[1]=x.height),y[2]=x.isRoot?-1:1,d.update(),i.renderPipes.uniformBatch){let e=i.renderPipes.uniformBatch.getUboResource(d);this._globalFilterBindGroup.setResource(e,0)}else this._globalFilterBindGroup.setResource(d,0);this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,i.encoder.draw({geometry:oi,shader:e,state:e._state,topology:`triangle-list`}),i.type===D.WEBGL&&i.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new n,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}calculateSpriteMatrix(e,t){let n=this._activeFilterData,r=e.set(n.inputTexture._source.width,0,0,n.inputTexture._source.height,n.bounds.minX,n.bounds.minY),i=t.worldTransform.copyTo(A.shared);return i.invert(),r.prepend(i),r.scale(1/t.texture.frame.width,1/t.texture.frame.height),r.translate(t.anchor.x,t.anchor.y),r}};si.extension={type:[F.WebGLSystem,F.WebGPUSystem],name:`filter`};export{_e as _,Ir as a,Jn as c,Z as d,At as f,ut as g,Et as h,Yr as i,qn as l,Dt as m,ti as n,mr as o,kt as p,ei as r,fr as s,si as t,$ as u,ge as v};
|