@omnimedia/omnitool 1.1.0-42 → 1.1.0-44
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/package.json +17 -18
- package/s/demo/demo.bundle.ts +20 -40
- package/s/demo/routines/export-test.ts +8 -0
- package/s/demo/routines/playback-test.ts +21 -0
- package/s/demo/routines/timeline-setup.ts +24 -0
- package/s/demo/routines/transcode-test.ts +2 -0
- package/s/driver/driver-worker.ts +9 -0
- package/s/driver/driver.test.ts +1 -1
- package/s/driver/driver.ts +8 -22
- package/s/driver/fns/schematic.ts +6 -2
- package/s/driver/fns/work.ts +2 -133
- package/s/driver/parts/compositor.ts +178 -0
- package/s/driver/parts/machina.ts +19 -20
- package/s/index.ts +1 -0
- package/s/timeline/index.ts +1 -1
- package/s/timeline/parts/media.ts +11 -2
- package/s/timeline/parts/{compositor → renderers}/parts/html-tree.ts +2 -2
- package/s/timeline/parts/{compositor → renderers}/parts/tree-builder.ts +4 -2
- package/s/timeline/parts/{compositor → renderers}/playback.ts +4 -13
- package/s/timeline/parts/{compositor → renderers}/samplers/html.ts +19 -5
- package/s/timeline/parts/{compositor → renderers}/samplers/webcodecs.ts +1 -1
- package/s/timeline/parts/resource-pool.ts +8 -4
- package/s/timeline/parts/resource.ts +1 -0
- package/s/timeline/sugar/o.ts +10 -2
- package/s/timeline/sugar/omni-test.ts +14 -14
- package/s/timeline/sugar/omni.ts +2 -2
- package/s/timeline/utils/datafile.ts +14 -4
- package/s/timeline/utils/dummy-data.ts +3 -3
- package/x/demo/WebGLRenderer-Q3OV2JVE.js +2 -0
- package/x/demo/WebGLRenderer-Q3OV2JVE.js.map +7 -0
- package/x/demo/WebGPURenderer-FUFF62QA.js +2 -0
- package/x/demo/WebGPURenderer-FUFF62QA.js.map +7 -0
- package/x/demo/browserAll-PGQYU756.js +2 -0
- package/x/demo/browserAll-PGQYU756.js.map +7 -0
- package/x/demo/chunk-2RBLPWNG.js +393 -0
- package/x/demo/chunk-2RBLPWNG.js.map +7 -0
- package/x/demo/chunk-6DBMQOFE.js +42 -0
- package/x/demo/chunk-6DBMQOFE.js.map +7 -0
- package/x/demo/chunk-LAJHJD2S.js +2 -0
- package/x/demo/chunk-LAJHJD2S.js.map +7 -0
- package/x/demo/chunk-LQU5JKKZ.js +269 -0
- package/x/demo/chunk-LQU5JKKZ.js.map +7 -0
- package/x/demo/chunk-RFNLITDQ.js +327 -0
- package/x/demo/chunk-RFNLITDQ.js.map +7 -0
- package/x/demo/chunk-TBWCKYN2.js +2 -0
- package/x/demo/chunk-TBWCKYN2.js.map +7 -0
- package/x/demo/chunk-TLDBHU4V.js +15 -0
- package/x/demo/chunk-TLDBHU4V.js.map +7 -0
- package/x/demo/chunk-X2GHKWPJ.js +157 -0
- package/x/demo/chunk-X2GHKWPJ.js.map +7 -0
- package/x/demo/demo.bundle.js +18 -27
- package/x/demo/demo.bundle.js.map +1 -1
- package/x/demo/demo.bundle.min.js +2378 -534
- package/x/demo/demo.bundle.min.js.map +4 -4
- package/x/demo/routines/export-test.d.ts +2 -0
- package/x/demo/routines/export-test.js +7 -0
- package/x/demo/routines/export-test.js.map +1 -0
- package/x/demo/routines/playback-test.d.ts +3 -0
- package/x/demo/routines/playback-test.js +17 -0
- package/x/demo/routines/playback-test.js.map +1 -0
- package/x/demo/routines/timeline-setup.d.ts +6 -0
- package/x/demo/routines/timeline-setup.js +13 -0
- package/x/demo/routines/timeline-setup.js.map +1 -0
- package/x/demo/routines/transcode-test.js +2 -0
- package/x/demo/routines/transcode-test.js.map +1 -1
- package/x/demo/webworkerAll-3YNCLHCR.js +2 -0
- package/x/demo/webworkerAll-3YNCLHCR.js.map +7 -0
- package/x/driver/WebGLRenderer-OMRWYQIV.js +2 -0
- package/x/driver/WebGLRenderer-OMRWYQIV.js.map +7 -0
- package/x/driver/WebGPURenderer-KQJB2OJJ.js +2 -0
- package/x/driver/WebGPURenderer-KQJB2OJJ.js.map +7 -0
- package/x/driver/browserAll-YBZEJCN3.js +2 -0
- package/x/driver/browserAll-YBZEJCN3.js.map +7 -0
- package/x/driver/chunk-3L3MB5NY.js +393 -0
- package/x/driver/chunk-3L3MB5NY.js.map +7 -0
- package/x/driver/chunk-42BQ4XKE.js +269 -0
- package/x/driver/chunk-42BQ4XKE.js.map +7 -0
- package/x/driver/chunk-4HAYG3N5.js +327 -0
- package/x/driver/chunk-4HAYG3N5.js.map +7 -0
- package/x/driver/chunk-BFBY7VYB.js +42 -0
- package/x/driver/chunk-BFBY7VYB.js.map +7 -0
- package/x/driver/chunk-KM6O72WE.js +157 -0
- package/x/driver/chunk-KM6O72WE.js.map +7 -0
- package/x/driver/chunk-N6HD4WYJ.js +2 -0
- package/x/driver/chunk-N6HD4WYJ.js.map +7 -0
- package/x/driver/chunk-WCZ2O3UN.js +15 -0
- package/x/driver/chunk-WCZ2O3UN.js.map +7 -0
- package/x/driver/chunk-XWNSF3WJ.js +2 -0
- package/x/driver/chunk-XWNSF3WJ.js.map +7 -0
- package/x/driver/driver-worker.d.ts +1 -0
- package/x/driver/driver-worker.js +6 -0
- package/x/driver/driver-worker.js.map +1 -0
- package/x/driver/driver.d.ts +5 -4
- package/x/driver/driver.js +10 -20
- package/x/driver/driver.js.map +1 -1
- package/x/driver/driver.test.js +1 -1
- package/x/driver/driver.test.js.map +1 -1
- package/x/driver/driver.worker.bundle.min.js +119 -3504
- package/x/driver/driver.worker.bundle.min.js.map +4 -4
- package/x/driver/fns/host.d.ts +1 -2
- package/x/driver/fns/schematic.d.ts +6 -1
- package/x/driver/fns/work.d.ts +2 -4
- package/x/driver/fns/work.js +1 -100
- package/x/driver/fns/work.js.map +1 -1
- package/x/driver/parts/compositor.d.ts +15 -0
- package/x/driver/parts/compositor.js +152 -0
- package/x/driver/parts/compositor.js.map +1 -0
- package/x/driver/parts/machina.d.ts +0 -20
- package/x/driver/parts/machina.js +6 -10
- package/x/driver/parts/machina.js.map +1 -1
- package/x/driver/webworkerAll-BKJQW6P7.js +2 -0
- package/x/driver/webworkerAll-BKJQW6P7.js.map +7 -0
- package/x/features/speech/transcribe/parts/prep-audio.d.ts +1 -1
- package/x/features/speech/transcribe/worker.bundle.min.js +899 -899
- package/x/features/speech/transcribe/worker.bundle.min.js.map +4 -4
- package/x/index.d.ts +1 -0
- package/x/index.html +2 -2
- package/x/index.js +1 -0
- package/x/index.js.map +1 -1
- package/x/timeline/index.d.ts +1 -1
- package/x/timeline/index.js +1 -1
- package/x/timeline/index.js.map +1 -1
- package/x/timeline/parts/filmstrip.d.ts +1 -1
- package/x/timeline/parts/media.d.ts +2 -0
- package/x/timeline/parts/media.js +10 -2
- package/x/timeline/parts/media.js.map +1 -1
- package/x/timeline/parts/renderers/export.js.map +1 -0
- package/x/timeline/parts/{compositor → renderers}/parts/html-tree.js +2 -2
- package/x/timeline/parts/renderers/parts/html-tree.js.map +1 -0
- package/x/timeline/parts/renderers/parts/schedulers.js.map +1 -0
- package/x/timeline/parts/{compositor → renderers}/parts/tree-builder.js +4 -2
- package/x/timeline/parts/renderers/parts/tree-builder.js.map +1 -0
- package/x/timeline/parts/renderers/parts/webcodecs-tree.js.map +1 -0
- package/x/timeline/parts/{compositor → renderers}/playback.d.ts +2 -4
- package/x/timeline/parts/{compositor → renderers}/playback.js +5 -14
- package/x/timeline/parts/renderers/playback.js.map +1 -0
- package/x/timeline/parts/{compositor → renderers}/samplers/html.js +14 -5
- package/x/timeline/parts/renderers/samplers/html.js.map +1 -0
- package/x/timeline/parts/{compositor → renderers}/samplers/webcodecs.js +1 -1
- package/x/timeline/parts/renderers/samplers/webcodecs.js.map +1 -0
- package/x/timeline/parts/resource-pool.d.ts +2 -0
- package/x/timeline/parts/resource-pool.js +7 -4
- package/x/timeline/parts/resource-pool.js.map +1 -1
- package/x/timeline/parts/resource.d.ts +1 -0
- package/x/timeline/sugar/o.d.ts +4 -1
- package/x/timeline/sugar/o.js +4 -2
- package/x/timeline/sugar/o.js.map +1 -1
- package/x/timeline/sugar/omni-test.js +14 -7
- package/x/timeline/sugar/omni-test.js.map +1 -1
- package/x/timeline/sugar/omni.d.ts +1 -2
- package/x/timeline/sugar/omni.js +2 -2
- package/x/timeline/sugar/omni.js.map +1 -1
- package/x/timeline/utils/datafile.d.ts +4 -3
- package/x/timeline/utils/datafile.js +16 -5
- package/x/timeline/utils/datafile.js.map +1 -1
- package/x/timeline/utils/dummy-data.d.ts +1 -2
- package/x/timeline/utils/dummy-data.js +4 -2
- package/x/timeline/utils/dummy-data.js.map +1 -1
- package/x/timeline/parts/compositor/export.js.map +0 -1
- package/x/timeline/parts/compositor/parts/html-tree.js.map +0 -1
- package/x/timeline/parts/compositor/parts/schedulers.js.map +0 -1
- package/x/timeline/parts/compositor/parts/tree-builder.js.map +0 -1
- package/x/timeline/parts/compositor/parts/webcodecs-tree.js.map +0 -1
- package/x/timeline/parts/compositor/playback.js.map +0 -1
- package/x/timeline/parts/compositor/samplers/html.js.map +0 -1
- package/x/timeline/parts/compositor/samplers/webcodecs.js.map +0 -1
- /package/s/timeline/parts/{compositor → renderers}/export.ts +0 -0
- /package/s/timeline/parts/{compositor → renderers}/parts/schedulers.ts +0 -0
- /package/s/timeline/parts/{compositor → renderers}/parts/webcodecs-tree.ts +0 -0
- /package/x/timeline/parts/{compositor → renderers}/export.d.ts +0 -0
- /package/x/timeline/parts/{compositor → renderers}/export.js +0 -0
- /package/x/timeline/parts/{compositor → renderers}/parts/html-tree.d.ts +0 -0
- /package/x/timeline/parts/{compositor → renderers}/parts/schedulers.d.ts +0 -0
- /package/x/timeline/parts/{compositor → renderers}/parts/schedulers.js +0 -0
- /package/x/timeline/parts/{compositor → renderers}/parts/tree-builder.d.ts +0 -0
- /package/x/timeline/parts/{compositor → renderers}/parts/webcodecs-tree.d.ts +0 -0
- /package/x/timeline/parts/{compositor → renderers}/parts/webcodecs-tree.js +0 -0
- /package/x/timeline/parts/{compositor → renderers}/samplers/html.d.ts +0 -0
- /package/x/timeline/parts/{compositor → renderers}/samplers/webcodecs.d.ts +0 -0
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import{a as Ps,b as nt}from"./chunk-TBWCKYN2.js";import{A as ms,Aa as Us,B as gs,Ba as Es,C as rr,D as xs,E as mt,F as it,G as _s,I as E,J as q,O as ys,P as bs,Q as gt,R as Ss,S as j,T as Ts,U as sr,V as ws,W as de,X as Zt,_ as Et,a as Fn,aa as Q,ba as Pt,c as Bn,ca as Gt,d as w,e as lt,ea as fe,f as Ut,fa as Jt,g as W,ga as pe,h as ct,ha as me,i as G,ia as ge,ja as vs,k as rt,ka as Cs,l as D,la as Ms,m as ds,ma as As,n as U,na as xe,o as L,oa as _e,pa as J,q as X,qa as ks,ra as It,sa as zt,t as H,ta as Fs,u as st,ua as Bs,v as tr,va as vt,w as er,wa as xt,x as fs,xa as ye,y as ps,ya as Rs}from"./chunk-LQU5JKKZ.js";var pi=Fn((Ph,fi)=>{fi.exports=Jn;var Ar={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Zn=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function Jn(n){var t=[];return n.replace(Zn,function(e,r,s){var i=r.toLowerCase();for(s=eo(s),i=="m"&&s.length>2&&(t.push([r].concat(s.splice(0,2))),i="l",r=r=="m"?"l":"L");;){if(s.length==Ar[i])return s.unshift(r),t.push(s);if(s.length<Ar[i])throw new Error("malformed path data");t.push([r].concat(s.splice(0,Ar[i])))}}),t}var to=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function eo(n){var t=n.match(to);return t?t.map(Number):[]}});var ir=(n=>(n[n.Low=0]="Low",n[n.Normal=1]="Normal",n[n.High=2]="High",n))(ir||{});function tt(n){if(typeof n!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(n)}`)}function te(n){return n.split("?")[0].split("#")[0]}function Rn(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Un(n,t,e){return n.replace(new RegExp(Rn(t),"g"),e)}function En(n,t){let e="",r=0,s=-1,i=0,o=-1;for(let a=0;a<=n.length;++a){if(a<n.length)o=n.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||i===1))if(s!==a-1&&i===2){if(e.length<2||r!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){let l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",r=0):(e=e.slice(0,l),r=e.length-1-e.lastIndexOf("/")),s=a,i=0;continue}}else if(e.length===2||e.length===1){e="",r=0,s=a,i=0;continue}}t&&(e.length>0?e+="/..":e="..",r=2)}else e.length>0?e+=`/${n.slice(s+1,a)}`:e=n.slice(s+1,a),r=a-s-1;s=a,i=0}else o===46&&i!==-1?++i:i=-1}return e}var Ct={toPosix(n){return Un(n,"\\","/")},isUrl(n){return/^https?:/.test(this.toPosix(n))},isDataUrl(n){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(n)},isBlobUrl(n){return n.startsWith("blob:")},hasProtocol(n){return/^[^/:]+:/.test(this.toPosix(n))},getProtocol(n){tt(n),n=this.toPosix(n);let t=/^file:\/\/\//.exec(n);if(t)return t[0];let e=/^[^/:]+:\/{0,2}/.exec(n);return e?e[0]:""},toAbsolute(n,t,e){if(tt(n),this.isDataUrl(n)||this.isBlobUrl(n))return n;let r=te(this.toPosix(t??j.get().getBaseUrl())),s=te(this.toPosix(e??this.rootname(r)));return n=this.toPosix(n),n.startsWith("/")?Ct.join(s,n.slice(1)):this.isAbsolute(n)?n:this.join(r,n)},normalize(n){if(tt(n),n.length===0)return".";if(this.isDataUrl(n)||this.isBlobUrl(n))return n;n=this.toPosix(n);let t="",e=n.startsWith("/");this.hasProtocol(n)&&(t=this.rootname(n),n=n.slice(t.length));let r=n.endsWith("/");return n=En(n,!1),n.length>0&&r&&(n+="/"),e?`/${n}`:t+n},isAbsolute(n){return tt(n),n=this.toPosix(n),this.hasProtocol(n)?!0:n.startsWith("/")},join(...n){if(n.length===0)return".";let t;for(let e=0;e<n.length;++e){let r=n[e];if(tt(r),r.length>0)if(t===void 0)t=r;else{let s=n[e-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?t+=`/../${r}`:t+=`/${r}`}}return t===void 0?".":this.normalize(t)},dirname(n){if(tt(n),n.length===0)return".";n=this.toPosix(n);let t=n.charCodeAt(0),e=t===47,r=-1,s=!0,i=this.getProtocol(n),o=n;n=n.slice(i.length);for(let a=n.length-1;a>=1;--a)if(t=n.charCodeAt(a),t===47){if(!s){r=a;break}}else s=!1;return r===-1?e?"/":this.isUrl(o)?i+n:i:e&&r===1?"//":i+n.slice(0,r)},rootname(n){tt(n),n=this.toPosix(n);let t="";if(n.startsWith("/")?t="/":t=this.getProtocol(n),this.isUrl(n)){let e=n.indexOf("/",t.length);e!==-1?t=n.slice(0,e):t=n,t.endsWith("/")||(t+="/")}return t},basename(n,t){tt(n),t&&tt(t),n=te(this.toPosix(n));let e=0,r=-1,s=!0,i;if(t!==void 0&&t.length>0&&t.length<=n.length){if(t.length===n.length&&t===n)return"";let o=t.length-1,a=-1;for(i=n.length-1;i>=0;--i){let l=n.charCodeAt(i);if(l===47){if(!s){e=i+1;break}}else a===-1&&(s=!1,a=i+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(r=i):(o=-1,r=a))}return e===r?r=a:r===-1&&(r=n.length),n.slice(e,r)}for(i=n.length-1;i>=0;--i)if(n.charCodeAt(i)===47){if(!s){e=i+1;break}}else r===-1&&(s=!1,r=i+1);return r===-1?"":n.slice(e,r)},extname(n){tt(n),n=te(this.toPosix(n));let t=-1,e=0,r=-1,s=!0,i=0;for(let o=n.length-1;o>=0;--o){let a=n.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}r===-1&&(s=!1,r=o+1),a===46?t===-1?t=o:i!==1&&(i=1):t!==-1&&(i=-1)}return t===-1||r===-1||i===0||i===1&&t===r-1&&t===e+1?"":n.slice(t,r)},parse(n){tt(n);let t={root:"",dir:"",base:"",ext:"",name:""};if(n.length===0)return t;n=te(this.toPosix(n));let e=n.charCodeAt(0),r=this.isAbsolute(n),s,i="";t.root=this.rootname(n),r||this.hasProtocol(n)?s=1:s=0;let o=-1,a=0,l=-1,h=!0,c=n.length-1,u=0;for(;c>=s;--c){if(e=n.charCodeAt(c),e===47){if(!h){a=c+1;break}continue}l===-1&&(h=!1,l=c+1),e===46?o===-1?o=c:u!==1&&(u=1):o!==-1&&(u=-1)}return o===-1||l===-1||u===0||u===1&&o===l-1&&o===a+1?l!==-1&&(a===0&&r?t.base=t.name=n.slice(1,l):t.base=t.name=n.slice(a,l)):(a===0&&r?(t.name=n.slice(1,o),t.base=n.slice(1,l)):(t.name=n.slice(a,o),t.base=n.slice(a,l)),t.ext=n.slice(o,l)),t.dir=this.dirname(n),i&&(t.dir=i+t.dir),t},sep:"/",delimiter:":",joinExtensions:[".html"]};var _t=(n,t,e=!1)=>(Array.isArray(n)||(n=[n]),t?n.map(r=>typeof r=="string"||e?t(r):r):n);function Gs(n,t,e,r,s){let i=t[e];for(let o=0;o<i.length;o++){let a=i[o];e<t.length-1?Gs(n.replace(r[e],a),t,e+1,r,s):s.push(n.replace(r[e],a))}}function Is(n){let t=/\{(.*?)\}/g,e=n.match(t),r=[];if(e){let s=[];e.forEach(i=>{let o=i.substring(1,i.length-1).split(",");s.push(o)}),Gs(n,s,0,e,r)}else r.push(n);return r}var nr=n=>!Array.isArray(n);var ee=class{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{let e=t;this._defaultSearchParams=Object.keys(e).map(r=>`${encodeURIComponent(r)}=${encodeURIComponent(e[r])}`).join("&")}}getAlias(t){let{alias:e,src:r}=t;return _t(e||r,i=>typeof i=="string"?i:Array.isArray(i)?i.map(o=>o?.src??o):i?.src?i.src:i,!0)}addManifest(t){this._manifest&&L("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){let r=[],s=e;Array.isArray(e)||(s=Object.entries(e).map(([i,o])=>typeof o=="string"||Array.isArray(o)?{alias:i,src:o}:{alias:i,...o})),s.forEach(i=>{let o=i.src,a=i.alias,l;if(typeof a=="string"){let h=this._createBundleAssetId(t,a);r.push(h),l=[a,h]}else{let h=a.map(c=>this._createBundleAssetId(t,c));r.push(...h),l=[...a,...h]}this.add({...i,alias:l,src:o})}),this._bundles[t]=r}add(t){let e=[];Array.isArray(t)?e.push(...t):e.push(t);let r;r=i=>{this.hasKey(i)&&L(`[Resolver] already has key: ${i} overwriting`)},_t(e).forEach(i=>{let{src:o}=i,{data:a,format:l,loadParser:h,parser:c}=i,u=_t(o).map(m=>typeof m=="string"?Is(m):Array.isArray(m)?m:[m]),f=this.getAlias(i);Array.isArray(f)?f.forEach(r):r(f);let d=[],p=m=>({...this._parsers.find(g=>g.test(m))?.parse(m),src:m});u.forEach(m=>{m.forEach(x=>{let g={};if(typeof x!="object"?g=p(x):(a=x.data??a,l=x.format??l,(x.loadParser||x.parser)&&(h=x.loadParser??h,c=x.parser??c),g={...p(x.src),...x}),!f)throw new Error(`[Resolver] alias is undefined for this asset: ${g.src}`);g=this._buildResolvedAsset(g,{aliases:f,data:a,format:l,loadParser:h,parser:c,progressSize:i.progressSize}),d.push(g)})}),f.forEach(m=>{this._assetMap[m]=d})})}resolveBundle(t){let e=nr(t);t=_t(t);let r={};return t.forEach(s=>{let i=this._bundles[s];if(i){let o=this.resolve(i),a={};for(let l in o){let h=o[l];a[this._extractAssetIdFromBundle(s,l)]=h}r[s]=a}}),e?r[t[0]]:r}resolveUrl(t){let e=this.resolve(t);if(typeof t!="string"){let r={};for(let s in e)r[s]=e[s].src;return r}return e.src}resolve(t){let e=nr(t);t=_t(t);let r={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let i=this._assetMap[s],o=this._getPreferredOrder(i);o?.priority.forEach(a=>{o.params[a].forEach(l=>{let h=i.filter(c=>c[a]?c[a]===l:!1);h.length&&(i=h)})}),this._resolverHash[s]=i[0]}else this._resolverHash[s]=this._buildResolvedAsset({alias:[s],src:s},{});r[s]=this._resolverHash[s]}),e?r[t[0]]:r}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){let r=t[e],s=this._preferredOrder.find(i=>i.params.format.includes(r.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;let e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){let{aliases:r,data:s,loadParser:i,parser:o,format:a,progressSize:l}=e;return(this._basePath||this._rootPath)&&(t.src=Ct.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=r??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=i??t.loadParser,t.parser=o??t.parser,t.format=a??t.format??Gn(t.src),l!==void 0&&(t.progressSize=l),t}};ee.RETINA_PREFIX=/@([0-9\.]+)x/;function Gn(n){return n.split(".").pop().split("?").shift().split("#").shift()}var or=(n,t)=>{let e=t.split("?")[1];return e&&(n+=`?${e}`),n};var zs=class re{constructor(t,e){this.linkedSheets=[];let r=t;t?.source instanceof it&&(r={texture:t,data:e});let{texture:s,data:i,cachePrefix:o=""}=r;this.cachePrefix=o,this._texture=s instanceof E?s:null,this.textureSource=s.source,this.textures={},this.animations={},this.data=i;let a=parseFloat(i.meta.scale);a?(this.resolution=a,s.source.resolution=this.resolution):this.resolution=s.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<=re.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t,r=re.BATCH_SIZE;for(;e-t<r&&e<this._frameKeys.length;){let s=this._frameKeys[e],i=this._frames[s],o=i.frame;if(o){let a=null,l=null,h=i.trimmed!==!1&&i.sourceSize?i.sourceSize:i.frame,c=new H(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);i.rotated?a=new H(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):a=new H(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),i.trimmed!==!1&&i.spriteSourceSize&&(l=new H(Math.floor(i.spriteSourceSize.x)/this.resolution,Math.floor(i.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new E({source:this.textureSource,frame:a,orig:c,trim:l,rotate:i.rotated?2:0,defaultAnchor:i.anchor,defaultBorders:i.borders,label:s.toString()})}e++}}_processAnimations(){let t=this.data.animations||{};for(let e in t){this.animations[e]=[];for(let r=0;r<t[e].length;r++){let s=t[e][r];this.animations[e].push(this.textures[s])}}}_parseComplete(){let t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*re.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*re.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){for(let e in this.textures)this.textures[e].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};zs.BATCH_SIZE=1e3;var ar=zs;var In=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Ds(n,t,e){let r={};if(n.forEach(s=>{r[s]=t}),Object.keys(t.textures).forEach(s=>{r[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){let s=Ct.dirname(n[0]);t.linkedSheets.forEach((i,o)=>{let a=Ds([`${s}/${t.data.meta.related_multi_packs[o]}`],i,!0);Object.assign(r,a)})}return r}var Ls={extension:w.Asset,cache:{test:n=>n instanceof ar,getCacheableAssets:(n,t)=>Ds(n,t,!1)},resolver:{extension:{type:w.ResolveParser,name:"resolveSpritesheet"},test:n=>{let e=n.split("?")[0].split("."),r=e.pop(),s=e.pop();return r==="json"&&In.includes(s)},parse:n=>{let t=n.split(".");return{resolution:parseFloat(ee.RETINA_PREFIX.exec(n)?.[1]??"1"),format:t[t.length-2],src:n}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:w.LoadParser,priority:ir.Normal,name:"spritesheetLoader"},async testParse(n,t){return Ct.extname(t.src).toLowerCase()===".json"&&!!n.frames},async parse(n,t,e){let{texture:r,imageFilename:s,textureOptions:i,cachePrefix:o}=t?.data??{},a=Ct.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let l;if(r instanceof E)l=r;else{let u=or(a+(s??n.meta.image),t.src);l=(await e.load([{src:u,data:i}]))[u]}let h=new ar({texture:l.source,data:n,cachePrefix:o});await h.parse();let c=n?.meta?.related_multi_packs;if(Array.isArray(c)){let u=[];for(let d of c){if(typeof d!="string")continue;let p=a+d;t.data?.ignoreMultiPack||(p=or(p,t.src),u.push(e.load({src:p,data:{textureOptions:i,ignoreMultiPack:!0}})))}let f=await Promise.all(u);h.linkedSheets=f,f.forEach(d=>{d.linkedSheets=[h].concat(h.linkedSheets.filter(p=>p!==d))})}return h},async unload(n,t,e){await e.unload(n.textureSource._sourceOrigin),n.destroy(!1)}}};lt.add(Ls);var zn=new st;function be(n,t,e){let r=zn;n.measurable=!0,fs(n,e,r),t.addBoundsMask(r),n.measurable=!1}function Se(n,t,e){let r=er.get();n.measurable=!0;let s=tr.get().identity(),i=Ws(n,e,s);ms(n,r,i),n.measurable=!1,t.addBoundsMask(r),tr.return(s),er.return(r)}function Ws(n,t,e){return n?(n!==t&&(Ws(n.parent,t,e),n.updateLocalTransform(),e.append(n.localTransform)),e):(L("Mask bounds, renderable is not inside the root container"),e)}var se=class{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof sr),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,e){this.inverse||be(this.mask,t,e)}addLocalBounds(t,e){Se(this.mask,t,e)}containsPoint(t,e){let r=this.mask;return e(r,t)}destroy(){this.reset()}static test(t){return t instanceof sr}};se.extension=w.MaskEffect;var ie=class{constructor(t){this.priority=0,this.pipe="colorMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}};ie.extension=w.MaskEffect;var ne=class{constructor(t){this.priority=0,this.pipe="stencilMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){be(this.mask,t,e)}addLocalBounds(t,e){Se(this.mask,t,e)}containsPoint(t,e){let r=this.mask;return e(r,t)}destroy(){this.reset()}static test(t){return t instanceof ys}};ne.extension=w.MaskEffect;var ot=class extends it{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}};ot.extension=w.TextureSource;var lr;async function Hs(){return lr??(lr=(async()=>{let t=j.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";let e=await new Promise(o=>{let a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!e)return"premultiply-alpha-on-upload";let r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r);let s=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,s),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);let i=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,i),t.deleteFramebuffer(s),t.deleteTexture(r),t.getExtension("WEBGL_lose_context")?.loseContext(),i[0]<=i[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),lr}var Te=class Os extends it{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Os.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 t=gt.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;let t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await Hs(),this._load=new Promise((r,s)=>{this.isValid?r(this):(this._resolve=r,this._reject=s,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){let t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){let t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();let t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(gt.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||(gt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(gt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Te.extension=w.TextureSource;Te.defaultOptions={...it.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Te.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};var Vs=Te;var cr=class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){let e=this._cache.get(t);return e||L(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){let r=_t(t),s;for(let l=0;l<this.parsers.length;l++){let h=this.parsers[l];if(h.test(e)){s=h.getCacheableAssets(r,e);break}}let i=new Map(Object.entries(s||{}));s||r.forEach(l=>{i.set(l,e)});let o=[...i.keys()],a={cacheKeys:o,keys:r};r.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{let h=s?s[l]:e;this._cache.has(l)&&this._cache.get(l)!==h&&L("[Cache] already has key:",l),this._cache.set(l,i.get(l))})}remove(t){if(!this._cacheMap.has(t)){L(`[Assets] Asset id ${t} was not found in the Cache`);return}let e=this._cacheMap.get(t);e.cacheKeys.forEach(s=>{this._cache.delete(s)}),e.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}},N=new cr;var hr=[];lt.handleByList(w.TextureSource,hr);function Ns(n={}){let t=n&&n.resource,e=t?n.resource:n,r=t?n:{resource:n};for(let s=0;s<hr.length;s++){let i=hr[s];if(i.test(e))return new i(r)}throw new Error(`Could not find a source type for resource: ${r.resource}`)}function Dn(n={},t=!1){let e=n&&n.resource,r=e?n.resource:n,s=e?n:{resource:n};if(!t&&N.has(r))return N.get(r);let i=new E({source:Ns(s)});return i.on("destroy",()=>{N.has(r)&&N.remove(r)}),t||N.set(r,i),i}function Ln(n,t=!1){return typeof n=="string"?N.get(n):n instanceof it?new E({source:n}):Dn(n,t)}E.from=Ln;it.from=Ns;lt.add(se,ie,ne,Vs,ot,ws,_s);var ur=class{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,r;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,r=globalThis.innerHeight;else{let{clientWidth:s,clientHeight:i}=this._resizeTo;e=s,r=i}this.renderer.resize(e,r),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}};ur.extension=w.Application;var dr=class{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,bs.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?gt.shared:new gt,t.autoStart&&this.start()}static destroy(){if(this._ticker){let t=this._ticker;this.ticker=null,t.destroy()}}};dr.extension=w.Application;function js(n,t,e,r,s,i,o,a=null){let l=0;e*=t,s*=i;let h=a.a,c=a.b,u=a.c,f=a.d,d=a.tx,p=a.ty;for(;l<o;){let m=n[e],x=n[e+1];r[s]=h*m+u*x+d,r[s+1]=c*m+f*x+p,s+=i,e+=t,l++}}function qs(n,t,e,r){let s=0;for(t*=e;s<r;)n[t]=0,n[t+1]=0,t+=e,s++}function fr(n,t,e,r,s){let i=t.a,o=t.b,a=t.c,l=t.d,h=t.tx,c=t.ty;e||(e=0),r||(r=2),s||(s=n.length/r-e);let u=e*r;for(let f=0;f<s;f++){let d=n[u],p=n[u+1];n[u]=i*d+a*p+h,n[u+1]=o*d+l*p+c,u+=r}}var Wn=new G,Mt=class{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){let t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,r=this.renderable;return r?ps(e,r.groupColor)+(this.alpha*r.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){return this.renderable?.groupTransform||Wn}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}};var Dt={extension:{type:w.ShapeBuilder,name:"circle"},build(n,t){let e,r,s,i,o,a;if(n.type==="circle"){let T=n;if(o=a=T.radius,o<=0)return!1;e=T.x,r=T.y,s=i=0}else if(n.type==="ellipse"){let T=n;if(o=T.halfWidth,a=T.halfHeight,o<=0||a<=0)return!1;e=T.x,r=T.y,s=i=0}else{let T=n,M=T.width/2,y=T.height/2;e=T.x+M,r=T.y+y,o=a=Math.max(0,Math.min(T.radius,Math.min(M,y))),s=M-o,i=y-a}if(s<0||i<0)return!1;let l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(s?4:0)+(i?4:0);if(h===0)return!1;if(l===0)return t[0]=t[6]=e+s,t[1]=t[3]=r+i,t[2]=t[4]=e-s,t[5]=t[7]=r-i,!0;let c=0,u=l*4+(s?2:0)+2,f=u,d=h,p=s+o,m=i,x=e+p,g=e-p,_=r+m;if(t[c++]=x,t[c++]=_,t[--u]=_,t[--u]=g,i){let T=r-m;t[f++]=g,t[f++]=T,t[--d]=T,t[--d]=x}for(let T=1;T<l;T++){let M=Math.PI/2*(T/l),y=s+Math.cos(M)*o,b=i+Math.sin(M)*a,B=e+y,P=e-y,C=r+b,v=r-b;t[c++]=B,t[c++]=C,t[--u]=C,t[--u]=P,t[f++]=P,t[f++]=v,t[--d]=v,t[--d]=B}p=s,m=i+a,x=e+p,g=e-p,_=r+m;let S=r-m;return t[c++]=x,t[c++]=_,t[--d]=S,t[--d]=x,s&&(t[c++]=g,t[c++]=_,t[--d]=S,t[--d]=g),!0},triangulate(n,t,e,r,s,i){if(n.length===0)return;let o=0,a=0;for(let c=0;c<n.length;c+=2)o+=n[c],a+=n[c+1];o/=n.length/2,a/=n.length/2;let l=r;t[l*e]=o,t[l*e+1]=a;let h=l++;for(let c=0;c<n.length;c+=2)t[l*e]=n[c],t[l*e+1]=n[c+1],c>0&&(s[i++]=l,s[i++]=h,s[i++]=l-1),l++;s[i++]=h+1,s[i++]=h,s[i++]=l-1}},$s={...Dt,extension:{...Dt.extension,name:"ellipse"}},Ys={...Dt,extension:{...Dt.extension,name:"roundedRectangle"}};function Xs(n){let t=n.length;if(t<6)return 1;let e=0;for(let r=0,s=n[t-2],i=n[t-1];r<t;r+=2){let o=n[r],a=n[r+1];e+=(o-s)*(a+i),s=o,i=a}return e<0?-1:1}function Ks(n,t,e,r,s,i,o,a){let l=n-e*s,h=t-r*s,c=n+e*i,u=t+r*i,f,d;o?(f=r,d=-e):(f=-r,d=e);let p=l+f,m=h+d,x=c+f,g=u+d;return a.push(p,m),a.push(x,g),2}function At(n,t,e,r,s,i,o,a){let l=e-n,h=r-t,c=Math.atan2(l,h),u=Math.atan2(s-n,i-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let f=c,d=u-c,p=Math.abs(d),m=Math.sqrt(l*l+h*h),x=(15*p*Math.sqrt(m)/Math.PI>>0)+1,g=d/x;if(f+=g,a){o.push(n,t),o.push(e,r);for(let _=1,S=f;_<x;_++,S+=g)o.push(n,t),o.push(n+Math.sin(S)*m,t+Math.cos(S)*m);o.push(n,t),o.push(s,i)}else{o.push(e,r),o.push(n,t);for(let _=1,S=f;_<x;_++,S+=g)o.push(n+Math.sin(S)*m,t+Math.cos(S)*m),o.push(n,t);o.push(s,i),o.push(n,t)}return x*2}function Qs(n,t,e,r,s,i){let o=1e-4;if(n.length===0)return;let a=t,l=a.alignment;if(t.alignment!==.5){let z=Xs(n);e&&(z*=-1),l=(l-.5)*z+.5}let h=new ct(n[0],n[1]),c=new ct(n[n.length-2],n[n.length-1]),u=r,f=Math.abs(h.x-c.x)<o&&Math.abs(h.y-c.y)<o;if(u){n=n.slice(),f&&(n.pop(),n.pop(),c.set(n[n.length-2],n[n.length-1]));let z=(h.x+c.x)*.5,pt=(c.y+h.y)*.5;n.unshift(z,pt),n.push(z,pt)}let d=s,p=n.length/2,m=n.length,x=d.length/2,g=a.width/2,_=g*g,S=a.miterLimit*a.miterLimit,T=n[0],M=n[1],y=n[2],b=n[3],B=0,P=0,C=-(M-b),v=T-y,R=0,I=0,O=Math.sqrt(C*C+v*v);C/=O,v/=O,C*=g,v*=g;let Rt=l,A=(1-Rt)*2,F=Rt*2;u||(a.cap==="round"?m+=At(T-C*(A-F)*.5,M-v*(A-F)*.5,T-C*A,M-v*A,T+C*F,M+v*F,d,!0)+2:a.cap==="square"&&(m+=Ks(T,M,C,v,A,F,!0,d))),d.push(T-C*A,M-v*A),d.push(T+C*F,M+v*F);for(let z=1;z<p-1;++z){T=n[(z-1)*2],M=n[(z-1)*2+1],y=n[z*2],b=n[z*2+1],B=n[(z+1)*2],P=n[(z+1)*2+1],C=-(M-b),v=T-y,O=Math.sqrt(C*C+v*v),C/=O,v/=O,C*=g,v*=g,R=-(b-P),I=y-B,O=Math.sqrt(R*R+I*I),R/=O,I/=O,R*=g,I*=g;let pt=y-T,Yt=M-b,Xt=y-B,Kt=P-b,ls=pt*Xt+Yt*Kt,ce=Yt*Xt-Kt*pt,Qt=ce<0;if(Math.abs(ce)<.001*Math.abs(ls)){d.push(y-C*A,b-v*A),d.push(y+C*F,b+v*F),ls>=0&&(a.join==="round"?m+=At(y,b,y-C*A,b-v*A,y-R*A,b-I*A,d,!1)+4:m+=2,d.push(y-R*F,b-I*F),d.push(y+R*A,b+I*A));continue}let cs=(-C+T)*(-v+b)-(-C+y)*(-v+M),hs=(-R+B)*(-I+b)-(-R+y)*(-I+P),he=(pt*hs-Xt*cs)/ce,ue=(Kt*cs-Yt*hs)/ce,Je=(he-y)*(he-y)+(ue-b)*(ue-b),bt=y+(he-y)*A,St=b+(ue-b)*A,Tt=y-(he-y)*F,wt=b-(ue-b)*F,An=Math.min(pt*pt+Yt*Yt,Xt*Xt+Kt*Kt),us=Qt?A:F,kn=An+us*us*_;Je<=kn?a.join==="bevel"||Je/_>S?(Qt?(d.push(bt,St),d.push(y+C*F,b+v*F),d.push(bt,St),d.push(y+R*F,b+I*F)):(d.push(y-C*A,b-v*A),d.push(Tt,wt),d.push(y-R*A,b-I*A),d.push(Tt,wt)),m+=2):a.join==="round"?Qt?(d.push(bt,St),d.push(y+C*F,b+v*F),m+=At(y,b,y+C*F,b+v*F,y+R*F,b+I*F,d,!0)+4,d.push(bt,St),d.push(y+R*F,b+I*F)):(d.push(y-C*A,b-v*A),d.push(Tt,wt),m+=At(y,b,y-C*A,b-v*A,y-R*A,b-I*A,d,!1)+4,d.push(y-R*A,b-I*A),d.push(Tt,wt)):(d.push(bt,St),d.push(Tt,wt)):(d.push(y-C*A,b-v*A),d.push(y+C*F,b+v*F),a.join==="round"?Qt?m+=At(y,b,y+C*F,b+v*F,y+R*F,b+I*F,d,!0)+2:m+=At(y,b,y-C*A,b-v*A,y-R*A,b-I*A,d,!1)+2:a.join==="miter"&&Je/_<=S&&(Qt?(d.push(Tt,wt),d.push(Tt,wt)):(d.push(bt,St),d.push(bt,St)),m+=2),d.push(y-R*A,b-I*A),d.push(y+R*F,b+I*F),m+=2)}T=n[(p-2)*2],M=n[(p-2)*2+1],y=n[(p-1)*2],b=n[(p-1)*2+1],C=-(M-b),v=T-y,O=Math.sqrt(C*C+v*v),C/=O,v/=O,C*=g,v*=g,d.push(y-C*A,b-v*A),d.push(y+C*F,b+v*F),u||(a.cap==="round"?m+=At(y-C*(A-F)*.5,b-v*(A-F)*.5,y-C*A,b-v*A,y+C*F,b+v*F,d,!1)+2:a.cap==="square"&&(m+=Ks(y,b,C,v,A,F,!1,d)));let $t=1e-4*1e-4;for(let z=x;z<m+x-2;++z)T=d[z*2],M=d[z*2+1],y=d[(z+1)*2],b=d[(z+1)*2+1],B=d[(z+2)*2],P=d[(z+2)*2+1],!(Math.abs(T*(b-P)+y*(P-M)+B*(M-b))<$t)&&i.push(z,z+1,z+2)}function Zs(n,t,e,r){let s=1e-4;if(n.length===0)return;let i=n[0],o=n[1],a=n[n.length-2],l=n[n.length-1],h=t||Math.abs(i-a)<s&&Math.abs(o-l)<s,c=e,u=n.length/2,f=c.length/2;for(let d=0;d<u;d++)c.push(n[d*2]),c.push(n[d*2+1]);for(let d=0;d<u-1;d++)r.push(f+d,f+d+1);h&&r.push(f+u-1,f)}function we(n,t,e,r,s,i,o){let a=Bs(n,t,2);if(!a)return;for(let h=0;h<a.length;h+=3)i[o++]=a[h]+s,i[o++]=a[h+1]+s,i[o++]=a[h+2]+s;let l=s*r;for(let h=0;h<n.length;h+=2)e[l]=n[h],e[l+1]=n[h+1],l+=r}var Vn=[],Js={extension:{type:w.ShapeBuilder,name:"polygon"},build(n,t){for(let e=0;e<n.points.length;e++)t[e]=n.points[e];return!0},triangulate(n,t,e,r,s,i){we(n,Vn,t,e,r,s,i)}};var ti={extension:{type:w.ShapeBuilder,name:"rectangle"},build(n,t){let e=n,r=e.x,s=e.y,i=e.width,o=e.height;return i>0&&o>0?(t[0]=r,t[1]=s,t[2]=r+i,t[3]=s,t[4]=r+i,t[5]=s+o,t[6]=r,t[7]=s+o,!0):!1},triangulate(n,t,e,r,s,i){let o=0;r*=e,t[r+o]=n[0],t[r+o+1]=n[1],o+=e,t[r+o]=n[2],t[r+o+1]=n[3],o+=e,t[r+o]=n[6],t[r+o+1]=n[7],o+=e,t[r+o]=n[4],t[r+o+1]=n[5],o+=e;let a=r/e;s[i++]=a,s[i++]=a+1,s[i++]=a+2,s[i++]=a+1,s[i++]=a+3,s[i++]=a+2}};var ei={extension:{type:w.ShapeBuilder,name:"triangle"},build(n,t){return t[0]=n.x,t[1]=n.y,t[2]=n.x2,t[3]=n.y2,t[4]=n.x3,t[5]=n.y3,!0},triangulate(n,t,e,r,s,i){let o=0;r*=e,t[r+o]=n[0],t[r+o+1]=n[1],o+=e,t[r+o]=n[2],t[r+o+1]=n[3],o+=e,t[r+o]=n[4],t[r+o+1]=n[5];let a=r/e;s[i++]=a,s[i++]=a+1,s[i++]=a+2}};var ri=[{offset:0,color:"white"},{offset:1,color:"black"}],mr=class pr{constructor(...t){this.uid=rt("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=Nn(t);e={...e.type==="radial"?pr.defaultRadialOptions:pr.defaultLinearOptions,...xs(e)},this._textureSize=e.textureSize,this._wrapMode=e.wrapMode,e.type==="radial"?(this.center=e.center,this.outerCenter=e.outerCenter??this.center,this.innerRadius=e.innerRadius,this.outerRadius=e.outerRadius,this.scale=e.scale,this.rotation=e.rotation):(this.start=e.start,this.end=e.end),this.textureSpace=e.textureSpace,this.type=e.type,e.colorStops.forEach(s=>{this.addColorStop(s.offset,s.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:W.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:r,y:s}=this.end,i=r-t,o=s-e,a=i<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(i<0){let x=t;t=r,r=x,i*=-1}if(o<0){let x=e;e=s,s=x,o*=-1}}let l=this.colorStops.length?this.colorStops:ri,h=this._textureSize,{canvas:c,context:u}=ii(h,1),f=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);si(f,l),u.fillStyle=f,u.fillRect(0,0,h,1),this.texture=new E({source:new ot({resource:c,addressMode:this._wrapMode})});let d=Math.sqrt(i*i+o*o),p=Math.atan2(o,i),m=new G;m.scale(d/h,1),m.rotate(p),m.translate(t,e),this.textureSpace==="local"&&m.scale(h,h),this.transform=m}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;let t=this.colorStops.length?this.colorStops:ri,e=this._textureSize,{canvas:r,context:s}=ii(e,e),{x:i,y:o}=this.center,{x:a,y:l}=this.outerCenter,h=this.innerRadius,c=this.outerRadius,u=a-c,f=l-c,d=e/(c*2),p=(i-u)*d,m=(o-f)*d,x=s.createRadialGradient(p,m,h*d,(a-u)*d,(l-f)*d,c*d);si(x,t),s.fillStyle=t[t.length-1].color,s.fillRect(0,0,e,e),s.fillStyle=x,s.translate(p,m),s.rotate(this.rotation),s.scale(1,this.scale),s.translate(-p,-m),s.fillRect(0,0,e,e),this.texture=new E({source:new ot({resource:r,addressMode:this._wrapMode})});let g=new G;g.scale(1/d,1/d),g.translate(u,f),this.textureSpace==="local"&&g.scale(e,e),this.transform=g}destroy(){this.texture?.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};mr.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};mr.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};var $=mr;function si(n,t){for(let e=0;e<t.length;e++){let r=t[e];n.addColorStop(r.offset,r.color)}}function ii(n,t){let e=j.get().createCanvas(n,t),r=e.getContext("2d");return{canvas:e,context:r}}function Nn(n){let t=n[0]??{};return(typeof t=="number"||n[1])&&(U("8.5.2","use options object instead"),t={type:"linear",start:{x:n[0],y:n[1]},end:{x:n[2],y:n[3]},textureSpace:n[4],textureSize:n[5]??$.defaultLinearOptions.textureSize}),t}var jn=new G,qn=new H;function ni(n,t,e,r){let s=t.matrix?n.copyFrom(t.matrix).invert():n.identity();if(t.textureSpace==="local"){let o=e.getBounds(qn);t.width&&o.pad(t.width);let{x:a,y:l}=o,h=1/o.width,c=1/o.height,u=-a*h,f=-l*c,d=s.a,p=s.b,m=s.c,x=s.d;s.a*=h,s.b*=h,s.c*=c,s.d*=c,s.tx=u*d+f*m+s.tx,s.ty=u*p+f*x+s.ty}else s.translate(t.texture.frame.x,t.texture.frame.y),s.scale(1/t.texture.source.width,1/t.texture.source.height);let i=t.texture.source.style;return!(t.fill instanceof $)&&i.addressMode==="clamp-to-edge"&&(i.addressMode="repeat",i.update()),r&&s.append(jn.copyFrom(r).invert()),s}var Pe={};lt.handleByMap(w.ShapeBuilder,Pe);lt.add(ti,Js,ei,Dt,$s,Ys);var $n=new H,Yn=new G;function ai(n,t){let{geometryData:e,batches:r}=t;r.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let s=0;s<n.instructions.length;s++){let i=n.instructions[s];if(i.action==="texture")Xn(i.data,r,e);else if(i.action==="fill"||i.action==="stroke"){let o=i.action==="stroke",a=i.data.path.shapePath,l=i.data.style,h=i.data.hole;o&&h&&oi(h.shapePath,l,!0,r,e),h&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=h.shapePath.shapePrimitives),oi(a,l,o,r,e)}}}function Xn(n,t,e){let r=[],s=Pe.rectangle,i=$n;i.x=n.dx,i.y=n.dy,i.width=n.dw,i.height=n.dh;let o=n.transform;if(!s.build(i,r))return;let{vertices:a,uvs:l,indices:h}=e,c=h.length,u=a.length/2;o&&fr(r,o),s.triangulate(r,a,2,u,h,c);let f=n.image,d=f.uvs;l.push(d.x0,d.y0,d.x1,d.y1,d.x3,d.y3,d.x2,d.y2);let p=X.get(Mt);p.indexOffset=c,p.indexSize=h.length-c,p.attributeOffset=u,p.attributeSize=a.length/2-u,p.baseColor=n.style,p.alpha=n.alpha,p.texture=f,p.geometryData=e,t.push(p)}function oi(n,t,e,r,s){let{vertices:i,uvs:o,indices:a}=s;n.shapePrimitives.forEach(({shape:l,transform:h,holes:c})=>{let u=[],f=Pe[l.type];if(!f.build(l,u))return;let d=a.length,p=i.length/2,m="triangle-list";if(h&&fr(u,h),e){let S=l.closePath??!0,T=t;T.pixelLine?(Zs(u,S,i,a),m="line-list"):Qs(u,T,!1,S,i,a)}else if(c){let S=[],T=u.slice();Kn(c).forEach(y=>{S.push(T.length/2),T.push(...y)}),we(T,S,i,2,p,a,d)}else f.triangulate(u,i,2,p,a,d);let x=o.length/2,g=t.texture;if(g!==E.WHITE){let S=ni(Yn,t,l,h);js(i,2,p,o,x,2,i.length/2-p,S)}else qs(o,x,2,i.length/2-p);let _=X.get(Mt);_.indexOffset=d,_.indexSize=a.length-d,_.attributeOffset=p,_.attributeSize=i.length/2-p,_.baseColor=t.color,_.alpha=t.alpha,_.texture=g,_.geometryData=s,_.topology=m,r.push(_)})}function Kn(n){let t=[];for(let e=0;e<n.length;e++){let r=n[e].shape,s=[];Pe[r.type].build(r,s)&&t.push(s)}return t}var gr=class{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}},xr=class{constructor(){this.instructions=new gs}init(t){let e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Fs({maxTextures:e}),this.instructions.reset()}get geometry(){return U(ds,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}},yr=class _r{constructor(t){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null),this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuContextHash"),t.renderableGC.addManagedHash(this,"_graphicsDataContextHash")}init(t){_r.defaultOptions.bezierSmoothness=t?.bezierSmoothness??_r.defaultOptions.bezierSmoothness}getContextRenderData(t){return this._graphicsDataContextHash[t.uid]||this._initContextRenderData(t)}updateGpuContext(t){let e=this._gpuContextHash[t.uid]||this._initContext(t);if(t.dirty){e?this._cleanGraphicsContextData(t):e=this._initContext(t),ai(t,e);let r=t.batchMode;t.customShader||r==="no-batch"?e.isBatchable=!1:r==="auto"?e.isBatchable=e.geometryData.vertices.length<400:e.isBatchable=!0,t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){let e=X.get(xr,{maxTextures:this._renderer.limits.maxBatchableTextures}),{batches:r,geometryData:s}=this._gpuContextHash[t.uid],i=s.vertices.length,o=s.indices.length;for(let c=0;c<r.length;c++)r[c].applyTransform=!1;let a=e.batcher;a.ensureAttributeBuffer(i),a.ensureIndexBuffer(o),a.begin();for(let c=0;c<r.length;c++){let u=r[c];a.add(u)}a.finish(e.instructions);let l=a.geometry;l.indexBuffer.setDataWithSize(a.indexBuffer,a.indexSize,!0),l.buffers[0].setDataWithSize(a.attributeBuffer.float32View,a.attributeSize,!0);let h=a.batches;for(let c=0;c<h.length;c++){let u=h[c];u.bindGroup=Ps(u.textures.textures,u.textures.count,this._renderer.limits.maxBatchableTextures)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){let e=new gr;return e.context=t,this._gpuContextHash[t.uid]=e,t.on("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]}onGraphicsContextDestroy(t){this._cleanGraphicsContextData(t),t.off("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]=null}_cleanGraphicsContextData(t){let e=this._gpuContextHash[t.uid];e.isBatchable||this._graphicsDataContextHash[t.uid]&&(X.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(r=>{X.return(r)})}destroy(){for(let t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context);this._gpuContextHash={},this._graphicsDataContextHash={},this._renderer=null}};yr.extension={type:[w.WebGLSystem,w.WebGPUSystem,w.CanvasSystem],name:"graphicsContext"};yr.defaultOptions={bezierSmoothness:.5};var ve=yr;var br=class{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{X.return(t)}),this.batches.length=0}},Sr=class{constructor(t,e){this.state=vt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this)}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){let e=t.context,r=!!t._gpuData,s=this.renderer.graphicsContext.updateGpuContext(e);return!!(s.isBatchable||r!==s.isBatchable)}addRenderable(t,e){let r=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),r.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){let r=this._getGpuDataForRenderable(t).batches;for(let s=0;s<r.length;s++){let i=r[s];i._batcher.updateElement(i)}}execute(t){if(!t.isRenderable)return;let e=this.renderer,r=t.context;if(!e.graphicsContext.getGpuContext(r).batches.length)return;let i=r.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;let o=i.resources.localUniforms.uniforms;o.uTransformMatrix=t.groupTransform,o.uRound=e._roundPixels|t._roundPixels,xt(t.groupColorAlpha,o.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){let e=this._getGpuDataForRenderable(t),r=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),r.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){let r=this.renderer.renderPipes.batch,s=this._getGpuDataForRenderable(t).batches;for(let i=0;i<s.length;i++){let o=s[i];r.addToBatch(o,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){let e=new br;return t._gpuData[this.renderer.uid]=e,e}_updateBatchesForRenderable(t,e){let r=t.context,s=this.renderer.graphicsContext.getGpuContext(r),i=this.renderer._roundPixels|t._roundPixels;e.batches=s.batches.map(o=>{let a=X.get(Mt);return o.copyTo(a),a.renderable=t,a.roundPixels=i,a})}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}};Sr.extension={type:[w.WebGLPipes,w.WebGPUPipes,w.CanvasPipes],name:"graphics"};var yt=class{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(t){this._topology=t}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(t){this.texture!==t&&(this.texture=t,this._textureMatrixUpdateId=-1)}get uvs(){let e=this.geometry.getBuffer("aUV"),r=e.data,s=r,i=this.texture.textureMatrix;return i.isSimple||(s=this._transformedUvs,(this._textureMatrixUpdateId!==i._updateID||this._uvUpdateId!==e._updateID)&&((!s||s.length<r.length)&&(s=this._transformedUvs=new Float32Array(r.length)),this._textureMatrixUpdateId=i._updateID,this._uvUpdateId=e._updateID,i.multiplyUvs(r,s))),s}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}};var Ce=class{destroy(){}},Tr=class{constructor(t,e){this.localUniforms=new J({uTransformMatrix:{value:new G,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new de({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){let e=this._getMeshData(t),r=e.batched,s=t.batched;if(e.batched=s,r!==s)return!0;if(s){let i=t._geometry;if(i.indices.length!==e.indexSize||i.positions.length!==e.vertexSize)return e.indexSize=i.indices.length,e.vertexSize=i.positions.length,!0;let o=this._getBatchableMesh(t);return o.texture.uid!==t._texture.uid&&(o._textureMatrixUpdateId=-1),!o._batcher.checkAndUpdateTexture(o,t._texture)}return!1}addRenderable(t,e){let r=this.renderer.renderPipes.batch,s=this._getMeshData(t);if(t.didViewUpdate&&(s.indexSize=t._geometry.indices?.length,s.vertexSize=t._geometry.positions?.length),s.batched){let i=this._getBatchableMesh(t);i.setTexture(t._texture),i.geometry=t._geometry,r.addToBatch(i,e)}else r.break(e),e.add(t)}updateRenderable(t){if(t.batched){let e=this._getBatchableMesh(t);e.setTexture(t._texture),e.geometry=t._geometry,e._batcher.updateElement(e)}}execute(t){if(!t.isRenderable)return;t.state.blendMode=Et(t.groupBlendMode,t.texture._source);let e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),xt(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){var e,r;return(e=t._gpuData)[r=this.renderer.uid]||(e[r]=new Ce),t._gpuData[this.renderer.uid].meshData||this._initMeshData(t)}_initMeshData(t){return t._gpuData[this.renderer.uid].meshData={batched:t.batched,indexSize:0,vertexSize:0},t._gpuData[this.renderer.uid].meshData}_getBatchableMesh(t){var e,r;return(e=t._gpuData)[r=this.renderer.uid]||(e[r]=new Ce),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){let e=new yt;return e.renderable=t,e.setTexture(t._texture),e.transform=t.groupTransform,e.roundPixels=this.renderer._roundPixels|t._roundPixels,t._gpuData[this.renderer.uid].batchableMesh=e,e}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}};Tr.extension={type:[w.WebGLPipes,w.WebGPUPipes,w.CanvasPipes],name:"mesh"};var Me=class{execute(t,e){let r=t.state,s=t.renderer,i=e.shader||t.defaultShader;i.resources.uTexture=e.texture._source,i.resources.uniforms=t.localUniforms;let o=s.gl,a=t.getBuffers(e);s.shader.bind(i),s.state.set(r),s.geometry.bind(a.geometry,i.glProgram);let h=a.geometry.indexBuffer.data.BYTES_PER_ELEMENT===2?o.UNSIGNED_SHORT:o.UNSIGNED_INT;o.drawElements(o.TRIANGLES,e.particleChildren.length*6,h,0)}};function wr(n,t=null){let e=n*6;if(e>65535?t||(t=new Uint32Array(e)):t||(t=new Uint16Array(e)),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let r=0,s=0;r<e;r+=6,s+=4)t[r+0]=s+0,t[r+1]=s+1,t[r+2]=s+2,t[r+3]=s+0,t[r+4]=s+2,t[r+5]=s+3;return t}function ci(n){return{dynamicUpdate:li(n,!0),staticUpdate:li(n,!1)}}function li(n,t){let e=[];e.push(`
|
|
2
|
+
|
|
3
|
+
var index = 0;
|
|
4
|
+
|
|
5
|
+
for (let i = 0; i < ps.length; ++i)
|
|
6
|
+
{
|
|
7
|
+
const p = ps[i];
|
|
8
|
+
|
|
9
|
+
`);let r=0;for(let i in n){let o=n[i];if(t!==o.dynamic)continue;e.push(`offset = index + ${r}`),e.push(o.code);let a=Jt(o.format);r+=a.stride/4}e.push(`
|
|
10
|
+
index += stride * 4;
|
|
11
|
+
}
|
|
12
|
+
`),e.unshift(`
|
|
13
|
+
var stride = ${r};
|
|
14
|
+
`);let s=e.join(`
|
|
15
|
+
`);return new Function("ps","f32v","u32v",s)}var Ae=class{constructor(t){this._size=0,this._generateParticleUpdateCache={};let e=this._size=t.size??1e3,r=t.properties,s=0,i=0;for(let c in r){let u=r[c],f=Jt(u.format);u.dynamic?i+=f.stride:s+=f.stride}this._dynamicStride=i/4,this._staticStride=s/4,this.staticAttributeBuffer=new Zt(e*4*s),this.dynamicAttributeBuffer=new Zt(e*4*i),this.indexBuffer=wr(e);let o=new Gt,a=0,l=0;this._staticBuffer=new Pt({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:Q.VERTEX|Q.COPY_DST}),this._dynamicBuffer=new Pt({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:Q.VERTEX|Q.COPY_DST});for(let c in r){let u=r[c],f=Jt(u.format);u.dynamic?(o.addAttribute(u.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:a*4,format:u.format}),a+=f.size):(o.addAttribute(u.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:l*4,format:u.format}),l+=f.size)}o.addIndex(this.indexBuffer);let h=this.getParticleUpdate(r);this._dynamicUpload=h.dynamicUpdate,this._staticUpload=h.staticUpdate,this.geometry=o}getParticleUpdate(t){let e=Qn(t);return this._generateParticleUpdateCache[e]?this._generateParticleUpdateCache[e]:(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t),this._generateParticleUpdateCache[e])}generateParticleUpdate(t){return ci(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new Zt(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new Zt(this._size*this._dynamicStride*4*4),this.indexBuffer=wr(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));let r=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,r.float32View,r.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){let s=this.staticAttributeBuffer;this._staticUpload(t,s.float32View,s.uint32View),this._staticBuffer.setDataWithSize(s.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}};function Qn(n){let t=[];for(let e in n){let r=n[e];t.push(e,r.code,r.dynamic?"d":"s")}return t.join("_")}var hi=`varying vec2 vUV;
|
|
16
|
+
varying vec4 vColor;
|
|
17
|
+
|
|
18
|
+
uniform sampler2D uTexture;
|
|
19
|
+
|
|
20
|
+
void main(void){
|
|
21
|
+
vec4 color = texture2D(uTexture, vUV) * vColor;
|
|
22
|
+
gl_FragColor = color;
|
|
23
|
+
}`;var ui=`attribute vec2 aVertex;
|
|
24
|
+
attribute vec2 aUV;
|
|
25
|
+
attribute vec4 aColor;
|
|
26
|
+
|
|
27
|
+
attribute vec2 aPosition;
|
|
28
|
+
attribute float aRotation;
|
|
29
|
+
|
|
30
|
+
uniform mat3 uTranslationMatrix;
|
|
31
|
+
uniform float uRound;
|
|
32
|
+
uniform vec2 uResolution;
|
|
33
|
+
uniform vec4 uColor;
|
|
34
|
+
|
|
35
|
+
varying vec2 vUV;
|
|
36
|
+
varying vec4 vColor;
|
|
37
|
+
|
|
38
|
+
vec2 roundPixels(vec2 position, vec2 targetSize)
|
|
39
|
+
{
|
|
40
|
+
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void main(void){
|
|
44
|
+
float cosRotation = cos(aRotation);
|
|
45
|
+
float sinRotation = sin(aRotation);
|
|
46
|
+
float x = aVertex.x * cosRotation - aVertex.y * sinRotation;
|
|
47
|
+
float y = aVertex.x * sinRotation + aVertex.y * cosRotation;
|
|
48
|
+
|
|
49
|
+
vec2 v = vec2(x, y);
|
|
50
|
+
v = v + aPosition;
|
|
51
|
+
|
|
52
|
+
gl_Position = vec4((uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
|
|
53
|
+
|
|
54
|
+
if(uRound == 1.0)
|
|
55
|
+
{
|
|
56
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
vUV = aUV;
|
|
60
|
+
vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;
|
|
61
|
+
}
|
|
62
|
+
`;var Pr=`
|
|
63
|
+
struct ParticleUniforms {
|
|
64
|
+
uTranslationMatrix:mat3x3<f32>,
|
|
65
|
+
uColor:vec4<f32>,
|
|
66
|
+
uRound:f32,
|
|
67
|
+
uResolution:vec2<f32>,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
|
|
71
|
+
{
|
|
72
|
+
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;
|
|
76
|
+
|
|
77
|
+
@group(1) @binding(0) var uTexture: texture_2d<f32>;
|
|
78
|
+
@group(1) @binding(1) var uSampler : sampler;
|
|
79
|
+
|
|
80
|
+
struct VSOutput {
|
|
81
|
+
@builtin(position) position: vec4<f32>,
|
|
82
|
+
@location(0) uv : vec2<f32>,
|
|
83
|
+
@location(1) color : vec4<f32>,
|
|
84
|
+
};
|
|
85
|
+
@vertex
|
|
86
|
+
fn mainVertex(
|
|
87
|
+
@location(0) aVertex: vec2<f32>,
|
|
88
|
+
@location(1) aPosition: vec2<f32>,
|
|
89
|
+
@location(2) aUV: vec2<f32>,
|
|
90
|
+
@location(3) aColor: vec4<f32>,
|
|
91
|
+
@location(4) aRotation: f32,
|
|
92
|
+
) -> VSOutput {
|
|
93
|
+
|
|
94
|
+
let v = vec2(
|
|
95
|
+
aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation),
|
|
96
|
+
aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)
|
|
97
|
+
) + aPosition;
|
|
98
|
+
|
|
99
|
+
var position = vec4((uniforms.uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
|
|
100
|
+
|
|
101
|
+
if(uniforms.uRound == 1.0) {
|
|
102
|
+
position = vec4(roundPixels(position.xy, uniforms.uResolution), position.zw);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;
|
|
106
|
+
|
|
107
|
+
return VSOutput(
|
|
108
|
+
position,
|
|
109
|
+
aUV,
|
|
110
|
+
vColor,
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@fragment
|
|
115
|
+
fn mainFragment(
|
|
116
|
+
@location(0) uv: vec2<f32>,
|
|
117
|
+
@location(1) color: vec4<f32>,
|
|
118
|
+
@builtin(position) position: vec4<f32>,
|
|
119
|
+
) -> @location(0) vec4<f32> {
|
|
120
|
+
|
|
121
|
+
var sample = textureSample(uTexture, uSampler, uv) * color;
|
|
122
|
+
|
|
123
|
+
return sample;
|
|
124
|
+
}`;var ke=class extends zt{constructor(){let t=fe.from({vertex:ui,fragment:hi}),e=pe.from({fragment:{source:Pr,entryPoint:"mainFragment"},vertex:{source:Pr,entryPoint:"mainVertex"}});super({glProgram:t,gpuProgram:e,resources:{uTexture:E.WHITE.source,uSampler:new mt({}),uniforms:{uTranslationMatrix:{value:new G,type:"mat3x3<f32>"},uColor:{value:new W(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}};var Lt=class{constructor(t,e){this.state=vt.for2d(),this.localUniforms=new J({uTranslationMatrix:{value:new G,type:"mat3x3<f32>"},uColor:{value:new Float32Array(4),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new ke,this.state=vt.for2d()}validateRenderable(t){return!1}addRenderable(t,e){this.renderer.renderPipes.batch.break(e),e.add(t)}getBuffers(t){return t._gpuData[this.renderer.uid]||this._initBuffer(t)}_initBuffer(t){return t._gpuData[this.renderer.uid]=new Ae({size:t.particleChildren.length,properties:t._properties}),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){let e=t.particleChildren;if(e.length===0)return;let r=this.renderer,s=this.getBuffers(t);t.texture||(t.texture=e[0].texture);let i=this.state;s.update(e,t._childrenDirty),t._childrenDirty=!1,i.blendMode=Et(t.blendMode,t.texture._source);let o=this.localUniforms.uniforms,a=o.uTranslationMatrix;t.worldTransform.copyTo(a),a.prepend(r.globalUniforms.globalUniformData.projectionMatrix),o.uResolution=r.globalUniforms.globalUniformData.resolution,o.uRound=r._roundPixels|t._roundPixels,xt(t.groupColorAlpha,o.uColor,0),this.adaptor.execute(this,t)}destroy(){this.renderer=null,this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}};var vr=class extends Lt{constructor(t){super(t,new Me)}};vr.extension={type:[w.WebGLPipes],name:"particle"};var Fe=class{execute(t,e){let r=t.renderer,s=e.shader||t.defaultShader;s.groups[0]=r.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),s.groups[1]=r.texture.getTextureBindGroup(e.texture);let i=t.state,o=t.getBuffers(e);r.encoder.draw({geometry:o.geometry,shader:e.shader||t.defaultShader,state:i,size:e.particleChildren.length*6})}};var Cr=class extends Lt{constructor(t){super(t,new Fe)}};Cr.extension={type:[w.WebGPUPipes],name:"particle"};function oe(n,t){let{texture:e,bounds:r}=n,s=t._style._getFinalPadding();Ts(r,t._anchor,e);let i=t._anchor._x*s*2,o=t._anchor._y*s*2;r.minX-=s-i,r.minY-=s-o,r.maxX-=s-i,r.maxY-=s-o}var Be=class extends ye{constructor(t){super(),this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){let t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){let{canvasText:t}=this._renderer;t.getReferenceCount(this.currentKey)>0?t.decreaseReferenceCount(this.currentKey):this.texture&&t.returnTexture(this.texture),this._renderer.runners.resolutionChange.remove(this),this._renderer=null}};var Mr=class{constructor(t){this._renderer=t}validateRenderable(t){let e=this._getGpuText(t),r=t.styleKey;return e.currentKey!==r?!0:t._didTextUpdate}addRenderable(t,e){let r=this._getGpuText(t);if(t._didTextUpdate){let s=t._autoResolution?this._renderer.resolution:t.resolution;(r.currentKey!==t.styleKey||t.resolution!==s)&&this._updateGpuText(t),t._didTextUpdate=!1,oe(r,t)}this._renderer.renderPipes.batch.addToBatch(r,e)}updateRenderable(t){let e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){let e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){let e=new Be(this._renderer);return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}};Mr.extension={type:[w.WebGLPipes,w.WebGPUPipes,w.CanvasPipes],name:"text"};var di={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"}},ht=class{constructor(t,e){this.uid=rt("fillPattern"),this._tick=0,this.transform=new G,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=di[e].addressModeU,t.source.style.addressModeV=di[e].addressModeV)}setTransform(t){let e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._tick++}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}};var mi=Bn(pi(),1);function gi(n,t){let e=(0,mi.default)(n),r=[],s=null,i=0,o=0;for(let a=0;a<e.length;a++){let l=e[a],h=l[0],c=l;switch(h){case"M":i=c[1],o=c[2],t.moveTo(i,o);break;case"m":i+=c[1],o+=c[2],t.moveTo(i,o);break;case"H":i=c[1],t.lineTo(i,o);break;case"h":i+=c[1],t.lineTo(i,o);break;case"V":o=c[1],t.lineTo(i,o);break;case"v":o+=c[1],t.lineTo(i,o);break;case"L":i=c[1],o=c[2],t.lineTo(i,o);break;case"l":i+=c[1],o+=c[2],t.lineTo(i,o);break;case"C":i=c[5],o=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],i,o);break;case"c":t.bezierCurveTo(i+c[1],o+c[2],i+c[3],o+c[4],i+c[5],o+c[6]),i+=c[5],o+=c[6];break;case"S":i=c[3],o=c[4],t.bezierCurveToShort(c[1],c[2],i,o);break;case"s":t.bezierCurveToShort(i+c[1],o+c[2],i+c[3],o+c[4]),i+=c[3],o+=c[4];break;case"Q":i=c[3],o=c[4],t.quadraticCurveTo(c[1],c[2],i,o);break;case"q":t.quadraticCurveTo(i+c[1],o+c[2],i+c[3],o+c[4]),i+=c[3],o+=c[4];break;case"T":i=c[1],o=c[2],t.quadraticCurveToShort(i,o);break;case"t":i+=c[1],o+=c[2],t.quadraticCurveToShort(i,o);break;case"A":i=c[6],o=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],i,o);break;case"a":i+=c[6],o+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],i,o);break;case"Z":case"z":t.closePath(),r.length>0&&(s=r.pop(),s?(i=s.startX,o=s.startY):(i=0,o=0)),s=null;break;default:L(`Unknown SVG path command: ${h}`)}h!=="Z"&&h!=="z"&&s===null&&(s={startX:i,startY:o},r.push(s))}return t}var Re=class n{constructor(t=0,e=0,r=0){this.type="circle",this.x=t,this.y=e,this.radius=r}clone(){return new n(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;let r=this.radius*this.radius,s=this.x-t,i=this.y-e;return s*=s,i*=i,s+i<=r}strokeContains(t,e,r,s=.5){if(this.radius===0)return!1;let i=this.x-t,o=this.y-e,a=this.radius,l=(1-s)*r,h=Math.sqrt(i*i+o*o);return h<=a+l&&h>a-(r-l)}getBounds(t){return t||(t=new H),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}};var Ue=class n{constructor(t=0,e=0,r=0,s=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=r,this.halfHeight=s}clone(){return new n(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let r=(t-this.x)/this.halfWidth,s=(e-this.y)/this.halfHeight;return r*=r,s*=s,r+s<=1}strokeContains(t,e,r,s=.5){let{halfWidth:i,halfHeight:o}=this;if(i<=0||o<=0)return!1;let a=r*(1-s),l=r-a,h=i-l,c=o-l,u=i+a,f=o+a,d=t-this.x,p=e-this.y,m=d*d/(h*h)+p*p/(c*c),x=d*d/(u*u)+p*p/(f*f);return m>1&&x<=1}getBounds(t){return t||(t=new H),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}};function xi(n,t,e,r,s,i){let o=n-e,a=t-r,l=s-e,h=i-r,c=o*l+a*h,u=l*l+h*h,f=-1;u!==0&&(f=c/u);let d,p;f<0?(d=e,p=r):f>1?(d=s,p=i):(d=e+f*l,p=r+f*h);let m=n-d,x=t-p;return m*m+x*x}var ro,so,Wt=class n{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){let r=[];for(let s=0,i=e.length;s<i;s++)r.push(e[s].x,e[s].y);e=r}this.points=e,this.closePath=!0}isClockwise(){let t=0,e=this.points,r=e.length;for(let s=0;s<r;s+=2){let i=e[s],o=e[s+1],a=e[(s+2)%r],l=e[(s+3)%r];t+=(a-i)*(l+o)}return t<0}containsPolygon(t){let e=this.getBounds(ro),r=t.getBounds(so);if(!e.containsRect(r))return!1;let s=t.points;for(let i=0;i<s.length;i+=2){let o=s[i],a=s[i+1];if(!this.contains(o,a))return!1}return!0}clone(){let t=this.points.slice(),e=new n(t);return e.closePath=this.closePath,e}contains(t,e){let r=!1,s=this.points.length/2;for(let i=0,o=s-1;i<s;o=i++){let a=this.points[i*2],l=this.points[i*2+1],h=this.points[o*2],c=this.points[o*2+1];l>e!=c>e&&t<(h-a)*((e-l)/(c-l))+a&&(r=!r)}return r}strokeContains(t,e,r,s=.5){let i=r*r,o=i*(1-s),a=i-o,{points:l}=this,h=l.length-(this.closePath?0:2);for(let c=0;c<h;c+=2){let u=l[c],f=l[c+1],d=l[(c+2)%l.length],p=l[(c+3)%l.length],m=xi(t,e,u,f,d,p),x=Math.sign((d-u)*(e-f)-(p-f)*(t-u));if(m<=(x<0?a:o))return!0}return!1}getBounds(t){t||(t=new H);let e=this.points,r=1/0,s=-1/0,i=1/0,o=-1/0;for(let a=0,l=e.length;a<l;a+=2){let h=e[a],c=e[a+1];r=h<r?h:r,s=h>s?h:s,i=c<i?c:i,o=c>o?c:o}return t.x=r,t.width=s-r,t.y=i,t.height=o-i,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return U("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return U("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}};var Ee=(n,t,e,r,s,i,o)=>{let a=n-e,l=t-r,h=Math.sqrt(a*a+l*l);return h>=s-i&&h<=s+o},Ge=class n{constructor(t=0,e=0,r=0,s=0,i=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=r,this.height=s,this.radius=i}getBounds(t){return t||(t=new H),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new n(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){let r=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+r&&e<=this.y+this.height-r||t>=this.x+r&&t<=this.x+this.width-r)return!0;let s=t-(this.x+r),i=e-(this.y+r),o=r*r;if(s*s+i*i<=o||(s=t-(this.x+this.width-r),s*s+i*i<=o)||(i=e-(this.y+this.height-r),s*s+i*i<=o)||(s=t-(this.x+r),s*s+i*i<=o))return!0}return!1}strokeContains(t,e,r,s=.5){let{x:i,y:o,width:a,height:l,radius:h}=this,c=r*(1-s),u=r-c,f=i+h,d=o+h,p=a-h*2,m=l-h*2,x=i+a,g=o+l;return(t>=i-c&&t<=i+u||t>=x-u&&t<=x+c)&&e>=d&&e<=d+m||(e>=o-c&&e<=o+u||e>=g-u&&e<=g+c)&&t>=f&&t<=f+p?!0:t<f&&e<d&&Ee(t,e,f,d,h,u,c)||t>x-h&&e<d&&Ee(t,e,x-h,d,h,u,c)||t>x-h&&e>g-h&&Ee(t,e,x-h,g-h,h,u,c)||t<f&&e>g-h&&Ee(t,e,f,g-h,h,u,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}};var io=8,Ie=11920929e-14,no=1,kr=.01,Ht=0,kt=0;function ze(n,t,e,r,s,i,o,a,l,h){let u=Math.min(.99,Math.max(0,h??ve.defaultOptions.bezierSmoothness)),f=(no-u)/1;return f*=f,oo(t,e,r,s,i,o,a,l,n,f),n}function oo(n,t,e,r,s,i,o,a,l,h){Fr(n,t,e,r,s,i,o,a,l,h,0),l.push(o,a)}function Fr(n,t,e,r,s,i,o,a,l,h,c){if(c>io)return;let u=Math.PI,f=(n+e)/2,d=(t+r)/2,p=(e+s)/2,m=(r+i)/2,x=(s+o)/2,g=(i+a)/2,_=(f+p)/2,S=(d+m)/2,T=(p+x)/2,M=(m+g)/2,y=(_+T)/2,b=(S+M)/2;if(c>0){let B=o-n,P=a-t,C=Math.abs((e-o)*P-(r-a)*B),v=Math.abs((s-o)*P-(i-a)*B),R,I;if(C>Ie&&v>Ie){if((C+v)*(C+v)<=h*(B*B+P*P)){if(Ht<kr){l.push(y,b);return}let O=Math.atan2(i-r,s-e);if(R=Math.abs(O-Math.atan2(r-t,e-n)),I=Math.abs(Math.atan2(a-i,o-s)-O),R>=u&&(R=2*u-R),I>=u&&(I=2*u-I),R+I<Ht){l.push(y,b);return}if(kt!==0){if(R>kt){l.push(e,r);return}if(I>kt){l.push(s,i);return}}}}else if(C>Ie){if(C*C<=h*(B*B+P*P)){if(Ht<kr){l.push(y,b);return}if(R=Math.abs(Math.atan2(i-r,s-e)-Math.atan2(r-t,e-n)),R>=u&&(R=2*u-R),R<Ht){l.push(e,r),l.push(s,i);return}if(kt!==0&&R>kt){l.push(e,r);return}}}else if(v>Ie){if(v*v<=h*(B*B+P*P)){if(Ht<kr){l.push(y,b);return}if(R=Math.abs(Math.atan2(a-i,o-s)-Math.atan2(i-r,s-e)),R>=u&&(R=2*u-R),R<Ht){l.push(e,r),l.push(s,i);return}if(kt!==0&&R>kt){l.push(s,i);return}}}else if(B=y-(n+o)/2,P=b-(t+a)/2,B*B+P*P<=h){l.push(y,b);return}}Fr(n,t,f,d,_,S,y,b,l,h,c+1),Fr(y,b,T,M,x,g,o,a,l,h,c+1)}var ao=8,lo=11920929e-14,co=1,ho=.01,_i=0;function yi(n,t,e,r,s,i,o,a){let h=Math.min(.99,Math.max(0,a??ve.defaultOptions.bezierSmoothness)),c=(co-h)/1;return c*=c,uo(t,e,r,s,i,o,n,c),n}function uo(n,t,e,r,s,i,o,a){Br(o,n,t,e,r,s,i,a,0),o.push(s,i)}function Br(n,t,e,r,s,i,o,a,l){if(l>ao)return;let h=Math.PI,c=(t+r)/2,u=(e+s)/2,f=(r+i)/2,d=(s+o)/2,p=(c+f)/2,m=(u+d)/2,x=i-t,g=o-e,_=Math.abs((r-i)*g-(s-o)*x);if(_>lo){if(_*_<=a*(x*x+g*g)){if(_i<ho){n.push(p,m);return}let S=Math.abs(Math.atan2(o-s,i-r)-Math.atan2(s-e,r-t));if(S>=h&&(S=2*h-S),S<_i){n.push(p,m);return}}}else if(x=p-(t+i)/2,g=m-(e+o)/2,x*x+g*g<=a){n.push(p,m);return}Br(n,t,e,c,u,p,m,a,l+1),Br(n,p,m,f,d,i,o,a,l+1)}function De(n,t,e,r,s,i,o,a){let l=Math.abs(s-i);(!o&&s>i||o&&i>s)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(r,1/3)*(l/Math.PI)))),a=Math.max(a,3);let h=l/a,c=s;h*=o?-1:1;for(let u=0;u<a+1;u++){let f=Math.cos(c),d=Math.sin(c),p=t+f*r,m=e+d*r;n.push(p,m),c+=h}}function bi(n,t,e,r,s,i){let o=n[n.length-2],l=n[n.length-1]-e,h=o-t,c=s-e,u=r-t,f=Math.abs(l*u-h*c);if(f<1e-8||i===0){(n[n.length-2]!==t||n[n.length-1]!==e)&&n.push(t,e);return}let d=l*l+h*h,p=c*c+u*u,m=l*c+h*u,x=i*Math.sqrt(d)/f,g=i*Math.sqrt(p)/f,_=x*m/d,S=g*m/p,T=x*u+g*h,M=x*c+g*l,y=h*(g+_),b=l*(g+_),B=u*(x+S),P=c*(x+S),C=Math.atan2(b-M,y-T),v=Math.atan2(P-M,B-T);De(n,T+t,M+e,i,C,v,h*c>u*l)}var ae=Math.PI*2,Rr={centerX:0,centerY:0,ang1:0,ang2:0},Ur=({x:n,y:t},e,r,s,i,o,a,l)=>{n*=e,t*=r;let h=s*n-i*t,c=i*n+s*t;return l.x=h+o,l.y=c+a,l};function fo(n,t){let e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=t===1.5707963267948966?.551915024494:e,s=Math.cos(n),i=Math.sin(n),o=Math.cos(n+t),a=Math.sin(n+t);return[{x:s-i*r,y:i+s*r},{x:o+a*r,y:a-o*r},{x:o,y:a}]}var Si=(n,t,e,r)=>{let s=n*r-t*e<0?-1:1,i=n*e+t*r;return i>1&&(i=1),i<-1&&(i=-1),s*Math.acos(i)},po=(n,t,e,r,s,i,o,a,l,h,c,u,f)=>{let d=Math.pow(s,2),p=Math.pow(i,2),m=Math.pow(c,2),x=Math.pow(u,2),g=d*p-d*x-p*m;g<0&&(g=0),g/=d*x+p*m,g=Math.sqrt(g)*(o===a?-1:1);let _=g*s/i*u,S=g*-i/s*c,T=h*_-l*S+(n+e)/2,M=l*_+h*S+(t+r)/2,y=(c-_)/s,b=(u-S)/i,B=(-c-_)/s,P=(-u-S)/i,C=Si(1,0,y,b),v=Si(y,b,B,P);a===0&&v>0&&(v-=ae),a===1&&v<0&&(v+=ae),f.centerX=T,f.centerY=M,f.ang1=C,f.ang2=v};function Ti(n,t,e,r,s,i,o,a=0,l=0,h=0){if(i===0||o===0)return;let c=Math.sin(a*ae/360),u=Math.cos(a*ae/360),f=u*(t-r)/2+c*(e-s)/2,d=-c*(t-r)/2+u*(e-s)/2;if(f===0&&d===0)return;i=Math.abs(i),o=Math.abs(o);let p=Math.pow(f,2)/Math.pow(i,2)+Math.pow(d,2)/Math.pow(o,2);p>1&&(i*=Math.sqrt(p),o*=Math.sqrt(p)),po(t,e,r,s,i,o,l,h,c,u,f,d,Rr);let{ang1:m,ang2:x}=Rr,{centerX:g,centerY:_}=Rr,S=Math.abs(x)/(ae/4);Math.abs(1-S)<1e-7&&(S=1);let T=Math.max(Math.ceil(S),1);x/=T;let M=n[n.length-2],y=n[n.length-1],b={x:0,y:0};for(let B=0;B<T;B++){let P=fo(m,x),{x:C,y:v}=Ur(P[0],i,o,u,c,g,_,b),{x:R,y:I}=Ur(P[1],i,o,u,c,g,_,b),{x:O,y:Rt}=Ur(P[2],i,o,u,c,g,_,b);ze(n,M,y,C,v,R,I,O,Rt),M=O,y=Rt,m+=x}}function wi(n,t,e){let r=(o,a)=>{let l=a.x-o.x,h=a.y-o.y,c=Math.sqrt(l*l+h*h),u=l/c,f=h/c;return{len:c,nx:u,ny:f}},s=(o,a)=>{o===0?n.moveTo(a.x,a.y):n.lineTo(a.x,a.y)},i=t[t.length-1];for(let o=0;o<t.length;o++){let a=t[o%t.length],l=a.radius??e;if(l<=0){s(o,a),i=a;continue}let h=t[(o+1)%t.length],c=r(a,i),u=r(a,h);if(c.len<1e-4||u.len<1e-4){s(o,a),i=a;continue}let f=Math.asin(c.nx*u.ny-c.ny*u.nx),d=1,p=!1;c.nx*u.nx-c.ny*-u.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,d=-1,p=!0):f>0&&(d=-1,p=!0);let m=f/2,x,g=Math.abs(Math.cos(m)*l/Math.sin(m));g>Math.min(c.len/2,u.len/2)?(g=Math.min(c.len/2,u.len/2),x=Math.abs(g*Math.sin(m)/Math.cos(m))):x=l;let _=a.x+u.nx*g+-u.ny*x*d,S=a.y+u.ny*g+u.nx*x*d,T=Math.atan2(c.ny,c.nx)+Math.PI/2*d,M=Math.atan2(u.ny,u.nx)-Math.PI/2*d;o===0&&n.moveTo(_+Math.cos(T)*x,S+Math.sin(T)*x),n.arc(_,S,x,T,M,p),i=a}}function Pi(n,t,e,r){let s=(a,l)=>Math.sqrt((a.x-l.x)**2+(a.y-l.y)**2),i=(a,l,h)=>({x:a.x+(l.x-a.x)*h,y:a.y+(l.y-a.y)*h}),o=t.length;for(let a=0;a<o;a++){let l=t[(a+1)%o],h=l.radius??e;if(h<=0){a===0?n.moveTo(l.x,l.y):n.lineTo(l.x,l.y);continue}let c=t[a],u=t[(a+2)%o],f=s(c,l),d;if(f<1e-4)d=l;else{let x=Math.min(f/2,h);d=i(l,c,x/f)}let p=s(u,l),m;if(p<1e-4)m=l;else{let x=Math.min(p/2,h);m=i(l,u,x/p)}a===0?n.moveTo(d.x,d.y):n.lineTo(d.x,d.y),n.quadraticCurveTo(l.x,l.y,m.x,m.y,r)}}var mo=new H,Le=class{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new st,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();let r=this._currentPoly.points,s=r[r.length-2],i=r[r.length-1];return(s!==t||i!==e)&&r.push(t,e),this}arc(t,e,r,s,i,o){this._ensurePoly(!1);let a=this._currentPoly.points;return De(a,t,e,r,s,i,o),this}arcTo(t,e,r,s,i){this._ensurePoly();let o=this._currentPoly.points;return bi(o,t,e,r,s,i),this}arcToSvg(t,e,r,s,i,o,a){let l=this._currentPoly.points;return Ti(l,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,r,s,i),this}bezierCurveTo(t,e,r,s,i,o,a){this._ensurePoly();let l=this._currentPoly;return ze(this._currentPoly.points,l.lastX,l.lastY,t,e,r,s,i,o,a),this}quadraticCurveTo(t,e,r,s,i){this._ensurePoly();let o=this._currentPoly;return yi(this._currentPoly.points,o.lastX,o.lastY,t,e,r,s,i),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));let r=this.shapePrimitives,s=r.length;for(let i=0;i<t.instructions.length;i++){let o=t.instructions[i];this[o.action](...o.data)}if(t.checkForHoles&&r.length-s>1){let i=null;for(let o=s;o<r.length;o++){let a=r[o];if(a.shape.type==="polygon"){let l=a.shape,h=i?.shape;h&&h.containsPolygon(l)?(i.holes||(i.holes=[]),i.holes.push(a),r.copyWithin(o,o+1),r.length--,o--):i=a}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,r,s,i){return this.drawShape(new H(t,e,r,s),i),this}circle(t,e,r,s){return this.drawShape(new Re(t,e,r),s),this}poly(t,e,r){let s=new Wt(t);return s.closePath=e,this.drawShape(s,r),this}regularPoly(t,e,r,s,i=0,o){s=Math.max(s|0,3);let a=-1*Math.PI/2+i,l=Math.PI*2/s,h=[];for(let c=0;c<s;c++){let u=a-c*l;h.push(t+r*Math.cos(u),e+r*Math.sin(u))}return this.poly(h,!0,o),this}roundPoly(t,e,r,s,i,o=0,a){if(s=Math.max(s|0,3),i<=0)return this.regularPoly(t,e,r,s,o);let l=r*Math.sin(Math.PI/s)-.001;i=Math.min(i,l);let h=-1*Math.PI/2+o,c=Math.PI*2/s,u=(s-2)*Math.PI/s/2;for(let f=0;f<s;f++){let d=f*c+h,p=t+r*Math.cos(d),m=e+r*Math.sin(d),x=d+Math.PI+u,g=d-Math.PI-u,_=p+i*Math.cos(x),S=m+i*Math.sin(x),T=p+i*Math.cos(g),M=m+i*Math.sin(g);f===0?this.moveTo(_,S):this.lineTo(_,S),this.quadraticCurveTo(p,m,T,M,a)}return this.closePath()}roundShape(t,e,r=!1,s){return t.length<3?this:(r?Pi(this,t,e,s):wi(this,t,e),this.closePath())}filletRect(t,e,r,s,i){if(i===0)return this.rect(t,e,r,s);let o=Math.min(r,s)/2,a=Math.min(o,Math.max(-o,i)),l=t+r,h=e+s,c=a<0?-a:0,u=Math.abs(a);return this.moveTo(t,e+u).arcTo(t+c,e+c,t+u,e,u).lineTo(l-u,e).arcTo(l-c,e+c,l,e+u,u).lineTo(l,h-u).arcTo(l-c,h-c,t+r-u,h,u).lineTo(t+u,h).arcTo(t+c,h-c,t,h-u,u).closePath()}chamferRect(t,e,r,s,i,o){if(i<=0)return this.rect(t,e,r,s);let a=Math.min(i,Math.min(r,s)/2),l=t+r,h=e+s,c=[t+a,e,l-a,e,l,e+a,l,h-a,l-a,h,t+a,h,t,h-a,t,e+a];for(let u=c.length-1;u>=2;u-=2)c[u]===c[u-2]&&c[u-1]===c[u-3]&&c.splice(u-1,2);return this.poly(c,!0,o)}ellipse(t,e,r,s,i){return this.drawShape(new Ue(t,e,r,s),i),this}roundRect(t,e,r,s,i,o){return this.drawShape(new Ge(t,e,r,s,i),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let r=this._currentPoly;return r&&this.endPoly(),r=new Wt,r.points.push(t,e),this._currentPoly=r,this}endPoly(t=!1){let e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new Wt,t)){let e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let r=e.shape.x,s=e.shape.y;if(e.transform&&!e.transform.isIdentity()){let i=e.transform,o=r;r=i.a*r+i.c*s+i.tx,s=i.b*o+i.d*s+i.ty}this._currentPoly.points.push(r,s)}else this._currentPoly.points.push(0,0)}}buildPath(){let t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){let r=t.instructions[e];this[r.action](...r.data)}this.finish()}get bounds(){let t=this._bounds;t.clear();let e=this.shapePrimitives;for(let r=0;r<e.length;r++){let s=e[r],i=s.shape.getBounds(mo);s.transform?t.addRect(i,s.transform):t.addRect(i)}return t}};var Z=class n{constructor(t,e=!1){this.instructions=[],this.uid=rt("graphicsPath"),this._dirty=!0,this.checkForHoles=e,typeof t=="string"?gi(t,this):this.instructions=t?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new Le(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,r,s,i){let o=this.instructions[this.instructions.length-1],a=this.getLastPoint(ct.shared),l=0,h=0;if(!o||o.action!=="bezierCurveTo")l=a.x,h=a.y;else{l=o.data[2],h=o.data[3];let c=a.x,u=a.y;l=c+(c-l),h=u+(u-h)}return this.instructions.push({action:"bezierCurveTo",data:[l,h,t,e,r,s,i]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,r){let s=this.instructions[this.instructions.length-1],i=this.getLastPoint(ct.shared),o=0,a=0;if(!s||s.action!=="quadraticCurveTo")o=i.x,a=i.y;else{o=s.data[0],a=s.data[1];let l=i.x,h=i.y;o=l+(l-o),a=h+(h-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,r]}),this._dirty=!0,this}rect(t,e,r,s,i){return this.instructions.push({action:"rect",data:[t,e,r,s,i]}),this._dirty=!0,this}circle(t,e,r,s){return this.instructions.push({action:"circle",data:[t,e,r,s]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,r,s,i,o,a){i||(i=s/2);let l=-1*Math.PI/2+o,h=r*2,c=Math.PI*2/h,u=[];for(let f=0;f<h;f++){let d=f%2?i:s,p=f*c+l;u.push(t+d*Math.cos(p),e+d*Math.sin(p))}return this.poly(u,!0,a),this}clone(t=!1){let e=new n;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let r=0;r<this.instructions.length;r++){let s=this.instructions[r];e.instructions.push({action:s.action,data:s.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;let e=t.a,r=t.b,s=t.c,i=t.d,o=t.tx,a=t.ty,l=0,h=0,c=0,u=0,f=0,d=0,p=0,m=0;for(let x=0;x<this.instructions.length;x++){let g=this.instructions[x],_=g.data;switch(g.action){case"moveTo":case"lineTo":l=_[0],h=_[1],_[0]=e*l+s*h+o,_[1]=r*l+i*h+a;break;case"bezierCurveTo":c=_[0],u=_[1],f=_[2],d=_[3],l=_[4],h=_[5],_[0]=e*c+s*u+o,_[1]=r*c+i*u+a,_[2]=e*f+s*d+o,_[3]=r*f+i*d+a,_[4]=e*l+s*h+o,_[5]=r*l+i*h+a;break;case"quadraticCurveTo":c=_[0],u=_[1],l=_[2],h=_[3],_[0]=e*c+s*u+o,_[1]=r*c+i*u+a,_[2]=e*l+s*h+o,_[3]=r*l+i*h+a;break;case"arcToSvg":l=_[5],h=_[6],p=_[0],m=_[1],_[0]=e*p+s*m,_[1]=r*p+i*m,_[5]=e*l+s*h+o,_[6]=r*l+i*h+a;break;case"circle":_[4]=le(_[3],t);break;case"rect":_[4]=le(_[4],t);break;case"ellipse":_[8]=le(_[8],t);break;case"roundRect":_[5]=le(_[5],t);break;case"addPath":_[0].transform(t);break;case"poly":_[2]=le(_[2],t);break;default:L("unknown transform action",g.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,r=this.instructions[e];if(!r)return t.x=0,t.y=0,t;for(;r.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;r=this.instructions[e]}switch(r.action){case"moveTo":case"lineTo":t.x=r.data[0],t.y=r.data[1];break;case"quadraticCurveTo":t.x=r.data[2],t.y=r.data[3];break;case"bezierCurveTo":t.x=r.data[4],t.y=r.data[5];break;case"arc":case"arcToSvg":t.x=r.data[5],t.y=r.data[6];break;case"addPath":r.data[0].getLastPoint(t);break}return t}};function le(n,t){return n?n.prepend(t):t.clone()}function V(n,t,e){let r=n.getAttribute(t);return r?Number(r):e}function vi(n,t){let e=n.querySelectorAll("defs");for(let r=0;r<e.length;r++){let s=e[r];for(let i=0;i<s.children.length;i++){let o=s.children[i];switch(o.nodeName.toLowerCase()){case"lineargradient":t.defs[o.id]=go(o);break;case"radialgradient":t.defs[o.id]=xo(o);break;default:break}}}}function go(n){let t=V(n,"x1",0),e=V(n,"y1",0),r=V(n,"x2",1),s=V(n,"y2",0),i=n.getAttribute("gradientUnits")||"objectBoundingBox",o=new $(t,e,r,s,i==="objectBoundingBox"?"local":"global");for(let a=0;a<n.children.length;a++){let l=n.children[a],h=V(l,"offset",0),c=W.shared.setValue(l.getAttribute("stop-color")).toNumber();o.addColorStop(h,c)}return o}function xo(n){return L("[SVG Parser] Radial gradients are not yet supported"),new $(0,0,1,0)}function Er(n){let t=n.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}var Ci={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function Gr(n,t){let e=n.getAttribute("style"),r={},s={},i={strokeStyle:r,fillStyle:s,useFill:!1,useStroke:!1};for(let o in Ci){let a=n.getAttribute(o);a&&Mi(t,i,o,a.trim())}if(e){let o=e.split(";");for(let a=0;a<o.length;a++){let l=o[a].trim(),[h,c]=l.split(":");Ci[h]&&Mi(t,i,h,c.trim())}}return{strokeStyle:i.useStroke?r:null,fillStyle:i.useFill?s:null,useFill:i.useFill,useStroke:i.useStroke}}function Mi(n,t,e,r){switch(e){case"stroke":if(r!=="none"){if(r.startsWith("url(")){let s=Er(r);t.strokeStyle.fill=n.defs[s]}else t.strokeStyle.color=W.shared.setValue(r).toNumber();t.useStroke=!0}break;case"stroke-width":t.strokeStyle.width=Number(r);break;case"fill":if(r!=="none"){if(r.startsWith("url(")){let s=Er(r);t.fillStyle.fill=n.defs[s]}else t.fillStyle.color=W.shared.setValue(r).toNumber();t.useFill=!0}break;case"fill-opacity":t.fillStyle.alpha=Number(r);break;case"stroke-opacity":t.strokeStyle.alpha=Number(r);break;case"opacity":t.fillStyle.alpha=Number(r),t.strokeStyle.alpha=Number(r);break}}function Ai(n){if(n.length<=2)return!0;let t=n.map(a=>a.area).sort((a,l)=>l-a),[e,r]=t,s=t[t.length-1],i=e/r,o=r/s;return!(i>3&&o<2)}function ki(n){return n.split(/(?=[Mm])/).filter(r=>r.trim().length>0)}function Fi(n){let t=n.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;let e=t.map(Number),r=[],s=[];for(let c=0;c<e.length;c+=2)c+1<e.length&&(r.push(e[c]),s.push(e[c+1]));if(r.length===0||s.length===0)return 0;let i=Math.min(...r),o=Math.max(...r),a=Math.min(...s),l=Math.max(...s);return(o-i)*(l-a)}function Ir(n,t){let e=new Z(n,!1);for(let r of e.instructions)t.instructions.push(r)}function Bi(n,t){if(typeof n=="string"){let o=document.createElement("div");o.innerHTML=n.trim(),n=o.querySelector("svg")}let e={context:t,defs:{},path:new Z};vi(n,e);let r=n.children,{fillStyle:s,strokeStyle:i}=Gr(n,e);for(let o=0;o<r.length;o++){let a=r[o];a.nodeName.toLowerCase()!=="defs"&&Ri(a,e,s,i)}return t}function Ri(n,t,e,r){let s=n.children,{fillStyle:i,strokeStyle:o}=Gr(n,t);i&&e?e={...e,...i}:i&&(e=i),o&&r?r={...r,...o}:o&&(r=o);let a=!e&&!r;a&&(e={color:0});let l,h,c,u,f,d,p,m,x,g,_,S,T,M,y,b,B;switch(n.nodeName.toLowerCase()){case"path":{M=n.getAttribute("d");let P=n.getAttribute("fill-rule"),C=ki(M),v=P==="evenodd",R=C.length>1;if(v&&R){let O=C.map(A=>({path:A,area:Fi(A)}));if(O.sort((A,F)=>F.area-A.area),C.length>3||!Ai(O))for(let A=0;A<O.length;A++){let F=O[A],$t=A===0;t.context.beginPath();let z=new Z(void 0,!0);Ir(F.path,z),t.context.path(z),$t?(e&&t.context.fill(e),r&&t.context.stroke(r)):t.context.cut()}else for(let A=0;A<O.length;A++){let F=O[A],$t=A%2===1;t.context.beginPath();let z=new Z(void 0,!0);Ir(F.path,z),t.context.path(z),$t?t.context.cut():(e&&t.context.fill(e),r&&t.context.stroke(r))}}else{let O=P?P==="evenodd":!0;y=new Z(M,O),t.context.path(y),e&&t.context.fill(e),r&&t.context.stroke(r)}break}case"circle":p=V(n,"cx",0),m=V(n,"cy",0),x=V(n,"r",0),t.context.ellipse(p,m,x,x),e&&t.context.fill(e),r&&t.context.stroke(r);break;case"rect":l=V(n,"x",0),h=V(n,"y",0),b=V(n,"width",0),B=V(n,"height",0),g=V(n,"rx",0),_=V(n,"ry",0),g||_?t.context.roundRect(l,h,b,B,g||_):t.context.rect(l,h,b,B),e&&t.context.fill(e),r&&t.context.stroke(r);break;case"ellipse":p=V(n,"cx",0),m=V(n,"cy",0),g=V(n,"rx",0),_=V(n,"ry",0),t.context.beginPath(),t.context.ellipse(p,m,g,_),e&&t.context.fill(e),r&&t.context.stroke(r);break;case"line":c=V(n,"x1",0),u=V(n,"y1",0),f=V(n,"x2",0),d=V(n,"y2",0),t.context.beginPath(),t.context.moveTo(c,u),t.context.lineTo(f,d),r&&t.context.stroke(r);break;case"polygon":T=n.getAttribute("points"),S=T.match(/\d+/g).map(P=>parseInt(P,10)),t.context.poly(S,!0),e&&t.context.fill(e),r&&t.context.stroke(r);break;case"polyline":T=n.getAttribute("points"),S=T.match(/\d+/g).map(P=>parseInt(P,10)),t.context.poly(S,!1),r&&t.context.stroke(r);break;case"g":case"svg":break;default:{L(`[SVG parser] <${n.nodeName}> elements unsupported`);break}}a&&(e=null);for(let P=0;P<s.length;P++)Ri(s[P],t,e,r)}function _o(n){return W.isColorLike(n)}function Ui(n){return n instanceof ht}function Ei(n){return n instanceof $}function yo(n){return n instanceof E}function bo(n,t,e){let r=W.shared.setValue(t??0);return n.color=r.toNumber(),n.alpha=r.alpha===1?e.alpha:r.alpha,n.texture=E.WHITE,{...e,...n}}function So(n,t,e){return n.texture=t,{...e,...n}}function Gi(n,t,e){return n.fill=t,n.color=16777215,n.texture=t.texture,n.matrix=t.transform,{...e,...n}}function Ii(n,t,e){return t.buildGradient(),n.fill=t,n.color=16777215,n.texture=t.texture,n.matrix=t.transform,n.textureSpace=t.textureSpace,{...e,...n}}function To(n,t){let e={...t,...n},r=W.shared.setValue(e.color);return e.alpha*=r.alpha,e.color=r.toNumber(),e}function ut(n,t){if(n==null)return null;let e={},r=n;return _o(n)?bo(e,n,t):yo(n)?So(e,n,t):Ui(n)?Gi(e,n,t):Ei(n)?Ii(e,n,t):r.fill&&Ui(r.fill)?Gi(r,r.fill,t):r.fill&&Ei(r.fill)?Ii(r,r.fill,t):To(r,t)}function Ot(n,t){let{width:e,alignment:r,miterLimit:s,cap:i,join:o,pixelLine:a,...l}=t,h=ut(n,l);return h?{width:e,alignment:r,miterLimit:s,cap:i,join:o,pixelLine:a,...h}:null}var wo=new ct,zi=new G,zr=class at extends Ut{constructor(){super(...arguments),this.uid=rt("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new Z,this._transform=new G,this._fillStyle={...at.defaultFillStyle},this._strokeStyle={...at.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new st,this._boundsDirty=!0}clone(){let t=new at;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=ut(t,at.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Ot(t,at.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=ut(t,at.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=ut(t,at.defaultStrokeStyle),this}texture(t,e,r,s,i,o){return this.instructions.push({action:"texture",data:{image:t,dx:r||0,dy:s||0,dw:i||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?W.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Z,this}fill(t,e){let r,s=this.instructions[this.instructions.length-1];return this._tick===0&&s?.action==="stroke"?r=s.data.path:r=this._activePath.clone(),r?(t!=null&&(e!==void 0&&typeof t=="number"&&(U(D,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=ut(t,at.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:r}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){let{x:t,y:e}=this._activePath.getLastPoint(ct.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e,r=this.instructions[this.instructions.length-1];return this._tick===0&&r?.action==="fill"?e=r.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Ot(t,at.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){let e=this.instructions[this.instructions.length-1-t],r=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(r);else{e.data.hole=r;break}}return this._initNextPathLocation(),this}arc(t,e,r,s,i,o){this._tick++;let a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,r,s,i,o),this}arcTo(t,e,r,s,i){this._tick++;let o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*r+o.c*s+o.tx,o.b*r+o.d*s+o.ty,i),this}arcToSvg(t,e,r,s,i,o,a){this._tick++;let l=this._transform;return this._activePath.arcToSvg(t,e,r,s,i,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(t,e,r,s,i,o,a){this._tick++;let l=this._transform;return this._activePath.bezierCurveTo(l.a*t+l.c*e+l.tx,l.b*t+l.d*e+l.ty,l.a*r+l.c*s+l.tx,l.b*r+l.d*s+l.ty,l.a*i+l.c*o+l.tx,l.b*i+l.d*o+l.ty,a),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(t,e,r,s){return this._tick++,this._activePath.ellipse(t,e,r,s,this._transform.clone()),this}circle(t,e,r){return this._tick++,this._activePath.circle(t,e,r,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;let r=this._transform;return this._activePath.lineTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty),this}moveTo(t,e){this._tick++;let r=this._transform,s=this._activePath.instructions,i=r.a*t+r.c*e+r.tx,o=r.b*t+r.d*e+r.ty;return s.length===1&&s[0].action==="moveTo"?(s[0].data[0]=i,s[0].data[1]=o,this):(this._activePath.moveTo(i,o),this)}quadraticCurveTo(t,e,r,s,i){this._tick++;let o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*r+o.c*s+o.tx,o.b*r+o.d*s+o.ty,i),this}rect(t,e,r,s){return this._tick++,this._activePath.rect(t,e,r,s,this._transform.clone()),this}roundRect(t,e,r,s,i){return this._tick++,this._activePath.roundRect(t,e,r,s,i,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,r,s,i=0,o){return this._tick++,this._activePath.regularPoly(t,e,r,s,i,o),this}roundPoly(t,e,r,s,i,o){return this._tick++,this._activePath.roundPoly(t,e,r,s,i,o),this}roundShape(t,e,r,s){return this._tick++,this._activePath.roundShape(t,e,r,s),this}filletRect(t,e,r,s,i){return this._tick++,this._activePath.filletRect(t,e,r,s,i),this}chamferRect(t,e,r,s,i,o){return this._tick++,this._activePath.chamferRect(t,e,r,s,i,o),this}star(t,e,r,s,i=0,o=0){return this._tick++,this._activePath.star(t,e,r,s,i,o,this._transform.clone()),this}svg(t){return this._tick++,Bi(t,this),this}restore(){let t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,r,s,i,o){return t instanceof G?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,r,s,i,o),this)}transform(t,e,r,s,i,o){return t instanceof G?(this._transform.append(t),this):(zi.set(t,e,r,s,i,o),this._transform.append(zi),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,!this.dirty&&(this.emit("update",this,16),this.dirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;let t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){let r=this.instructions[e],s=r.action;if(s==="fill"){let i=r.data;t.addBounds(i.path.bounds)}else if(s==="texture"){let i=r.data;t.addFrame(i.dx,i.dy,i.dx+i.dw,i.dy+i.dh,i.transform)}if(s==="stroke"){let i=r.data,o=i.style.alignment,a=i.style.width*(1-o),l=i.path.bounds;t.addFrame(l.minX-a,l.minY-a,l.maxX+a,l.maxY+a)}}return t}containsPoint(t){if(!this.bounds.containsPoint(t.x,t.y))return!1;let e=this.instructions,r=!1;for(let s=0;s<e.length;s++){let i=e[s],o=i.data,a=o.path;if(!i.action||!a)continue;let l=o.style,h=a.shapePath.shapePrimitives;for(let c=0;c<h.length;c++){let u=h[c].shape;if(!l||!u)continue;let f=h[c].transform,d=f?f.applyInverse(t,wo):t;if(i.action==="fill")r=u.contains(d.x,d.y);else{let m=l;r=u.strokeContains(d.x,d.y,m.width,m.alignment)}let p=o.hole;if(p){let m=p.shapePath?.shapePrimitives;if(m)for(let x=0;x<m.length;x++)m[x].shape.contains(d.x,d.y)&&(r=!1)}if(r)return!0}}return r}destroy(t=!1){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t?.texture){let r=typeof t=="boolean"?t:t?.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(r)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(r))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};zr.defaultFillStyle={color:16777215,alpha:1,texture:E.WHITE,matrix:null,fill:null,textureSpace:"local"};zr.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:E.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};var K=zr;var Dr=class Vt extends Ut{constructor(t={}){super(),this.uid=rt("textStyle"),this._tick=0,Po(t);let e={...Vt.defaultTextStyle,...t};for(let r in e){let s=r;this[s]=e[r]}this.update(),this._tick=0}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update())}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy({...Vt.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...Vt.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.update())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.update())}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.update())}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.update())}get filters(){return this._filters}set filters(t){this._filters!==t&&(this._filters=Object.freeze(t),this.update())}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.update())}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy({...K.defaultFillStyle,...t},()=>{this._fill=ut({...this._originalFill},K.defaultFillStyle)})),this._fill=ut(t===0?"black":t,K.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...K.defaultStrokeStyle,...t},()=>{this._stroke=Ot({...this._originalStroke},K.defaultStrokeStyle)})),this._stroke=Ot(t,K.defaultStrokeStyle),this.update())}update(){this._tick++,this.emit("update",this)}reset(){let t=Vt.defaultTextStyle;for(let e in t)this[e]=t[e]}get styleKey(){return`${this.uid}-${this._tick}`}clone(){return new Vt({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,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){if(this.removeAllListeners(),typeof t=="boolean"?t:t?.texture){let r=typeof t=="boolean"?t:t?.textureSource;this._fill?.texture&&this._fill.texture.destroy(r),this._originalFill?.texture&&this._originalFill.texture.destroy(r),this._stroke?.texture&&this._stroke.texture.destroy(r),this._originalStroke?.texture&&this._originalStroke.texture.destroy(r)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(r,s,i)=>(r[s]===i||(r[s]=i,e?.(s,i),this.update()),!0)})}_isFillStyle(t){return(t??null)!==null&&!(W.isColorLike(t)||t instanceof $||t instanceof ht)}};Dr.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Dr.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 dt=Dr;function Po(n){let t=n;if(typeof t.dropShadow=="boolean"&&t.dropShadow){let e=dt.defaultDropShadow;n.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){U(D,"strokeThickness is now a part of stroke");let e=t.stroke,r={};if(W.isColorLike(e))r.color=e;else if(e instanceof $||e instanceof ht)r.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))r=e;else throw new Error("Invalid stroke value.");n.stroke={...r,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if(U(D,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");t.fill.length!==t.fillGradientStops.length&&L("The number of fill colors must match the number of fill gradient stops.");let e=new $({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),r=t.fillGradientStops.slice(),s=t.fill.map(i=>W.shared.setValue(i).toNumber());r.forEach((i,o)=>{e.addColorStop(i,s[o])}),n.fill={fill:e}}}var vo=new st;function We(n,t,e,r){let s=vo;s.minX=0,s.minY=0,s.maxX=n.width/r|0,s.maxY=n.height/r|0;let i=q.getOptimalTexture(s.width,s.height,r,!1);return i.source.uploadMethodId="image",i.source.resource=n,i.source.alphaMode="premultiply-alpha-on-upload",i.frame.width=t/r,i.frame.height=e/r,i.source.emit("update",i.source),i.updateUvs(),i}var Ft=null,ft=null;function Co(n,t){Ft||(Ft=j.get().createCanvas(256,128),ft=Ft.getContext("2d",{willReadFrequently:!0}),ft.globalCompositeOperation="copy",ft.globalAlpha=1),(Ft.width<n||Ft.height<t)&&(Ft.width=rr(n),Ft.height=rr(t))}function Di(n,t,e){for(let r=0,s=4*e*t;r<t;++r,s+=4)if(n[s+3]!==0)return!1;return!0}function Li(n,t,e,r,s){let i=4*t;for(let o=r,a=r*i+4*e;o<=s;++o,a+=i)if(n[a+3]!==0)return!1;return!0}function Wi(...n){let t=n[0];t.canvas||(t={canvas:n[0],resolution:n[1]});let{canvas:e}=t,r=Math.min(t.resolution??1,1),s=t.width??e.width,i=t.height??e.height,o=t.output;if(Co(s,i),!ft)throw new TypeError("Failed to get canvas 2D context");ft.drawImage(e,0,0,s,i,0,0,s*r,i*r);let l=ft.getImageData(0,0,s,i).data,h=0,c=0,u=s-1,f=i-1;for(;c<i&&Di(l,s,c);)++c;if(c===i)return H.EMPTY;for(;Di(l,s,f);)--f;for(;Li(l,s,h,c,f);)++h;for(;Li(l,s,u,c,f);)--u;return++u,++f,ft.globalCompositeOperation="source-over",ft.strokeRect(h,c,u-h,f-c),ft.globalCompositeOperation="copy",o??(o=new H),o.set(h/r,c/r,(u-h)/r,(f-c)/r),o}var Lr=class{constructor(t=0,e=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=r,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){let e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map(e=>[e,this.get(e)])}evict(t=!1){if(t||this.size>0){let e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e=this.items[t];if(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){let t=[],e=this.first;for(;e!==null;)t.push(e.key),e=e.next;return t}setWithEvicted(t,e,r=this.resetTtl){let s=null;if(this.has(t))this.set(t,e,!0,r);else{this.max>0&&this.size===this.max&&(s={...this.first},this.evict(!0));let i=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=i:this.last.next=i,this.last=i}return s}set(t,e,r=!1,s=this.resetTtl){let i=this.items[t];return r||i!==void 0?(i.value=e,r===!1&&s&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(i)):(this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=i:this.last.next=i,this.last=i),this}values(t=this.keys()){return t.map(e=>this.get(e))}};function He(n=1e3,t=0,e=!1){if(isNaN(n)||n<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof e!="boolean")throw new TypeError("Invalid resetTtl value");return new Lr(n,t,e)}var Mo=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Bt(n){let t=typeof n.fontSize=="number"?`${n.fontSize}px`:n.fontSize,e=n.fontFamily;Array.isArray(n.fontFamily)||(e=n.fontFamily.split(","));for(let r=e.length-1;r>=0;r--){let s=e[r].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!Mo.includes(s)&&(s=`"${s}"`),e[r]=s}return`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${t} ${e.join(",")}`}var Wr={willReadFrequently:!0},et=class k{static get experimentalLetterSpacingSupported(){let t=k._experimentalLetterSpacingSupported;if(t===void 0){let e=j.get().getCanvasRenderingContext2D().prototype;t=k._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,r,s,i,o,a,l,h){this.text=t,this.style=e,this.width=r,this.height=s,this.lines=i,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(t=" ",e,r=k._canvas,s=e.wordWrap){let i=`${t}-${e.styleKey}-wordWrap-${s}`;if(k._measurementCache.has(i))return k._measurementCache.get(i);let o=Bt(e),a=k.measureFont(o);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);let l=k.__context;l.font=o;let c=(s?k._wordWrap(t,e,r):t).split(/(?:\r\n|\r|\n)/),u=new Array(c.length),f=0;for(let _=0;_<c.length;_++){let S=k._measureText(c[_],e.letterSpacing,l);u[_]=S,f=Math.max(f,S)}let d=e._stroke?.width||0,p=f+d;e.dropShadow&&(p+=e.dropShadow.distance);let m=e.lineHeight||a.fontSize,x=Math.max(m,a.fontSize+d)+(c.length-1)*(m+e.leading);e.dropShadow&&(x+=e.dropShadow.distance);let g=new k(t,e,p,x,c,u,m+e.leading,f,a);return k._measurementCache.set(i,g),g}static _measureText(t,e,r){let s=!1;k.experimentalLetterSpacingSupported&&(k.experimentalLetterSpacing?(r.letterSpacing=`${e}px`,r.textLetterSpacing=`${e}px`,s=!0):(r.letterSpacing="0px",r.textLetterSpacing="0px"));let i=r.measureText(t),o=i.width,a=-i.actualBoundingBoxLeft,h=i.actualBoundingBoxRight-a;if(o>0)if(s)o-=e,h-=e;else{let c=(k.graphemeSegmenter(t).length-1)*e;o+=c,h+=c}return Math.max(o,h)}static _wordWrap(t,e,r=k._canvas){let s=r.getContext("2d",Wr),i=0,o="",a="",l=Object.create(null),{letterSpacing:h,whiteSpace:c}=e,u=k._collapseSpaces(c),f=k._collapseNewlines(c),d=!u,p=e.wordWrapWidth+h,m=k._tokenize(t);for(let x=0;x<m.length;x++){let g=m[x];if(k._isNewline(g)){if(!f){a+=k._addLine(o),d=!u,o="",i=0;continue}g=" "}if(u){let S=k.isBreakingSpace(g),T=k.isBreakingSpace(o[o.length-1]);if(S&&T)continue}let _=k._getFromCache(g,h,l,s);if(_>p)if(o!==""&&(a+=k._addLine(o),o="",i=0),k.canBreakWords(g,e.breakWords)){let S=k.wordWrapSplit(g);for(let T=0;T<S.length;T++){let M=S[T],y=M,b=1;for(;S[T+b];){let P=S[T+b];if(!k.canBreakChars(y,P,g,T,e.breakWords))M+=P;else break;y=P,b++}T+=b-1;let B=k._getFromCache(M,h,l,s);B+i>p&&(a+=k._addLine(o),d=!1,o="",i=0),o+=M,i+=B}}else{o.length>0&&(a+=k._addLine(o),o="",i=0);let S=x===m.length-1;a+=k._addLine(g,!S),d=!1,o="",i=0}else _+i>p&&(d=!1,a+=k._addLine(o),o="",i=0),(o.length>0||!k.isBreakingSpace(g)||d)&&(o+=g,i+=_)}return a+=k._addLine(o,!1),a}static _addLine(t,e=!0){return t=k._trimRight(t),t=e?`${t}
|
|
125
|
+
`:t,t}static _getFromCache(t,e,r,s){let i=r[t];return typeof i!="number"&&(i=k._measureText(t,e,s)+e,r[t]=i),i}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){let r=t[e];if(!k.isBreakingSpace(r))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:k._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:k._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){let e=[],r="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){let i=t[s],o=t[s+1];if(k.isBreakingSpace(i,o)||k._isNewline(i)){r!==""&&(e.push(r),r=""),i==="\r"&&o===`
|
|
126
|
+
`?(e.push(`\r
|
|
127
|
+
`),s++):e.push(i);continue}r+=i}return r!==""&&e.push(r),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,r,s,i){return!0}static wordWrapSplit(t){return k.graphemeSegmenter(t)}static measureFont(t){if(k._fonts[t])return k._fonts[t];let e=k._context;e.font=t;let r=e.measureText(k.METRICS_STRING+k.BASELINE_SYMBOL),s={ascent:r.actualBoundingBoxAscent,descent:r.actualBoundingBoxDescent,fontSize:r.actualBoundingBoxAscent+r.actualBoundingBoxDescent};return k._fonts[t]=s,s}static clearMetrics(t=""){t?delete k._fonts[t]:k._fonts={}}static get _canvas(){if(!k.__canvas){let t;try{let e=new OffscreenCanvas(0,0);if(e.getContext("2d",Wr)?.measureText)return k.__canvas=e,e;t=j.get().createCanvas()}catch{t=j.get().createCanvas()}t.width=t.height=10,k.__canvas=t}return k.__canvas}static get _context(){return k.__context||(k.__context=k._canvas.getContext("2d",Wr)),k.__context}};et.METRICS_STRING="|\xC9q\xC5";et.BASELINE_SYMBOL="M";et.BASELINE_MULTIPLIER=1.4;et.HEIGHT_MULTIPLIER=2;et.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){let n=new Intl.Segmenter;return t=>{let e=n.segment(t),r=[],s=0;for(let i of e)r[s++]=i.segment;return r}}return n=>[...n]})();et.experimentalLetterSpacing=!1;et._fonts={};et._newlines=[10,13];et._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];et._measurementCache=He(1e3);var Y=et;var Hi=1e5;function Nt(n,t,e,r=0){if(n.texture===E.WHITE&&!n.fill)return W.shared.setValue(n.color).setAlpha(n.alpha??1).toHexa();if(n.fill){if(n.fill instanceof ht){let s=n.fill,i=t.createPattern(s.texture.source.resource,"repeat"),o=s.transform.copyTo(G.shared);return o.scale(s.texture.frame.width,s.texture.frame.height),i.setTransform(o),i}else if(n.fill instanceof $){let s=n.fill,i=s.type==="linear",o=s.textureSpace==="local",a=1,l=1;o&&e&&(a=e.width+r,l=e.height+r);let h,c=!1;if(i){let{start:u,end:f}=s;h=t.createLinearGradient(u.x*a,u.y*l,f.x*a,f.y*l),c=Math.abs(f.x-u.x)<Math.abs((f.y-u.y)*.1)}else{let{center:u,innerRadius:f,outerCenter:d,outerRadius:p}=s;h=t.createRadialGradient(u.x*a,u.y*l,f*a,d.x*a,d.y*l,p*a)}if(c&&o&&e){let u=e.lineHeight/l;for(let f=0;f<e.lines.length;f++){let d=(f*e.lineHeight+r/2)/l;s.colorStops.forEach(p=>{let m=d+p.offset*u;h.addColorStop(Math.floor(m*Hi)/Hi,W.shared.setValue(p.color).toHex())})}}else s.colorStops.forEach(u=>{h.addColorStop(u.offset,W.shared.setValue(u.color).toHex())});return h}}else{let s=t.createPattern(n.texture.source.resource,"repeat"),i=n.matrix.copyTo(G.shared);return i.scale(n.texture.frame.width,n.texture.frame.height),s.setTransform(i),s}return L("FillStyle not recognised",n),"red"}var Oi=new H,Hr=class{getCanvasAndContext(t){let{text:e,style:r,resolution:s=1}=t,i=r._getFinalPadding(),o=Y.measureText(e||" ",r),a=Math.ceil(Math.ceil(Math.max(1,o.width)+i*2)*s),l=Math.ceil(Math.ceil(Math.max(1,o.height)+i*2)*s),h=nt.getOptimalCanvasAndContext(a,l);this._renderTextToCanvas(e,r,i,s,h);let c=r.trim?Wi({canvas:h.canvas,width:a,height:l,resolution:1,output:Oi}):Oi.set(0,0,a,l);return{canvasAndContext:h,frame:c}}returnCanvasAndContext(t){nt.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,r,s,i){let{canvas:o,context:a}=i,l=Bt(e),h=Y.measureText(t||" ",e),c=h.lines,u=h.lineHeight,f=h.lineWidths,d=h.maxLineWidth,p=h.fontProperties,m=o.height;if(a.resetTransform(),a.scale(s,s),a.textBaseline=e.textBaseline,e._stroke?.width){let S=e._stroke;a.lineWidth=S.width,a.miterLimit=S.miterLimit,a.lineJoin=S.join,a.lineCap=S.cap}a.font=l;let x,g,_=e.dropShadow?2:1;for(let S=0;S<_;++S){let T=e.dropShadow&&S===0,M=T?Math.ceil(Math.max(1,m)+r*2):0,y=M*s;if(T){a.fillStyle="black",a.strokeStyle="black";let P=e.dropShadow,C=P.color,v=P.alpha;a.shadowColor=W.shared.setValue(C).setAlpha(v).toRgbaString();let R=P.blur*s,I=P.distance*s;a.shadowBlur=R,a.shadowOffsetX=Math.cos(P.angle)*I,a.shadowOffsetY=Math.sin(P.angle)*I+y}else{if(a.fillStyle=e._fill?Nt(e._fill,a,h,r*2):null,e._stroke?.width){let P=e._stroke.width*.5+r*2;a.strokeStyle=Nt(e._stroke,a,h,P)}a.shadowColor="black"}let b=(u-p.fontSize)/2;u-p.fontSize<0&&(b=0);let B=e._stroke?.width??0;for(let P=0;P<c.length;P++)x=B/2,g=B/2+P*u+p.ascent+b,e.align==="right"?x+=d-f[P]:e.align==="center"&&(x+=(d-f[P])/2),e._stroke?.width&&this._drawLetterSpacing(c[P],e,i,x+r,g+r-M,!0),e._fill!==void 0&&this._drawLetterSpacing(c[P],e,i,x+r,g+r-M)}}_drawLetterSpacing(t,e,r,s,i,o=!1){let{context:a}=r,l=e.letterSpacing,h=!1;if(Y.experimentalLetterSpacingSupported&&(Y.experimentalLetterSpacing?(a.letterSpacing=`${l}px`,a.textLetterSpacing=`${l}px`,h=!0):(a.letterSpacing="0px",a.textLetterSpacing="0px")),l===0||h){o?a.strokeText(t,s,i):a.fillText(t,s,i);return}let c=s,u=Y.graphemeSegmenter(t),f=a.measureText(t).width,d=0;for(let p=0;p<u.length;++p){let m=u[p];o?a.strokeText(m,c,i):a.fillText(m,c,i);let x="";for(let g=p+1;g<u.length;++g)x+=u[g];d=a.measureText(x).width,c+=f-d+l,f=d}}},Oe=new Hr;var Or=class{constructor(t){this._activeTextures={},this._renderer=t}getTexture(t,e,r,s){typeof t=="string"&&(U("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:r,resolution:e}),t.style instanceof dt||(t.style=new dt(t.style)),t.textureStyle instanceof mt||(t.textureStyle=new mt(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());let{text:i,style:o,textureStyle:a}=t,l=t.resolution??this._renderer.resolution,{frame:h,canvasAndContext:c}=Oe.getCanvasAndContext({text:i,style:o,resolution:l}),u=We(c.canvas,h.width,h.height,l);if(a&&(u.source.style=a),o.trim&&(h.pad(o.padding),u.frame.copyFrom(h),u.frame.scale(1/l),u.updateUvs()),o.filters){let f=this._applyFilters(u,o.filters);return this.returnTexture(u),Oe.returnCanvasAndContext(c),f}return this._renderer.texture.initSource(u._source),Oe.returnCanvasAndContext(c),u}returnTexture(t){let e=t.source;e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",q.returnTexture(t,!0)}renderTextToCanvas(){U("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;let e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;let r=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle});return this._activeTextures[e]={texture:r,usageCount:1},r}decreaseReferenceCount(t){let e=this._activeTextures[t];e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null)}getReferenceCount(t){return this._activeTextures[t]?.usageCount??0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){let r=this._renderer.renderTarget.renderTarget,s=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(r,!1),s}destroy(){this._renderer=null;for(let t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}};Or.extension={type:[w.WebGLSystem,w.WebGPUSystem,w.CanvasSystem],name:"canvasText"};var Ve=class n extends Ss{constructor(t){t instanceof K&&(t={context:t});let{context:e,roundPixels:r,...s}=t||{};super({label:"Graphics",...s}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new K,this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=r??!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||t?.context===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new n(this._context.clone()):(this._ownedContext=null,new n(this._context))}lineStyle(t,e,r){U(D,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");let s={};return t&&(s.width=t),e&&(s.color=e),r&&(s.alpha=r),this.context.strokeStyle=s,this}beginFill(t,e){U(D,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");let r={};return t!==void 0&&(r.color=t),e!==void 0&&(r.alpha=e),this.context.fillStyle=r,this}endFill(){U(D,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();let t=this.context.strokeStyle;return(t.width!==K.defaultStrokeStyle.width||t.color!==K.defaultStrokeStyle.color||t.alpha!==K.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return U(D,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return U(D,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return U(D,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return U(D,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return U(D,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return U(D,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}};var Vi={name:"local-uniform-msdf-bit",vertex:{header:`
|
|
128
|
+
struct LocalUniforms {
|
|
129
|
+
uColor:vec4<f32>,
|
|
130
|
+
uTransformMatrix:mat3x3<f32>,
|
|
131
|
+
uDistance: f32,
|
|
132
|
+
uRound:f32,
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
136
|
+
`,main:`
|
|
137
|
+
vColor *= localUniforms.uColor;
|
|
138
|
+
modelMatrix *= localUniforms.uTransformMatrix;
|
|
139
|
+
`,end:`
|
|
140
|
+
if(localUniforms.uRound == 1)
|
|
141
|
+
{
|
|
142
|
+
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
143
|
+
}
|
|
144
|
+
`},fragment:{header:`
|
|
145
|
+
struct LocalUniforms {
|
|
146
|
+
uColor:vec4<f32>,
|
|
147
|
+
uTransformMatrix:mat3x3<f32>,
|
|
148
|
+
uDistance: f32
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
152
|
+
`,main:`
|
|
153
|
+
outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));
|
|
154
|
+
`}},Ni={name:"local-uniform-msdf-bit",vertex:{header:`
|
|
155
|
+
uniform mat3 uTransformMatrix;
|
|
156
|
+
uniform vec4 uColor;
|
|
157
|
+
uniform float uRound;
|
|
158
|
+
`,main:`
|
|
159
|
+
vColor *= uColor;
|
|
160
|
+
modelMatrix *= uTransformMatrix;
|
|
161
|
+
`,end:`
|
|
162
|
+
if(uRound == 1.)
|
|
163
|
+
{
|
|
164
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
165
|
+
}
|
|
166
|
+
`},fragment:{header:`
|
|
167
|
+
uniform float uDistance;
|
|
168
|
+
`,main:`
|
|
169
|
+
outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));
|
|
170
|
+
`}};var ji={name:"msdf-bit",fragment:{header:`
|
|
171
|
+
fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {
|
|
172
|
+
|
|
173
|
+
// MSDF
|
|
174
|
+
var median = msdfColor.r + msdfColor.g + msdfColor.b -
|
|
175
|
+
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
|
|
176
|
+
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
|
|
177
|
+
|
|
178
|
+
// SDF
|
|
179
|
+
median = min(median, msdfColor.a);
|
|
180
|
+
|
|
181
|
+
var screenPxDistance = distance * (median - 0.5);
|
|
182
|
+
var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
|
183
|
+
if (median < 0.01) {
|
|
184
|
+
alpha = 0.0;
|
|
185
|
+
} else if (median > 0.99) {
|
|
186
|
+
alpha = 1.0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Gamma correction for coverage-like alpha
|
|
190
|
+
var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));
|
|
191
|
+
var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);
|
|
192
|
+
var coverage: f32 = pow(shapeColor.a * alpha, gamma);
|
|
193
|
+
|
|
194
|
+
return coverage;
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
`}},qi={name:"msdf-bit",fragment:{header:`
|
|
198
|
+
float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {
|
|
199
|
+
|
|
200
|
+
// MSDF
|
|
201
|
+
float median = msdfColor.r + msdfColor.g + msdfColor.b -
|
|
202
|
+
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
|
|
203
|
+
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
|
|
204
|
+
|
|
205
|
+
// SDF
|
|
206
|
+
median = min(median, msdfColor.a);
|
|
207
|
+
|
|
208
|
+
float screenPxDistance = distance * (median - 0.5);
|
|
209
|
+
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
|
210
|
+
|
|
211
|
+
if (median < 0.01) {
|
|
212
|
+
alpha = 0.0;
|
|
213
|
+
} else if (median > 0.99) {
|
|
214
|
+
alpha = 1.0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Gamma correction for coverage-like alpha
|
|
218
|
+
float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));
|
|
219
|
+
float gamma = mix(1.0, 1.0 / 2.2, luma);
|
|
220
|
+
float coverage = pow(shapeColor.a * alpha, gamma);
|
|
221
|
+
|
|
222
|
+
return coverage;
|
|
223
|
+
}
|
|
224
|
+
`}};var Vr,Nr,Ne=class extends zt{constructor(t){let e=new J({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new G,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});Vr??(Vr=me({name:"sdf-shader",bits:[vs,Ms(t),Vi,ji,xe]})),Nr??(Nr=ge({name:"sdf-shader",bits:[Cs,As(t),Ni,qi,_e]})),super({glProgram:Nr,gpuProgram:Vr,resources:{localUniforms:e,batchSamplers:ks(t)}})}};var je=class extends Ut{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 U(D,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return U(D,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return U(D,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return U(D,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return U(D,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners();for(let e in this.chars)this.chars[e].texture?.destroy();this.chars=null,t&&(this.pages.forEach(e=>e.texture.destroy(!0)),this.pages=null)}};var $i=class Yi extends je{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._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;let e={...Yi.defaultOptions,...t};this._textureSize=e.textureSize,this._mipmap=e.mipmap;let r=e.style.clone();e.overrideFill&&(r._fill.color=16777215,r._fill.alpha=1,r._fill.texture=E.WHITE,r._fill.fill=null),this.applyFillAsTint=e.overrideFill;let s=r.fontSize;r.fontSize=this.baseMeasurementFontSize;let i=Bt(r);e.overrideSize?r._stroke&&(r._stroke.width*=this.baseRenderedFontSize/s):r.fontSize=this.baseRenderedFontSize=s,this._style=r,this._skipKerning=e.skipKerning??!1,this.resolution=e.resolution??1,this._padding=e.padding??4,e.textureStyle&&(this._textureStyle=e.textureStyle instanceof mt?e.textureStyle:new mt(e.textureStyle)),this.fontMetrics=Y.measureFont(i),this.lineHeight=r.lineHeight||this.fontMetrics.fontSize||r.fontSize}ensureCharacters(t){let e=Y.graphemeSegmenter(t).filter(x=>!this._currentChars.includes(x)).filter((x,g,_)=>_.indexOf(x)===g);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let r;this._currentPageIndex===-1?r=this._nextPage():r=this.pages[this._currentPageIndex];let{canvas:s,context:i}=r.canvasAndContext,o=r.texture.source,a=this._style,l=this._currentX,h=this._currentY,c=this._currentMaxCharHeight,u=this.baseRenderedFontSize/this.baseMeasurementFontSize,f=this._padding*u,d=!1,p=s.width/this.resolution,m=s.height/this.resolution;for(let x=0;x<e.length;x++){let g=e[x],_=Y.measureText(g,a,s,!1);_.lineHeight=_.height;let S=_.width*u,T=Math.ceil((a.fontStyle==="italic"?2:1)*S),M=_.height*u,y=T+f*2,b=M+f*2;if(d=!1,g!==`
|
|
225
|
+
`&&g!=="\r"&&g!==" "&&g!==" "&&(d=!0,c=Math.ceil(Math.max(b,c))),l+y>p&&(h+=c,c=b,l=0,h+c>m)){o.update();let P=this._nextPage();s=P.canvasAndContext.canvas,i=P.canvasAndContext.context,o=P.texture.source,l=0,h=0,c=0}let B=S/u-(a.dropShadow?.distance??0)-(a._stroke?.width??0);if(this.chars[g]={id:g.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:B,kerning:{}},d){this._drawGlyph(i,_,l+f,h+f,u,a);let P=o.width*u,C=o.height*u,v=new H(l/P*o.width,h/C*o.height,y/P*o.width,b/C*o.height);this.chars[g].texture=new E({source:o,frame:v}),l+=Math.ceil(y)}}o.update(),this._currentX=l,this._currentY=h,this._currentMaxCharHeight=c,this._skipKerning&&this._applyKerning(e,i)}get pageTextures(){return U(D,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){let r=this._measureCache;for(let s=0;s<t.length;s++){let i=t[s];for(let o=0;o<this._currentChars.length;o++){let a=this._currentChars[o],l=r[i];l||(l=r[i]=e.measureText(i).width);let h=r[a];h||(h=r[a]=e.measureText(a).width);let c=e.measureText(i+a).width,u=c-(l+h);u&&(this.chars[i].kerning[a]=u),c=e.measureText(i+a).width,u=c-(l+h),u&&(this.chars[a].kerning[i]=u)}}}_nextPage(){this._currentPageIndex++;let t=this.resolution,e=nt.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);let r=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),s=new E({source:new ot({resource:e.canvas,resolution:r,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(s.source.style=this._textureStyle);let i={canvasAndContext:e,texture:s};return this.pages[this._currentPageIndex]=i,i}_setupContext(t,e,r){e.fontSize=this.baseRenderedFontSize,t.scale(r,r),t.font=Bt(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;let s=e._stroke,i=s?.width??0;if(s&&(t.lineWidth=i,t.lineJoin=s.join,t.miterLimit=s.miterLimit,t.strokeStyle=Nt(s,t)),e._fill&&(t.fillStyle=Nt(e._fill,t)),e.dropShadow){let o=e.dropShadow,a=W.shared.setValue(o.color).toArray(),l=o.blur*r,h=o.distance*r;t.shadowColor=`rgba(${a[0]*255},${a[1]*255},${a[2]*255},${o.alpha})`,t.shadowBlur=l,t.shadowOffsetX=Math.cos(o.angle)*h,t.shadowOffsetY=Math.sin(o.angle)*h}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,r,s,i,o){let a=e.text,l=e.fontProperties,c=(o._stroke?.width??0)*i,u=r+c/2,f=s-c/2,d=l.descent*i,p=e.lineHeight*i,m=!1;o.stroke&&c&&(m=!0,t.strokeText(a,u,f+p-d));let{shadowBlur:x,shadowOffsetX:g,shadowOffsetY:_}=t;o._fill&&(m&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(a,u,f+p-d)),m&&(t.shadowBlur=x,t.shadowOffsetX=g,t.shadowOffsetY=_)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){let{canvasAndContext:e,texture:r}=this.pages[t];nt.returnCanvasAndContext(e),r.destroy(!0)}this.pages=null}};$i.defaultOptions={textureSize:512,style:new dt,mipmap:!0};var jr=$i;function qe(n,t,e,r){let s={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};s.offsetY=e.baseLineOffset;let i=s.lines[0],o=null,a=!0,l={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},h=e.baseMeasurementFontSize/t.fontSize,c=t.letterSpacing*h,u=t.wordWrapWidth*h,f=t.lineHeight?t.lineHeight*h:e.lineHeight,d=t.wordWrap&&t.breakWords,p=g=>{let _=i.width;for(let S=0;S<l.index;S++){let T=g.positions[S];i.chars.push(g.chars[S]),i.charPositions.push(T+_)}i.width+=g.width,a=!1,l.width=0,l.index=0,l.chars.length=0},m=()=>{let g=i.chars.length-1;if(r){let _=i.chars[g];for(;_===" ";)i.width-=e.chars[_].xAdvance,_=i.chars[--g]}s.width=Math.max(s.width,i.width),i={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,s.lines.push(i),s.height+=f},x=g=>g-c>u;for(let g=0;g<n.length+1;g++){let _,S=g===n.length;S||(_=n[g]);let T=e.chars[_]||e.chars[" "];if(/(?:\s)/.test(_)||_==="\r"||_===`
|
|
226
|
+
`||S){if(!a&&t.wordWrap&&x(i.width+l.width)?(m(),p(l),S||i.charPositions.push(0)):(l.start=i.width,p(l),S||i.charPositions.push(0)),_==="\r"||_===`
|
|
227
|
+
`)m();else if(!S){let B=T.xAdvance+(T.kerning[o]||0)+c;i.width+=B,i.spaceWidth=B,i.spacesIndex.push(i.charPositions.length),i.chars.push(_)}}else{let b=T.kerning[o]||0,B=T.xAdvance+b+c;d&&x(i.width+l.width+B)&&(p(l),m()),l.positions[l.index++]=l.width+b,l.chars.push(_),l.width+=B}o=_}return m(),t.align==="center"?Ao(s):t.align==="right"?ko(s):t.align==="justify"&&Fo(s),s}function Ao(n){for(let t=0;t<n.lines.length;t++){let e=n.lines[t],r=n.width/2-e.width/2;for(let s=0;s<e.charPositions.length;s++)e.charPositions[s]+=r}}function ko(n){for(let t=0;t<n.lines.length;t++){let e=n.lines[t],r=n.width-e.width;for(let s=0;s<e.charPositions.length;s++)e.charPositions[s]+=r}}function Fo(n){let t=n.width;for(let e=0;e<n.lines.length;e++){let r=n.lines[e],s=0,i=r.spacesIndex[s++],o=0,a=r.spacesIndex.length,h=(t-r.width)/a;for(let c=0;c<r.charPositions.length;c++)c===i&&(i=r.spacesIndex[s++],o+=h),r.charPositions[c]+=o}}function Xi(n){if(n==="")return[];typeof n=="string"&&(n=[n]);let t=[];for(let e=0,r=n.length;e<r;e++){let s=n[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);if(s[0].length===0||s[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");let i=s[0].charCodeAt(0),o=s[1].charCodeAt(0);if(o<i)throw new Error("[BitmapFont]: Invalid character range.");for(let a=i,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...Array.from(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}var $e=0,qr=class{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1,textureStyle:null},this.measureCache=He(1e3)}getFont(t,e){let r=`${e.fontFamily}-bitmap`,s=!0;if(e._fill.fill&&!e._stroke?(r+=e._fill.fill.styleKey,s=!1):(e._stroke||e.dropShadow)&&(r=`${e.styleKey}-bitmap`,s=!1),!N.has(r)){let o=Object.create(e);o.lineHeight=0;let a=new jr({style:o,overrideFill:s,overrideSize:!0,...this.defaultOptions});$e++,$e>50&&L("BitmapText",`You have dynamically created ${$e} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),a.once("destroy",()=>{$e--,N.remove(r)}),N.set(r,a)}let i=N.get(r);return i.ensureCharacters?.(t),i}getLayout(t,e,r=!0){let s=this.getFont(t,e),i=`${t}-${e.styleKey}-${r}`;if(this.measureCache.has(i))return this.measureCache.get(i);let o=Y.graphemeSegmenter(t),a=qe(o,e,s,r);return this.measureCache.set(i,a),a}measureText(t,e,r=!0){return this.getLayout(t,e,r)}install(...t){let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:t[2]?.chars,resolution:t[2]?.resolution,padding:t[2]?.padding,skipKerning:t[2]?.skipKerning},U(D,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));let r=e?.name;if(!r)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};let s=e.style,i=s instanceof dt?s:new dt(s),o=e.dynamicFill??this._canUseTintForStyle(i),a=new jr({style:i,overrideFill:o,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1,textureStyle:e.textureStyle}),l=Xi(e.chars);return a.ensureCharacters(l.join("")),N.set(`${r}-bitmap`,a),a.once("destroy",()=>N.remove(`${r}-bitmap`)),a}uninstall(t){let e=`${t}-bitmap`,r=N.get(e);r&&r.destroy()}_canUseTintForStyle(t){return!t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}},Ki=new qr;var $r=class extends Ve{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}},Yr=class{constructor(t){this._renderer=t}validateRenderable(t){let e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){let r=this._getGpuBitmapText(t);Qi(t,r),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,r)),this._renderer.renderPipes.graphics.addRenderable(r,e),r.context.customShader&&this._updateDistanceField(t)}updateRenderable(t){let e=this._getGpuBitmapText(t);Qi(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){let{context:r}=e,s=Ki.getFont(t.text,t._style);r.clear(),s.distanceField.type!=="none"&&(r.customShader||(r.customShader=new Ne(this._renderer.limits.maxBatchableTextures)));let i=Y.graphemeSegmenter(t.text),o=t._style,a=s.baseLineOffset,l=qe(i,o,s,!0),h=o.padding,c=l.scale,u=l.width,f=l.height+l.offsetY;o._stroke&&(u+=o._stroke.width/c,f+=o._stroke.width/c),r.translate(-t._anchor._x*u-h,-t._anchor._y*f-h).scale(c,c);let d=s.applyFillAsTint?o._fill.color:16777215,p=s.fontMetrics.fontSize,m=s.lineHeight;o.lineHeight&&(p=o.fontSize/c,m=o.lineHeight/c);let x=(m-p)/2;x-s.baseLineOffset<0&&(x=0);for(let g=0;g<l.lines.length;g++){let _=l.lines[g];for(let S=0;S<_.charPositions.length;S++){let T=_.chars[S],M=s.chars[T];if(M?.texture){let y=M.texture;r.texture(y,d||"black",Math.round(_.charPositions[S]+M.xOffset),Math.round(a+M.yOffset+x),y.orig.width,y.orig.height)}}a+=m}}_getGpuBitmapText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){let e=new $r;return t._gpuData[this._renderer.uid]=e,this._updateContext(t,e),e}_updateDistanceField(t){let e=this._getGpuBitmapText(t).context,r=t._style.fontFamily,s=N.get(`${r}-bitmap`),{a:i,b:o,c:a,d:l}=t.groupTransform,h=Math.sqrt(i*i+o*o),c=Math.sqrt(a*a+l*l),u=(Math.abs(h)+Math.abs(c))/2,f=s.baseRenderedFontSize/t._style.fontSize,d=u*s.distanceField.range*(1/f);e.customShader.resources.localUniforms.uniforms.uDistance=d}destroy(){this._renderer=null}};Yr.extension={type:[w.WebGLPipes,w.WebGPUPipes,w.CanvasPipes],name:"bitmapText"};function Qi(n,t){t.groupTransform=n.groupTransform,t.groupColorAlpha=n.groupColorAlpha,t.groupColor=n.groupColor,t.groupBlendMode=n.groupBlendMode,t.globalDisplayStatus=n.globalDisplayStatus,t.groupTransform=n.groupTransform,t.localDisplayStatus=n.localDisplayStatus,t.groupAlpha=n.groupAlpha,t._roundPixels=n._roundPixels}var Ye=class extends ye{constructor(t){super(),this.generatingTexture=!1,this.currentKey="--",this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){let t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){let{htmlText:t}=this._renderer;t.getReferenceCount(this.currentKey)===null?t.returnTexturePromise(this.texturePromise):t.decreaseReferenceCount(this.currentKey),this._renderer.runners.resolutionChange.remove(this),this.texturePromise=null,this._renderer=null}};var Xr=class{constructor(t){this._renderer=t}validateRenderable(t){let e=this._getGpuText(t),r=t.styleKey;return e.currentKey!==r}addRenderable(t,e){let r=this._getGpuText(t);if(t._didTextUpdate){let s=t._autoResolution?this._renderer.resolution:t.resolution;(r.currentKey!==t.styleKey||t.resolution!==s)&&this._updateGpuText(t).catch(i=>{console.error(i)}),t._didTextUpdate=!1,oe(r,t)}this._renderer.renderPipes.batch.addToBatch(r,e)}updateRenderable(t){let e=this._getGpuText(t);e._batcher.updateElement(e)}async _updateGpuText(t){t._didTextUpdate=!1;let e=this._getGpuText(t);if(e.generatingTexture)return;let r=e.texturePromise;e.texturePromise=null,e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;let s=this._renderer.htmlText.getTexturePromise(t);r&&(s=s.finally(()=>{this._renderer.htmlText.decreaseReferenceCount(e.currentKey),this._renderer.htmlText.returnTexturePromise(r)})),e.texturePromise=s,e.currentKey=t.styleKey,e.texture=await s;let i=t.renderGroup||t.parentRenderGroup;i&&(i.structureDidChange=!0),e.generatingTexture=!1,oe(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){let e=new Ye(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.texture=E.EMPTY,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}};Xr.extension={type:[w.WebGLPipes,w.WebGPUPipes,w.CanvasPipes],name:"htmlText"};function Zi(){let{userAgent:n}=j.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(n)}var Ji="http://www.w3.org/2000/svg",tn="http://www.w3.org/1999/xhtml",jt=class{constructor(){this.svgRoot=document.createElementNS(Ji,"svg"),this.foreignObject=document.createElementNS(Ji,"foreignObject"),this.domElement=document.createElementNS(tn,"div"),this.styleElement=document.createElementNS(tn,"style");let{foreignObject:t,svgRoot:e,styleElement:r,domElement:s}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(r),t.appendChild(s),this.image=j.get().createImage()}destroy(){this.svgRoot.remove(),this.foreignObject.remove(),this.styleElement.remove(),this.domElement.remove(),this.image.src="",this.image.remove(),this.svgRoot=null,this.foreignObject=null,this.styleElement=null,this.domElement=null,this.image=null,this.canvasAndContext=null}};function en(n,t){let e=t.fontFamily,r=[],s={},i=/font-family:([^;"\s]+)/g,o=n.match(i);function a(l){s[l]||(r.push(l),s[l]=!0)}if(Array.isArray(e))for(let l=0;l<e.length;l++)a(e[l]);else a(e);o&&o.forEach(l=>{let h=l.split(":")[1].trim();a(h)});for(let l in t.tagStyles){let h=t.tagStyles[l].fontFamily;a(h)}return r}async function rn(n){let e=await(await j.get().fetch(n)).blob(),r=new FileReader;return await new Promise((i,o)=>{r.onloadend=()=>i(r.result),r.onerror=o,r.readAsDataURL(e)})}async function sn(n,t){let e=await rn(t);return`@font-face {
|
|
228
|
+
font-family: "${n.fontFamily}";
|
|
229
|
+
font-weight: ${n.fontWeight};
|
|
230
|
+
font-style: ${n.fontStyle};
|
|
231
|
+
src: url('${e}');
|
|
232
|
+
}`}var Kr=new Map;async function nn(n){let t=n.filter(e=>N.has(`${e}-and-url`)).map(e=>{if(!Kr.has(e)){let{entries:r}=N.get(`${e}-and-url`),s=[];r.forEach(i=>{let o=i.url,l=i.faces.map(h=>({weight:h.weight,style:h.style}));s.push(...l.map(h=>sn({fontWeight:h.weight,fontStyle:h.style,fontFamily:e},o)))}),Kr.set(e,Promise.all(s).then(i=>i.join(`
|
|
233
|
+
`)))}return Kr.get(e)});return(await Promise.all(t)).join(`
|
|
234
|
+
`)}function on(n,t,e,r,s){let{domElement:i,styleElement:o,svgRoot:a}=s;i.innerHTML=`<style>${t.cssStyle}</style><div style='padding:0;'>${n}</div>`,i.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),o.textContent=r;let{width:l,height:h}=s.image;return a.setAttribute("width",l.toString()),a.setAttribute("height",h.toString()),new XMLSerializer().serializeToString(a)}function an(n,t){let e=nt.getOptimalCanvasAndContext(n.width,n.height,t),{context:r}=e;return r.clearRect(0,0,n.width,n.height),r.drawImage(n,0,0),e}function ln(n,t,e){return new Promise(async r=>{e&&await new Promise(s=>setTimeout(s,100)),n.onload=()=>{r()},n.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,n.crossOrigin="anonymous"})}var cn;function hn(n,t,e,r){r||(r=cn||(cn=new jt));let{domElement:s,styleElement:i,svgRoot:o}=r;s.innerHTML=`<style>${t.cssStyle};</style><div style='padding:0'>${n}</div>`,s.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(i.textContent=e),document.body.appendChild(o);let a=s.getBoundingClientRect();o.remove();let l=t.padding*2;return{width:a.width-l,height:a.height-l}}var Qr=class{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===It.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getManagedTexture(t){let e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].promise;let r=this._buildTexturePromise(t).then(s=>(this._activeTextures[e].texture=s,s));return this._activeTextures[e]={texture:null,promise:r,usageCount:1},r}getReferenceCount(t){return this._activeTextures[t]?.usageCount??null}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){let e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e.texture):e.promise.then(r=>{e.texture=r,this._cleanUp(e.texture)}).catch(()=>{L("HTMLTextSystem: Failed to clean texture")}),this._activeTextures[t]=null))}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){let{text:e,style:r,resolution:s,textureStyle:i}=t,o=X.get(jt),a=en(e,r),l=await nn(a),h=hn(e,r,l,o),c=Math.ceil(Math.ceil(Math.max(1,h.width)+r.padding*2)*s),u=Math.ceil(Math.ceil(Math.max(1,h.height)+r.padding*2)*s),f=o.image,d=2;f.width=(c|0)+d,f.height=(u|0)+d;let p=on(e,r,s,l,o);await ln(f,p,Zi()&&a.length>0);let m=f,x;this._createCanvas&&(x=an(f,s));let g=We(x?x.canvas:m,f.width-d,f.height-d,s);return i&&(g.source.style=i),this._createCanvas&&(this._renderer.texture.initSource(g.source),nt.returnCanvasAndContext(x)),X.return(o),g}returnTexturePromise(t){t.then(e=>{this._cleanUp(e)}).catch(()=>{L("HTMLTextSystem: Failed to clean texture")})}_cleanUp(t){q.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null;for(let t in this._activeTextures)this._activeTextures[t]&&this.returnTexturePromise(this._activeTextures[t].promise);this._activeTextures=null}};Qr.extension={type:[w.WebGLSystem,w.WebGPUSystem,w.CanvasSystem],name:"htmlText"};var un=class dn extends Gt{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(U(D,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...dn.defaultOptions,...e};let r=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),s=e.uvs;s||(e.positions?s=new Float32Array(r.length):s=new Float32Array([0,0,1,0,1,1,0,1]));let i=e.indices||new Uint32Array([0,1,2,0,2,3]),o=e.shrinkBuffersToFit,a=new Pt({data:r,label:"attribute-mesh-positions",shrinkToFit:o,usage:Q.VERTEX|Q.COPY_DST}),l=new Pt({data:s,label:"attribute-mesh-uvs",shrinkToFit:o,usage:Q.VERTEX|Q.COPY_DST}),h=new Pt({data:i,label:"index-mesh-buffer",shrinkToFit:o,usage:Q.INDEX|Q.COPY_DST});super({attributes:{aPosition:{buffer:a,format:"float32x2",stride:8,offset:0},aUV:{buffer:l,format:"float32x2",stride:8,offset:0}},indexBuffer:h,topology:e.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};un.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};var qt=un;var fn={name:"tiling-bit",vertex:{header:`
|
|
235
|
+
struct TilingUniforms {
|
|
236
|
+
uMapCoord:mat3x3<f32>,
|
|
237
|
+
uClampFrame:vec4<f32>,
|
|
238
|
+
uClampOffset:vec2<f32>,
|
|
239
|
+
uTextureTransform:mat3x3<f32>,
|
|
240
|
+
uSizeAnchor:vec4<f32>
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
244
|
+
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
245
|
+
@group(2) @binding(2) var uSampler: sampler;
|
|
246
|
+
`,main:`
|
|
247
|
+
uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;
|
|
248
|
+
|
|
249
|
+
position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
|
|
250
|
+
`},fragment:{header:`
|
|
251
|
+
struct TilingUniforms {
|
|
252
|
+
uMapCoord:mat3x3<f32>,
|
|
253
|
+
uClampFrame:vec4<f32>,
|
|
254
|
+
uClampOffset:vec2<f32>,
|
|
255
|
+
uTextureTransform:mat3x3<f32>,
|
|
256
|
+
uSizeAnchor:vec4<f32>
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
260
|
+
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
261
|
+
@group(2) @binding(2) var uSampler: sampler;
|
|
262
|
+
`,main:`
|
|
263
|
+
|
|
264
|
+
var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
|
|
265
|
+
coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
|
|
266
|
+
var unclamped = coord;
|
|
267
|
+
coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);
|
|
268
|
+
|
|
269
|
+
var bias = 0.;
|
|
270
|
+
|
|
271
|
+
if(unclamped.x == coord.x && unclamped.y == coord.y)
|
|
272
|
+
{
|
|
273
|
+
bias = -32.;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
outColor = textureSampleBias(uTexture, uSampler, coord, bias);
|
|
277
|
+
`}},pn={name:"tiling-bit",vertex:{header:`
|
|
278
|
+
uniform mat3 uTextureTransform;
|
|
279
|
+
uniform vec4 uSizeAnchor;
|
|
280
|
+
|
|
281
|
+
`,main:`
|
|
282
|
+
uv = (uTextureTransform * vec3(aUV, 1.0)).xy;
|
|
283
|
+
|
|
284
|
+
position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
|
|
285
|
+
`},fragment:{header:`
|
|
286
|
+
uniform sampler2D uTexture;
|
|
287
|
+
uniform mat3 uMapCoord;
|
|
288
|
+
uniform vec4 uClampFrame;
|
|
289
|
+
uniform vec2 uClampOffset;
|
|
290
|
+
`,main:`
|
|
291
|
+
|
|
292
|
+
vec2 coord = vUV + ceil(uClampOffset - vUV);
|
|
293
|
+
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
|
294
|
+
vec2 unclamped = coord;
|
|
295
|
+
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
|
296
|
+
|
|
297
|
+
outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
|
|
298
|
+
|
|
299
|
+
`}};var Zr,Jr,Xe=class extends zt{constructor(){Zr??(Zr=me({name:"tiling-sprite-shader",bits:[Rs,fn,xe]})),Jr??(Jr=ge({name:"tiling-sprite-shader",bits:[Us,pn,_e]}));let t=new J({uMapCoord:{value:new G,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 G,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:Jr,gpuProgram:Zr,resources:{localUniforms:new J({uTransformMatrix:{value:new G,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:E.EMPTY.source,uSampler:E.EMPTY.source.style}})}updateUniforms(t,e,r,s,i,o){let a=this.resources.tilingUniforms,l=o.width,h=o.height,c=o.textureMatrix,u=a.uniforms.uTextureTransform;u.set(r.a*l/t,r.b*l/e,r.c*h/t,r.d*h/e,r.tx/t,r.ty/e),u.invert(),a.uniforms.uMapCoord=c.mapCoord,a.uniforms.uClampFrame=c.uClampFrame,a.uniforms.uClampOffset=c.uClampOffset,a.uniforms.uTextureTransform=u,a.uniforms.uSizeAnchor[0]=t,a.uniforms.uSizeAnchor[1]=e,a.uniforms.uSizeAnchor[2]=s,a.uniforms.uSizeAnchor[3]=i,o&&(this.resources.uTexture=o.source,this.resources.uSampler=o.source.style)}};var Ke=class extends qt{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 mn(n,t){let e=n.anchor.x,r=n.anchor.y;t[0]=-e*n.width,t[1]=-r*n.height,t[2]=(1-e)*n.width,t[3]=-r*n.height,t[4]=(1-e)*n.width,t[5]=(1-r)*n.height,t[6]=-e*n.width,t[7]=(1-r)*n.height}function gn(n,t,e,r){let s=0,i=n.length/(t||2),o=r.a,a=r.b,l=r.c,h=r.d,c=r.tx,u=r.ty;for(e*=t;s<i;){let f=n[e],d=n[e+1];n[e]=o*f+l*d+c,n[e+1]=a*f+h*d+u,e+=t,s++}}function xn(n,t){let e=n.texture,r=e.frame.width,s=e.frame.height,i=0,o=0;n.applyAnchorToTexture&&(i=n.anchor.x,o=n.anchor.y),t[0]=t[6]=-i,t[2]=t[4]=1-i,t[1]=t[3]=-o,t[5]=t[7]=1-o;let a=G.shared;a.copyFrom(n._tileTransform.matrix),a.tx/=n.width,a.ty/=n.height,a.invert(),a.scale(n.width/r,n.height/s),gn(t,2,0,a)}var Qe=new Ke,ts=class{constructor(){this.canBatch=!0,this.geometry=new qt({indices:Qe.indices.slice(),positions:Qe.positions.slice(),uvs:Qe.uvs.slice()})}destroy(){this.geometry.destroy(),this.shader?.destroy()}},es=class{constructor(t){this._state=vt.default2d,this._renderer=t}validateRenderable(t){let e=this._getTilingSpriteData(t),r=e.canBatch;this._updateCanBatch(t);let s=e.canBatch;if(s&&s===r){let{batchableMesh:i}=e;return!i._batcher.checkAndUpdateTexture(i,t.texture)}return r!==s}addRenderable(t,e){let r=this._renderer.renderPipes.batch;this._updateCanBatch(t);let s=this._getTilingSpriteData(t),{geometry:i,canBatch:o}=s;if(o){s.batchableMesh||(s.batchableMesh=new yt);let a=s.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),a.geometry=i,a.renderable=t,a.transform=t.groupTransform,a.setTexture(t._texture)),a.roundPixels=this._renderer._roundPixels|t._roundPixels,r.addToBatch(a,e)}else r.break(e),s.shader||(s.shader=new Xe),this.updateRenderable(t),e.add(t)}execute(t){let{shader:e}=this._getTilingSpriteData(t);e.groups[0]=this._renderer.globalUniforms.bindGroup;let r=e.resources.localUniforms.uniforms;r.uTransformMatrix=t.groupTransform,r.uRound=this._renderer._roundPixels|t._roundPixels,xt(t.groupColorAlpha,r.uColor,0),this._state.blendMode=Et(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:Qe,shader:e,state:this._state})}updateRenderable(t){let e=this._getTilingSpriteData(t),{canBatch:r}=e;if(r){let{batchableMesh:s}=e;t.didViewUpdate&&this._updateBatchableMesh(t),s._batcher.updateElement(s)}else if(t.didViewUpdate){let{shader:s}=e;s.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}}_getTilingSpriteData(t){return t._gpuData[this._renderer.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){let e=new ts;return e.renderable=t,t._gpuData[this._renderer.uid]=e,e}_updateBatchableMesh(t){let e=this._getTilingSpriteData(t),{geometry:r}=e,s=t.texture.source.style;s.addressMode!=="repeat"&&(s.addressMode="repeat",s.update()),xn(t,r.uvs),mn(t,r.positions)}destroy(){this._renderer=null}_updateCanBatch(t){let e=this._getTilingSpriteData(t),r=t.texture,s=!0;return this._renderer.type===It.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=r.textureMatrix.isSimple&&(s||r.source.isPowerOfTwo),e.canBatch}};es.extension={type:[w.WebGLPipes,w.WebGPUPipes,w.CanvasPipes],name:"tilingSprite"};var _n=class yn extends qt{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(U(D,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),e={width:e,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(e)}build(t){t={...yn.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 e=this.verticesX*this.verticesY,r=[],s=[],i=[],o=this.verticesX-1,a=this.verticesY-1,l=this.width/o,h=this.height/a;for(let u=0;u<e;u++){let f=u%this.verticesX,d=u/this.verticesX|0;r.push(f*l,d*h),s.push(f/o,d/a)}let c=o*a;for(let u=0;u<c;u++){let f=u%o,d=u/o|0,p=d*this.verticesX+f,m=d*this.verticesX+f+1,x=(d+1)*this.verticesX+f,g=(d+1)*this.verticesX+f+1;i.push(p,m,x,m,g,x)}this.buffers[0].data=new Float32Array(r),this.buffers[1].data=new Float32Array(s),this.indexBuffer.data=new Uint32Array(i),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};_n.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};var bn=_n;var Sn=class Tn extends bn{constructor(t={}){t={...Tn.defaultOptions,...t},super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){this.width=t.width??this.width,this.height=t.height??this.height,this._originalWidth=t.originalWidth??this._originalWidth,this._originalHeight=t.originalHeight??this._originalHeight,this._leftWidth=t.leftWidth??this._leftWidth,this._rightWidth=t.rightWidth??this._rightWidth,this._topHeight=t.topHeight??this._topHeight,this._bottomHeight=t.bottomHeight??this._bottomHeight,this._anchorX=t.anchor?.x,this._anchorY=t.anchor?.y,this.updateUvs(),this.updatePositions()}updatePositions(){let t=this.positions,{width:e,height:r,_leftWidth:s,_rightWidth:i,_topHeight:o,_bottomHeight:a,_anchorX:l,_anchorY:h}=this,c=s+i,u=e>c?1:e/c,f=o+a,d=r>f?1:r/f,p=Math.min(u,d),m=l*e,x=h*r;t[0]=t[8]=t[16]=t[24]=-m,t[2]=t[10]=t[18]=t[26]=s*p-m,t[4]=t[12]=t[20]=t[28]=e-i*p-m,t[6]=t[14]=t[22]=t[30]=e-m,t[1]=t[3]=t[5]=t[7]=-x,t[9]=t[11]=t[13]=t[15]=o*p-x,t[17]=t[19]=t[21]=t[23]=r-a*p-x,t[25]=t[27]=t[29]=t[31]=r-x,this.getBuffer("aPosition").update()}updateUvs(){let t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;let e=1/this._originalWidth,r=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=r*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-r*this._bottomHeight,this.getBuffer("aUV").update()}};Sn.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};var wn=Sn;var rs=class extends yt{constructor(){super(),this.geometry=new wn}destroy(){this.geometry.destroy()}},ss=class{constructor(t){this._renderer=t}addRenderable(t,e){let r=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,r),this._renderer.renderPipes.batch.addToBatch(r,e)}updateRenderable(t){let e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){let e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture)}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){let e=t._gpuData[this._renderer.uid]=new rs,r=e;return r.renderable=t,r.transform=t.groupTransform,r.texture=t._texture,r.roundPixels=this._renderer._roundPixels|t._roundPixels,t.didViewUpdate||this._updateBatchableSprite(t,r),e}destroy(){this._renderer=null}};ss.extension={type:[w.WebGLPipes,w.WebGPUPipes,w.CanvasPipes],name:"nineSliceSprite"};var is=class{constructor(t){this._renderer=t}push(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}};is.extension={type:[w.WebGLPipes,w.WebGPUPipes,w.CanvasPipes],name:"filter"};var Pn=`in vec2 aPosition;
|
|
300
|
+
out vec2 vTextureCoord;
|
|
301
|
+
|
|
302
|
+
uniform vec4 uInputSize;
|
|
303
|
+
uniform vec4 uOutputFrame;
|
|
304
|
+
uniform vec4 uOutputTexture;
|
|
305
|
+
|
|
306
|
+
vec4 filterVertexPosition( void )
|
|
307
|
+
{
|
|
308
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
309
|
+
|
|
310
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
311
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
312
|
+
|
|
313
|
+
return vec4(position, 0.0, 1.0);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
vec2 filterTextureCoord( void )
|
|
317
|
+
{
|
|
318
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
void main(void)
|
|
322
|
+
{
|
|
323
|
+
gl_Position = filterVertexPosition();
|
|
324
|
+
vTextureCoord = filterTextureCoord();
|
|
325
|
+
}
|
|
326
|
+
`;var vn=`in vec2 vTextureCoord;
|
|
327
|
+
out vec4 finalColor;
|
|
328
|
+
uniform sampler2D uTexture;
|
|
329
|
+
void main() {
|
|
330
|
+
finalColor = texture(uTexture, vTextureCoord);
|
|
331
|
+
}
|
|
332
|
+
`;var ns=`struct GlobalFilterUniforms {
|
|
333
|
+
uInputSize: vec4<f32>,
|
|
334
|
+
uInputPixel: vec4<f32>,
|
|
335
|
+
uInputClamp: vec4<f32>,
|
|
336
|
+
uOutputFrame: vec4<f32>,
|
|
337
|
+
uGlobalFrame: vec4<f32>,
|
|
338
|
+
uOutputTexture: vec4<f32>,
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
|
|
342
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
343
|
+
@group(0) @binding(2) var uSampler: sampler;
|
|
344
|
+
|
|
345
|
+
struct VSOutput {
|
|
346
|
+
@builtin(position) position: vec4<f32>,
|
|
347
|
+
@location(0) uv: vec2<f32>
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
|
|
351
|
+
{
|
|
352
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
353
|
+
|
|
354
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
355
|
+
position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
356
|
+
|
|
357
|
+
return vec4(position, 0.0, 1.0);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
|
|
361
|
+
{
|
|
362
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
@vertex
|
|
366
|
+
fn mainVertex(
|
|
367
|
+
@location(0) aPosition: vec2<f32>,
|
|
368
|
+
) -> VSOutput {
|
|
369
|
+
return VSOutput(
|
|
370
|
+
filterVertexPosition(aPosition),
|
|
371
|
+
filterTextureCoord(aPosition)
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
@fragment
|
|
376
|
+
fn mainFragment(
|
|
377
|
+
@location(0) uv: vec2<f32>,
|
|
378
|
+
) -> @location(0) vec4<f32> {
|
|
379
|
+
return textureSample(uTexture, uSampler, uv);
|
|
380
|
+
}
|
|
381
|
+
`;var Ze=class extends Es{constructor(){let t=pe.from({vertex:{source:ns,entryPoint:"mainVertex"},fragment:{source:ns,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=fe.from({vertex:Pn,fragment:vn,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}};var Cn=new G;function Mn(n,t){t.clear();let e=t.matrix;for(let r=0;r<n.length;r++){let s=n[r];if(s.globalDisplayStatus<7)continue;let i=s.renderGroup??s.parentRenderGroup;i?.isCachedAsTexture?t.matrix=Cn.copyFrom(i.textureOffsetInverseTransform).append(s.worldTransform):i?._parentCacheAsTextureRenderGroup?t.matrix=Cn.copyFrom(i._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(s.groupTransform):t.matrix=s.worldTransform,t.addBounds(s.bounds)}return t.matrix=e,t}var Bo=new Gt({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])}),os=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new st,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}},as=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new J({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 de({}),this.renderer=t}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){let e=this.renderer,r=t.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=r,s.container=t.container,s.outputRenderSurface=e.renderTarget.renderSurface;let i=e.renderTarget.renderTarget.colorTexture.source,o=i.resolution,a=i.antialias;if(r.every(d=>!d.enabled)){s.skip=!0;return}let l=s.bounds;if(this._calculateFilterArea(t,l),this._calculateFilterBounds(s,e.renderTarget.rootViewPort,a,o,1),s.skip)return;let h=this._getPreviousFilterData(),c=this._findFilterResolution(o),u=0,f=0;h&&(u=h.bounds.minX,f=h.bounds.minY),this._calculateGlobalFrame(s,u,f,c,i.width,i.height),this._setupFilterTextures(s,l,e,h)}generateFilteredTexture({texture:t,filters:e}){let r=this._pushFilterData();this._activeFilterData=r,r.skip=!1,r.filters=e;let s=t.source,i=s.resolution,o=s.antialias;if(e.every(d=>!d.enabled))return r.skip=!0,t;let a=r.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(r,a.rectangle,o,i,0),r.skip)return t;let l=i;this._calculateGlobalFrame(r,0,0,l,s.width,s.height),r.outputRenderSurface=q.getOptimalTexture(a.width,a.height,r.resolution,r.antialias),r.backTexture=E.EMPTY,r.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,!0);let f=r.outputRenderSurface;return f.source.alphaMode="premultiplied-alpha",f}pop(){let t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&q.returnTexture(e.backTexture),q.returnTexture(e.inputTexture))}getBackTexture(t,e,r){let s=t.colorTexture.source._resolution,i=q.getOptimalTexture(e.width,e.height,s,!1),o=e.minX,a=e.minY;r&&(o-=r.minX,a-=r.minY),o=Math.floor(o*s),a=Math.floor(a*s);let l=Math.ceil(e.width*s),h=Math.ceil(e.height*s);return this.renderer.renderTarget.copyToTexture(t,i,{x:o,y:a},{width:l,height:h},{x:0,y:0}),i}applyFilter(t,e,r,s){let i=this.renderer,o=this._activeFilterData,l=o.outputRenderSurface===r,h=i.renderTarget.rootRenderTarget.colorTexture.source._resolution,c=this._findFilterResolution(h),u=0,f=0;if(l){let p=this._findPreviousFilterOffset();u=p.x,f=p.y}this._updateFilterUniforms(e,r,o,u,f,c,l,s);let d=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,e,i)}calculateSpriteMatrix(t,e){let r=this._activeFilterData,s=t.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),i=e.worldTransform.copyTo(G.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&i.prepend(o.cacheToLocalTransform),i.invert(),s.prepend(i),s.scale(1/e.texture.orig.width,1/e.texture.orig.height),s.translate(e.anchor.x,e.anchor.y),s}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new Ze),this._passthroughFilter}_setupBindGroupsAndRender(t,e,r){if(r.renderPipes.uniformBatch){let s=r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(s,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,r.encoder.draw({geometry:Bo,shader:t,state:t._state,topology:"triangle-list"}),r.type===It.WEBGL&&r.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,r,s){if(t.backTexture=E.EMPTY,t.inputTexture=q.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){r.renderTarget.finishRenderPass();let i=r.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(i,e,s?.bounds)}r.renderTarget.bind(t.inputTexture,!0),r.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,r,s,i,o){let a=t.globalFrame;a.x=e*s,a.y=r*s,a.width=i*s,a.height=o*s}_updateFilterUniforms(t,e,r,s,i,o,a,l){let h=this._filterGlobalUniforms.uniforms,c=h.uOutputFrame,u=h.uInputSize,f=h.uInputPixel,d=h.uInputClamp,p=h.uGlobalFrame,m=h.uOutputTexture;a?(c[0]=r.bounds.minX-s,c[1]=r.bounds.minY-i):(c[0]=0,c[1]=0),c[2]=t.frame.width,c[3]=t.frame.height,u[0]=t.source.width,u[1]=t.source.height,u[2]=1/u[0],u[3]=1/u[1],f[0]=t.source.pixelWidth,f[1]=t.source.pixelHeight,f[2]=1/f[0],f[3]=1/f[1],d[0]=.5*f[2],d[1]=.5*f[3],d[2]=t.frame.width*u[2]-.5*f[2],d[3]=t.frame.height*u[3]-.5*f[3];let x=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=s*o,p[1]=i*o,p[2]=x.source.width*o,p[3]=x.source.height*o,e instanceof E&&(e.source.resource=null);let g=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!l),e instanceof E?(m[0]=e.frame.width,m[1]=e.frame.height):(m[0]=g.width,m[1]=g.height),m[2]=g.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,r=this._filterStackIndex;for(;r>0;){r--;let s=this._filterStack[r];if(!s.skip){t=s.bounds.minX,e=s.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?Mn(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){let s=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;s&&e.applyMatrix(s)}}_applyFiltersToTexture(t,e){let r=t.inputTexture,s=t.bounds,i=t.filters,o=t.firstEnabledIndex,a=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),o===a)i[o].apply(this,r,t.outputRenderSurface,e);else{let l=t.inputTexture,h=q.getOptimalTexture(s.width,s.height,l.source._resolution,!1),c=h;for(let u=o;u<a;u++){let f=i[u];if(!f.enabled)continue;f.apply(this,l,c,!0);let d=l;l=c,c=d}i[a].apply(this,l,t.outputRenderSurface,e),q.returnTexture(h)}}_calculateFilterBounds(t,e,r,s,i){let o=this.renderer,a=t.bounds,l=t.filters,h=1/0,c=0,u=!0,f=!1,d=!1,p=!0,m=-1,x=-1;for(let g=0;g<l.length;g++){let _=l[g];if(!_.enabled)continue;if(m===-1&&(m=g),x=g,h=Math.min(h,_.resolution==="inherit"?s:_.resolution),c+=_.padding,_.antialias==="off"?u=!1:_.antialias==="inherit"&&u&&(u=r),_.clipToViewport||(p=!1),!!!(_.compatibleRenderers&o.type)){d=!1;break}if(_.blendRequired&&!(o.backBuffer?.useBackBuffer??!0)){L("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),d=!1;break}d=!0,f||(f=_.blendRequired)}if(!d){t.skip=!0;return}if(p&&a.fitBounds(0,e.width/s,0,e.height/s),a.scale(h).ceil().scale(1/h).pad((c|0)*i),!a.isPositive){t.skip=!0;return}t.antialias=u,t.resolution=h,t.blendRequired=f,t.firstEnabledIndex=m,t.lastEnabledIndex=x}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new os),this._filterStackIndex++,t}};as.extension={type:[w.WebGLSystem,w.WebGPUSystem],name:"filter"};export{ur as a,dr as b,ot as c,ve as d,Sr as e,Tr as f,vr as g,Cr as h,Mr as i,dt as j,Y as k,Oe as l,Or as m,Yr as n,Xr as o,Qr as p,es as q,ss as r,is as s,as as t};
|
|
382
|
+
/*! Bundled license information:
|
|
383
|
+
|
|
384
|
+
tiny-lru/dist/tiny-lru.js:
|
|
385
|
+
(**
|
|
386
|
+
* tiny-lru
|
|
387
|
+
*
|
|
388
|
+
* @copyright 2025 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
389
|
+
* @license BSD-3-Clause
|
|
390
|
+
* @version 11.4.5
|
|
391
|
+
*)
|
|
392
|
+
*/
|
|
393
|
+
//# sourceMappingURL=chunk-2RBLPWNG.js.map
|