@annotorious/openseadragon 3.0.21 → 3.1.0

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.
@@ -1,21 +1,21 @@
1
- (function(Dt,kt){typeof exports=="object"&&typeof module<"u"?kt(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],kt):(Dt=typeof globalThis<"u"?globalThis:Dt||self,kt(Dt.AnnotoriousOSD={},Dt.OpenSeadragon))})(this,function(Dt,kt){"use strict";var UA=Object.defineProperty;var kA=(Dt,kt,kr)=>kt in Dt?UA(Dt,kt,{enumerable:!0,configurable:!0,writable:!0,value:kr}):Dt[kt]=kr;var xh=(Dt,kt,kr)=>kA(Dt,typeof kt!="symbol"?kt+"":kt,kr);var kr=Object.prototype.hasOwnProperty;function Gr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Gr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(kr.call(r,e)&&++i&&!kr.call(t,e)||!(e in t)||!Gr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}var Po=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(Po||{});const Xt=[];for(let r=0;r<256;++r)Xt.push((r+256).toString(16).slice(1));function om(r,t=0){return(Xt[r[t+0]]+Xt[r[t+1]]+Xt[r[t+2]]+Xt[r[t+3]]+"-"+Xt[r[t+4]]+Xt[r[t+5]]+"-"+Xt[r[t+6]]+Xt[r[t+7]]+"-"+Xt[r[t+8]]+Xt[r[t+9]]+"-"+Xt[r[t+10]]+Xt[r[t+11]]+Xt[r[t+12]]+Xt[r[t+13]]+Xt[r[t+14]]+Xt[r[t+15]]).toLowerCase()}let Mo;const am=new Uint8Array(16);function lm(){if(!Mo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Mo=crypto.getRandomValues.bind(crypto)}return Mo(am)}const hm=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Rh={randomUUID:hm};function um(r,t,e){var i;if(Rh.randomUUID&&!r)return Rh.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??lm();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,om(s)}const Do=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},cm=(r,t,e,i)=>({id:um(),annotation:typeof r=="string"?r:r.id,created:e||new Date,creator:i,...t}),dm=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},fm=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},pm=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Gr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),mm=(r,t)=>!Gr(r.target,t.target),gm=(r,t)=>{const e=dm(r,t),i=fm(r,t),s=pm(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:mm(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var wr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(wr||{});const ym=(r,t)=>{const e=new Set((r.created||[]).map(c=>c.id)),i=new Set((r.updated||[]).map(({newValue:c})=>c.id)),s=new Set((t.created||[]).map(c=>c.id)),n=new Set((t.deleted||[]).map(c=>c.id)),o=new Set((t.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((t.updated||[]).filter(({oldValue:c})=>e.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(r.created||[]).filter(c=>!n.has(c.id)).map(c=>o.has(c.id)?t.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...t.created||[]],h=[...(r.deleted||[]).filter(c=>!s.has(c.id)),...(t.deleted||[]).filter(c=>!e.has(c.id))],u=[...(r.updated||[]).filter(({newValue:c})=>!n.has(c.id)).map(c=>{const{oldValue:d,newValue:p}=c;if(o.has(p.id)){const f=t.updated.find(m=>m.oldValue.id===p.id).newValue;return gm(d,f)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}};let _m=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const vm=250,xm=(r,t)=>{const e=_m(),i=(t==null?void 0:t.changes)||[];let s=t?t.pointer:-1,n=!1,o=0;const a=f=>{if(!n){const{changes:m}=f,_=performance.now();if(_-o>vm)i.splice(s+1),i.push(m),s=i.length-1;else{const g=i.length-1;i[g]=ym(i[g],m)}o=_}n=!1};r.observe(a,{origin:wr.LOCAL});const l=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),h=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),u=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:m})=>m)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:m})=>m)),d=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),p=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>i.length-1>s,canUndo:()=>s>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:s}),on:(f,m)=>e.on(f,m),redo:()=>{if(i.length-1>s){n=!0;const{created:f,updated:m,deleted:_}=i[s+1];h(f),c(m),p(_),e.emit("redo",i[s+1]),s+=1}},undo:()=>{if(s>-1){n=!0;const{created:f,updated:m,deleted:_}=i[s];l(f),u(m),d(_),e.emit("undo",i[s]),s-=1}}}},bm=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],u,c;const d=(g,v)=>{l.has(g)?l.get(g).push(v):l.set(g,[v])},p=(g,v)=>{const y=l.get(g);if(y){const x=y.indexOf(v);x!==-1&&y.splice(x,1)}},f=(g,v,y)=>{l.has(g)&&setTimeout(()=>{l.get(g).forEach(x=>{if(e){const b=Array.isArray(v)?v.map(T=>e.serialize(T)):e.serialize(v),E=y?y instanceof PointerEvent?y:e.serialize(y):void 0;x(b,E)}else x(v,y)})},1)},m=()=>{const{selected:g}=n,v=(g||[]).map(({id:y})=>o.getAnnotation(y));v.forEach(y=>{const x=h.find(b=>b.id===y.id);(!x||!Gr(x,y))&&f("updateAnnotation",y,x)}),h=h.map(y=>v.find(({id:b})=>b===y.id)||y)};n.subscribe(({selected:g})=>{if(!(h.length===0&&g.length===0)){if(h.length===0&&g.length>0)h=g.map(({id:v})=>o.getAnnotation(v));else if(h.length>0&&g.length===0)h.forEach(v=>{const y=o.getAnnotation(v.id);y&&!Gr(y,v)&&f("updateAnnotation",y,v)}),h=[];else{const v=new Set(h.map(x=>x.id)),y=new Set(g.map(({id:x})=>x));h.filter(x=>!y.has(x.id)).forEach(x=>{const b=o.getAnnotation(x.id);b&&!Gr(b,x)&&f("updateAnnotation",b,x)}),h=[...h.filter(x=>y.has(x.id)),...g.filter(({id:x})=>!v.has(x)).map(({id:x})=>o.getAnnotation(x))]}f("selectionChanged",h)}}),s.subscribe(g=>{!u&&g?f("mouseEnterAnnotation",o.getAnnotation(g)):u&&!g?f("mouseLeaveAnnotation",o.getAnnotation(u)):u&&g&&(f("mouseLeaveAnnotation",o.getAnnotation(u)),f("mouseEnterAnnotation",o.getAnnotation(g))),u=g}),a==null||a.subscribe(g=>f("viewportIntersect",g.map(v=>o.getAnnotation(v)))),o.observe(g=>{i&&(c&&clearTimeout(c),c=setTimeout(m,1e3));const{created:v,deleted:y}=g.changes;(v||[]).forEach(x=>f("createAnnotation",x)),(y||[]).forEach(x=>f("deleteAnnotation",x)),(g.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:b})=>{const E=h.find(T=>T.id===x.id)||x;h=h.map(T=>T.id===x.id?b:T),f("updateAnnotation",b,E)})},{origin:wr.LOCAL}),o.observe(g=>{if(h){const v=new Set(h.map(x=>x.id)),y=(g.changes.updated||[]).filter(({newValue:x})=>v.has(x.id)).map(({newValue:x})=>x);y.length>0&&(h=h.map(x=>y.find(E=>E.id===x.id)||x))}},{origin:wr.REMOTE});const _=g=>v=>{const{updated:y}=v;g?(y||[]).forEach(x=>f("updateAnnotation",x.oldValue,x.newValue)):(y||[]).forEach(x=>f("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:p,emit:f}},wm=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),Tm=(r,t,e)=>{const{store:i,selection:s}=r,n=g=>{if(e){const{parsed:v,error:y}=e.parse(g);v?i.addAnnotation(v,wr.REMOTE):console.error(y)}else i.addAnnotation(Do(g),wr.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=g=>{const v=i.getAnnotation(g);return e&&v?e.serialize(v):v},h=()=>e?i.all().map(e.serialize):i.all(),u=()=>{var g;const v=(((g=s.selected)==null?void 0:g.map(y=>y.id))||[]).map(y=>i.getAnnotation(y)).filter(Boolean);return e?v.map(e.serialize):v},c=(g,v=!0)=>fetch(g).then(y=>y.json()).then(y=>(p(y,v),y)),d=g=>{if(typeof g=="string"){const v=i.getAnnotation(g);if(i.deleteAnnotation(g),v)return e?e.serialize(v):v}else{const v=e?e.parse(g).parsed:g;if(v)return i.deleteAnnotation(v),g}},p=(g,v=!0)=>{if(e){const y=e.parseAll||wm(e),{parsed:x,failed:b}=y(g);b.length>0&&console.warn(`Discarded ${b.length} invalid annotations`,b),i.bulkAddAnnotation(x,v,wr.REMOTE)}else i.bulkAddAnnotation(g.map(Do),v,wr.REMOTE)},f=(g,v)=>{g?s.setSelected(g,v):s.clear()},m=g=>{s.clear(),s.setUserSelectAction(g)},_=g=>{if(e){const v=e.parse(g).parsed,y=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),y}else{const v=i.getAnnotation(g.id);return i.updateAnnotation(Do(g)),v}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:u,loadAnnotations:c,redo:t.redo,removeAnnotation:d,setAnnotations:p,setSelected:f,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},Em="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Am=r=>crypto.getRandomValues(new Uint8Array(r)),Sm=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=n)return o}}},Cm=(r,t=21)=>Sm(r,t|0,Am),Im=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Em[e[r]&63];return t};const Rm=()=>({isGuest:!0,id:Cm("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Pm=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],Mm=()=>{const r=[...Pm];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};Im();var Dm=Object.defineProperty,Bm=(r,t,e)=>t in r?Dm(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ph=(r,t,e)=>Bm(r,typeof t!="symbol"?t+"":t,e);function It(){}function Bo(r,t){for(const e in t)r[e]=t[e];return r}function Mh(r){return r()}function Dh(){return Object.create(null)}function Ue(r){r.forEach(Mh)}function Gt(r){return typeof r=="function"}function Kt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Om(r){return Object.keys(r).length===0}function Bh(r,...t){if(r==null){for(const i of t)i(void 0);return It}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Oo(r,t,e){r.$$.on_destroy.push(Bh(t,e))}function Lm(r,t,e,i){if(r){const s=Oh(r,t,e,i);return r[0](s)}}function Oh(r,t,e,i){return r[1]&&i?Bo(e.ctx.slice(),r[1](i(t))):e.ctx}function Fm(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Nm(r,t,e,i,s,n){if(s){const o=Oh(t,e,i,n);r.p(o,s)}}function Um(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function Lh(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Hs(r){return r??""}function ke(r,t){r.appendChild(t)}function lt(r,t,e){r.insertBefore(t,e||null)}function ot(r){r.parentNode&&r.parentNode.removeChild(r)}function Lo(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function bt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Fh(r){return document.createTextNode(r)}function we(){return Fh(" ")}function Te(){return Fh("")}function Ot(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function R(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function km(r){return Array.from(r.childNodes)}function Tr(r,t,e){r.classList.toggle(t,!!e)}function Gm(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let qi;function Ki(r){qi=r}function Nh(){if(!qi)throw new Error("Function called outside component initialization");return qi}function Zi(r){Nh().$$.on_mount.push(r)}function ai(){const r=Nh();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Gm(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function lr(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const li=[],$s=[];let hi=[];const Uh=[],Hm=Promise.resolve();let Fo=!1;function $m(){Fo||(Fo=!0,Hm.then(kh))}function No(r){hi.push(r)}const Uo=new Set;let ui=0;function kh(){if(ui!==0)return;const r=qi;do{try{for(;ui<li.length;){const t=li[ui];ui++,Ki(t),Vm(t.$$)}}catch(t){throw li.length=0,ui=0,t}for(Ki(null),li.length=0,ui=0;$s.length;)$s.pop()();for(let t=0;t<hi.length;t+=1){const e=hi[t];Uo.has(e)||(Uo.add(e),e())}hi.length=0}while(li.length);for(;Uh.length;)Uh.pop()();Fo=!1,Uo.clear(),Ki(r)}function Vm(r){if(r.fragment!==null){r.update(),Ue(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(No)}}function Xm(r){const t=[],e=[];hi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),hi=t}const Vs=new Set;let Hr;function Ee(){Hr={r:0,c:[],p:Hr}}function Ae(){Hr.r||Ue(Hr.c),Hr=Hr.p}function ct(r,t){r&&r.i&&(Vs.delete(r),r.i(t))}function yt(r,t,e,i){if(r&&r.o){if(Vs.has(r))return;Vs.add(r),Hr.c.push(()=>{Vs.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function ci(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function ge(r){r&&r.c()}function he(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),No(()=>{const n=r.$$.on_mount.map(Mh).filter(Gt);r.$$.on_destroy?r.$$.on_destroy.push(...n):Ue(n),r.$$.on_mount=[]}),s.forEach(No)}function ue(r,t){const e=r.$$;e.fragment!==null&&(Xm(e.after_update),Ue(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Wm(r,t){r.$$.dirty[0]===-1&&(li.push(r),$m(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ye(r,t,e,i,s,n,o=null,a=[-1]){const l=qi;Ki(r);const h=r.$$={fragment:null,ctx:[],props:n,update:It,not_equal:s,bound:Dh(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Dh(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=e?e(r,t.props||{},(c,d,...p)=>{const f=p.length?p[0]:d;return h.ctx&&s(h.ctx[c],h.ctx[c]=f)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](f),u&&Wm(r,c)),d}):[],h.update(),u=!0,Ue(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=km(t.target);h.fragment&&h.fragment.l(c),c.forEach(ot)}else h.fragment&&h.fragment.c();t.intro&&ct(r.$$.fragment),he(r,t.target,t.anchor),kh()}Ki(l)}class _e{constructor(){Ph(this,"$$"),Ph(this,"$$set")}$destroy(){ue(this,1),this.$destroy=It}$on(t,e){if(!Gt(e))return It;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!Om(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const zm="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(zm);var Et=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(Et||{});const ko={},Go=(r,t)=>ko[r]=t,Ho=r=>ko[r.type].area(r),jm=(r,t,e)=>ko[r.type].intersects(r,t,e),Xs=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},Ym={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=t-i,c=e-s,d=l*u+h*c,p=h*u-l*c;return d*d/(n*n)+p*p/(o*o)<=1}};Go(Et.ELLIPSE,Ym);const qm={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],u=i[o][1];l>e!=u>e&&t<(h-a)*(e-l)/(u-l)+a&&(s=!s)}return s}};Go(Et.POLYGON,qm);const Km={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};Go(Et.RECTANGLE,Km);const hr=r=>Ws(r.target),Ws=r=>{var t,e;return(r==null?void 0:r.annotation)!==void 0&&((e=(t=r==null?void 0:r.selector)==null?void 0:t.geometry)==null?void 0:e.bounds)!==void 0},Zm=(r,t=!1)=>{const e=typeof r=="string"?r:r.value,i=/^(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g,s=[...e.matchAll(i)][0],[n,o,a,l,h,u,c]=s;if(o!=="xywh")throw new Error("Unsupported MediaFragment: "+e);if(a&&a!=="pixel")throw new Error(`Unsupported MediaFragment unit: ${a}`);const[d,p,f,m]=[l,h,u,c].map(parseFloat);return{type:Et.RECTANGLE,geometry:{x:d,y:p,w:f,h:m,bounds:{minX:d,minY:t?p-m:p,maxX:d+f,maxY:t?p:p+m}}}},Jm=r=>{const{x:t,y:e,w:i,h:s}=r;return{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=pixel:${t},${e},${i},${s}`}},Gh="http://www.w3.org/2000/svg",Hh=r=>{const t=i=>{Array.from(i.attributes).forEach(s=>{s.name.startsWith("on")&&i.removeAttribute(s.name)})},e=r.getElementsByTagName("script");return Array.from(e).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(r.querySelectorAll("*")).forEach(t),r},Qm=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${Gh}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},tg=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(Gh),i=t.lookupNamespaceURI(null);return e||i?Hh(t).firstChild:Hh(Qm(t)).firstChild},eg=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:Et.POLYGON,geometry:{points:s,bounds:Xs(s)}}},rg=r=>{const t=tg(r),e=parseFloat(t.getAttribute("cx")),i=parseFloat(t.getAttribute("cy")),s=parseFloat(t.getAttribute("rx")),n=parseFloat(t.getAttribute("ry")),o={minX:e-s,minY:i-n,maxX:e+s,maxY:i+n};return{type:Et.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:o}}},ig=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return eg(t);if(t.includes("<ellipse "))return rg(t);throw"Unsupported SVG shape: "+t},sg=r=>{let t;if(r.type===Et.POLYGON){const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}else if(r.type===Et.ELLIPSE){const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`},Wt=[];for(let r=0;r<256;++r)Wt.push((r+256).toString(16).slice(1));function ng(r,t=0){return(Wt[r[t+0]]+Wt[r[t+1]]+Wt[r[t+2]]+Wt[r[t+3]]+"-"+Wt[r[t+4]]+Wt[r[t+5]]+"-"+Wt[r[t+6]]+Wt[r[t+7]]+"-"+Wt[r[t+8]]+Wt[r[t+9]]+"-"+Wt[r[t+10]]+Wt[r[t+11]]+Wt[r[t+12]]+Wt[r[t+13]]+Wt[r[t+14]]+Wt[r[t+15]]).toLowerCase()}let $o;const og=new Uint8Array(16);function ag(){if(!$o){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");$o=crypto.getRandomValues.bind(crypto)}return $o(og)}const lg=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),$h={randomUUID:lg};function Vh(r,t,e){var i;if($h.randomUUID&&!r)return $h.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??ag();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,ng(s)}var Xh=Object.prototype.hasOwnProperty;function Er(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Er(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Xh.call(r,e)&&++i&&!Xh.call(t,e)||!(e in t)||!Er(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function Vo(){}function hg(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const di=[];function Xo(r,t=Vo){let e;const i=new Set;function s(a){if(hg(r,a)&&(r=a,e)){const l=!di.length;for(const h of i)h[1](),di.push(h,r);if(l){for(let h=0;h<di.length;h+=2)di[h][0](di[h+1]);di.length=0}}}function n(a){s(a(r))}function o(a,l=Vo){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||Vo),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const ug=r=>{const{subscribe:t,set:e}=Xo();let i;return t(s=>i=s),r.observe(({changes:s})=>{if(i){(s.deleted||[]).some(o=>o.id===i)&&e(void 0);const n=(s.updated||[]).find(({oldValue:o})=>o.id===i);n&&e(n.newValue.id)}}),{get current(){return i},subscribe:t,set:e}};var Wh=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(Wh||{});const zs={selected:[]},cg=(r,t,e)=>{const{subscribe:i,set:s}=Xo(zs);let n=t,o=zs;i(f=>o=f);const a=()=>{Er(o,zs)||s(zs)},l=()=>{var f;return((f=o.selected)==null?void 0:f.length)===0},h=f=>{if(l())return!1;const m=typeof f=="string"?f:f.id;return o.selected.some(_=>_.id===m)},u=(f,m)=>{let _;if(Array.isArray(f)){if(_=f.map(v=>r.getAnnotation(v)).filter(Boolean),_.length<f.length){console.warn("Invalid selection: "+f.filter(v=>!_.some(y=>y.id===v)));return}}else{const v=r.getAnnotation(f);if(!v){console.warn("Invalid selection: "+f);return}_=[v]}const g=_.reduce((v,y)=>{const x=zh(y,n,e);return x==="EDIT"?[...v,{id:y.id,editable:!0}]:x==="SELECT"?[...v,{id:y.id}]:v},[]);s({selected:g,event:m})},c=(f,m)=>{const _=Array.isArray(f)?f:[f],g=_.map(v=>r.getAnnotation(v)).filter(v=>!!v);s({selected:g.map(v=>{const y=m===void 0?zh(v,n,e)==="EDIT":m;return{id:v.id,editable:y}})}),g.length!==_.length&&console.warn("Invalid selection",f)},d=f=>{if(l())return!1;const{selected:m}=o;m.some(({id:_})=>f.includes(_))&&s({selected:m.filter(({id:_})=>!f.includes(_))})},p=f=>{n=f,c(o.selected.map(({id:m})=>m))};return r.observe(({changes:f})=>d((f.deleted||[]).map(m=>m.id))),{get event(){return o?o.event:null},get selected(){return o?[...o.selected]:null},get userSelectAction(){return n},clear:a,isEmpty:l,isSelected:h,setSelected:c,setUserSelectAction:p,subscribe:i,userSelect:u}},zh=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"},zt=[];for(let r=0;r<256;++r)zt.push((r+256).toString(16).slice(1));function dg(r,t=0){return(zt[r[t+0]]+zt[r[t+1]]+zt[r[t+2]]+zt[r[t+3]]+"-"+zt[r[t+4]]+zt[r[t+5]]+"-"+zt[r[t+6]]+zt[r[t+7]]+"-"+zt[r[t+8]]+zt[r[t+9]]+"-"+zt[r[t+10]]+zt[r[t+11]]+zt[r[t+12]]+zt[r[t+13]]+zt[r[t+14]]+zt[r[t+15]]).toLowerCase()}let Wo;const fg=new Uint8Array(16);function pg(){if(!Wo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Wo=crypto.getRandomValues.bind(crypto)}return Wo(fg)}const mg=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),jh={randomUUID:mg};function gg(r,t,e){var i;if(jh.randomUUID&&!r)return jh.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??pg();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,dg(s)}const zo=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},yg=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},_g=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},vg=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Er(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),xg=(r,t)=>!Er(r.target,t.target),Yh=(r,t)=>{const e=yg(r,t),i=_g(r,t),s=vg(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:xg(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Rt=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Rt||{});const bg=(r,t)=>{var e,i;const{changes:s,origin:n}=t;if(!(r.options.origin?r.options.origin===n:n!=="SILENT"))return!1;if(r.options.ignore){const{ignore:o}=r.options,a=l=>l&&l.length>0;if(!(a(s.created)||a(s.deleted))){const l=(e=s.updated)==null?void 0:e.some(u=>a(u.bodiesCreated)||a(u.bodiesDeleted)||a(u.bodiesUpdated)),h=(i=s.updated)==null?void 0:i.some(u=>u.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(r.options.annotations){const o=new Set([...(s.created||[]).map(a=>a.id),...(s.deleted||[]).map(a=>a.id),...(s.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(r.options.annotations)?r.options.annotations:[r.options.annotations]).find(a=>o.has(a))}else return!0},wg=(r,t)=>{const e=new Set((r.created||[]).map(c=>c.id)),i=new Set((r.updated||[]).map(({newValue:c})=>c.id)),s=new Set((t.created||[]).map(c=>c.id)),n=new Set((t.deleted||[]).map(c=>c.id)),o=new Set((t.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((t.updated||[]).filter(({oldValue:c})=>e.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(r.created||[]).filter(c=>!n.has(c.id)).map(c=>o.has(c.id)?t.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...t.created||[]],h=[...(r.deleted||[]).filter(c=>!s.has(c.id)),...(t.deleted||[]).filter(c=>!e.has(c.id))],u=[...(r.updated||[]).filter(({newValue:c})=>!n.has(c.id)).map(c=>{const{oldValue:d,newValue:p}=c;if(o.has(p.id)){const f=t.updated.find(m=>m.oldValue.id===p.id).newValue;return Yh(d,f)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}},jo=r=>{const t=r.id===void 0?gg():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},Tg=r=>r.id!==void 0,Eg=()=>{const r=new Map,t=new Map,e=[],i=(S,P={})=>{e.push({onChange:S,options:P})},s=S=>{const P=e.findIndex(C=>C.onChange==S);P>-1&&e.splice(P,1)},n=(S,P)=>{const C={origin:S,changes:{created:P.created||[],updated:P.updated||[],deleted:P.deleted||[]},state:[...r.values()]};e.forEach(w=>{bg(w,C)&&w.onChange(C)})},o=(S,P=Rt.LOCAL)=>{if(S.id&&r.get(S.id))throw Error(`Cannot add annotation ${S.id} - exists already`);{const C=jo(S);r.set(C.id,C),C.bodies.forEach(w=>t.set(w.id,C.id)),n(P,{created:[C]})}},a=(S,P)=>{const C=jo(typeof S=="string"?P:S),w=typeof S=="string"?S:S.id,D=w&&r.get(w);if(D){const N=Yh(D,C);return w===C.id?r.set(w,C):(r.delete(w),r.set(C.id,C)),D.bodies.forEach(V=>t.delete(V.id)),C.bodies.forEach(V=>t.set(V.id,C.id)),N}else console.warn(`Cannot update annotation ${w} - does not exist`)},l=(S,P=Rt.LOCAL,C=Rt.LOCAL)=>{const w=Tg(P)?C:P,D=a(S,P);D&&n(w,{updated:[D]})},h=(S,P=Rt.LOCAL)=>{const C=S.reduce((w,D)=>{const N=a(D);return N?[...w,N]:w},[]);C.length>0&&n(P,{updated:C})},u=(S,P=Rt.LOCAL)=>{const C=r.get(S.annotation);if(C){const w={...C,bodies:[...C.bodies,S]};r.set(C.id,w),t.set(S.id,w.id),n(P,{updated:[{oldValue:C,newValue:w,bodiesCreated:[S]}]})}else console.warn(`Attempt to add body to missing annotation: ${S.annotation}`)},c=()=>[...r.values()],d=(S=Rt.LOCAL)=>{const P=[...r.values()];r.clear(),t.clear(),n(S,{deleted:P})},p=(S,P=!0,C=Rt.LOCAL)=>{const w=S.map(jo);if(P){const D=[...r.values()];r.clear(),t.clear(),w.forEach(N=>{r.set(N.id,N),N.bodies.forEach(V=>t.set(V.id,N.id))}),n(C,{created:w,deleted:D})}else{const D=S.reduce((N,V)=>{const H=V.id&&r.get(V.id);return H?[...N,H]:N},[]);if(D.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${D.map(N=>N.id).join(", ")}`);w.forEach(N=>{r.set(N.id,N),N.bodies.forEach(V=>t.set(V.id,N.id))}),n(C,{created:w})}},f=S=>{const P=typeof S=="string"?S:S.id,C=r.get(P);if(C)return r.delete(P),C.bodies.forEach(w=>t.delete(w.id)),C;console.warn(`Attempt to delete missing annotation: ${P}`)},m=(S,P=Rt.LOCAL)=>{const C=f(S);C&&n(P,{deleted:[C]})},_=(S,P=Rt.LOCAL)=>{const C=S.reduce((w,D)=>{const N=f(D);return N?[...w,N]:w},[]);C.length>0&&n(P,{deleted:C})},g=S=>{const P=r.get(S.annotation);if(P){const C=P.bodies.find(w=>w.id===S.id);if(C){t.delete(C.id);const w={...P,bodies:P.bodies.filter(D=>D.id!==S.id)};return r.set(P.id,w),{oldValue:P,newValue:w,bodiesDeleted:[C]}}else console.warn(`Attempt to delete missing body ${S.id} from annotation ${S.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${S.annotation}`)},v=(S,P=Rt.LOCAL)=>{const C=g(S);C&&n(P,{updated:[C]})},y=(S,P=Rt.LOCAL)=>{const C=S.map(w=>g(w)).filter(Boolean);C.length>0&&n(P,{updated:C})},x=S=>{const P=r.get(S);return P?{...P}:void 0},b=S=>{const P=t.get(S);if(P){const C=x(P).bodies.find(w=>w.id===S);if(C)return C;console.error(`Store integrity error: body ${S} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${S}`)},E=(S,P)=>{if(S.annotation!==P.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const C=r.get(S.annotation);if(C){const w=C.bodies.find(N=>N.id===S.id),D={...C,bodies:C.bodies.map(N=>N.id===w.id?P:N)};return r.set(C.id,D),w.id!==P.id&&(t.delete(w.id),t.set(P.id,D.id)),{oldValue:C,newValue:D,bodiesUpdated:[{oldBody:w,newBody:P}]}}else console.warn(`Attempt to add body to missing annotation ${S.annotation}`)},T=(S,P,C=Rt.LOCAL)=>{const w=E(S,P);w&&n(C,{updated:[w]})},A=(S,P=Rt.LOCAL)=>{const C=S.map(w=>E({id:w.id,annotation:w.annotation},w)).filter(Boolean);n(P,{updated:C})},M=S=>{const P=r.get(S.annotation);if(P){const C={...P,target:{...P.target,...S}};return r.set(P.id,C),{oldValue:P,newValue:C,targetUpdated:{oldTarget:P.target,newTarget:S}}}else console.warn(`Attempt to update target on missing annotation: ${S.annotation}`)};return{addAnnotation:o,addBody:u,all:c,bulkAddAnnotation:p,bulkDeleteAnnotation:_,bulkDeleteBodies:y,bulkUpdateAnnotation:h,bulkUpdateBodies:A,bulkUpdateTargets:(S,P=Rt.LOCAL)=>{const C=S.map(w=>M(w)).filter(Boolean);C.length>0&&n(P,{updated:C})},clear:d,deleteAnnotation:m,deleteBody:v,getAnnotation:x,getBody:b,observe:i,unobserve:s,updateAnnotation:l,updateBody:T,updateTarget:(S,P=Rt.LOCAL)=>{const C=M(S);C&&n(P,{updated:[C]})}}},Ag=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let Sg=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const Cg=250,Ig=(r,t)=>{const e=Sg(),i=(t==null?void 0:t.changes)||[];let s=t?t.pointer:-1,n=!1,o=0;const a=f=>{if(!n){const{changes:m}=f,_=performance.now();if(_-o>Cg)i.splice(s+1),i.push(m),s=i.length-1;else{const g=i.length-1;i[g]=wg(i[g],m)}o=_}n=!1};r.observe(a,{origin:Rt.LOCAL});const l=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),h=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),u=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:m})=>m)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:m})=>m)),d=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),p=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>i.length-1>s,canUndo:()=>s>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:s}),on:(f,m)=>e.on(f,m),redo:()=>{if(i.length-1>s){n=!0;const{created:f,updated:m,deleted:_}=i[s+1];h(f),c(m),p(_),e.emit("redo",i[s+1]),s+=1}},undo:()=>{if(s>-1){n=!0;const{created:f,updated:m,deleted:_}=i[s];l(f),u(m),d(_),e.emit("undo",i[s]),s-=1}}}},Rg=()=>{const{subscribe:r,set:t}=Xo([]);return{subscribe:r,set:t}},Pg=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],u,c;const d=(g,v)=>{l.has(g)?l.get(g).push(v):l.set(g,[v])},p=(g,v)=>{const y=l.get(g);if(y){const x=y.indexOf(v);x!==-1&&y.splice(x,1)}},f=(g,v,y)=>{l.has(g)&&setTimeout(()=>{l.get(g).forEach(x=>{if(e){const b=Array.isArray(v)?v.map(T=>e.serialize(T)):e.serialize(v),E=y?y instanceof PointerEvent?y:e.serialize(y):void 0;x(b,E)}else x(v,y)})},1)},m=()=>{const{selected:g}=n,v=(g||[]).map(({id:y})=>o.getAnnotation(y));v.forEach(y=>{const x=h.find(b=>b.id===y.id);(!x||!Er(x,y))&&f("updateAnnotation",y,x)}),h=h.map(y=>v.find(({id:x})=>x===y.id)||y)};n.subscribe(({selected:g})=>{if(!(h.length===0&&g.length===0)){if(h.length===0&&g.length>0)h=g.map(({id:v})=>o.getAnnotation(v));else if(h.length>0&&g.length===0)h.forEach(v=>{const y=o.getAnnotation(v.id);y&&!Er(y,v)&&f("updateAnnotation",y,v)}),h=[];else{const v=new Set(h.map(x=>x.id)),y=new Set(g.map(({id:x})=>x));h.filter(x=>!y.has(x.id)).forEach(x=>{const b=o.getAnnotation(x.id);b&&!Er(b,x)&&f("updateAnnotation",b,x)}),h=[...h.filter(x=>y.has(x.id)),...g.filter(({id:x})=>!v.has(x)).map(({id:x})=>o.getAnnotation(x))]}f("selectionChanged",h)}}),s.subscribe(g=>{!u&&g?f("mouseEnterAnnotation",o.getAnnotation(g)):u&&!g?f("mouseLeaveAnnotation",o.getAnnotation(u)):u&&g&&(f("mouseLeaveAnnotation",o.getAnnotation(u)),f("mouseEnterAnnotation",o.getAnnotation(g))),u=g}),a==null||a.subscribe(g=>f("viewportIntersect",g.map(v=>o.getAnnotation(v)))),o.observe(g=>{i&&(c&&clearTimeout(c),c=setTimeout(m,1e3));const{created:v,deleted:y}=g.changes;(v||[]).forEach(x=>f("createAnnotation",x)),(y||[]).forEach(x=>f("deleteAnnotation",x)),(g.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:b})=>{const E=h.find(T=>T.id===x.id)||x;h=h.map(T=>T.id===x.id?b:T),f("updateAnnotation",b,E)})},{origin:Rt.LOCAL}),o.observe(g=>{if(h){const v=new Set(h.map(x=>x.id)),y=(g.changes.updated||[]).filter(({newValue:x})=>v.has(x.id)).map(({newValue:x})=>x);y.length>0&&(h=h.map(x=>y.find(b=>b.id===x.id)||x))}},{origin:Rt.REMOTE});const _=g=>v=>{const{updated:y}=v;g?(y||[]).forEach(x=>f("updateAnnotation",x.oldValue,x.newValue)):(y||[]).forEach(x=>f("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:p,emit:f}},Mg=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),Dg=(r,t,e)=>{const{store:i,selection:s}=r,n=g=>{if(e){const{parsed:v,error:y}=e.parse(g);v?i.addAnnotation(v,Rt.REMOTE):console.error(y)}else i.addAnnotation(zo(g),Rt.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=g=>{const v=i.getAnnotation(g);return e&&v?e.serialize(v):v},h=()=>e?i.all().map(e.serialize):i.all(),u=()=>{var g;const v=(((g=s.selected)==null?void 0:g.map(y=>y.id))||[]).map(y=>i.getAnnotation(y)).filter(Boolean);return e?v.map(e.serialize):v},c=(g,v=!0)=>fetch(g).then(y=>y.json()).then(y=>(p(y,v),y)),d=g=>{if(typeof g=="string"){const v=i.getAnnotation(g);if(i.deleteAnnotation(g),v)return e?e.serialize(v):v}else{const v=e?e.parse(g).parsed:g;if(v)return i.deleteAnnotation(v),g}},p=(g,v=!0)=>{if(e){const y=e.parseAll||Mg(e),{parsed:x,failed:b}=y(g);b.length>0&&console.warn(`Discarded ${b.length} invalid annotations`,b),i.bulkAddAnnotation(x,v,Rt.REMOTE)}else i.bulkAddAnnotation(g.map(zo),v,Rt.REMOTE)},f=(g,v)=>{g?s.setSelected(g,v):s.clear()},m=g=>{s.clear(),s.setUserSelectAction(g)},_=g=>{if(e){const v=e.parse(g).parsed,y=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),y}else{const v=i.getAnnotation(g.id);return i.updateAnnotation(zo(g)),v}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:u,loadAnnotations:c,redo:t.redo,removeAnnotation:d,setAnnotations:p,setSelected:f,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},Bg=(r,t,e)=>typeof t=="function"?t(r,e):t,Og=(r,t)=>typeof r!="function"&&typeof t!="function"?{...r||{},...t||{}}:(e,i)=>{const s=typeof r=="function"?r(e,i):r,n=typeof t=="function"?t(e,i):t;return{...s||{},...n||{}}},Lg="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Fg=r=>crypto.getRandomValues(new Uint8Array(r)),Ng=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=n)return o}}},Ug=(r,t=21)=>Ng(r,t|0,Fg),kg=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Lg[e[r]&63];return t};const Gg=()=>({isGuest:!0,id:Ug("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Hg=r=>{const t=JSON.stringify(r);let e=0;for(let i=0,s=t.length;i<s;i++){let n=t.charCodeAt(i);e=(e<<5)-e+n,e|=0}return`${e}`},qh=r=>r?typeof r=="object"?{...r}:r:void 0,$g=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:s,purpose:n,value:o,created:a,modified:l,creator:h,...u}=e;return{id:i||`temp-${Hg(e)}`,annotation:t,type:s,purpose:n,value:o,creator:qh(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...u}}),Vg=r=>r.map(t=>{var e;const{annotation:i,created:s,updated:n,...o}=t,a={...o,created:s==null?void 0:s.toISOString(),modified:n==null?void 0:n.toISOString()};return(e=a.id)!=null&&e.startsWith("temp-")&&delete a.id,a});kg();const Xg=(r,t={strict:!0,invertY:!1})=>({parse:e=>Wg(e,t),serialize:e=>zg(e,r,t)}),Wg=(r,t={strict:!0,invertY:!1})=>{const e=r.id||Vh(),{creator:i,created:s,modified:n,body:o,...a}=r,l=$g(o||[],e),h=Array.isArray(r.target)?r.target[0]:r.target,u=Array.isArray(h.selector)?h.selector[0]:h.selector,c=(u==null?void 0:u.type)==="FragmentSelector"?Zm(u,t.invertY):(u==null?void 0:u.type)==="SvgSelector"?ig(u):void 0;return c||!t.strict?{parsed:{...a,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:qh(i),updated:n?new Date(n):void 0,...Array.isArray(a.target)?a.target[0]:a.target,annotation:e,selector:c||u}}}:{error:Error(`Invalid selector: ${JSON.stringify(u)}`)}},zg=(r,t,e={strict:!0,invertY:!1})=>{const{selector:i,creator:s,created:n,updated:o,updatedBy:a,...l}=r.target;let h;try{h=i.type==Et.RECTANGLE?Jm(i.geometry):sg(i)}catch(c){if(e.strict)throw c;h=i}const u={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:Vg(r.bodies),created:n==null?void 0:n.toISOString(),creator:s,modified:o==null?void 0:o.toISOString(),target:{...l,source:t,selector:h}};return delete u.bodies,"annotation"in u.target&&delete u.target.annotation,u};function Kh(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function Zh(r){let t,e;return t=new Ji({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Gt(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){ge(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function jg(r){let t,e,i,s,n,o,a,l,h,u,c,d=ci(r[4].points),p=[];for(let m=0;m<d.length;m+=1)p[m]=Zh(Kh(r,d,m));const f=m=>yt(p[m],1,1,()=>{p[m]=null});return{c(){t=bt("polygon"),s=we(),n=bt("polygon"),a=we();for(let m=0;m<p.length;m+=1)p[m].c();l=Te(),R(t,"class","a9s-outer"),R(t,"style",e=r[1]?"display:none;":void 0),R(t,"points",i=r[4].points.map(Jh).join(" ")),R(n,"class","a9s-inner a9s-shape-handle"),R(n,"style",r[1]),R(n,"points",o=r[4].points.map(Qh).join(" "))},m(m,_){lt(m,t,_),lt(m,s,_),lt(m,n,_),lt(m,a,_);for(let g=0;g<p.length;g+=1)p[g]&&p[g].m(m,_);lt(m,l,_),h=!0,u||(c=[Ot(t,"pointerdown",function(){Gt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Ot(n,"pointerdown",function(){Gt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],u=!0)},p(m,_){if(r=m,(!h||_&2&&e!==(e=r[1]?"display:none;":void 0))&&R(t,"style",e),(!h||_&16&&i!==(i=r[4].points.map(Jh).join(" ")))&&R(t,"points",i),(!h||_&2)&&R(n,"style",r[1]),(!h||_&16&&o!==(o=r[4].points.map(Qh).join(" ")))&&R(n,"points",o),_&536){d=ci(r[4].points);let g;for(g=0;g<d.length;g+=1){const v=Kh(r,d,g);p[g]?(p[g].p(v,_),ct(p[g],1)):(p[g]=Zh(v),p[g].c(),ct(p[g],1),p[g].m(l.parentNode,l))}for(Ee(),g=d.length;g<p.length;g+=1)f(g);Ae()}},i(m){if(!h){for(let _=0;_<d.length;_+=1)ct(p[_]);h=!0}},o(m){p=p.filter(Boolean);for(let _=0;_<p.length;_+=1)yt(p[_]);h=!1},d(m){m&&(ot(t),ot(s),ot(n),ot(a),ot(l)),Lo(p,m),u=!1,Ue(c)}}}function Yg(r){let t,e;return t=new nu({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[jg,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){ge(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}const Jh=r=>r.join(","),Qh=r=>r.join(",");function qg(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{let m;const _=d.geometry;p==="SHAPE"?m=_.points.map(([v,y])=>[v+f[0],y+f[1]]):m=_.points.map(([v,y],x)=>p===`HANDLE-${x}`?[v+f[0],y+f[1]]:[v,y]);const g=Xs(m);return{...d,geometry:{points:m,bounds:g}}};function h(d){lr.call(this,r,d)}function u(d){lr.call(this,r,d)}function c(d){lr.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class Kg extends _e{constructor(t){super(),ye(this,t,qg,Yg,Kt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const Yo=(r,t)=>{const e=Math.abs(t[0]-r[0]),i=Math.abs(t[1]-r[1]);return Math.sqrt(Math.pow(e,2)+Math.pow(i,2))},fi=[];function Zg(r,t=It){let e;const i=new Set;function s(a){if(Kt(r,a)&&(r=a,e)){const l=!fi.length;for(const h of i)h[1](),fi.push(h,r);if(l){for(let h=0;h<fi.length;h+=2)fi[h][0](fi[h+1]);fi.length=0}}}function n(a){s(a(r))}function o(a,l=It){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||It),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const Jg=(r,t)=>{const{naturalWidth:e,naturalHeight:i}=r;if(!e&&!i){const{width:s,height:n}=r;t.setAttribute("viewBox",`0 0 ${s} ${n}`),r.addEventListener("load",o=>{const a=o.target;t.setAttribute("viewBox",`0 0 ${a.naturalWidth} ${a.naturalHeight}`)})}else t.setAttribute("viewBox",`0 0 ${e} ${i}`)},Qg=(r,t)=>{Jg(r,t);const{subscribe:e,set:i}=Zg(1);let s;return window.ResizeObserver&&(s=new ResizeObserver(()=>{const n=t.getBoundingClientRect(),{width:o,height:a}=t.viewBox.baseVal,l=Math.max(n.width/o,n.height/a);i(l)}),s.observe(t.parentElement)),{destroy:()=>{s&&s.disconnect()},subscribe:e}},tu=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function ty(r){let t,e,i,s,n,o;return{c(){t=bt("rect"),R(t,"class",e=Hs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),R(t,"x",i=r[0]-r[5]/2),R(t,"y",s=r[1]-r[5]/2),R(t,"width",r[5]),R(t,"height",r[5])},m(a,l){lt(a,t,l),n||(o=Ot(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=Hs(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&R(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&R(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&R(t,"y",s),l&32&&R(t,"width",a[5]),l&32&&R(t,"height",a[5])},d(a){a&&ot(t),n=!1,o()}}}function ey(r){let t,e,i,s,n,o,a,l,h;return{c(){t=bt("g"),e=bt("circle"),s=bt("rect"),R(e,"cx",r[0]),R(e,"cy",r[1]),R(e,"r",i=r[3]/r[2]),R(e,"class","a9s-touch-halo svelte-1sgkh33"),Tr(e,"touched",r[4]),R(s,"class",n=Hs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),R(s,"x",o=r[0]-r[5]/2),R(s,"y",a=r[1]-r[5]/2),R(s,"width",r[5]),R(s,"height",r[5]),R(t,"class","a9s-touch-handle")},m(u,c){lt(u,t,c),ke(t,e),ke(t,s),l||(h=[Ot(e,"pointerdown",r[10]),Ot(e,"pointerdown",r[6]),Ot(e,"pointerup",r[7]),Ot(s,"pointerdown",r[9]),Ot(s,"pointerdown",r[6]),Ot(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&R(e,"cx",u[0]),c&2&&R(e,"cy",u[1]),c&12&&i!==(i=u[3]/u[2])&&R(e,"r",i),c&16&&Tr(e,"touched",u[4]),c&256&&n!==(n=Hs(`a9s-handle ${u[8].class||""}`.trim())+" svelte-1sgkh33")&&R(s,"class",n),c&33&&o!==(o=u[0]-u[5]/2)&&R(s,"x",o),c&34&&a!==(a=u[1]-u[5]/2)&&R(s,"y",a),c&32&&R(s,"width",u[5]),c&32&&R(s,"height",u[5])},d(u){u&&ot(t),l=!1,Ue(h)}}}function ry(r){let t;function e(s,n){return tu?ey:ty}let i=e()(r);return{c(){i.c(),t=Te()},m(s,n){i.m(s,n),lt(s,t,n)},p(s,[n]){i.p(s,n)},i:It,o:It,d(s){s&&ot(t),i.d(s)}}}function iy(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=f=>{f.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(f){lr.call(this,r,f)}function d(f){lr.call(this,r,f)}function p(f){lr.call(this,r,f)}return r.$$set=f=>{e(8,t=Bo(Bo({},t),Lh(f))),"x"in f&&e(0,s=f.x),"y"in f&&e(1,n=f.y),"scale"in f&&e(2,o=f.scale),"radius"in f&&e(3,a=f.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=Lh(t),[s,n,o,a,l,i,h,u,t,c,d,p]}class Ji extends _e{constructor(t){super(),ye(this,t,iy,ry,Kt,{x:0,y:1,scale:2,radius:3})}}function sy(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,_,g,v,y,x,b,E,T,A,M,S,P,C,w,D,N,V,H,W,rt,I,F,G,Q,K,k,it,gt;return W=new Ji({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),W.$on("pointerdown",function(){Gt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),I=new Ji({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),I.$on("pointerdown",function(){Gt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),G=new Ji({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),G.$on("pointerdown",function(){Gt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),K=new Ji({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),K.$on("pointerdown",function(){Gt(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=bt("rect"),a=we(),l=bt("rect"),p=we(),f=bt("rect"),v=we(),y=bt("rect"),T=we(),A=bt("rect"),C=we(),w=bt("rect"),H=we(),ge(W.$$.fragment),rt=we(),ge(I.$$.fragment),F=we(),ge(G.$$.fragment),Q=we(),ge(K.$$.fragment),R(t,"class","a9s-outer"),R(t,"style",e=r[1]?"display:none;":void 0),R(t,"x",i=r[4].x),R(t,"y",s=r[4].y),R(t,"width",n=r[4].w),R(t,"height",o=r[4].h),R(l,"class","a9s-inner a9s-shape-handle"),R(l,"style",r[1]),R(l,"x",h=r[4].x),R(l,"y",u=r[4].y),R(l,"width",c=r[4].w),R(l,"height",d=r[4].h),R(f,"class","a9s-edge-handle a9s-edge-handle-top"),R(f,"x",m=r[4].x),R(f,"y",_=r[4].y),R(f,"height",1),R(f,"width",g=r[4].w),R(y,"class","a9s-edge-handle a9s-edge-handle-right"),R(y,"x",x=r[4].x+r[4].w),R(y,"y",b=r[4].y),R(y,"height",E=r[4].h),R(y,"width",1),R(A,"class","a9s-edge-handle a9s-edge-handle-bottom"),R(A,"x",M=r[4].x),R(A,"y",S=r[4].y+r[4].h),R(A,"height",1),R(A,"width",P=r[4].w),R(w,"class","a9s-edge-handle a9s-edge-handle-left"),R(w,"x",D=r[4].x),R(w,"y",N=r[4].y),R(w,"height",V=r[4].h),R(w,"width",1)},m(B,O){lt(B,t,O),lt(B,a,O),lt(B,l,O),lt(B,p,O),lt(B,f,O),lt(B,v,O),lt(B,y,O),lt(B,T,O),lt(B,A,O),lt(B,C,O),lt(B,w,O),lt(B,H,O),he(W,B,O),lt(B,rt,O),he(I,B,O),lt(B,F,O),he(G,B,O),lt(B,Q,O),he(K,B,O),k=!0,it||(gt=[Ot(t,"pointerdown",function(){Gt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Ot(l,"pointerdown",function(){Gt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Ot(f,"pointerdown",function(){Gt(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Ot(y,"pointerdown",function(){Gt(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Ot(A,"pointerdown",function(){Gt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Ot(w,"pointerdown",function(){Gt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],it=!0)},p(B,O){r=B,(!k||O&2&&e!==(e=r[1]?"display:none;":void 0))&&R(t,"style",e),(!k||O&16&&i!==(i=r[4].x))&&R(t,"x",i),(!k||O&16&&s!==(s=r[4].y))&&R(t,"y",s),(!k||O&16&&n!==(n=r[4].w))&&R(t,"width",n),(!k||O&16&&o!==(o=r[4].h))&&R(t,"height",o),(!k||O&2)&&R(l,"style",r[1]),(!k||O&16&&h!==(h=r[4].x))&&R(l,"x",h),(!k||O&16&&u!==(u=r[4].y))&&R(l,"y",u),(!k||O&16&&c!==(c=r[4].w))&&R(l,"width",c),(!k||O&16&&d!==(d=r[4].h))&&R(l,"height",d),(!k||O&16&&m!==(m=r[4].x))&&R(f,"x",m),(!k||O&16&&_!==(_=r[4].y))&&R(f,"y",_),(!k||O&16&&g!==(g=r[4].w))&&R(f,"width",g),(!k||O&16&&x!==(x=r[4].x+r[4].w))&&R(y,"x",x),(!k||O&16&&b!==(b=r[4].y))&&R(y,"y",b),(!k||O&16&&E!==(E=r[4].h))&&R(y,"height",E),(!k||O&16&&M!==(M=r[4].x))&&R(A,"x",M),(!k||O&16&&S!==(S=r[4].y+r[4].h))&&R(A,"y",S),(!k||O&16&&P!==(P=r[4].w))&&R(A,"width",P),(!k||O&16&&D!==(D=r[4].x))&&R(w,"x",D),(!k||O&16&&N!==(N=r[4].y))&&R(w,"y",N),(!k||O&16&&V!==(V=r[4].h))&&R(w,"height",V);const tt={};O&16&&(tt.x=r[4].x),O&16&&(tt.y=r[4].y),O&8&&(tt.scale=r[3]),W.$set(tt);const nt={};O&16&&(nt.x=r[4].x+r[4].w),O&16&&(nt.y=r[4].y),O&8&&(nt.scale=r[3]),I.$set(nt);const vt={};O&16&&(vt.x=r[4].x+r[4].w),O&16&&(vt.y=r[4].y+r[4].h),O&8&&(vt.scale=r[3]),G.$set(vt);const xt={};O&16&&(xt.x=r[4].x),O&16&&(xt.y=r[4].y+r[4].h),O&8&&(xt.scale=r[3]),K.$set(xt)},i(B){k||(ct(W.$$.fragment,B),ct(I.$$.fragment,B),ct(G.$$.fragment,B),ct(K.$$.fragment,B),k=!0)},o(B){yt(W.$$.fragment,B),yt(I.$$.fragment,B),yt(G.$$.fragment,B),yt(K.$$.fragment,B),k=!1},d(B){B&&(ot(t),ot(a),ot(l),ot(p),ot(f),ot(v),ot(y),ot(T),ot(A),ot(C),ot(w),ot(H),ot(rt),ot(F),ot(Q)),ue(W,B),ue(I,B),ue(G,B),ue(K,B),it=!1,Ue(gt)}}}function ny(r){let t,e;return t=new nu({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[sy,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){ge(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function oy(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{const m=d.geometry.bounds;let[_,g]=[m.minX,m.minY],[v,y]=[m.maxX,m.maxY];const[x,b]=f;if(p==="SHAPE")_+=x,v+=x,g+=b,y+=b;else{switch(p){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{g+=b;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{y+=b;break}}switch(p){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{_+=x;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{v+=x;break}}}const E=Math.min(_,v),T=Math.min(g,y),A=Math.abs(v-_),M=Math.abs(y-g);return{...d,geometry:{x:E,y:T,w:A,h:M,bounds:{minX:E,minY:T,maxX:E+A,maxY:T+M}}}};function h(d){lr.call(this,r,d)}function u(d){lr.call(this,r,d)}function c(d){lr.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class ay extends _e{constructor(t){super(),ye(this,t,oy,ny,Kt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const eu=new Map([[Et.RECTANGLE,ay],[Et.POLYGON,Kg]]),ru=r=>eu.get(r.type),iu=(r,t)=>eu.set(r,t),ly=r=>({}),su=r=>({grab:r[0]});function hy(r){let t,e,i,s;const n=r[7].default,o=Lm(n,r,r[6],su);return{c(){t=bt("g"),o&&o.c(),R(t,"class","a9s-annotation selected")},m(a,l){lt(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Ot(t,"pointerup",r[2]),Ot(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&Nm(o,n,a,a[6],e?Fm(n,a[6],l,ly):Um(a[6]),su)},i(a){e||(ct(o,a),e=!0)},o(a){yt(o,a),e=!1},d(a){a&&ot(t),o&&o.d(a),i=!1,Ue(s)}}}function uy(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=ai();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,u,c;const d=m=>_=>{h=m,u=l.elementToImage(_.offsetX,_.offsetY),c=o,_.target.setPointerCapture(_.pointerId),n("grab",_)},p=m=>{if(h){const[_,g]=l.elementToImage(m.offsetX,m.offsetY),v=[_-u[0],g-u[1]];e(3,o=a(c,h,v)),n("change",o)}},f=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,c=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,p,f,o,a,l,s,i]}class nu extends _e{constructor(t){super(),ye(this,t,uy,hy,Kt,{shape:3,editor:4,transform:5})}}const js=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}};function cy(r,t,e){let i;const s=ai();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return Zi(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=js(n,a)),r.$$.dirty&65&&n&&(c==null||c.$set({shape:n.target.selector})),r.$$.dirty&80&&c&&c.$set({transform:h}),r.$$.dirty&96&&c&&c.$set({viewportScale:u}),r.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[n,o,a,l,h,u,c,i]}class dy extends _e{constructor(t){super(),ye(this,t,cy,null,Kt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function fy(r,t,e){const i=ai();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return Zi(()=>{const u=n.closest("svg"),c=[],d=(p,f,m)=>{u==null||u.addEventListener(p,f,m),c.push(()=>u==null?void 0:u.removeEventListener(p,f,m))};return e(5,h=new o({target:n,props:{addEventListener:d,drawingMode:s,transform:a,viewportScale:l}})),h.$on("create",p=>i("create",p.detail)),()=>{c.forEach(p=>p()),h.$destroy()}}),r.$$set=u=>{"drawingMode"in u&&e(0,s=u.drawingMode),"target"in u&&e(1,n=u.target),"tool"in u&&e(2,o=u.tool),"transform"in u&&e(3,a=u.transform),"viewportScale"in u&&e(4,l=u.viewportScale)},r.$$.update=()=>{r.$$.dirty&40&&h&&h.$set({transform:a}),r.$$.dirty&48&&h&&h.$set({viewportScale:l})},[s,n,o,a,l,h]}class py extends _e{constructor(t){super(),ye(this,t,fy,null,Kt,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function ou(r){let t,e;return{c(){t=bt("rect"),e=bt("rect"),R(t,"class","a9s-outer"),R(t,"x",r[1]),R(t,"y",r[2]),R(t,"width",r[3]),R(t,"height",r[4]),R(e,"class","a9s-inner"),R(e,"x",r[1]),R(e,"y",r[2]),R(e,"width",r[3]),R(e,"height",r[4])},m(i,s){lt(i,t,s),lt(i,e,s)},p(i,s){s&2&&R(t,"x",i[1]),s&4&&R(t,"y",i[2]),s&8&&R(t,"width",i[3]),s&16&&R(t,"height",i[4]),s&2&&R(e,"x",i[1]),s&4&&R(e,"y",i[2]),s&8&&R(e,"width",i[3]),s&16&&R(e,"height",i[4])},d(i){i&&(ot(t),ot(e))}}}function my(r){let t,e=r[0]&&ou(r);return{c(){t=bt("g"),e&&e.c(),R(t,"class","a9s-annotation a9s-rubberband")},m(i,s){lt(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=ou(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:It,o:It,d(i){i&&ot(t),e&&e.d()}}}function gy(r,t,e){const i=ai();let{addEventListener:s}=t,{drawingMode:n}=t,{transform:o}=t,a,l,h,u,c,d,p;const f=v=>{const y=v;a=performance.now(),n==="drag"&&(e(0,l=o.elementToImage(y.offsetX,y.offsetY)),h=l,e(1,u=l[0]),e(2,c=l[1]),e(3,d=1),e(4,p=1))},m=v=>{const y=v;l&&(h=o.elementToImage(y.offsetX,y.offsetY),e(1,u=Math.min(h[0],l[0])),e(2,c=Math.min(h[1],l[1])),e(3,d=Math.abs(h[0]-l[0])),e(4,p=Math.abs(h[1]-l[1])))},_=v=>{const y=v,x=performance.now()-a;if(n==="click"){if(x>300)return;l?g():(e(0,l=o.elementToImage(y.offsetX,y.offsetY)),h=l,e(1,u=l[0]),e(2,c=l[1]),e(3,d=1),e(4,p=1))}else l&&(x>300||d*p>100?(y.stopPropagation(),g()):(e(0,l=void 0),h=void 0))},g=()=>{if(d*p>15){const v={type:Et.RECTANGLE,geometry:{bounds:{minX:u,minY:c,maxX:u+d,maxY:c+p},x:u,y:c,w:d,h:p}};i("create",v)}e(0,l=void 0),h=void 0};return Zi(()=>{s("pointerdown",f),s("pointermove",m),s("pointerup",_,!0)}),r.$$set=v=>{"addEventListener"in v&&e(5,s=v.addEventListener),"drawingMode"in v&&e(6,n=v.drawingMode),"transform"in v&&e(7,o=v.transform)},[l,u,c,d,p,s,n,o]}class yy extends _e{constructor(t){super(),ye(this,t,gy,my,Kt,{addEventListener:5,drawingMode:6,transform:7})}}function qo(r){const t=r.slice(),e=(t[2]?t[0]:[...t[0],t[1]]).map(i=>i.join(",")).join(" ");return t[16]=e,t}function au(r){let t,e,i,s,n,o=r[2]&&lu(r);return{c(){t=bt("polygon"),i=bt("polygon"),o&&o.c(),n=Te(),R(t,"class","a9s-outer"),R(t,"points",e=r[16]),R(i,"class","a9s-inner"),R(i,"points",s=r[16])},m(a,l){lt(a,t,l),lt(a,i,l),o&&o.m(a,l),lt(a,n,l)},p(a,l){l&7&&e!==(e=a[16])&&R(t,"points",e),l&7&&s!==(s=a[16])&&R(i,"points",s),a[2]?o?o.p(a,l):(o=lu(a),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},d(a){a&&(ot(t),ot(i),ot(n)),o&&o.d(a)}}}function lu(r){let t,e,i;return{c(){t=bt("rect"),R(t,"class","a9s-handle"),R(t,"x",e=r[0][0][0]-r[3]/2),R(t,"y",i=r[0][0][1]-r[3]/2),R(t,"height",r[3]),R(t,"width",r[3])},m(s,n){lt(s,t,n)},p(s,n){n&9&&e!==(e=s[0][0][0]-s[3]/2)&&R(t,"x",e),n&9&&i!==(i=s[0][0][1]-s[3]/2)&&R(t,"y",i),n&8&&R(t,"height",s[3]),n&8&&R(t,"width",s[3])},d(s){s&&ot(t)}}}function _y(r){let t,e=r[1]&&au(qo(r));return{c(){t=bt("g"),e&&e.c(),R(t,"class","a9s-annotation a9s-rubberband")},m(i,s){lt(i,t,s),e&&e.m(t,null)},p(i,[s]){i[1]?e?e.p(qo(i),s):(e=au(qo(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:It,o:It,d(i){i&&ot(t),e&&e.d()}}}const vy=20,xy=1500;function by(r,t,e){let i;const s=ai();let{addEventListener:n}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,u=[],c,d,p=!1;const f=y=>{const x=y,{timeStamp:b,offsetX:E,offsetY:T}=x;if(h={timeStamp:b,offsetX:E,offsetY:T},o==="drag"&&u.length===0){const A=a.elementToImage(x.offsetX,x.offsetY);u.push(A),e(1,c=A)}},m=y=>{const x=y;if(d&&clearTimeout(d),u.length>0){if(e(1,c=a.elementToImage(x.offsetX,x.offsetY)),u.length>2){const b=Yo(c,u[0])*l;e(2,p=b<vy)}x.pointerType==="touch"&&(d=setTimeout(()=>{g()},xy))}},_=y=>{const x=y;if(d&&clearTimeout(d),o==="click"){const b=x.timeStamp-h.timeStamp,E=Yo([h.offsetX,h.offsetY],[x.offsetX,x.offsetY]);if(b>300||E>15)return;if(p)v();else if(u.length===0){const T=a.elementToImage(x.offsetX,x.offsetY);u.push(T),e(1,c=T)}else u.push(c)}else{if(u.length===1&&Yo(u[0],c)<=4){e(0,u=[]),e(1,c=void 0);return}x.stopImmediatePropagation(),p?v():u.push(c)}},g=()=>{if(!c)return;const y=[...u,c],x={type:Et.POLYGON,geometry:{bounds:Xs(y),points:y}};Ho(x)>4&&(e(0,u=[]),e(1,c=void 0),s("create",x))},v=()=>{const y={type:Et.POLYGON,geometry:{bounds:Xs(u),points:[...u]}};e(0,u=[]),e(1,c=void 0),s("create",y)};return Zi(()=>{n("pointerdown",f,!0),n("pointermove",m),n("pointerup",_,!0),n("dblclick",g,!0)}),r.$$set=y=>{"addEventListener"in y&&e(4,n=y.addEventListener),"drawingMode"in y&&e(5,o=y.drawingMode),"transform"in y&&e(6,a=y.transform),"viewportScale"in y&&e(7,l=y.viewportScale)},r.$$.update=()=>{r.$$.dirty&128&&e(3,i=10/l)},[u,c,p,i,n,o,a,l]}class wy extends _e{constructor(t){super(),ye(this,t,by,_y,Kt,{addEventListener:4,drawingMode:5,transform:6,viewportScale:7})}}const Ko=new Map([["rectangle",{tool:yy}],["polygon",{tool:wy}]]),Ys=()=>[...Ko.keys()],qs=r=>Ko.get(r),hu=(r,t,e)=>Ko.set(r,{tool:t,opts:e});function Ty(r){let t,e,i,s,n;return{c(){t=bt("g"),e=bt("ellipse"),s=bt("ellipse"),R(e,"class","a9s-outer"),R(e,"style",i=r[1]?"display:none;":void 0),R(e,"cx",r[2]),R(e,"cy",r[3]),R(e,"rx",r[4]),R(e,"ry",r[5]),R(s,"class","a9s-inner"),R(s,"style",r[1]),R(s,"cx",r[2]),R(s,"cy",r[3]),R(s,"rx",r[4]),R(s,"ry",r[5]),R(t,"class","a9s-annotation"),R(t,"data-id",n=r[0].id)},m(o,a){lt(o,t,a),ke(t,e),ke(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&R(e,"style",i),a&2&&R(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&R(t,"data-id",n)},i:It,o:It,d(o){o&&ot(t)}}}function Ey(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{cx:a,cy:l,rx:h,ry:u}=n;return r.$$set=c=>{"annotation"in c&&e(0,s=c.annotation),"geom"in c&&e(6,n=c.geom),"style"in c&&e(7,o=c.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=js(s,o))},[s,i,a,l,h,u,n,o]}class Ay extends _e{constructor(t){super(),ye(this,t,Ey,Ty,Kt,{annotation:0,geom:6,style:7})}}function Sy(r){let t,e,i,s,n;return{c(){t=bt("g"),e=bt("polygon"),s=bt("polygon"),R(e,"class","a9s-outer"),R(e,"style",i=r[1]?"display:none;":void 0),R(e,"points",r[2].map(Cy).join(" ")),R(s,"class","a9s-inner"),R(s,"style",r[1]),R(s,"points",r[2].map(Iy).join(" ")),R(t,"class","a9s-annotation"),R(t,"data-id",n=r[0].id)},m(o,a){lt(o,t,a),ke(t,e),ke(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&R(e,"style",i),a&2&&R(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&R(t,"data-id",n)},i:It,o:It,d(o){o&&ot(t)}}}const Cy=r=>r.join(","),Iy=r=>r.join(",");function Ry(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{points:a}=n;return r.$$set=l=>{"annotation"in l&&e(0,s=l.annotation),"geom"in l&&e(3,n=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=js(s,o))},[s,i,a,n,o]}class Py extends _e{constructor(t){super(),ye(this,t,Ry,Sy,Kt,{annotation:0,geom:3,style:4})}}function My(r){let t,e,i,s,n;return{c(){t=bt("g"),e=bt("rect"),s=bt("rect"),R(e,"class","a9s-outer"),R(e,"style",i=r[5]?"display:none;":void 0),R(e,"x",r[4]),R(e,"y",r[3]),R(e,"width",r[2]),R(e,"height",r[1]),R(s,"class","a9s-inner"),R(s,"style",r[5]),R(s,"x",r[4]),R(s,"y",r[3]),R(s,"width",r[2]),R(s,"height",r[1]),R(t,"class","a9s-annotation"),R(t,"data-id",n=r[0].id)},m(o,a){lt(o,t,a),ke(t,e),ke(t,s)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&R(e,"style",i),a&16&&R(e,"x",o[4]),a&8&&R(e,"y",o[3]),a&4&&R(e,"width",o[2]),a&2&&R(e,"height",o[1]),a&32&&R(s,"style",o[5]),a&16&&R(s,"x",o[4]),a&8&&R(s,"y",o[3]),a&4&&R(s,"width",o[2]),a&2&&R(s,"height",o[1]),a&1&&n!==(n=o[0].id)&&R(t,"data-id",n)},i:It,o:It,d(o){o&&ot(t)}}}function Dy(r,t,e){let i,s,n,o,a,{annotation:l}=t,{geom:h}=t,{style:u}=t;return r.$$set=c=>{"annotation"in c&&e(0,l=c.annotation),"geom"in c&&e(6,h=c.geom),"style"in c&&e(7,u=c.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=js(l,u)),r.$$.dirty&64&&e(4,{x:s,y:n,w:o,h:a}=h,s,(e(3,n),e(6,h)),(e(2,o),e(6,h)),(e(1,a),e(6,h)))},[l,a,o,n,s,i,h,u]}class By extends _e{constructor(t){super(),ye(this,t,Dy,My,Kt,{annotation:0,geom:6,style:7})}}const Oy=r=>({elementToImage:(t,e)=>{const i=r.getBoundingClientRect(),s=r.createSVGPoint();s.x=t+i.x,s.y=e+i.y;const{x:n,y:o}=s.matrixTransform(r.getScreenCTM().inverse());return[n,o]}}),Ly=250,Fy=(r,t)=>{const e=ai();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<Ly){const{x:n,y:o}=uu(s,r),a=t.getAt(n,o);a?e("click",{originalEvent:s,annotation:a}):e("click",{originalEvent:s})}}}},uu=(r,t)=>{const e=t.createSVGPoint(),i=t.getBoundingClientRect(),s=r.clientX-i.x,n=r.clientY-i.y,{left:o,top:a}=t.getBoundingClientRect();return e.x=s+o,e.y=n+a,e.matrixTransform(t.getScreenCTM().inverse())};function cu(r,t,e){const i=r.slice();i[39]=t[e];const s=i[24](i[39].target.selector);return i[40]=s,i}function du(r,t,e){const i=r.slice();return i[43]=t[e],i}function Zo(r){const t=r.slice(),e=t[43].target.selector;return t[46]=e,t}function fu(r){let t=r[43].id,e,i,s=pu(r);return{c(){s.c(),e=Te()},m(n,o){s.m(n,o),lt(n,e,o),i=!0},p(n,o){o[0]&65536&&Kt(t,t=n[43].id)?(Ee(),yt(s,1,1,It),Ae(),s=pu(n),s.c(),ct(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ct(s),i=!0)},o(n){yt(s),i=!1},d(n){n&&ot(e),s.d(n)}}}function Ny(r){let t,e;return t=new Py({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){ge(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function Uy(r){let t,e;return t=new By({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){ge(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function ky(r){var t;let e,i;return e=new Ay({props:{annotation:r[43],geom:(t=r[46])==null?void 0:t.geometry,style:r[1]}}),{c(){ge(e.$$.fragment)},m(s,n){he(e,s,n),i=!0},p(s,n){var o;const a={};n[0]&65536&&(a.annotation=s[43]),n[0]&65536&&(a.geom=(o=s[46])==null?void 0:o.geometry),n[0]&2&&(a.style=s[1]),e.$set(a)},i(s){i||(ct(e.$$.fragment,s),i=!0)},o(s){yt(e.$$.fragment,s),i=!1},d(s){ue(e,s)}}}function pu(r){let t,e,i,s;const n=[ky,Uy,Ny],o=[];function a(l,h){var u,c,d;return((u=l[46])==null?void 0:u.type)===Et.ELLIPSE?0:((c=l[46])==null?void 0:c.type)===Et.RECTANGLE?1:((d=l[46])==null?void 0:d.type)===Et.POLYGON?2:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Te()},m(l,h){~t&&o[t].m(l,h),lt(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(Ee(),yt(o[u],1,1,()=>{o[u]=null}),Ae()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ct(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ct(e),s=!0)},o(l){yt(e),s=!1},d(l){l&&ot(i),~t&&o[t].d(l)}}}function mu(r){let t=hr(r[43])&&!r[9](r[43]),e,i,s=t&&fu(Zo(r));return{c(){s&&s.c(),e=Te()},m(n,o){s&&s.m(n,o),lt(n,e,o),i=!0},p(n,o){o[0]&66048&&(t=hr(n[43])&&!n[9](n[43])),t?s?(s.p(Zo(n),o),o[0]&66048&&ct(s,1)):(s=fu(Zo(n)),s.c(),ct(s,1),s.m(e.parentNode,e)):s&&(Ee(),yt(s,1,1,()=>{s=null}),Ae())},i(n){i||(ct(s),i=!0)},o(n){yt(s),i=!1},d(n){n&&ot(e),s&&s.d(n)}}}function gu(r){let t,e,i,s;const n=[Hy,Gy],o=[];function a(l,h){return l[8]?0:l[14]&&l[0]?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Te()},m(l,h){~t&&o[t].m(l,h),lt(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(Ee(),yt(o[u],1,1,()=>{o[u]=null}),Ae()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ct(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ct(e),s=!0)},o(l){yt(e),s=!1},d(l){l&&ot(i),~t&&o[t].d(l)}}}function Gy(r){let t=`${r[2]}-${r[5]}`,e,i,s=yu(r);return{c(){s.c(),e=Te()},m(n,o){s.m(n,o),lt(n,e,o),i=!0},p(n,o){o[0]&36&&Kt(t,t=`${n[2]}-${n[5]}`)?(Ee(),yt(s,1,1,It),Ae(),s=yu(n),s.c(),ct(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ct(s),i=!0)},o(n){yt(s),i=!1},d(n){n&&ot(e),s.d(n)}}}function Hy(r){let t,e,i=ci(r[8]),s=[];for(let o=0;o<i.length;o+=1)s[o]=xu(cu(r,i,o));const n=o=>yt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Te()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);lt(o,t,a),e=!0},p(o,a){if(a[0]&21107010){i=ci(o[8]);let l;for(l=0;l<i.length;l+=1){const h=cu(o,i,l);s[l]?(s[l].p(h,a),ct(s[l],1)):(s[l]=xu(h),s[l].c(),ct(s[l],1),s[l].m(t.parentNode,t))}for(Ee(),l=i.length;l<s.length;l+=1)n(l);Ae()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ct(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)yt(s[a]);e=!1},d(o){o&&ot(t),Lo(s,o)}}}function yu(r){let t,e;return t=new py({props:{target:r[6],tool:r[14],drawingMode:r[13],transform:r[12],viewportScale:r[17]}}),t.$on("create",r[21]),{c(){ge(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){const n={};s[0]&64&&(n.target=i[6]),s[0]&16384&&(n.tool=i[14]),s[0]&8192&&(n.drawingMode=i[13]),s[0]&4096&&(n.transform=i[12]),s[0]&131072&&(n.viewportScale=i[17]),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function _u(r){let t=r[39].id,e,i,s=vu(r);return{c(){s.c(),e=Te()},m(n,o){s.m(n,o),lt(n,e,o),i=!0},p(n,o){o[0]&256&&Kt(t,t=n[39].id)?(Ee(),yt(s,1,1,It),Ae(),s=vu(n),s.c(),ct(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ct(s),i=!0)},o(n){yt(s),i=!1},d(n){n&&ot(e),s.d(n)}}}function vu(r){let t,e;return t=new dy({props:{target:r[6],editor:r[24](r[39].target.selector),annotation:r[39],style:r[1],transform:r[12],viewportScale:r[17]}}),t.$on("change",function(){Gt(r[22](r[39]))&&r[22](r[39]).apply(this,arguments)}),{c(){ge(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&64&&(n.target=r[6]),s[0]&256&&(n.editor=r[24](r[39].target.selector)),s[0]&256&&(n.annotation=r[39]),s[0]&2&&(n.style=r[1]),s[0]&4096&&(n.transform=r[12]),s[0]&131072&&(n.viewportScale=r[17]),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function xu(r){let t,e,i=r[40]&&_u(r);return{c(){i&&i.c(),t=Te()},m(s,n){i&&i.m(s,n),lt(s,t,n),e=!0},p(s,n){s[40]?i?(i.p(s,n),n[0]&256&&ct(i,1)):(i=_u(s),i.c(),ct(i,1),i.m(t.parentNode,t)):i&&(Ee(),yt(i,1,1,()=>{i=null}),Ae())},i(s){e||(ct(i),e=!0)},o(s){yt(i),e=!1},d(s){s&&ot(t),i&&i.d(s)}}}function $y(r){let t,e,i,s,n,o,a=ci(r[16].filter(r[34])),l=[];for(let c=0;c<a.length;c+=1)l[c]=mu(du(r,a,c));const h=c=>yt(l[c],1,1,()=>{l[c]=null});let u=r[6]&&gu(r);return{c(){t=bt("svg"),e=bt("g");for(let c=0;c<l.length;c+=1)l[c].c();i=bt("g"),u&&u.c(),R(i,"class","drawing"),R(t,"class","a9s-annotationlayer"),Tr(t,"drawing",r[14]),Tr(t,"hidden",!r[3]),Tr(t,"hover",r[15])},m(c,d){lt(c,t,d),ke(t,e);for(let p=0;p<l.length;p+=1)l[p]&&l[p].m(e,null);ke(t,i),u&&u.m(i,null),r[35](i),r[36](t),s=!0,n||(o=[Ot(t,"pointerup",function(){Gt(r[10])&&r[10].apply(this,arguments)}),Ot(t,"pointerdown",function(){Gt(r[11])&&r[11].apply(this,arguments)}),Ot(t,"pointermove",r[23])],n=!0)},p(c,d){if(r=c,d[0]&66050){a=ci(r[16].filter(r[34]));let p;for(p=0;p<a.length;p+=1){const f=du(r,a,p);l[p]?(l[p].p(f,d),ct(l[p],1)):(l[p]=mu(f),l[p].c(),ct(l[p],1),l[p].m(e,null))}for(Ee(),p=a.length;p<l.length;p+=1)h(p);Ae()}r[6]?u?(u.p(r,d),d[0]&64&&ct(u,1)):(u=gu(r),u.c(),ct(u,1),u.m(i,null)):u&&(Ee(),yt(u,1,1,()=>{u=null}),Ae()),(!s||d[0]&16384)&&Tr(t,"drawing",r[14]),(!s||d[0]&8)&&Tr(t,"hidden",!r[3]),(!s||d[0]&32768)&&Tr(t,"hover",r[15])},i(c){if(!s){for(let d=0;d<a.length;d+=1)ct(l[d]);ct(u),s=!0}},o(c){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)yt(l[d]);yt(u),s=!1},d(c){c&&ot(t),Lo(l,c),u&&u.d(),r[35](null),r[36](null),n=!1,Ue(o)}}}function Vy(r,t,e){let i,s,n,o,a,l,h,u,c,d,p,f=It,m=()=>(f(),f=Bh(D,B=>e(17,p=B)),D);r.$$.on_destroy.push(()=>f());let{drawingEnabled:_}=t,{image:g}=t,{preferredDrawingMode:v}=t,{state:y}=t,{style:x=void 0}=t,{toolName:b=Ys()[0]}=t,{user:E}=t,{visible:T=!0}=t,A=0;const M=()=>e(5,A+=1),S=()=>b,P=()=>_;let C,w,D;Zi(()=>m(e(7,D=Qg(g,w))));const{hover:N,selection:V,store:H}=y;Oo(r,N,B=>e(15,u=B)),Oo(r,V,B=>e(33,c=B)),Oo(r,H,B=>e(16,d=B));let W,rt;const I=B=>{W&&H.unobserve(W);const O=B.filter(({editable:tt})=>tt).map(({id:tt})=>tt);O.length>0?(e(8,rt=O.map(tt=>H.getAnnotation(tt)).filter(tt=>tt&&hr(tt))),W=tt=>{const{updated:nt}=tt.changes;e(8,rt=nt==null?void 0:nt.map(vt=>vt.newValue))},H.observe(W,{annotations:O})):e(8,rt=void 0)},F=B=>{const O=Vh(),tt={id:O,bodies:[],target:{annotation:O,selector:B.detail,creator:E,created:new Date}};H.addAnnotation(tt),V.setSelected(tt.id)},G=B=>O=>{var tt;const{target:nt}=B,vt=10*60*1e3,xt=((tt=nt.creator)==null?void 0:tt.id)!==E.id||!nt.created||new Date().getTime()-nt.created.getTime()>vt;H.updateTarget({...nt,selector:O.detail,created:xt?nt.created:new Date,updated:xt?new Date:void 0,updatedBy:xt?E:void 0})},Q=B=>{const{x:O,y:tt}=uu(B,w),nt=H.getAt(O,tt);nt?u!==nt.id&&N.set(nt.id):N.set(void 0)},K=B=>ru(B),k=B=>hr(B);function it(B){$s[B?"unshift":"push"](()=>{C=B,e(6,C)})}function gt(B){$s[B?"unshift":"push"](()=>{w=B,e(4,w)})}return r.$$set=B=>{"drawingEnabled"in B&&e(0,_=B.drawingEnabled),"image"in B&&e(25,g=B.image),"preferredDrawingMode"in B&&e(26,v=B.preferredDrawingMode),"state"in B&&e(27,y=B.state),"style"in B&&e(1,x=B.style),"toolName"in B&&e(2,b=B.toolName),"user"in B&&e(28,E=B.user),"visible"in B&&e(3,T=B.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(14,{tool:i,opts:s}=qs(b)||{tool:void 0,opts:void 0},i,(e(32,s),e(2,b))),r.$$.dirty[0]&67108864|r.$$.dirty[1]&2&&e(13,n=(s==null?void 0:s.drawingMode)||v),r.$$.dirty[0]&16&&e(12,o=Oy(w)),r.$$.dirty[0]&16&&e(11,{onPointerDown:a,onPointerUp:l}=Fy(w,H),a,(e(10,l),e(4,w))),r.$$.dirty[1]&4&&e(9,h=B=>c.selected.find(O=>O.id===B.id&&O.editable)),r.$$.dirty[1]&4&&I(c.selected)},[_,x,b,T,w,A,C,D,rt,h,l,a,o,n,i,u,d,p,N,V,H,F,G,Q,K,g,v,y,E,M,S,P,s,c,k,it,gt]}class Xy extends _e{constructor(t){super(),ye(this,t,Vy,$y,Kt,{drawingEnabled:0,image:25,preferredDrawingMode:26,state:27,style:1,toolName:2,user:28,visible:3,cancelDrawing:29,getDrawingTool:30,isDrawingEnabled:31},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[29]}get getDrawingTool(){return this.$$.ctx[30]}get isDrawingEnabled(){return this.$$.ctx[31]}}function bu(r,t,e=0,i=r.length-1,s=Wy){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,u=Math.log(l),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(l-c)/l)*(h-l/2<0?-1:1),p=Math.max(e,Math.floor(t-h*c/l+d)),f=Math.min(i,Math.floor(t+(l-h)*c/l+d));bu(r,t,p,f,s)}const n=r[t];let o=e,a=i;for(Qi(r,e,t),s(r[i],n)>0&&Qi(r,e,i);o<a;){for(Qi(r,o,a),o++,a--;s(r[o],n)<0;)o++;for(;s(r[a],n)>0;)a--}s(r[e],n)===0?Qi(r,e,a):(a++,Qi(r,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function Qi(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function Wy(r,t){return r<t?-1:r>t?1:0}class zy{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!Zs(t,e))return i;const s=this.toBBox,n=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;Zs(t,l)&&(e.leaf?i.push(a):Qo(t,l)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!Zs(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const n=e.children[s],o=e.leaf?this.toBBox(n):n;if(Zs(t,o)){if(e.leaf||Qo(t,o))return!0;i.push(n)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=mi([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),n=[],o=[];let a,l,h;for(;i||n.length;){if(i||(i=n.pop(),l=n[n.length-1],a=o.pop(),h=!0),i.leaf){const u=jy(t,i.children,e);if(u!==-1)return i.children.splice(u,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&Qo(i,s)?(n.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const n=i-e+1;let o=this._maxEntries,a;if(n<=o)return a=mi(t.slice(e,i+1)),pi(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=mi([]),a.leaf=!1,a.height=s;const l=Math.ceil(n/o),h=l*Math.ceil(Math.sqrt(o));wu(t,e,i,h,this.compareMinX);for(let u=e;u<=i;u+=h){const c=Math.min(u+h-1,i);wu(t,u,c,l,this.compareMinY);for(let d=u;d<=c;d+=l){const p=Math.min(d+l-1,c);a.children.push(this._build(t,d,p,s-1))}}return pi(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let n=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],u=Jo(h),c=Ky(t,h)-u;c<o?(o=c,n=u<n?u:n,a=h):c===o&&u<n&&(n=u,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),n=[],o=this._chooseSubtree(s,this.data,e,n);for(o.children.push(t),es(o,s);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(s,n,e)}_split(t,e){const i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);const o=this._chooseSplitIndex(i,n,s),a=mi(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,pi(i,this.toBBox),pi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=mi([t,e]),this.data.height=t.height+1,this.data.leaf=!1,pi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,n=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=ts(t,0,a,this.toBBox),h=ts(t,a,i,this.toBBox),u=Zy(l,h),c=Jo(l)+Jo(h);u<n?(n=u,s=a,o=c<o?c:o):u===n&&c<o&&(o=c,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:Yy,n=t.leaf?this.compareMinY:qy,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,n);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const n=this.toBBox,o=ts(t,0,e,n),a=ts(t,i-e,i,n);let l=Ks(o)+Ks(a);for(let h=e;h<i-e;h++){const u=t.children[h];es(o,t.leaf?n(u):u),l+=Ks(o)}for(let h=i-e-1;h>=e;h--){const u=t.children[h];es(a,t.leaf?n(u):u),l+=Ks(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)es(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():pi(t[e],this.toBBox)}}function jy(r,t,e){if(!e)return t.indexOf(r);for(let i=0;i<t.length;i++)if(e(r,t[i]))return i;return-1}function pi(r,t){ts(r,0,r.children.length,t,r)}function ts(r,t,e,i,s){s||(s=mi(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let n=t;n<e;n++){const o=r.children[n];es(s,r.leaf?i(o):o)}return s}function es(r,t){return r.minX=Math.min(r.minX,t.minX),r.minY=Math.min(r.minY,t.minY),r.maxX=Math.max(r.maxX,t.maxX),r.maxY=Math.max(r.maxY,t.maxY),r}function Yy(r,t){return r.minX-t.minX}function qy(r,t){return r.minY-t.minY}function Jo(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function Ks(r){return r.maxX-r.minX+(r.maxY-r.minY)}function Ky(r,t){return(Math.max(t.maxX,r.maxX)-Math.min(t.minX,r.minX))*(Math.max(t.maxY,r.maxY)-Math.min(t.minY,r.minY))}function Zy(r,t){const e=Math.max(r.minX,t.minX),i=Math.max(r.minY,t.minY),s=Math.min(r.maxX,t.maxX),n=Math.min(r.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,n-i)}function Qo(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function Zs(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function mi(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function wu(r,t,e,i,s){const n=[t,e];for(;n.length;){if(e=n.pop(),t=n.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;bu(r,o,t,e,s),n.push(t,o,o,e)}}const Jy=()=>{const r=new zy,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=o=>{if(!Ws(o))return;const{minX:a,minY:l,maxX:h,maxY:u}=o.selector.geometry.bounds,c={minX:a,minY:l,maxX:h,maxY:u,target:o};r.insert(c),t.set(o.annotation,c)},n=o=>{if(!Ws(o))return;const a=t.get(o.annotation);a&&r.remove(a),t.delete(o.annotation)};return{all:e,clear:i,getAt:(o,a)=>{const l=r.search({minX:o,minY:a,maxX:o,maxY:a}).map(h=>h.target).filter(h=>h.selector.type===Et.RECTANGLE||jm(h.selector,o,a));if(l.length>0)return l.sort((h,u)=>Ho(h.selector)-Ho(u.selector)),l[0]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(u=>u.target),insert:s,remove:n,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,u)=>{if(Ws(u)){const{minX:c,minY:d,maxX:p,maxY:f}=u.selector.geometry.bounds;return[...h,{minX:c,minY:d,maxX:p,maxY:f,target:u}]}else return h},[]);l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{n(o),s(a)}}},Tu=r=>{const t=Eg(),e=Jy(),i=cg(t,r.userSelectAction,r.adapter),s=ug(t),n=Rg();return t.observe(({changes:o})=>{e.set((o.created||[]).map(a=>a.target),!1),(o.deleted||[]).forEach(a=>e.remove(a.target)),(o.updated||[]).forEach(({oldValue:a,newValue:l})=>e.update(a.target,l.target))}),{store:{...t,getAt:(o,a)=>{const l=e.getAt(o,a);return l?t.getAnnotation(l.annotation):void 0},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(u=>t.getAnnotation(u.annotation))},selection:i,hover:s,viewport:n}},Qy=r=>{const t=Tu(r);return{...t,store:Ag(t.store)}},t_=r=>{let t,e;if(r.nodeName==="CANVAS")t=r,e=t.getContext("2d",{willReadFrequently:!0});else{const s=r;t=document.createElement("canvas"),t.width=s.width,t.height=s.height,e=t.getContext("2d",{willReadFrequently:!0}),e.drawImage(s,0,0,s.width,s.height)}let i=0;for(let s=1;s<10;s++)for(let n=1;n<10;n++){const o=Math.round(n*t.width/10),a=Math.round(s*t.height/10),l=e.getImageData(o,a,1,1).data,h=(.299*l[0]+.587*l[1]+.114*l[2])/255;i+=h}return i/81},Eu=r=>{const t=t_(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},Au=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?Eu(r):e),Su=(r,t)=>({...r,drawingEnabled:r.drawingEnabled===void 0?t.drawingEnabled:r.drawingEnabled,drawingMode:r.drawingMode||t.drawingMode,userSelectAction:r.userSelectAction||t.userSelectAction,theme:r.theme||t.theme}),Cu=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,Iu=(r,t)=>{const e=t||document,i=o=>{const a=o;a.key==="z"&&a.ctrlKey?r.undo():a.key==="y"&&a.ctrlKey&&r.redo()},s=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?r.redo():r.undo())},n=()=>{Cu?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return Cu?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},e_=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=Su(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:Wh.EDIT,theme:"light"}),s=Qy(i),{selection:n,store:o}=s,a=Ig(o,i.initialHistory),l=Pg(s,a,i.adapter,i.autoSave),h=document.createElement("DIV");h.style.position="relative",h.style.display="inline-block",e.style.display="block",e.parentNode.insertBefore(h,e),h.appendChild(e);const u=Iu(a);let c=Gg();Au(e,h,i.theme);const d=new Xy({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:c}});d.$on("click",C=>{const{originalEvent:w,annotation:D}=C.detail;D?n.userSelect(D.id,w):n.isEmpty()||n.clear()});const p=Dg(s,a,i.adapter),f=()=>d.cancelDrawing(),m=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),u.destroy(),a.destroy()},_=()=>d.getDrawingTool(),g=()=>c,v=()=>d.isDrawingEnabled(),y=(C,w,D)=>hu(C,w,D),x=(C,w)=>iu(C,w),b=C=>{if(!qs(C))throw`No drawing tool named ${C}`;d.$set({toolName:C})},E=C=>d.$set({drawingEnabled:C}),T=C=>{console.warn("Filter not implemented yet")},A=C=>d.$set({style:C}),M=C=>Au(e,h,C),S=C=>{c=C,d.$set({user:C})},P=C=>d.$set({visible:C});return{...p,cancelDrawing:f,destroy:m,getDrawingTool:_,getUser:g,isDrawingEnabled:v,listDrawingTools:Ys,on:l.on,off:l.off,registerDrawingTool:y,registerShapeEditor:x,setDrawingEnabled:E,setDrawingTool:b,setFilter:T,setStyle:A,setTheme:M,setUser:S,setVisible:P,element:h,state:s}};function Ge(){}function ta(r,t){for(const e in t)r[e]=t[e];return r}function Ru(r){return r()}function Pu(){return Object.create(null)}function ur(r){r.forEach(Ru)}function Zt(r){return typeof r=="function"}function re(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function r_(r){return Object.keys(r).length===0}function i_(r,...t){if(r==null){for(const i of t)i(void 0);return Ge}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function ea(r,t,e){r.$$.on_destroy.push(i_(t,e))}function Mu(r,t,e,i){if(r){const s=Du(r,t,e,i);return r[0](s)}}function Du(r,t,e,i){return r[1]&&i?ta(e.ctx.slice(),r[1](i(t))):e.ctx}function Bu(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Ou(r,t,e,i,s,n){if(s){const o=Du(t,e,i,n);r.p(o,s)}}function Lu(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function Fu(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Js(r){return r??""}const s_=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function cr(r,t){r.appendChild(t)}function mt(r,t,e){r.insertBefore(t,e||null)}function ft(r){r.parentNode&&r.parentNode.removeChild(r)}function ra(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function At(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function ia(r){return document.createTextNode(r)}function Se(){return ia(" ")}function dr(){return ia("")}function jt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function L(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function n_(r){return Array.from(r.childNodes)}function o_(r,t){t=""+t,r.data!==t&&(r.data=t)}function Qs(r,t,e){r.classList.toggle(t,!!e)}function a_(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let rs;function is(r){rs=r}function sa(){if(!rs)throw new Error("Function called outside component initialization");return rs}function tn(r){sa().$$.on_mount.push(r)}function l_(r){sa().$$.on_destroy.push(r)}function en(){const r=sa();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=a_(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function fr(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const gi=[],rn=[];let yi=[];const Nu=[],h_=Promise.resolve();let na=!1;function u_(){na||(na=!0,h_.then(Uu))}function oa(r){yi.push(r)}const aa=new Set;let _i=0;function Uu(){if(_i!==0)return;const r=rs;do{try{for(;_i<gi.length;){const t=gi[_i];_i++,is(t),c_(t.$$)}}catch(t){throw gi.length=0,_i=0,t}for(is(null),gi.length=0,_i=0;rn.length;)rn.pop()();for(let t=0;t<yi.length;t+=1){const e=yi[t];aa.has(e)||(aa.add(e),e())}yi.length=0}while(gi.length);for(;Nu.length;)Nu.pop()();na=!1,aa.clear(),is(r)}function c_(r){if(r.fragment!==null){r.update(),ur(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(oa)}}function d_(r){const t=[],e=[];yi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),yi=t}const sn=new Set;let $r;function He(){$r={r:0,c:[],p:$r}}function $e(){$r.r||ur($r.c),$r=$r.p}function ht(r,t){r&&r.i&&(sn.delete(r),r.i(t))}function pt(r,t,e,i){if(r&&r.o){if(sn.has(r))return;sn.add(r),$r.c.push(()=>{sn.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function vi(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function ie(r){r&&r.c()}function Jt(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),oa(()=>{const n=r.$$.on_mount.map(Ru).filter(Zt);r.$$.on_destroy?r.$$.on_destroy.push(...n):ur(n),r.$$.on_mount=[]}),s.forEach(oa)}function Qt(r,t){const e=r.$$;e.fragment!==null&&(d_(e.after_update),ur(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function f_(r,t){r.$$.dirty[0]===-1&&(gi.push(r),u_(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ce(r,t,e,i,s,n,o=null,a=[-1]){const l=rs;is(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Ge,not_equal:s,bound:Pu(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Pu(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=e?e(r,t.props||{},(c,d,...p)=>{const f=p.length?p[0]:d;return h.ctx&&s(h.ctx[c],h.ctx[c]=f)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](f),u&&f_(r,c)),d}):[],h.update(),u=!0,ur(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=n_(t.target);h.fragment&&h.fragment.l(c),c.forEach(ft)}else h.fragment&&h.fragment.c();t.intro&&ht(r.$$.fragment),Jt(r,t.target,t.anchor),Uu()}is(l)}class de{constructor(){xh(this,"$$");xh(this,"$$set")}$destroy(){Qt(this,1),this.$destroy=Ge}$on(t,e){if(!Zt(e))return Ge;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!r_(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const p_="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(p_);var Vr=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(Vr||{}),la=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(la||{}),ha=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(ha||{}),U=(r=>(r[r.NORMAL=0]="NORMAL",r[r.ADD=1]="ADD",r[r.MULTIPLY=2]="MULTIPLY",r[r.SCREEN=3]="SCREEN",r[r.OVERLAY=4]="OVERLAY",r[r.DARKEN=5]="DARKEN",r[r.LIGHTEN=6]="LIGHTEN",r[r.COLOR_DODGE=7]="COLOR_DODGE",r[r.COLOR_BURN=8]="COLOR_BURN",r[r.HARD_LIGHT=9]="HARD_LIGHT",r[r.SOFT_LIGHT=10]="SOFT_LIGHT",r[r.DIFFERENCE=11]="DIFFERENCE",r[r.EXCLUSION=12]="EXCLUSION",r[r.HUE=13]="HUE",r[r.SATURATION=14]="SATURATION",r[r.COLOR=15]="COLOR",r[r.LUMINOSITY=16]="LUMINOSITY",r[r.NORMAL_NPM=17]="NORMAL_NPM",r[r.ADD_NPM=18]="ADD_NPM",r[r.SCREEN_NPM=19]="SCREEN_NPM",r[r.NONE=20]="NONE",r[r.SRC_OVER=0]="SRC_OVER",r[r.SRC_IN=21]="SRC_IN",r[r.SRC_OUT=22]="SRC_OUT",r[r.SRC_ATOP=23]="SRC_ATOP",r[r.DST_OVER=24]="DST_OVER",r[r.DST_IN=25]="DST_IN",r[r.DST_OUT=26]="DST_OUT",r[r.DST_ATOP=27]="DST_ATOP",r[r.ERASE=26]="ERASE",r[r.SUBTRACT=28]="SUBTRACT",r[r.XOR=29]="XOR",r))(U||{}),Ce=(r=>(r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r))(Ce||{}),$=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))($||{}),xi=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(xi||{}),J=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(J||{}),q=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(q||{}),Ie=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(Ie||{}),pr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(pr||{}),Ve=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(Ve||{}),ae=(r=>(r[r.NPM=0]="NPM",r[r.UNPACK=1]="UNPACK",r[r.PMA=2]="PMA",r[r.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",r[r.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",r[r.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",r))(ae||{}),Xe=(r=>(r[r.NO=0]="NO",r[r.YES=1]="YES",r[r.AUTO=2]="AUTO",r[r.BLEND=0]="BLEND",r[r.CLEAR=1]="CLEAR",r[r.BLIT=2]="BLIT",r))(Xe||{}),ua=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(ua||{}),ve=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(ve||{}),Ft=(r=>(r[r.NONE=0]="NONE",r[r.SCISSOR=1]="SCISSOR",r[r.STENCIL=2]="STENCIL",r[r.SPRITE=3]="SPRITE",r[r.COLOR=4]="COLOR",r))(Ft||{}),Lt=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Lt||{}),We=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(We||{});const z={ADAPTER:{createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")},RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var ca=/iPhone/i,ku=/iPod/i,Gu=/iPad/i,Hu=/\biOS-universal(?:.+)Mac\b/i,da=/\bAndroid(?:.+)Mobile\b/i,$u=/Android/i,bi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,nn=/Silk/i,mr=/Windows Phone/i,Vu=/\bWindows(?:.+)ARM\b/i,Xu=/BlackBerry/i,Wu=/BB10/i,zu=/Opera Mini/i,ju=/\b(CriOS|Chrome)(?:.+)Mobile/i,Yu=/Mobile(?:.+)Firefox\b/i,qu=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function m_(r){return function(t){return t.test(r)}}function Ku(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var s=m_(e),n={apple:{phone:s(ca)&&!s(mr),ipod:s(ku),tablet:!s(ca)&&(s(Gu)||qu(t))&&!s(mr),universal:s(Hu),device:(s(ca)||s(ku)||s(Gu)||s(Hu)||qu(t))&&!s(mr)},amazon:{phone:s(bi),tablet:!s(bi)&&s(nn),device:s(bi)||s(nn)},android:{phone:!s(mr)&&s(bi)||!s(mr)&&s(da),tablet:!s(mr)&&!s(bi)&&!s(da)&&(s(nn)||s($u)),device:!s(mr)&&(s(bi)||s(nn)||s(da)||s($u))||s(/\bokhttp\b/i)},windows:{phone:s(mr),tablet:s(Vu),device:s(mr)||s(Vu)},other:{blackberry:s(Xu),blackberry10:s(Wu),opera:s(zu),firefox:s(Yu),chrome:s(ju),device:s(Xu)||s(Wu)||s(zu)||s(Yu)||s(ju)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const g_=Ku.default??Ku,ze=g_(globalThis.navigator);z.RETINA_PREFIX=/@([0-9\.]+)x/,z.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var ss=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Zu(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function y_(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var Ju={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,h,u){this.fn=l,this.context=h,this.once=u||!1}function n(l,h,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var p=new s(u,c||l,d),f=e?e+h:h;return l._events[f]?l._events[f].fn?l._events[f]=[l._events[f],p]:l._events[f].push(p):(l._events[f]=p,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],u,c;if(this._eventsCount===0)return h;for(c in u=this._events)t.call(u,c)&&h.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(u)):h},a.prototype.listeners=function(h){var u=e?e+h:h,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,p=c.length,f=new Array(p);d<p;d++)f[d]=c[d].fn;return f},a.prototype.listenerCount=function(h){var u=e?e+h:h,c=this._events[u];return c?c.fn?1:c.length:0},a.prototype.emit=function(h,u,c,d,p,f){var m=e?e+h:h;if(!this._events[m])return!1;var _=this._events[m],g=arguments.length,v,y;if(_.fn){switch(_.once&&this.removeListener(h,_.fn,void 0,!0),g){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,u),!0;case 3:return _.fn.call(_.context,u,c),!0;case 4:return _.fn.call(_.context,u,c,d),!0;case 5:return _.fn.call(_.context,u,c,d,p),!0;case 6:return _.fn.call(_.context,u,c,d,p,f),!0}for(y=1,v=new Array(g-1);y<g;y++)v[y-1]=arguments[y];_.fn.apply(_.context,v)}else{var x=_.length,b;for(y=0;y<x;y++)switch(_[y].once&&this.removeListener(h,_[y].fn,void 0,!0),g){case 1:_[y].fn.call(_[y].context);break;case 2:_[y].fn.call(_[y].context,u);break;case 3:_[y].fn.call(_[y].context,u,c);break;case 4:_[y].fn.call(_[y].context,u,c,d);break;default:if(!v)for(b=1,v=new Array(g-1);b<g;b++)v[b-1]=arguments[b];_[y].fn.apply(_[y].context,v)}}return!0},a.prototype.on=function(h,u,c){return n(this,h,u,c,!1)},a.prototype.once=function(h,u,c){return n(this,h,u,c,!0)},a.prototype.removeListener=function(h,u,c,d){var p=e?e+h:h;if(!this._events[p])return this;if(!u)return o(this,p),this;var f=this._events[p];if(f.fn)f.fn===u&&(!d||f.once)&&(!c||f.context===c)&&o(this,p);else{for(var m=0,_=[],g=f.length;m<g;m++)(f[m].fn!==u||d&&!f[m].once||c&&f[m].context!==c)&&_.push(f[m]);_.length?this._events[p]=_.length===1?_[0]:_:o(this,p)}return this},a.prototype.removeAllListeners=function(h){var u;return h?(u=e?e+h:h,this._events[u]&&o(this,u)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(Ju);var __=Ju.exports;const wi=Zu(__);var fa={exports:{}};fa.exports=on,fa.exports.default=on;function on(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=Qu(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,u,c,d,p;if(i&&(n=T_(r,t,n,e)),r.length>80*e){a=h=r[0],l=u=r[1];for(var f=e;f<s;f+=e)c=r[f],d=r[f+1],c<a&&(a=c),d<l&&(l=d),c>h&&(h=c),d>u&&(u=d);p=Math.max(h-a,u-l),p=p!==0?32767/p:0}return ns(n,o,e,a,l,p,0),o}function Qu(r,t,e,i,s){var n,o;if(s===ga(r,t,e,i)>0)for(n=t;n<e;n+=i)o=rc(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=rc(n,r[n],r[n+1],o);return o&&an(o,o.next)&&(as(o),o=o.next),o}function Xr(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(an(e,e.next)||Pt(e.prev,e,e.next)===0)){if(as(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function ns(r,t,e,i,s,n,o){if(r){!o&&n&&I_(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?x_(r,i,s,n):v_(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),as(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=b_(Xr(r),t,e),ns(r,t,e,i,s,n,2)):o===2&&w_(r,t,e,i,s,n):ns(Xr(r),t,e,i,s,n,1);break}}}}function v_(r){var t=r.prev,e=r,i=r.next;if(Pt(t,e,i)>=0)return!1;for(var s=t.x,n=e.x,o=i.x,a=t.y,l=e.y,h=i.y,u=s<n?s<o?s:o:n<o?n:o,c=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,p=a>l?a>h?a:h:l>h?l:h,f=i.next;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=c&&f.y<=p&&Ti(s,a,n,l,o,h,f.x,f.y)&&Pt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function x_(r,t,e,i){var s=r.prev,n=r,o=r.next;if(Pt(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,u=s.y,c=n.y,d=o.y,p=a<l?a<h?a:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=a>l?a>h?a:h:l>h?l:h,_=u>c?u>d?u:d:c>d?c:d,g=pa(p,f,t,e,i),v=pa(m,_,t,e,i),y=r.prevZ,x=r.nextZ;y&&y.z>=g&&x&&x.z<=v;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=_&&y!==s&&y!==o&&Ti(a,u,l,c,h,d,y.x,y.y)&&Pt(y.prev,y,y.next)>=0||(y=y.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==s&&x!==o&&Ti(a,u,l,c,h,d,x.x,x.y)&&Pt(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;y&&y.z>=g;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=_&&y!==s&&y!==o&&Ti(a,u,l,c,h,d,y.x,y.y)&&Pt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==s&&x!==o&&Ti(a,u,l,c,h,d,x.x,x.y)&&Pt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function b_(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!an(s,n)&&tc(s,i,i.next,n)&&os(s,n)&&os(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),as(i),as(i.next),i=r=n),i=i.next}while(i!==r);return Xr(i)}function w_(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&M_(o,a)){var l=ec(o,a);o=Xr(o,o.next),l=Xr(l,l.next),ns(o,t,e,i,s,n,0),ns(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function T_(r,t,e,i){var s=[],n,o,a,l,h;for(n=0,o=t.length;n<o;n++)a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,h=Qu(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(P_(h));for(s.sort(E_),n=0;n<s.length;n++)e=A_(s[n],e);return e}function E_(r,t){return r.x-t.x}function A_(r,t){var e=S_(r,t);if(!e)return t;var i=ec(e,r);return Xr(i,i.next),Xr(e,e.next)}function S_(r,t){var e=t,i=r.x,s=r.y,n=-1/0,o;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var a=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===i))return o}e=e.next}while(e!==t);if(!o)return null;var l=o,h=o.x,u=o.y,c=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&Ti(s<u?i:n,s,h,u,s<u?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),os(e,r)&&(d<c||d===c&&(e.x>o.x||e.x===o.x&&C_(o,e)))&&(o=e,c=d)),e=e.next;while(e!==l);return o}function C_(r,t){return Pt(r.prev,r,t.prev)<0&&Pt(t.next,r,r.next)<0}function I_(r,t,e,i){var s=r;do s.z===0&&(s.z=pa(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,R_(s)}function R_(r){var t,e,i,s,n,o,a,l,h=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t<h&&(a++,i=i.nextZ,!!i);t++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,h*=2}while(o>1);return r}function pa(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function P_(r){var t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function Ti(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function M_(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!D_(r,t)&&(os(r,t)&&os(t,r)&&B_(r,t)&&(Pt(r.prev,r,t.prev)||Pt(r,t.prev,t))||an(r,t)&&Pt(r.prev,r,r.next)>0&&Pt(t.prev,t,t.next)>0)}function Pt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function an(r,t){return r.x===t.x&&r.y===t.y}function tc(r,t,e,i){var s=hn(Pt(r,t,e)),n=hn(Pt(r,t,i)),o=hn(Pt(e,i,r)),a=hn(Pt(e,i,t));return!!(s!==n&&o!==a||s===0&&ln(r,e,t)||n===0&&ln(r,i,t)||o===0&&ln(e,r,i)||a===0&&ln(e,t,i))}function ln(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function hn(r){return r>0?1:r<0?-1:0}function D_(r,t){var e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&tc(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function os(r,t){return Pt(r.prev,r,r.next)<0?Pt(r,t,r.next)>=0&&Pt(r,r.prev,t)>=0:Pt(r,t,r.prev)<0||Pt(r,r.next,t)<0}function B_(r,t){var e=r,i=!1,s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function ec(r,t){var e=new ma(r.i,r.x,r.y),i=new ma(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function rc(r,t,e,i){var s=new ma(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function as(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function ma(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}on.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(ga(r,0,n,e));if(s)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,u=a<l-1?t[a+1]*e:r.length;o-=Math.abs(ga(r,h,u,e))}var c=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,p=i[a+1]*e,f=i[a+2]*e;c+=Math.abs((r[d]-r[f])*(r[p+1]-r[d+1])-(r[d]-r[p])*(r[f+1]-r[d+1]))}return o===0&&c===0?0:Math.abs((c-o)/o)};function ga(r,t,e,i){for(var s=0,n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}on.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,s=0;s<r.length;s++){for(var n=0;n<r[s].length;n++)for(var o=0;o<t;o++)e.vertices.push(r[s][n][o]);s>0&&(i+=r[s-1].length,e.holes.push(i))}return e};var O_=fa.exports;const ic=Zu(O_);var un={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */un.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=!r.nodeType&&r,n=typeof ss=="object"&&ss;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,l=36,h=1,u=26,c=38,d=700,p=72,f=128,m="-",_=/^xn--/,g=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,y={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},x=l-h,b=Math.floor,E=String.fromCharCode,T;function A(I){throw new RangeError(y[I])}function M(I,F){for(var G=I.length,Q=[];G--;)Q[G]=F(I[G]);return Q}function S(I,F){var G=I.split("@"),Q="";G.length>1&&(Q=G[0]+"@",I=G[1]),I=I.replace(v,".");var K=I.split("."),k=M(K,F).join(".");return Q+k}function P(I){for(var F=[],G=0,Q=I.length,K,k;G<Q;)K=I.charCodeAt(G++),K>=55296&&K<=56319&&G<Q?(k=I.charCodeAt(G++),(k&64512)==56320?F.push(((K&1023)<<10)+(k&1023)+65536):(F.push(K),G--)):F.push(K);return F}function C(I){return M(I,function(F){var G="";return F>65535&&(F-=65536,G+=E(F>>>10&1023|55296),F=56320|F&1023),G+=E(F),G}).join("")}function w(I){return I-48<10?I-22:I-65<26?I-65:I-97<26?I-97:l}function D(I,F){return I+22+75*(I<26)-((F!=0)<<5)}function N(I,F,G){var Q=0;for(I=G?b(I/d):I>>1,I+=b(I/F);I>x*u>>1;Q+=l)I=b(I/x);return b(Q+(x+1)*I/(I+c))}function V(I){var F=[],G=I.length,Q,K=0,k=f,it=p,gt,B,O,tt,nt,vt,xt,nr,or;for(gt=I.lastIndexOf(m),gt<0&&(gt=0),B=0;B<gt;++B)I.charCodeAt(B)>=128&&A("not-basic"),F.push(I.charCodeAt(B));for(O=gt>0?gt+1:0;O<G;){for(tt=K,nt=1,vt=l;O>=G&&A("invalid-input"),xt=w(I.charCodeAt(O++)),(xt>=l||xt>b((a-K)/nt))&&A("overflow"),K+=xt*nt,nr=vt<=it?h:vt>=it+u?u:vt-it,!(xt<nr);vt+=l)or=l-nr,nt>b(a/or)&&A("overflow"),nt*=or;Q=F.length+1,it=N(K-tt,Q,tt==0),b(K/Q)>a-k&&A("overflow"),k+=b(K/Q),K%=Q,F.splice(K++,0,k)}return C(F)}function H(I){var F,G,Q,K,k,it,gt,B,O,tt,nt,vt=[],xt,nr,or,Ls;for(I=P(I),xt=I.length,F=f,G=0,k=p,it=0;it<xt;++it)nt=I[it],nt<128&&vt.push(E(nt));for(Q=K=vt.length,K&&vt.push(m);Q<xt;){for(gt=a,it=0;it<xt;++it)nt=I[it],nt>=F&&nt<gt&&(gt=nt);for(nr=Q+1,gt-F>b((a-G)/nr)&&A("overflow"),G+=(gt-F)*nr,F=gt,it=0;it<xt;++it)if(nt=I[it],nt<F&&++G>a&&A("overflow"),nt==F){for(B=G,O=l;tt=O<=k?h:O>=k+u?u:O-k,!(B<tt);O+=l)Ls=B-tt,or=l-tt,vt.push(E(D(tt+Ls%or,0))),B=b(Ls/or);vt.push(E(D(B,0))),k=N(G,nr,Q==K),G=0,++Q}++G,++F}return vt.join("")}function W(I){return S(I,function(F){return _.test(F)?V(F.slice(4).toLowerCase()):F})}function rt(I){return S(I,function(F){return g.test(F)?"xn--"+H(F):F})}if(o={version:"1.4.1",ucs2:{decode:P,encode:C},decode:V,encode:H,toASCII:rt,toUnicode:W},i&&s)if(r.exports==i)s.exports=o;else for(T in o)o.hasOwnProperty(T)&&(i[T]=o[T]);else e.punycode=o})(ss)}(un,un.exports);var L_=un.exports,Ei=TypeError;const F_=y_(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ya=typeof Map=="function"&&Map.prototype,_a=Object.getOwnPropertyDescriptor&&ya?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,cn=ya&&_a&&typeof _a.get=="function"?_a.get:null,sc=ya&&Map.prototype.forEach,va=typeof Set=="function"&&Set.prototype,xa=Object.getOwnPropertyDescriptor&&va?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,dn=va&&xa&&typeof xa.get=="function"?xa.get:null,nc=va&&Set.prototype.forEach,N_=typeof WeakMap=="function"&&WeakMap.prototype,ls=N_?WeakMap.prototype.has:null,U_=typeof WeakSet=="function"&&WeakSet.prototype,hs=U_?WeakSet.prototype.has:null,k_=typeof WeakRef=="function"&&WeakRef.prototype,oc=k_?WeakRef.prototype.deref:null,G_=Boolean.prototype.valueOf,H_=Object.prototype.toString,$_=Function.prototype.toString,V_=String.prototype.match,ba=String.prototype.slice,Ar=String.prototype.replace,X_=String.prototype.toUpperCase,ac=String.prototype.toLowerCase,lc=RegExp.prototype.test,hc=Array.prototype.concat,je=Array.prototype.join,W_=Array.prototype.slice,uc=Math.floor,wa=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ta=Object.getOwnPropertySymbols,Ea=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Ai=typeof Symbol=="function"&&typeof Symbol.iterator=="object",te=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Ai||!0)?Symbol.toStringTag:null,cc=Object.prototype.propertyIsEnumerable,dc=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function fc(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||lc.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-uc(-r):uc(r);if(i!==r){var s=String(i),n=ba.call(t,s.length+1);return Ar.call(s,e,"$&_")+"."+Ar.call(Ar.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Ar.call(t,e,"$&_")}var Aa=F_,pc=Aa.custom,mc=vc(pc)?pc:null,gc={__proto__:null,double:'"',single:"'"},z_={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},fn=function r(t,e,i,s){var n=e||{};if(gr(n,"quoteStyle")&&!gr(gc,n.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(gr(n,"maxStringLength")&&(typeof n.maxStringLength=="number"?n.maxStringLength<0&&n.maxStringLength!==1/0:n.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=gr(n,"customInspect")?n.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(gr(n,"indent")&&n.indent!==null&&n.indent!==" "&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(gr(n,"numericSeparator")&&typeof n.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=n.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return bc(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?fc(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?fc(t,h):h}var u=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=u&&u>0&&typeof t=="object")return Sa(t)?"[Array]":"[Object]";var c=uv(n,i);if(typeof s>"u")s=[];else if(xc(s,t)>=0)return"[Circular]";function d(w,D,N){if(D&&(s=W_.call(s),s.push(D)),N){var V={depth:n.depth};return gr(n,"quoteStyle")&&(V.quoteStyle=n.quoteStyle),r(w,V,i+1,s)}return r(w,n,i+1,s)}if(typeof t=="function"&&!_c(t)){var p=ev(t),f=pn(t,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(f.length>0?" { "+je.call(f,", ")+" }":"")}if(vc(t)){var m=Ai?Ar.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Ea.call(t);return typeof t=="object"&&!Ai?us(m):m}if(av(t)){for(var _="<"+ac.call(String(t.nodeName)),g=t.attributes||[],v=0;v<g.length;v++)_+=" "+g[v].name+"="+yc(j_(g[v].value),"double",n);return _+=">",t.childNodes&&t.childNodes.length&&(_+="..."),_+="</"+ac.call(String(t.nodeName))+">",_}if(Sa(t)){if(t.length===0)return"[]";var y=pn(t,d);return c&&!hv(y)?"["+Ia(y,c)+"]":"[ "+je.call(y,", ")+" ]"}if(q_(t)){var x=pn(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!cc.call(t,"cause")?"{ ["+String(t)+"] "+je.call(hc.call("[cause]: "+d(t.cause),x),", ")+" }":x.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+je.call(x,", ")+" }"}if(typeof t=="object"&&o){if(mc&&typeof t[mc]=="function"&&Aa)return Aa(t,{depth:u-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(rv(t)){var b=[];return sc&&sc.call(t,function(w,D){b.push(d(D,t,!0)+" => "+d(w,t))}),wc("Map",cn.call(t),b,c)}if(nv(t)){var E=[];return nc&&nc.call(t,function(w){E.push(d(w,t))}),wc("Set",dn.call(t),E,c)}if(iv(t))return Ca("WeakMap");if(ov(t))return Ca("WeakSet");if(sv(t))return Ca("WeakRef");if(Z_(t))return us(d(Number(t)));if(Q_(t))return us(d(wa.call(t)));if(J_(t))return us(G_.call(t));if(K_(t))return us(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof ss<"u"&&t===ss)return"{ [object globalThis] }";if(!Y_(t)&&!_c(t)){var T=pn(t,d),A=dc?dc(t)===Object.prototype:t instanceof Object||t.constructor===Object,M=t instanceof Object?"":"null prototype",S=!A&&te&&Object(t)===t&&te in t?ba.call(Sr(t),8,-1):M?"Object":"",P=A||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",C=P+(S||M?"["+je.call(hc.call([],S||[],M||[]),": ")+"] ":"");return T.length===0?C+"{}":c?C+"{"+Ia(T,c)+"}":C+"{ "+je.call(T,", ")+" }"}return String(t)};function yc(r,t,e){var i=e.quoteStyle||t,s=gc[i];return s+r+s}function j_(r){return Ar.call(String(r),/"/g,"&quot;")}function Sa(r){return Sr(r)==="[object Array]"&&(!te||!(typeof r=="object"&&te in r))}function Y_(r){return Sr(r)==="[object Date]"&&(!te||!(typeof r=="object"&&te in r))}function _c(r){return Sr(r)==="[object RegExp]"&&(!te||!(typeof r=="object"&&te in r))}function q_(r){return Sr(r)==="[object Error]"&&(!te||!(typeof r=="object"&&te in r))}function K_(r){return Sr(r)==="[object String]"&&(!te||!(typeof r=="object"&&te in r))}function Z_(r){return Sr(r)==="[object Number]"&&(!te||!(typeof r=="object"&&te in r))}function J_(r){return Sr(r)==="[object Boolean]"&&(!te||!(typeof r=="object"&&te in r))}function vc(r){if(Ai)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Ea)return!1;try{return Ea.call(r),!0}catch{}return!1}function Q_(r){if(!r||typeof r!="object"||!wa)return!1;try{return wa.call(r),!0}catch{}return!1}var tv=Object.prototype.hasOwnProperty||function(r){return r in this};function gr(r,t){return tv.call(r,t)}function Sr(r){return H_.call(r)}function ev(r){if(r.name)return r.name;var t=V_.call($_.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function xc(r,t){if(r.indexOf)return r.indexOf(t);for(var e=0,i=r.length;e<i;e++)if(r[e]===t)return e;return-1}function rv(r){if(!cn||!r||typeof r!="object")return!1;try{cn.call(r);try{dn.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function iv(r){if(!ls||!r||typeof r!="object")return!1;try{ls.call(r,ls);try{hs.call(r,hs)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function sv(r){if(!oc||!r||typeof r!="object")return!1;try{return oc.call(r),!0}catch{}return!1}function nv(r){if(!dn||!r||typeof r!="object")return!1;try{dn.call(r);try{cn.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function ov(r){if(!hs||!r||typeof r!="object")return!1;try{hs.call(r,hs);try{ls.call(r,ls)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function av(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function bc(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return bc(ba.call(r,0,t.maxStringLength),t)+i}var s=z_[t.quoteStyle||"single"];s.lastIndex=0;var n=Ar.call(Ar.call(r,s,"\\$1"),/[\x00-\x1f]/g,lv);return yc(n,"single",t)}function lv(r){var t=r.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+X_.call(t.toString(16))}function us(r){return"Object("+r+")"}function Ca(r){return r+" { ? }"}function wc(r,t,e,i){var s=i?Ia(e,i):je.call(e,", ");return r+" ("+t+") {"+s+"}"}function hv(r){for(var t=0;t<r.length;t++)if(xc(r[t],`
2
- `)>=0)return!1;return!0}function uv(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=je.call(Array(r.indent+1)," ");else return null;return{base:e,prev:je.call(Array(t+1),e)}}function Ia(r,t){if(r.length===0)return"";var e=`
3
- `+t.prev+t.base;return e+je.call(r,","+e)+`
4
- `+t.prev}function pn(r,t){var e=Sa(r),i=[];if(e){i.length=r.length;for(var s=0;s<r.length;s++)i[s]=gr(r,s)?t(r[s],r):""}var n=typeof Ta=="function"?Ta(r):[],o;if(Ai){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in r)gr(r,l)&&(e&&String(Number(l))===l&&l<r.length||Ai&&o["$"+l]instanceof Symbol||(lc.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof Ta=="function")for(var h=0;h<n.length;h++)cc.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var cv=fn,dv=Ei,mn=function(r,t,e){for(var i=r,s;(s=i.next)!=null;i=s)if(s.key===t)return i.next=s.next,e||(s.next=r.next,r.next=s),s},fv=function(r,t){if(r){var e=mn(r,t);return e&&e.value}},pv=function(r,t,e){var i=mn(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},mv=function(r,t){return r?!!mn(r,t):!1},gv=function(r,t){if(r)return mn(r,t,!0)},yv=function(){var t,e={assert:function(i){if(!e.has(i))throw new dv("Side channel does not contain "+cv(i))},delete:function(i){var s=t&&t.next,n=gv(t,i);return n&&s&&s===n&&(t=void 0),!!n},get:function(i){return fv(t,i)},has:function(i){return mv(t,i)},set:function(i,s){t||(t={next:void 0}),pv(t,i,s)}};return e},Tc=Object,_v=Error,vv=EvalError,xv=RangeError,bv=ReferenceError,wv=SyntaxError,Tv=URIError,Ev=Math.abs,Av=Math.floor,Sv=Math.max,Cv=Math.min,Iv=Math.pow,Rv=Math.round,Pv=Number.isNaN||function(t){return t!==t},Mv=Pv,Dv=function(t){return Mv(t)||t===0?t:t<0?-1:1},Bv=Object.getOwnPropertyDescriptor,gn=Bv;if(gn)try{gn([],"length")}catch{gn=null}var Ec=gn,yn=Object.defineProperty||!1;if(yn)try{yn({},"a",{value:1})}catch{yn=!1}var Ov=yn,Ra,Ac;function Lv(){return Ac||(Ac=1,Ra=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;t[e]=s;for(var n in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==s||a.enumerable!==!0)return!1}return!0}),Ra}var Pa,Sc;function Fv(){if(Sc)return Pa;Sc=1;var r=typeof Symbol<"u"&&Symbol,t=Lv();return Pa=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},Pa}var Ma,Cc;function Ic(){return Cc||(Cc=1,Ma=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),Ma}var Da,Rc;function Pc(){if(Rc)return Da;Rc=1;var r=Tc;return Da=r.getPrototypeOf||null,Da}var Ba,Mc;function Nv(){if(Mc)return Ba;Mc=1;var r="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,e=Math.max,i="[object Function]",s=function(l,h){for(var u=[],c=0;c<l.length;c+=1)u[c]=l[c];for(var d=0;d<h.length;d+=1)u[d+l.length]=h[d];return u},n=function(l,h){for(var u=[],c=h,d=0;c<l.length;c+=1,d+=1)u[d]=l[c];return u},o=function(a,l){for(var h="",u=0;u<a.length;u+=1)h+=a[u],u+1<a.length&&(h+=l);return h};return Ba=function(l){var h=this;if(typeof h!="function"||t.apply(h)!==i)throw new TypeError(r+h);for(var u=n(arguments,1),c,d=function(){if(this instanceof c){var g=h.apply(this,s(u,arguments));return Object(g)===g?g:this}return h.apply(l,s(u,arguments))},p=e(0,h.length-u.length),f=[],m=0;m<p;m++)f[m]="$"+m;if(c=Function("binder","return function ("+o(f,",")+"){ return binder.apply(this,arguments); }")(d),h.prototype){var _=function(){};_.prototype=h.prototype,c.prototype=new _,_.prototype=null}return c},Ba}var Oa,Dc;function _n(){if(Dc)return Oa;Dc=1;var r=Nv();return Oa=Function.prototype.bind||r,Oa}var La,Bc;function Fa(){return Bc||(Bc=1,La=Function.prototype.call),La}var Na,Oc;function Lc(){return Oc||(Oc=1,Na=Function.prototype.apply),Na}var Uv=typeof Reflect<"u"&&Reflect&&Reflect.apply,kv=_n(),Gv=Lc(),Hv=Fa(),$v=Uv,Vv=$v||kv.call(Hv,Gv),Xv=_n(),Wv=Ei,zv=Fa(),jv=Vv,Fc=function(t){if(t.length<1||typeof t[0]!="function")throw new Wv("a function is required");return jv(Xv,zv,t)},Ua,Nc;function Yv(){if(Nc)return Ua;Nc=1;var r=Fc,t=Ec,e;try{e=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var i=!!e&&t&&t(Object.prototype,"__proto__"),s=Object,n=s.getPrototypeOf;return Ua=i&&typeof i.get=="function"?r([i.get]):typeof n=="function"?function(a){return n(a==null?a:s(a))}:!1,Ua}var ka,Uc;function qv(){if(Uc)return ka;Uc=1;var r=Ic(),t=Pc(),e=Yv();return ka=r?function(s){return r(s)}:t?function(s){if(!s||typeof s!="object"&&typeof s!="function")throw new TypeError("getProto: not an object");return t(s)}:e?function(s){return e(s)}:null,ka}var Ga,kc;function Kv(){if(kc)return Ga;kc=1;var r=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=_n();return Ga=e.call(r,t),Ga}var _t,Zv=Tc,Jv=_v,Qv=vv,t0=xv,e0=bv,Si=wv,Ci=Ei,r0=Tv,i0=Ev,s0=Av,n0=Sv,o0=Cv,a0=Iv,l0=Rv,h0=Dv,Gc=Function,Ha=function(r){try{return Gc('"use strict"; return ('+r+").constructor;")()}catch{}},cs=Ec,u0=Ov,$a=function(){throw new Ci},c0=cs?function(){try{return arguments.callee,$a}catch{try{return cs(arguments,"callee").get}catch{return $a}}}():$a,Ii=Fv()(),Ht=qv(),d0=Pc(),f0=Ic(),Hc=Lc(),ds=Fa(),Ri={},p0=typeof Uint8Array>"u"||!Ht?_t:Ht(Uint8Array),Wr={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?_t:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?_t:ArrayBuffer,"%ArrayIteratorPrototype%":Ii&&Ht?Ht([][Symbol.iterator]()):_t,"%AsyncFromSyncIteratorPrototype%":_t,"%AsyncFunction%":Ri,"%AsyncGenerator%":Ri,"%AsyncGeneratorFunction%":Ri,"%AsyncIteratorPrototype%":Ri,"%Atomics%":typeof Atomics>"u"?_t:Atomics,"%BigInt%":typeof BigInt>"u"?_t:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?_t:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?_t:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?_t:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Jv,"%eval%":eval,"%EvalError%":Qv,"%Float32Array%":typeof Float32Array>"u"?_t:Float32Array,"%Float64Array%":typeof Float64Array>"u"?_t:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?_t:FinalizationRegistry,"%Function%":Gc,"%GeneratorFunction%":Ri,"%Int8Array%":typeof Int8Array>"u"?_t:Int8Array,"%Int16Array%":typeof Int16Array>"u"?_t:Int16Array,"%Int32Array%":typeof Int32Array>"u"?_t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Ii&&Ht?Ht(Ht([][Symbol.iterator]())):_t,"%JSON%":typeof JSON=="object"?JSON:_t,"%Map%":typeof Map>"u"?_t:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Ii||!Ht?_t:Ht(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Zv,"%Object.getOwnPropertyDescriptor%":cs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?_t:Promise,"%Proxy%":typeof Proxy>"u"?_t:Proxy,"%RangeError%":t0,"%ReferenceError%":e0,"%Reflect%":typeof Reflect>"u"?_t:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?_t:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Ii||!Ht?_t:Ht(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?_t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Ii&&Ht?Ht(""[Symbol.iterator]()):_t,"%Symbol%":Ii?Symbol:_t,"%SyntaxError%":Si,"%ThrowTypeError%":c0,"%TypedArray%":p0,"%TypeError%":Ci,"%Uint8Array%":typeof Uint8Array>"u"?_t:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?_t:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?_t:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?_t:Uint32Array,"%URIError%":r0,"%WeakMap%":typeof WeakMap>"u"?_t:WeakMap,"%WeakRef%":typeof WeakRef>"u"?_t:WeakRef,"%WeakSet%":typeof WeakSet>"u"?_t:WeakSet,"%Function.prototype.call%":ds,"%Function.prototype.apply%":Hc,"%Object.defineProperty%":u0,"%Object.getPrototypeOf%":d0,"%Math.abs%":i0,"%Math.floor%":s0,"%Math.max%":n0,"%Math.min%":o0,"%Math.pow%":a0,"%Math.round%":l0,"%Math.sign%":h0,"%Reflect.getPrototypeOf%":f0};if(Ht)try{null.error}catch(r){var m0=Ht(Ht(r));Wr["%Error.prototype%"]=m0}var g0=function r(t){var e;if(t==="%AsyncFunction%")e=Ha("async function () {}");else if(t==="%GeneratorFunction%")e=Ha("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=Ha("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&Ht&&(e=Ht(s.prototype))}return Wr[t]=e,e},$c={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},fs=_n(),vn=Kv(),y0=fs.call(ds,Array.prototype.concat),_0=fs.call(Hc,Array.prototype.splice),Vc=fs.call(ds,String.prototype.replace),xn=fs.call(ds,String.prototype.slice),v0=fs.call(ds,RegExp.prototype.exec),x0=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,b0=/\\(\\)?/g,w0=function(t){var e=xn(t,0,1),i=xn(t,-1);if(e==="%"&&i!=="%")throw new Si("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new Si("invalid intrinsic syntax, expected opening `%`");var s=[];return Vc(t,x0,function(n,o,a,l){s[s.length]=a?Vc(l,b0,"$1"):o||n}),s},T0=function(t,e){var i=t,s;if(vn($c,i)&&(s=$c[i],i="%"+s[0]+"%"),vn(Wr,i)){var n=Wr[i];if(n===Ri&&(n=g0(i)),typeof n>"u"&&!e)throw new Ci("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new Si("intrinsic "+t+" does not exist!")},Va=function(t,e){if(typeof t!="string"||t.length===0)throw new Ci("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new Ci('"allowMissing" argument must be a boolean');if(v0(/^%?[^%]*%?$/,t)===null)throw new Si("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=w0(t),s=i.length>0?i[0]:"",n=T0("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],_0(i,y0([0,1],h)));for(var u=1,c=!0;u<i.length;u+=1){var d=i[u],p=xn(d,0,1),f=xn(d,-1);if((p==='"'||p==="'"||p==="`"||f==='"'||f==="'"||f==="`")&&p!==f)throw new Si("property names with quotes must have matching quotes");if((d==="constructor"||!c)&&(l=!0),s+="."+d,o="%"+s+"%",vn(Wr,o))a=Wr[o];else if(a!=null){if(!(d in a)){if(!e)throw new Ci("base intrinsic for "+t+" exists, but the property is not available.");return}if(cs&&u+1>=i.length){var m=cs(a,d);c=!!m,c&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else c=vn(a,d),a=a[d];c&&!l&&(Wr[o]=a)}}return a},Xc=Va,Wc=Fc,E0=Wc([Xc("%String.prototype.indexOf%")]),zc=function(t,e){var i=Xc(t,!!e);return typeof i=="function"&&E0(t,".prototype.")>-1?Wc([i]):i},A0=Va,ps=zc,S0=fn,C0=Ei,jc=A0("%Map%",!0),I0=ps("Map.prototype.get",!0),R0=ps("Map.prototype.set",!0),P0=ps("Map.prototype.has",!0),M0=ps("Map.prototype.delete",!0),D0=ps("Map.prototype.size",!0),Yc=!!jc&&function(){var t,e={assert:function(i){if(!e.has(i))throw new C0("Side channel does not contain "+S0(i))},delete:function(i){if(t){var s=M0(t,i);return D0(t)===0&&(t=void 0),s}return!1},get:function(i){if(t)return I0(t,i)},has:function(i){return t?P0(t,i):!1},set:function(i,s){t||(t=new jc),R0(t,i,s)}};return e},B0=Va,bn=zc,O0=fn,wn=Yc,L0=Ei,Pi=B0("%WeakMap%",!0),F0=bn("WeakMap.prototype.get",!0),N0=bn("WeakMap.prototype.set",!0),U0=bn("WeakMap.prototype.has",!0),k0=bn("WeakMap.prototype.delete",!0),G0=Pi?function(){var t,e,i={assert:function(s){if(!i.has(s))throw new L0("Side channel does not contain "+O0(s))},delete:function(s){if(Pi&&s&&(typeof s=="object"||typeof s=="function")){if(t)return k0(t,s)}else if(wn&&e)return e.delete(s);return!1},get:function(s){return Pi&&s&&(typeof s=="object"||typeof s=="function")&&t?F0(t,s):e&&e.get(s)},has:function(s){return Pi&&s&&(typeof s=="object"||typeof s=="function")&&t?U0(t,s):!!e&&e.has(s)},set:function(s,n){Pi&&s&&(typeof s=="object"||typeof s=="function")?(t||(t=new Pi),N0(t,s,n)):wn&&(e||(e=wn()),e.set(s,n))}};return i}:wn,H0=Ei,$0=fn,V0=yv,X0=Yc,W0=G0,z0=W0||X0||V0,j0=function(){var t,e={assert:function(i){if(!e.has(i))throw new H0("Side channel does not contain "+$0(i))},delete:function(i){return!!t&&t.delete(i)},get:function(i){return t&&t.get(i)},has:function(i){return!!t&&t.has(i)},set:function(i,s){t||(t=z0()),t.set(i,s)}};return e},Y0=String.prototype.replace,q0=/%20/g,Xa={RFC1738:"RFC1738",RFC3986:"RFC3986"},Wa={default:Xa.RFC3986,formatters:{RFC1738:function(r){return Y0.call(r,q0,"+")},RFC3986:function(r){return String(r)}},RFC1738:Xa.RFC1738,RFC3986:Xa.RFC3986},K0=Wa,za=Object.prototype.hasOwnProperty,zr=Array.isArray,Ye=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),Z0=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(zr(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},qc=function(t,e){for(var i=e&&e.plainObjects?{__proto__:null}:{},s=0;s<t.length;++s)typeof t[s]<"u"&&(i[s]=t[s]);return i},J0=function r(t,e,i){if(!e)return t;if(typeof e!="object"&&typeof e!="function"){if(zr(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!za.call(Object.prototype,e))&&(t[e]=!0);else return[t,e];return t}if(!t||typeof t!="object")return[t].concat(e);var s=t;return zr(t)&&!zr(e)&&(s=qc(t,i)),zr(t)&&zr(e)?(e.forEach(function(n,o){if(za.call(t,o)){var a=t[o];a&&typeof a=="object"&&n&&typeof n=="object"?t[o]=r(a,n,i):t.push(n)}else t[o]=n}),t):Object.keys(e).reduce(function(n,o){var a=e[o];return za.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},Q0=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},tx=function(r,t,e){var i=r.replace(/\+/g," ");if(e==="iso-8859-1")return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch{return i}},ja=1024,ex=function(t,e,i,s,n){if(t.length===0)return t;var o=t;if(typeof t=="symbol"?o=Symbol.prototype.toString.call(t):typeof t!="string"&&(o=String(t)),i==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(p){return"%26%23"+parseInt(p.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;l+=ja){for(var h=o.length>=ja?o.slice(l,l+ja):o,u=[],c=0;c<h.length;++c){var d=h.charCodeAt(c);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||n===K0.RFC1738&&(d===40||d===41)){u[u.length]=h.charAt(c);continue}if(d<128){u[u.length]=Ye[d];continue}if(d<2048){u[u.length]=Ye[192|d>>6]+Ye[128|d&63];continue}if(d<55296||d>=57344){u[u.length]=Ye[224|d>>12]+Ye[128|d>>6&63]+Ye[128|d&63];continue}c+=1,d=65536+((d&1023)<<10|h.charCodeAt(c)&1023),u[u.length]=Ye[240|d>>18]+Ye[128|d>>12&63]+Ye[128|d>>6&63]+Ye[128|d&63]}a+=u.join("")}return a},rx=function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],s=0;s<e.length;++s)for(var n=e[s],o=n.obj[n.prop],a=Object.keys(o),l=0;l<a.length;++l){var h=a[l],u=o[h];typeof u=="object"&&u!==null&&i.indexOf(u)===-1&&(e.push({obj:o,prop:h}),i.push(u))}return Z0(e),t},ix=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},sx=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},nx=function(t,e){return[].concat(t,e)},ox=function(t,e){if(zr(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},Kc={arrayToObject:qc,assign:Q0,combine:nx,compact:rx,decode:tx,encode:ex,isBuffer:sx,isRegExp:ix,maybeMap:ox,merge:J0},Zc=j0,Tn=Kc,ms=Wa,ax=Object.prototype.hasOwnProperty,Jc={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},qe=Array.isArray,lx=Array.prototype.push,Qc=function(r,t){lx.apply(r,qe(t)?t:[t])},hx=Date.prototype.toISOString,td=ms.default,Nt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Tn.encode,encodeValuesOnly:!1,filter:void 0,format:td,formatter:ms.formatters[td],indices:!1,serializeDate:function(t){return hx.call(t)},skipNulls:!1,strictNullHandling:!1},ux=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},Ya={},cx=function r(t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,_,g,v){for(var y=t,x=v,b=0,E=!1;(x=x.get(Ya))!==void 0&&!E;){var T=x.get(t);if(b+=1,typeof T<"u"){if(T===b)throw new RangeError("Cyclic object value");E=!0}typeof x.get(Ya)>"u"&&(b=0)}if(typeof u=="function"?y=u(e,y):y instanceof Date?y=p(y):i==="comma"&&qe(y)&&(y=Tn.maybeMap(y,function(I){return I instanceof Date?p(I):I})),y===null){if(o)return h&&!_?h(e,Nt.encoder,g,"key",f):e;y=""}if(ux(y)||Tn.isBuffer(y)){if(h){var A=_?e:h(e,Nt.encoder,g,"key",f);return[m(A)+"="+m(h(y,Nt.encoder,g,"value",f))]}return[m(e)+"="+m(String(y))]}var M=[];if(typeof y>"u")return M;var S;if(i==="comma"&&qe(y))_&&h&&(y=Tn.maybeMap(y,h)),S=[{value:y.length>0?y.join(",")||null:void 0}];else if(qe(u))S=u;else{var P=Object.keys(y);S=c?P.sort(c):P}var C=l?String(e).replace(/\./g,"%2E"):String(e),w=s&&qe(y)&&y.length===1?C+"[]":C;if(n&&qe(y)&&y.length===0)return w+"[]";for(var D=0;D<S.length;++D){var N=S[D],V=typeof N=="object"&&N&&typeof N.value<"u"?N.value:y[N];if(!(a&&V===null)){var H=d&&l?String(N).replace(/\./g,"%2E"):String(N),W=qe(y)?typeof i=="function"?i(w,H):w:w+(d?"."+H:"["+H+"]");v.set(t,b);var rt=Zc();rt.set(Ya,v),Qc(M,r(V,W,i,s,n,o,a,l,i==="comma"&&_&&qe(y)?null:h,u,c,d,p,f,m,_,g,rt))}}return M},dx=function(t){if(!t)return Nt;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.encodeDotInKeys<"u"&&typeof t.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");var e=t.charset||Nt.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var i=ms.default;if(typeof t.format<"u"){if(!ax.call(ms.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=ms.formatters[i],n=Nt.filter;(typeof t.filter=="function"||qe(t.filter))&&(n=t.filter);var o;if(t.arrayFormat in Jc?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=Nt.arrayFormat,"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var a=typeof t.allowDots>"u"?t.encodeDotInKeys===!0?!0:Nt.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Nt.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Nt.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Nt.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?Nt.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Nt.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:Nt.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:Nt.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Nt.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:Nt.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Nt.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Nt.strictNullHandling}},fx=function(r,t){var e=r,i=dx(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):qe(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a=Jc[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;s||(s=Object.keys(e)),i.sort&&s.sort(i.sort);for(var h=Zc(),u=0;u<s.length;++u){var c=s[u],d=e[c];i.skipNulls&&d===null||Qc(o,cx(d,c,a,l,i.allowEmptyArrays,i.strictNullHandling,i.skipNulls,i.encodeDotInKeys,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,h))}var p=o.join(i.delimiter),f=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),p.length>0?f+p:""},jr=Kc,qa=Object.prototype.hasOwnProperty,ed=Array.isArray,Mt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:jr.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},px=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},rd=function(r,t,e){if(r&&typeof r=="string"&&t.comma&&r.indexOf(",")>-1)return r.split(",");if(t.throwOnLimitExceeded&&e>=t.arrayLimit)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(t.arrayLimit===1?"":"s")+" allowed in an array.");return r},mx="utf8=%26%2310003%3B",gx="utf8=%E2%9C%93",yx=function(t,e){var i={__proto__:null},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;s=s.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=s.split(e.delimiter,e.throwOnLimitExceeded?n+1:n);if(e.throwOnLimitExceeded&&o.length>n)throw new RangeError("Parameter limit exceeded. Only "+n+" parameter"+(n===1?"":"s")+" allowed.");var a=-1,l,h=e.charset;if(e.charsetSentinel)for(l=0;l<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===gx?h="utf-8":o[l]===mx&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var u=o[l],c=u.indexOf("]="),d=c===-1?u.indexOf("="):c+1,p,f;d===-1?(p=e.decoder(u,Mt.decoder,h,"key"),f=e.strictNullHandling?null:""):(p=e.decoder(u.slice(0,d),Mt.decoder,h,"key"),f=jr.maybeMap(rd(u.slice(d+1),e,ed(i[p])?i[p].length:0),function(_){return e.decoder(_,Mt.decoder,h,"value")})),f&&e.interpretNumericEntities&&h==="iso-8859-1"&&(f=px(String(f))),u.indexOf("[]=")>-1&&(f=ed(f)?[f]:f);var m=qa.call(i,p);m&&e.duplicates==="combine"?i[p]=jr.combine(i[p],f):(!m||e.duplicates==="last")&&(i[p]=f)}return i},_x=function(r,t,e,i){var s=0;if(r.length>0&&r[r.length-1]==="[]"){var n=r.slice(0,-1).join("");s=Array.isArray(t)&&t[n]?t[n].length:0}for(var o=i?t:rd(t,e,s),a=r.length-1;a>=0;--a){var l,h=r[a];if(h==="[]"&&e.parseArrays)l=e.allowEmptyArrays&&(o===""||e.strictNullHandling&&o===null)?[]:jr.combine([],o);else{l=e.plainObjects?{__proto__:null}:{};var u=h.charAt(0)==="["&&h.charAt(h.length-1)==="]"?h.slice(1,-1):h,c=e.decodeDotInKeys?u.replace(/%2E/g,"."):u,d=parseInt(c,10);!e.parseArrays&&c===""?l={0:o}:!isNaN(d)&&h!==c&&String(d)===c&&d>=0&&e.parseArrays&&d<=e.arrayLimit?(l=[],l[d]=o):c!=="__proto__"&&(l[c]=o)}o=l}return o},vx=function(t,e,i,s){if(t){var n=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=i.depth>0&&o.exec(n),h=l?n.slice(0,l.index):n,u=[];if(h){if(!i.plainObjects&&qa.call(Object.prototype,h)&&!i.allowPrototypes)return;u.push(h)}for(var c=0;i.depth>0&&(l=a.exec(n))!==null&&c<i.depth;){if(c+=1,!i.plainObjects&&qa.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;u.push(l[1])}if(l){if(i.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+i.depth+" and strictDepth is true");u.push("["+n.slice(l.index)+"]")}return _x(u,e,i,s)}},xx=function(t){if(!t)return Mt;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.decodeDotInKeys<"u"&&typeof t.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(t.decoder!==null&&typeof t.decoder<"u"&&typeof t.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(typeof t.throwOnLimitExceeded<"u"&&typeof t.throwOnLimitExceeded!="boolean")throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var e=typeof t.charset>"u"?Mt.charset:t.charset,i=typeof t.duplicates>"u"?Mt.duplicates:t.duplicates;if(i!=="combine"&&i!=="first"&&i!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var s=typeof t.allowDots>"u"?t.decodeDotInKeys===!0?!0:Mt.allowDots:!!t.allowDots;return{allowDots:s,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Mt.allowEmptyArrays,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Mt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Mt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Mt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Mt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Mt.comma,decodeDotInKeys:typeof t.decodeDotInKeys=="boolean"?t.decodeDotInKeys:Mt.decodeDotInKeys,decoder:typeof t.decoder=="function"?t.decoder:Mt.decoder,delimiter:typeof t.delimiter=="string"||jr.isRegExp(t.delimiter)?t.delimiter:Mt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Mt.depth,duplicates:i,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Mt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Mt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Mt.plainObjects,strictDepth:typeof t.strictDepth=="boolean"?!!t.strictDepth:Mt.strictDepth,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Mt.strictNullHandling,throwOnLimitExceeded:typeof t.throwOnLimitExceeded=="boolean"?t.throwOnLimitExceeded:!1}},bx=function(r,t){var e=xx(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?{__proto__:null}:{};for(var i=typeof r=="string"?yx(r,e):r,s=e.plainObjects?{__proto__:null}:{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],l=vx(a,i[a],e,typeof r=="string");s=jr.merge(s,l,e)}return e.allowSparse===!0?s:jr.compact(s)},wx=fx,Tx=bx,Ex=Wa,Ax={formats:Ex,parse:Tx,stringify:wx},Sx=L_;function Re(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Cx=/^([a-z0-9.+-]+:)/i,Ix=/:[0-9]*$/,Rx=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,Px=["<",">",'"',"`"," ","\r",`
5
- `," "],Mx=["{","}","|","\\","^","`"].concat(Px),Ka=["'"].concat(Mx),id=["%","/","?",";","#"].concat(Ka),sd=["/","?","#"],Dx=255,nd=/^[+a-z0-9A-Z_-]{0,63}$/,Bx=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Ox={javascript:!0,"javascript:":!0},Za={javascript:!0,"javascript:":!0},Mi={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},Ja=Ax;function En(r,t,e){if(r&&typeof r=="object"&&r instanceof Re)return r;var i=new Re;return i.parse(r,t,e),i}Re.prototype.parse=function(r,t,e){if(typeof r!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof r);var i=r.indexOf("?"),s=i!==-1&&i<r.indexOf("#")?"?":"#",n=r.split(s),o=/\\/g;n[0]=n[0].replace(o,"/"),r=n.join(s);var a=r;if(a=a.trim(),!e&&r.split("#").length===1){var l=Rx.exec(a);if(l)return this.path=a,this.href=a,this.pathname=l[1],l[2]?(this.search=l[2],t?this.query=Ja.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=Cx.exec(a);if(h){h=h[0];var u=h.toLowerCase();this.protocol=u,a=a.substr(h.length)}if(e||h||a.match(/^\/\/[^@/]+@[^@/]+/)){var c=a.substr(0,2)==="//";c&&!(h&&Za[h])&&(a=a.substr(2),this.slashes=!0)}if(!Za[h]&&(c||h&&!Mi[h])){for(var d=-1,p=0;p<sd.length;p++){var f=a.indexOf(sd[p]);f!==-1&&(d===-1||f<d)&&(d=f)}var m,_;d===-1?_=a.lastIndexOf("@"):_=a.lastIndexOf("@",d),_!==-1&&(m=a.slice(0,_),a=a.slice(_+1),this.auth=decodeURIComponent(m)),d=-1;for(var p=0;p<id.length;p++){var f=a.indexOf(id[p]);f!==-1&&(d===-1||f<d)&&(d=f)}d===-1&&(d=a.length),this.host=a.slice(0,d),a=a.slice(d),this.parseHost(),this.hostname=this.hostname||"";var g=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!g)for(var v=this.hostname.split(/\./),p=0,y=v.length;p<y;p++){var x=v[p];if(x&&!x.match(nd)){for(var b="",E=0,T=x.length;E<T;E++)x.charCodeAt(E)>127?b+="x":b+=x[E];if(!b.match(nd)){var A=v.slice(0,p),M=v.slice(p+1),S=x.match(Bx);S&&(A.push(S[1]),M.unshift(S[2])),M.length&&(a="/"+M.join(".")+a),this.hostname=A.join(".");break}}}this.hostname.length>Dx?this.hostname="":this.hostname=this.hostname.toLowerCase(),g||(this.hostname=Sx.toASCII(this.hostname));var P=this.port?":"+this.port:"",C=this.hostname||"";this.host=C+P,this.href+=this.host,g&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!Ox[u])for(var p=0,y=Ka.length;p<y;p++){var w=Ka[p];if(a.indexOf(w)!==-1){var D=encodeURIComponent(w);D===w&&(D=escape(w)),a=a.split(w).join(D)}}var N=a.indexOf("#");N!==-1&&(this.hash=a.substr(N),a=a.slice(0,N));var V=a.indexOf("?");if(V!==-1?(this.search=a.substr(V),this.query=a.substr(V+1),t&&(this.query=Ja.parse(this.query)),a=a.slice(0,V)):t&&(this.search="",this.query={}),a&&(this.pathname=a),Mi[u]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var P=this.pathname||"",H=this.search||"";this.path=P+H}return this.href=this.format(),this};function Lx(r){return typeof r=="string"&&(r=En(r)),r instanceof Re?r.format():Re.prototype.format.call(r)}Re.prototype.format=function(){var r=this.auth||"";r&&(r=encodeURIComponent(r),r=r.replace(/%3A/i,":"),r+="@");var t=this.protocol||"",e=this.pathname||"",i=this.hash||"",s=!1,n="";this.host?s=r+this.host:this.hostname&&(s=r+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(n=Ja.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||Mi[t])&&s!==!1?(s="//"+(s||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):s||(s=""),i&&i.charAt(0)!=="#"&&(i="#"+i),o&&o.charAt(0)!=="?"&&(o="?"+o),e=e.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),o=o.replace("#","%23"),t+s+e+o+i};function Fx(r,t){return En(r,!1,!0).resolve(t)}Re.prototype.resolve=function(r){return this.resolveObject(En(r,!1,!0)).format()},Re.prototype.resolveObject=function(r){if(typeof r=="string"){var t=new Re;t.parse(r,!1,!0),r=t}for(var e=new Re,i=Object.keys(this),s=0;s<i.length;s++){var n=i[s];e[n]=this[n]}if(e.hash=r.hash,r.href==="")return e.href=e.format(),e;if(r.slashes&&!r.protocol){for(var o=Object.keys(r),a=0;a<o.length;a++){var l=o[a];l!=="protocol"&&(e[l]=r[l])}return Mi[e.protocol]&&e.hostname&&!e.pathname&&(e.pathname="/",e.path=e.pathname),e.href=e.format(),e}if(r.protocol&&r.protocol!==e.protocol){if(!Mi[r.protocol]){for(var h=Object.keys(r),u=0;u<h.length;u++){var c=h[u];e[c]=r[c]}return e.href=e.format(),e}if(e.protocol=r.protocol,!r.host&&!Za[r.protocol]){for(var y=(r.pathname||"").split("/");y.length&&!(r.host=y.shift()););r.host||(r.host=""),r.hostname||(r.hostname=""),y[0]!==""&&y.unshift(""),y.length<2&&y.unshift(""),e.pathname=y.join("/")}else e.pathname=r.pathname;if(e.search=r.search,e.query=r.query,e.host=r.host||"",e.auth=r.auth,e.hostname=r.hostname||r.host,e.port=r.port,e.pathname||e.search){var d=e.pathname||"",p=e.search||"";e.path=d+p}return e.slashes=e.slashes||r.slashes,e.href=e.format(),e}var f=e.pathname&&e.pathname.charAt(0)==="/",m=r.host||r.pathname&&r.pathname.charAt(0)==="/",_=m||f||e.host&&r.pathname,g=_,v=e.pathname&&e.pathname.split("/")||[],y=r.pathname&&r.pathname.split("/")||[],x=e.protocol&&!Mi[e.protocol];if(x&&(e.hostname="",e.port=null,e.host&&(v[0]===""?v[0]=e.host:v.unshift(e.host)),e.host="",r.protocol&&(r.hostname=null,r.port=null,r.host&&(y[0]===""?y[0]=r.host:y.unshift(r.host)),r.host=null),_=_&&(y[0]===""||v[0]==="")),m)e.host=r.host||r.host===""?r.host:e.host,e.hostname=r.hostname||r.hostname===""?r.hostname:e.hostname,e.search=r.search,e.query=r.query,v=y;else if(y.length)v||(v=[]),v.pop(),v=v.concat(y),e.search=r.search,e.query=r.query;else if(r.search!=null){if(x){e.host=v.shift(),e.hostname=e.host;var b=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;b&&(e.auth=b.shift(),e.hostname=b.shift(),e.host=e.hostname)}return e.search=r.search,e.query=r.query,(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!v.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var E=v.slice(-1)[0],T=(e.host||r.host||v.length>1)&&(E==="."||E==="..")||E==="",A=0,M=v.length;M>=0;M--)E=v[M],E==="."?v.splice(M,1):E===".."?(v.splice(M,1),A++):A&&(v.splice(M,1),A--);if(!_&&!g)for(;A--;A)v.unshift("..");_&&v[0]!==""&&(!v[0]||v[0].charAt(0)!=="/")&&v.unshift(""),T&&v.join("/").substr(-1)!=="/"&&v.push("");var S=v[0]===""||v[0]&&v[0].charAt(0)==="/";if(x){e.hostname=S?"":v.length?v.shift():"",e.host=e.hostname;var b=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;b&&(e.auth=b.shift(),e.hostname=b.shift(),e.host=e.hostname)}return _=_||e.host&&v.length,_&&!S&&v.unshift(""),v.length>0?e.pathname=v.join("/"):(e.pathname=null,e.path=null),(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=r.auth||e.auth,e.slashes=e.slashes||r.slashes,e.href=e.format(),e},Re.prototype.parseHost=function(){var r=this.host,t=Ix.exec(r);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),r=r.substr(0,r.length-t.length)),r&&(this.hostname=r)};var Nx=En,Ux=Fx,kx=Lx;const od={};function et(r,t,e=3){if(od[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
1
+ (function(Ut,ne){typeof exports=="object"&&typeof module<"u"?ne(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],ne):(Ut=typeof globalThis<"u"?globalThis:Ut||self,ne(Ut.AnnotoriousOSD={},Ut.OpenSeadragon))})(this,function(Ut,ne){"use strict";var Xw=Object.defineProperty;var Ww=(Ut,ne,Nr)=>ne in Ut?Xw(Ut,ne,{enumerable:!0,configurable:!0,writable:!0,value:Nr}):Ut[ne]=Nr;var lh=(Ut,ne,Nr)=>Ww(Ut,typeof ne!="symbol"?ne+"":ne,Nr);var Nr=Object.prototype.hasOwnProperty;function Ur(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Ur(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Nr.call(r,e)&&++i&&!Nr.call(t,e)||!(e in t)||!Ur(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}var ea=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(ea||{});const Yt=[];for(let r=0;r<256;++r)Yt.push((r+256).toString(16).slice(1));function Qp(r,t=0){return(Yt[r[t+0]]+Yt[r[t+1]]+Yt[r[t+2]]+Yt[r[t+3]]+"-"+Yt[r[t+4]]+Yt[r[t+5]]+"-"+Yt[r[t+6]]+Yt[r[t+7]]+"-"+Yt[r[t+8]]+Yt[r[t+9]]+"-"+Yt[r[t+10]]+Yt[r[t+11]]+Yt[r[t+12]]+Yt[r[t+13]]+Yt[r[t+14]]+Yt[r[t+15]]).toLowerCase()}let ra;const tm=new Uint8Array(16);function em(){if(!ra){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ra=crypto.getRandomValues.bind(crypto)}return ra(tm)}const rm=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),yh={randomUUID:rm};function im(r,t,e){if(yh.randomUUID&&!r)return yh.randomUUID();r=r||{};const i=r.random||(r.rng||em)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Qp(i)}const ia=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},sm=(r,t,e,i)=>({id:im(),annotation:typeof r=="string"?r:r.id,created:e||new Date,creator:i,...t}),nm=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},am=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},om=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Ur(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),lm=(r,t)=>!Ur(r.target,t.target),hm=(r,t)=>{const e=nm(r,t),i=am(r,t),s=om(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:lm(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var wr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(wr||{});const um=(r,t)=>{const e=new Set((r.created||[]).map(c=>c.id)),i=new Set((r.updated||[]).map(({newValue:c})=>c.id)),s=new Set((t.created||[]).map(c=>c.id)),n=new Set((t.deleted||[]).map(c=>c.id)),a=new Set((t.updated||[]).map(({oldValue:c})=>c.id)),o=new Set((t.updated||[]).filter(({oldValue:c})=>e.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(r.created||[]).filter(c=>!n.has(c.id)).map(c=>a.has(c.id)?t.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...t.created||[]],h=[...(r.deleted||[]).filter(c=>!s.has(c.id)),...(t.deleted||[]).filter(c=>!e.has(c.id))],u=[...(r.updated||[]).filter(({newValue:c})=>!n.has(c.id)).map(c=>{const{oldValue:d,newValue:p}=c;if(a.has(p.id)){const f=t.updated.find(g=>g.oldValue.id===p.id).newValue;return hm(d,f)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!o.has(c.id))];return{created:l,deleted:h,updated:u}};let cm=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const dm=250,fm=(r,t)=>{const e=cm(),i=(t==null?void 0:t.changes)||[];let s=t?t.pointer:-1,n=!1,a=0;const o=f=>{if(!n){const{changes:g}=f,y=performance.now();if(y-a>dm)i.splice(s+1),i.push(g),s=i.length-1;else{const m=i.length-1;i[m]=um(i[m],g)}a=y}n=!1};r.observe(o,{origin:wr.LOCAL});const l=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),h=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),u=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:g})=>g)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:g})=>g)),d=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),p=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>i.length-1>s,canUndo:()=>s>-1,destroy:()=>r.unobserve(o),getHistory:()=>({changes:[...i],pointer:s}),on:(f,g)=>e.on(f,g),redo:()=>{if(i.length-1>s){n=!0;const{created:f,updated:g,deleted:y}=i[s+1];h(f),c(g),p(y),e.emit("redo",i[s+1]),s+=1}},undo:()=>{if(s>-1){n=!0;const{created:f,updated:g,deleted:y}=i[s];l(f),u(g),d(y),e.emit("undo",i[s]),s-=1}}}},pm=(r,t,e,i)=>{const{hover:s,selection:n,store:a,viewport:o}=r,l=new Map;let h=[],u,c;const d=(m,_)=>{l.has(m)?l.get(m).push(_):l.set(m,[_])},p=(m,_)=>{const v=l.get(m);if(v){const x=v.indexOf(_);x!==-1&&v.splice(x,1)}},f=(m,_,v)=>{l.has(m)&&setTimeout(()=>{l.get(m).forEach(x=>{if(e){const b=Array.isArray(_)?_.map(w=>e.serialize(w)):e.serialize(_),R=v?v instanceof PointerEvent?v:e.serialize(v):void 0;x(b,R)}else x(_,v)})},1)},g=()=>{const{selected:m}=n,_=(m||[]).map(({id:v})=>a.getAnnotation(v));_.forEach(v=>{const x=h.find(b=>b.id===v.id);(!x||!Ur(x,v))&&f("updateAnnotation",v,x)}),h=h.map(v=>_.find(({id:b})=>b===v.id)||v)};n.subscribe(({selected:m})=>{if(!(h.length===0&&m.length===0)){if(h.length===0&&m.length>0)h=m.map(({id:_})=>a.getAnnotation(_));else if(h.length>0&&m.length===0)h.forEach(_=>{const v=a.getAnnotation(_.id);v&&!Ur(v,_)&&f("updateAnnotation",v,_)}),h=[];else{const _=new Set(h.map(x=>x.id)),v=new Set(m.map(({id:x})=>x));h.filter(x=>!v.has(x.id)).forEach(x=>{const b=a.getAnnotation(x.id);b&&!Ur(b,x)&&f("updateAnnotation",b,x)}),h=[...h.filter(x=>v.has(x.id)),...m.filter(({id:x})=>!_.has(x)).map(({id:x})=>a.getAnnotation(x))]}f("selectionChanged",h)}}),s.subscribe(m=>{!u&&m?f("mouseEnterAnnotation",a.getAnnotation(m)):u&&!m?f("mouseLeaveAnnotation",a.getAnnotation(u)):u&&m&&(f("mouseLeaveAnnotation",a.getAnnotation(u)),f("mouseEnterAnnotation",a.getAnnotation(m))),u=m}),o==null||o.subscribe(m=>f("viewportIntersect",m.map(_=>a.getAnnotation(_)))),a.observe(m=>{i&&(c&&clearTimeout(c),c=setTimeout(g,1e3));const{created:_,deleted:v}=m.changes;(_||[]).forEach(x=>f("createAnnotation",x)),(v||[]).forEach(x=>f("deleteAnnotation",x)),(m.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:b})=>{const R=h.find(w=>w.id===x.id)||x;h=h.map(w=>w.id===x.id?b:w),f("updateAnnotation",b,R)})},{origin:wr.LOCAL}),a.observe(m=>{if(h){const _=new Set(h.map(x=>x.id)),v=(m.changes.updated||[]).filter(({newValue:x})=>_.has(x.id)).map(({newValue:x})=>x);v.length>0&&(h=h.map(x=>v.find(R=>R.id===x.id)||x))}},{origin:wr.REMOTE});const y=m=>_=>{const{updated:v}=_;m?(v||[]).forEach(x=>f("updateAnnotation",x.oldValue,x.newValue)):(v||[]).forEach(x=>f("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",y(!0)),t.on("redo",y(!1)),{on:d,off:p,emit:f}},mm=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),gm=(r,t,e)=>{const{store:i,selection:s}=r,n=m=>{if(e){const{parsed:_,error:v}=e.parse(m);_?i.addAnnotation(_,wr.REMOTE):console.error(v)}else i.addAnnotation(ia(m),wr.REMOTE)},a=()=>s.clear(),o=()=>i.clear(),l=m=>{const _=i.getAnnotation(m);return e&&_?e.serialize(_):_},h=()=>e?i.all().map(e.serialize):i.all(),u=()=>{var m;const _=(((m=s.selected)==null?void 0:m.map(v=>v.id))||[]).map(v=>i.getAnnotation(v)).filter(Boolean);return e?_.map(e.serialize):_},c=(m,_=!0)=>fetch(m).then(v=>v.json()).then(v=>(p(v,_),v)),d=m=>{if(typeof m=="string"){const _=i.getAnnotation(m);if(i.deleteAnnotation(m),_)return e?e.serialize(_):_}else{const _=e?e.parse(m).parsed:m;if(_)return i.deleteAnnotation(_),m}},p=(m,_=!0)=>{if(e){const v=e.parseAll||mm(e),{parsed:x,failed:b}=v(m);b.length>0&&console.warn(`Discarded ${b.length} invalid annotations`,b),i.bulkAddAnnotation(x,_,wr.REMOTE)}else i.bulkAddAnnotation(m.map(ia),_,wr.REMOTE)},f=(m,_)=>{m?s.setSelected(m,_):s.clear()},g=m=>{s.clear(),s.setUserSelectAction(m)},y=m=>{if(e){const _=e.parse(m).parsed,v=e.serialize(i.getAnnotation(_.id));return i.updateAnnotation(_),v}else{const _=i.getAnnotation(m.id);return i.updateAnnotation(ia(m)),_}};return{addAnnotation:n,cancelSelected:a,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:o,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:u,loadAnnotations:c,redo:t.redo,removeAnnotation:d,setAnnotations:p,setSelected:f,setUserSelectAction:g,undo:t.undo,updateAnnotation:y}},ym="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let _m=r=>crypto.getRandomValues(new Uint8Array(r)),vm=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let a="";for(;;){let o=e(s),l=s|0;for(;l--;)if(a+=r[o[l]&i]||"",a.length>=n)return a}}},xm=(r,t=21)=>vm(r,t|0,_m),bm=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=ym[e[r]&63];return t};const wm=()=>({isGuest:!0,id:xm("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Tm=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],Em=()=>{const r=[...Tm];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};bm();var Am=Object.defineProperty,Sm=(r,t,e)=>t in r?Am(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_h=(r,t,e)=>Sm(r,typeof t!="symbol"?t+"":t,e);function Lt(){}function sa(r,t){for(const e in t)r[e]=t[e];return r}function vh(r){return r()}function xh(){return Object.create(null)}function We(r){r.forEach(vh)}function Wt(r){return typeof r=="function"}function te(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Cm(r){return Object.keys(r).length===0}function bh(r,...t){if(r==null){for(const i of t)i(void 0);return Lt}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function na(r,t,e){r.$$.on_destroy.push(bh(t,e))}function Im(r,t,e,i){if(r){const s=wh(r,t,e,i);return r[0](s)}}function wh(r,t,e,i){return r[1]&&i?sa(e.ctx.slice(),r[1](i(t))):e.ctx}function Rm(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],a=Math.max(t.dirty.length,s.length);for(let o=0;o<a;o+=1)n[o]=t.dirty[o]|s[o];return n}return t.dirty|s}return t.dirty}function Pm(r,t,e,i,s,n){if(s){const a=wh(t,e,i,n);r.p(a,s)}}function Mm(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function Th(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Cs(r){return r??""}function ze(r,t){r.appendChild(t)}function mt(r,t,e){r.insertBefore(t,e||null)}function ft(r){r.parentNode&&r.parentNode.removeChild(r)}function aa(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function St(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Eh(r){return document.createTextNode(r)}function Ie(){return Eh(" ")}function Re(){return Eh("")}function Gt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function N(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Dm(r){return Array.from(r.childNodes)}function Tr(r,t,e){r.classList.toggle(t,!!e)}function Bm(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Wi;function zi(r){Wi=r}function Ah(){if(!Wi)throw new Error("Function called outside component initialization");return Wi}function ji(r){Ah().$$.on_mount.push(r)}function ni(){const r=Ah();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Bm(t,e,{cancelable:i});return s.slice().forEach(a=>{a.call(r,n)}),!n.defaultPrevented}return!0}}function ur(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const ai=[],Is=[];let oi=[];const Sh=[],Om=Promise.resolve();let oa=!1;function Lm(){oa||(oa=!0,Om.then(Ch))}function la(r){oi.push(r)}const ha=new Set;let li=0;function Ch(){if(li!==0)return;const r=Wi;do{try{for(;li<ai.length;){const t=ai[li];li++,zi(t),Fm(t.$$)}}catch(t){throw ai.length=0,li=0,t}for(zi(null),ai.length=0,li=0;Is.length;)Is.pop()();for(let t=0;t<oi.length;t+=1){const e=oi[t];ha.has(e)||(ha.add(e),e())}oi.length=0}while(ai.length);for(;Sh.length;)Sh.pop()();oa=!1,ha.clear(),zi(r)}function Fm(r){if(r.fragment!==null){r.update(),We(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(la)}}function Nm(r){const t=[],e=[];oi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),oi=t}const Rs=new Set;let kr;function Pe(){kr={r:0,c:[],p:kr}}function Me(){kr.r||We(kr.c),kr=kr.p}function yt(r,t){r&&r.i&&(Rs.delete(r),r.i(t))}function Et(r,t,e,i){if(r&&r.o){if(Rs.has(r))return;Rs.add(r),kr.c.push(()=>{Rs.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function hi(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function be(r){r&&r.c()}function fe(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),la(()=>{const n=r.$$.on_mount.map(vh).filter(Wt);r.$$.on_destroy?r.$$.on_destroy.push(...n):We(n),r.$$.on_mount=[]}),s.forEach(la)}function pe(r,t){const e=r.$$;e.fragment!==null&&(Nm(e.after_update),We(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Um(r,t){r.$$.dirty[0]===-1&&(ai.push(r),Lm(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function we(r,t,e,i,s,n,a=null,o=[-1]){const l=Wi;zi(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Lt,not_equal:s,bound:xh(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:xh(),dirty:o,skip_bound:!1,root:t.target||l.$$.root};a&&a(h.root);let u=!1;if(h.ctx=e?e(r,t.props||{},(c,d,...p)=>{const f=p.length?p[0]:d;return h.ctx&&s(h.ctx[c],h.ctx[c]=f)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](f),u&&Um(r,c)),d}):[],h.update(),u=!0,We(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=Dm(t.target);h.fragment&&h.fragment.l(c),c.forEach(ft)}else h.fragment&&h.fragment.c();t.intro&&yt(r.$$.fragment),fe(r,t.target,t.anchor),Ch()}zi(l)}class Te{constructor(){_h(this,"$$"),_h(this,"$$set")}$destroy(){pe(this,1),this.$destroy=Lt}$on(t,e){if(!Wt(e))return Lt;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!Cm(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const km="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(km);var Nt=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(Nt||{});const ua={},ca=(r,t)=>ua[r]=t,da=r=>ua[r.type].area(r),Gm=(r,t,e)=>ua[r.type].intersects(r,t,e),Ps=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,a])=>{t=Math.min(t,n),e=Math.min(e,a),i=Math.max(i,n),s=Math.max(s,a)}),{minX:t,minY:e,maxX:i,maxY:s}},Hm={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:a}=r.geometry,o=0,l=Math.cos(o),h=Math.sin(o),u=t-i,c=e-s,d=l*u+h*c,p=h*u-l*c;return d*d/(n*n)+p*p/(a*a)<=1}};ca(Nt.ELLIPSE,Hm);const $m={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,a=i.length-1;n<i.length;a=n++){const o=i[n][0],l=i[n][1],h=i[a][0],u=i[a][1];l>e!=u>e&&t<(h-o)*(e-l)/(u-l)+o&&(s=!s)}return s}};ca(Nt.POLYGON,$m);const Vm={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};ca(Nt.RECTANGLE,Vm);const ui=r=>Ms(r.target),Ms=r=>{var t,e;return(r==null?void 0:r.annotation)!==void 0&&((e=(t=r==null?void 0:r.selector)==null?void 0:t.geometry)==null?void 0:e.bounds)!==void 0},Xm=(r,t=!1)=>{const e=typeof r=="string"?r:r.value,i=/^(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g,s=[...e.matchAll(i)][0],[n,a,o,l,h,u,c]=s;if(a!=="xywh")throw new Error("Unsupported MediaFragment: "+e);if(o&&o!=="pixel")throw new Error(`Unsupported MediaFragment unit: ${o}`);const[d,p,f,g]=[l,h,u,c].map(parseFloat);return{type:Nt.RECTANGLE,geometry:{x:d,y:p,w:f,h:g,bounds:{minX:d,minY:t?p-g:p,maxX:d+f,maxY:t?p:p+g}}}},Wm=r=>{const{x:t,y:e,w:i,h:s}=r;return{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=pixel:${t},${e},${i},${s}`}},Ih="http://www.w3.org/2000/svg",Rh=r=>{const t=i=>{Array.from(i.attributes).forEach(s=>{s.name.startsWith("on")&&i.removeAttribute(s.name)})},e=r.getElementsByTagName("script");return Array.from(e).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(r.querySelectorAll("*")).forEach(t),r},zm=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${Ih}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},jm=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(Ih),i=t.lookupNamespaceURI(null);return e||i?Rh(t).firstChild:Rh(zm(t)).firstChild},Ym=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:Nt.POLYGON,geometry:{points:s,bounds:Ps(s)}}},qm=r=>{const t=jm(r),e=parseFloat(t.getAttribute("cx")),i=parseFloat(t.getAttribute("cy")),s=parseFloat(t.getAttribute("rx")),n=parseFloat(t.getAttribute("ry")),a={minX:e-s,minY:i-n,maxX:e+s,maxY:i+n};return{type:Nt.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:a}}},Km=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return Ym(t);if(t.includes("<ellipse "))return qm(t);throw"Unsupported SVG shape: "+t},Zm=r=>{let t;if(r.type===Nt.POLYGON){const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}else if(r.type===Nt.ELLIPSE){const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`},qt=[];for(let r=0;r<256;++r)qt.push((r+256).toString(16).slice(1));function Jm(r,t=0){return(qt[r[t+0]]+qt[r[t+1]]+qt[r[t+2]]+qt[r[t+3]]+"-"+qt[r[t+4]]+qt[r[t+5]]+"-"+qt[r[t+6]]+qt[r[t+7]]+"-"+qt[r[t+8]]+qt[r[t+9]]+"-"+qt[r[t+10]]+qt[r[t+11]]+qt[r[t+12]]+qt[r[t+13]]+qt[r[t+14]]+qt[r[t+15]]).toLowerCase()}let fa;const Qm=new Uint8Array(16);function tg(){if(!fa){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");fa=crypto.getRandomValues.bind(crypto)}return fa(Qm)}const eg=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ph={randomUUID:eg};function Mh(r,t,e){if(Ph.randomUUID&&!r)return Ph.randomUUID();r=r||{};const i=r.random||(r.rng||tg)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Jm(i)}var Dh=Object.prototype.hasOwnProperty;function Er(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Er(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Dh.call(r,e)&&++i&&!Dh.call(t,e)||!(e in t)||!Er(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function pa(){}function rg(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const ci=[];function ma(r,t=pa){let e;const i=new Set;function s(o){if(rg(r,o)&&(r=o,e)){const l=!ci.length;for(const h of i)h[1](),ci.push(h,r);if(l){for(let h=0;h<ci.length;h+=2)ci[h][0](ci[h+1]);ci.length=0}}}function n(o){s(o(r))}function a(o,l=pa){const h=[o,l];return i.add(h),i.size===1&&(e=t(s,n)||pa),o(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:a}}const ig=r=>{const{subscribe:t,set:e}=ma();let i;return t(s=>i=s),r.observe(({changes:s})=>{if(i){(s.deleted||[]).some(a=>a.id===i)&&e(void 0);const n=(s.updated||[]).find(({oldValue:a})=>a.id===i);n&&e(n.newValue.id)}}),{get current(){return i},subscribe:t,set:e}};var Bh=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(Bh||{});const Ds={selected:[]},sg=(r,t,e)=>{const{subscribe:i,set:s}=ma(Ds);let n=t,a=Ds;i(f=>a=f);const o=()=>{Er(a,Ds)||s(Ds)},l=()=>{var f;return((f=a.selected)==null?void 0:f.length)===0},h=f=>{if(l())return!1;const g=typeof f=="string"?f:f.id;return a.selected.some(y=>y.id===g)},u=(f,g)=>{let y;if(Array.isArray(f)){if(y=f.map(_=>r.getAnnotation(_)).filter(Boolean),y.length<f.length){console.warn("Invalid selection: "+f.filter(_=>!y.some(v=>v.id===_)));return}}else{const _=r.getAnnotation(f);if(!_){console.warn("Invalid selection: "+f);return}y=[_]}const m=y.reduce((_,v)=>{const x=Oh(v,n,e);return x==="EDIT"?[..._,{id:v.id,editable:!0}]:x==="SELECT"?[..._,{id:v.id}]:_},[]);s({selected:m,event:g})},c=(f,g)=>{const y=Array.isArray(f)?f:[f],m=y.map(_=>r.getAnnotation(_)).filter(_=>!!_);s({selected:m.map(_=>{const v=g===void 0?Oh(_,n,e)==="EDIT":g;return{id:_.id,editable:v}})}),m.length!==y.length&&console.warn("Invalid selection",f)},d=f=>{if(l())return!1;const{selected:g}=a;g.some(({id:y})=>f.includes(y))&&s({selected:g.filter(({id:y})=>!f.includes(y))})},p=f=>{n=f,c(a.selected.map(({id:g})=>g))};return r.observe(({changes:f})=>d((f.deleted||[]).map(g=>g.id))),{get event(){return a?a.event:null},get selected(){return a?[...a.selected]:null},get userSelectAction(){return n},clear:o,isEmpty:l,isSelected:h,setSelected:c,setUserSelectAction:p,subscribe:i,userSelect:u}},Oh=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"},Kt=[];for(let r=0;r<256;++r)Kt.push((r+256).toString(16).slice(1));function ng(r,t=0){return(Kt[r[t+0]]+Kt[r[t+1]]+Kt[r[t+2]]+Kt[r[t+3]]+"-"+Kt[r[t+4]]+Kt[r[t+5]]+"-"+Kt[r[t+6]]+Kt[r[t+7]]+"-"+Kt[r[t+8]]+Kt[r[t+9]]+"-"+Kt[r[t+10]]+Kt[r[t+11]]+Kt[r[t+12]]+Kt[r[t+13]]+Kt[r[t+14]]+Kt[r[t+15]]).toLowerCase()}let ga;const ag=new Uint8Array(16);function og(){if(!ga){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ga=crypto.getRandomValues.bind(crypto)}return ga(ag)}const lg=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Lh={randomUUID:lg};function hg(r,t,e){if(Lh.randomUUID&&!r)return Lh.randomUUID();r=r||{};const i=r.random||(r.rng||og)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,ng(i)}const ya=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},ug=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},cg=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},dg=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Er(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),fg=(r,t)=>!Er(r.target,t.target),Fh=(r,t)=>{const e=ug(r,t),i=cg(r,t),s=dg(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:fg(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Ft=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Ft||{});const pg=(r,t)=>{var e,i;const{changes:s,origin:n}=t;if(!(r.options.origin?r.options.origin===n:n!=="SILENT"))return!1;if(r.options.ignore){const{ignore:a}=r.options,o=l=>l&&l.length>0;if(!(o(s.created)||o(s.deleted))){const l=(e=s.updated)==null?void 0:e.some(u=>o(u.bodiesCreated)||o(u.bodiesDeleted)||o(u.bodiesUpdated)),h=(i=s.updated)==null?void 0:i.some(u=>u.targetUpdated);if(a==="BODY_ONLY"&&l&&!h||a==="TARGET_ONLY"&&h&&!l)return!1}}if(r.options.annotations){const a=new Set([...(s.created||[]).map(o=>o.id),...(s.deleted||[]).map(o=>o.id),...(s.updated||[]).map(({oldValue:o})=>o.id)]);return!!(Array.isArray(r.options.annotations)?r.options.annotations:[r.options.annotations]).find(o=>a.has(o))}else return!0},mg=(r,t)=>{const e=new Set((r.created||[]).map(c=>c.id)),i=new Set((r.updated||[]).map(({newValue:c})=>c.id)),s=new Set((t.created||[]).map(c=>c.id)),n=new Set((t.deleted||[]).map(c=>c.id)),a=new Set((t.updated||[]).map(({oldValue:c})=>c.id)),o=new Set((t.updated||[]).filter(({oldValue:c})=>e.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(r.created||[]).filter(c=>!n.has(c.id)).map(c=>a.has(c.id)?t.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...t.created||[]],h=[...(r.deleted||[]).filter(c=>!s.has(c.id)),...(t.deleted||[]).filter(c=>!e.has(c.id))],u=[...(r.updated||[]).filter(({newValue:c})=>!n.has(c.id)).map(c=>{const{oldValue:d,newValue:p}=c;if(a.has(p.id)){const f=t.updated.find(g=>g.oldValue.id===p.id).newValue;return Fh(d,f)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!o.has(c.id))];return{created:l,deleted:h,updated:u}},_a=r=>{const t=r.id===void 0?hg():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},gg=r=>r.id!==void 0,yg=()=>{const r=new Map,t=new Map,e=[],i=(M,F={})=>{e.push({onChange:M,options:F})},s=M=>{const F=e.findIndex(S=>S.onChange==M);F>-1&&e.splice(F,1)},n=(M,F)=>{const S={origin:M,changes:{created:F.created||[],updated:F.updated||[],deleted:F.deleted||[]},state:[...r.values()]};e.forEach(I=>{pg(I,S)&&I.onChange(S)})},a=(M,F=Ft.LOCAL)=>{if(M.id&&r.get(M.id))throw Error(`Cannot add annotation ${M.id} - exists already`);{const S=_a(M);r.set(S.id,S),S.bodies.forEach(I=>t.set(I.id,S.id)),n(F,{created:[S]})}},o=(M,F)=>{const S=_a(typeof M=="string"?F:M),I=typeof M=="string"?M:M.id,H=I&&r.get(I);if(H){const j=Fh(H,S);return I===S.id?r.set(I,S):(r.delete(I),r.set(S.id,S)),H.bodies.forEach(A=>t.delete(A.id)),S.bodies.forEach(A=>t.set(A.id,S.id)),j}else console.warn(`Cannot update annotation ${I} - does not exist`)},l=(M,F=Ft.LOCAL,S=Ft.LOCAL)=>{const I=gg(F)?S:F,H=o(M,F);H&&n(I,{updated:[H]})},h=(M,F=Ft.LOCAL)=>{const S=M.reduce((I,H)=>{const j=o(H);return j?[...I,j]:I},[]);S.length>0&&n(F,{updated:S})},u=(M,F=Ft.LOCAL)=>{const S=r.get(M.annotation);if(S){const I={...S,bodies:[...S.bodies,M]};r.set(S.id,I),t.set(M.id,I.id),n(F,{updated:[{oldValue:S,newValue:I,bodiesCreated:[M]}]})}else console.warn(`Attempt to add body to missing annotation: ${M.annotation}`)},c=()=>[...r.values()],d=(M=Ft.LOCAL)=>{const F=[...r.values()];r.clear(),t.clear(),n(M,{deleted:F})},p=(M,F=!0,S=Ft.LOCAL)=>{const I=M.map(_a);if(F){const H=[...r.values()];r.clear(),t.clear(),I.forEach(j=>{r.set(j.id,j),j.bodies.forEach(A=>t.set(A.id,j.id))}),n(S,{created:I,deleted:H})}else{const H=M.reduce((j,A)=>{const C=A.id&&r.get(A.id);return C?[...j,C]:j},[]);if(H.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${H.map(j=>j.id).join(", ")}`);I.forEach(j=>{r.set(j.id,j),j.bodies.forEach(A=>t.set(A.id,j.id))}),n(S,{created:I})}},f=M=>{const F=typeof M=="string"?M:M.id,S=r.get(F);if(S)return r.delete(F),S.bodies.forEach(I=>t.delete(I.id)),S;console.warn(`Attempt to delete missing annotation: ${F}`)},g=(M,F=Ft.LOCAL)=>{const S=f(M);S&&n(F,{deleted:[S]})},y=(M,F=Ft.LOCAL)=>{const S=M.reduce((I,H)=>{const j=f(H);return j?[...I,j]:I},[]);S.length>0&&n(F,{deleted:S})},m=M=>{const F=r.get(M.annotation);if(F){const S=F.bodies.find(I=>I.id===M.id);if(S){t.delete(S.id);const I={...F,bodies:F.bodies.filter(H=>H.id!==M.id)};return r.set(F.id,I),{oldValue:F,newValue:I,bodiesDeleted:[S]}}else console.warn(`Attempt to delete missing body ${M.id} from annotation ${M.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${M.annotation}`)},_=(M,F=Ft.LOCAL)=>{const S=m(M);S&&n(F,{updated:[S]})},v=(M,F=Ft.LOCAL)=>{const S=M.map(I=>m(I)).filter(Boolean);S.length>0&&n(F,{updated:S})},x=M=>{const F=r.get(M);return F?{...F}:void 0},b=M=>{const F=t.get(M);if(F){const S=x(F).bodies.find(I=>I.id===M);if(S)return S;console.error(`Store integrity error: body ${M} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${M}`)},R=(M,F)=>{if(M.annotation!==F.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const S=r.get(M.annotation);if(S){const I=S.bodies.find(j=>j.id===M.id),H={...S,bodies:S.bodies.map(j=>j.id===I.id?F:j)};return r.set(S.id,H),I.id!==F.id&&(t.delete(I.id),t.set(F.id,H.id)),{oldValue:S,newValue:H,bodiesUpdated:[{oldBody:I,newBody:F}]}}else console.warn(`Attempt to add body to missing annotation ${M.annotation}`)},w=(M,F,S=Ft.LOCAL)=>{const I=R(M,F);I&&n(S,{updated:[I]})},D=(M,F=Ft.LOCAL)=>{const S=M.map(I=>R({id:I.id,annotation:I.annotation},I)).filter(Boolean);n(F,{updated:S})},U=M=>{const F=r.get(M.annotation);if(F){const S={...F,target:{...F.target,...M}};return r.set(F.id,S),{oldValue:F,newValue:S,targetUpdated:{oldTarget:F.target,newTarget:M}}}else console.warn(`Attempt to update target on missing annotation: ${M.annotation}`)};return{addAnnotation:a,addBody:u,all:c,bulkAddAnnotation:p,bulkDeleteAnnotation:y,bulkDeleteBodies:v,bulkUpdateAnnotation:h,bulkUpdateBodies:D,bulkUpdateTargets:(M,F=Ft.LOCAL)=>{const S=M.map(I=>U(I)).filter(Boolean);S.length>0&&n(F,{updated:S})},clear:d,deleteAnnotation:g,deleteBody:_,getAnnotation:x,getBody:b,observe:i,unobserve:s,updateAnnotation:l,updateBody:w,updateTarget:(M,F=Ft.LOCAL)=>{const S=U(M);S&&n(F,{updated:[S]})}}},_g=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let vg=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const xg=250,bg=(r,t)=>{const e=vg(),i=(t==null?void 0:t.changes)||[];let s=t?t.pointer:-1,n=!1,a=0;const o=f=>{if(!n){const{changes:g}=f,y=performance.now();if(y-a>xg)i.splice(s+1),i.push(g),s=i.length-1;else{const m=i.length-1;i[m]=mg(i[m],g)}a=y}n=!1};r.observe(o,{origin:Ft.LOCAL});const l=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),h=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),u=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:g})=>g)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:g})=>g)),d=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),p=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>i.length-1>s,canUndo:()=>s>-1,destroy:()=>r.unobserve(o),getHistory:()=>({changes:[...i],pointer:s}),on:(f,g)=>e.on(f,g),redo:()=>{if(i.length-1>s){n=!0;const{created:f,updated:g,deleted:y}=i[s+1];h(f),c(g),p(y),e.emit("redo",i[s+1]),s+=1}},undo:()=>{if(s>-1){n=!0;const{created:f,updated:g,deleted:y}=i[s];l(f),u(g),d(y),e.emit("undo",i[s]),s-=1}}}},wg=()=>{const{subscribe:r,set:t}=ma([]);return{subscribe:r,set:t}},Tg=(r,t,e,i)=>{const{hover:s,selection:n,store:a,viewport:o}=r,l=new Map;let h=[],u,c;const d=(m,_)=>{l.has(m)?l.get(m).push(_):l.set(m,[_])},p=(m,_)=>{const v=l.get(m);if(v){const x=v.indexOf(_);x!==-1&&v.splice(x,1)}},f=(m,_,v)=>{l.has(m)&&setTimeout(()=>{l.get(m).forEach(x=>{if(e){const b=Array.isArray(_)?_.map(w=>e.serialize(w)):e.serialize(_),R=v?v instanceof PointerEvent?v:e.serialize(v):void 0;x(b,R)}else x(_,v)})},1)},g=()=>{const{selected:m}=n,_=(m||[]).map(({id:v})=>a.getAnnotation(v));_.forEach(v=>{const x=h.find(b=>b.id===v.id);(!x||!Er(x,v))&&f("updateAnnotation",v,x)}),h=h.map(v=>_.find(({id:x})=>x===v.id)||v)};n.subscribe(({selected:m})=>{if(!(h.length===0&&m.length===0)){if(h.length===0&&m.length>0)h=m.map(({id:_})=>a.getAnnotation(_));else if(h.length>0&&m.length===0)h.forEach(_=>{const v=a.getAnnotation(_.id);v&&!Er(v,_)&&f("updateAnnotation",v,_)}),h=[];else{const _=new Set(h.map(x=>x.id)),v=new Set(m.map(({id:x})=>x));h.filter(x=>!v.has(x.id)).forEach(x=>{const b=a.getAnnotation(x.id);b&&!Er(b,x)&&f("updateAnnotation",b,x)}),h=[...h.filter(x=>v.has(x.id)),...m.filter(({id:x})=>!_.has(x)).map(({id:x})=>a.getAnnotation(x))]}f("selectionChanged",h)}}),s.subscribe(m=>{!u&&m?f("mouseEnterAnnotation",a.getAnnotation(m)):u&&!m?f("mouseLeaveAnnotation",a.getAnnotation(u)):u&&m&&(f("mouseLeaveAnnotation",a.getAnnotation(u)),f("mouseEnterAnnotation",a.getAnnotation(m))),u=m}),o==null||o.subscribe(m=>f("viewportIntersect",m.map(_=>a.getAnnotation(_)))),a.observe(m=>{i&&(c&&clearTimeout(c),c=setTimeout(g,1e3));const{created:_,deleted:v}=m.changes;(_||[]).forEach(x=>f("createAnnotation",x)),(v||[]).forEach(x=>f("deleteAnnotation",x)),(m.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:b})=>{const R=h.find(w=>w.id===x.id)||x;h=h.map(w=>w.id===x.id?b:w),f("updateAnnotation",b,R)})},{origin:Ft.LOCAL}),a.observe(m=>{if(h){const _=new Set(h.map(x=>x.id)),v=(m.changes.updated||[]).filter(({newValue:x})=>_.has(x.id)).map(({newValue:x})=>x);v.length>0&&(h=h.map(x=>v.find(b=>b.id===x.id)||x))}},{origin:Ft.REMOTE});const y=m=>_=>{const{updated:v}=_;m?(v||[]).forEach(x=>f("updateAnnotation",x.oldValue,x.newValue)):(v||[]).forEach(x=>f("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",y(!0)),t.on("redo",y(!1)),{on:d,off:p,emit:f}},Eg=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),Ag=(r,t,e)=>{const{store:i,selection:s}=r,n=m=>{if(e){const{parsed:_,error:v}=e.parse(m);_?i.addAnnotation(_,Ft.REMOTE):console.error(v)}else i.addAnnotation(ya(m),Ft.REMOTE)},a=()=>s.clear(),o=()=>i.clear(),l=m=>{const _=i.getAnnotation(m);return e&&_?e.serialize(_):_},h=()=>e?i.all().map(e.serialize):i.all(),u=()=>{var m;const _=(((m=s.selected)==null?void 0:m.map(v=>v.id))||[]).map(v=>i.getAnnotation(v)).filter(Boolean);return e?_.map(e.serialize):_},c=(m,_=!0)=>fetch(m).then(v=>v.json()).then(v=>(p(v,_),v)),d=m=>{if(typeof m=="string"){const _=i.getAnnotation(m);if(i.deleteAnnotation(m),_)return e?e.serialize(_):_}else{const _=e?e.parse(m).parsed:m;if(_)return i.deleteAnnotation(_),m}},p=(m,_=!0)=>{if(e){const v=e.parseAll||Eg(e),{parsed:x,failed:b}=v(m);b.length>0&&console.warn(`Discarded ${b.length} invalid annotations`,b),i.bulkAddAnnotation(x,_,Ft.REMOTE)}else i.bulkAddAnnotation(m.map(ya),_,Ft.REMOTE)},f=(m,_)=>{m?s.setSelected(m,_):s.clear()},g=m=>{s.clear(),s.setUserSelectAction(m)},y=m=>{if(e){const _=e.parse(m).parsed,v=e.serialize(i.getAnnotation(_.id));return i.updateAnnotation(_),v}else{const _=i.getAnnotation(m.id);return i.updateAnnotation(ya(m)),_}};return{addAnnotation:n,cancelSelected:a,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:o,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:u,loadAnnotations:c,redo:t.redo,removeAnnotation:d,setAnnotations:p,setSelected:f,setUserSelectAction:g,undo:t.undo,updateAnnotation:y}},Sg=(r,t,e)=>typeof t=="function"?t(r,e):t,Cg=(r,t)=>typeof r!="function"&&typeof t!="function"?{...r||{},...t||{}}:(e,i)=>{const s=typeof r=="function"?r(e,i):r,n=typeof t=="function"?t(e,i):t;return{...s||{},...n||{}}},Ig="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Rg=r=>crypto.getRandomValues(new Uint8Array(r)),Pg=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let a="";for(;;){let o=e(s),l=s|0;for(;l--;)if(a+=r[o[l]&i]||"",a.length>=n)return a}}},Mg=(r,t=21)=>Pg(r,t|0,Rg),Dg=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Ig[e[r]&63];return t};const Bg=()=>({isGuest:!0,id:Mg("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Og=r=>{const t=JSON.stringify(r);let e=0;for(let i=0,s=t.length;i<s;i++){let n=t.charCodeAt(i);e=(e<<5)-e+n,e|=0}return`${e}`},Nh=r=>r?typeof r=="object"?{...r}:r:void 0,Lg=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:s,purpose:n,value:a,created:o,modified:l,creator:h,...u}=e;return{id:i||`temp-${Og(e)}`,annotation:t,type:s,purpose:n,value:a,creator:Nh(h),created:o?new Date(o):void 0,updated:l?new Date(l):void 0,...u}}),Fg=r=>r.map(t=>{var e;const{annotation:i,created:s,updated:n,...a}=t,o={...a,created:s==null?void 0:s.toISOString(),modified:n==null?void 0:n.toISOString()};return(e=o.id)!=null&&e.startsWith("temp-")&&delete o.id,o});Dg();const Ng=(r,t={strict:!0,invertY:!1})=>({parse:e=>Ug(e,t),serialize:e=>kg(e,r,t)}),Ug=(r,t={strict:!0,invertY:!1})=>{const e=r.id||Mh(),{creator:i,created:s,modified:n,body:a,...o}=r,l=Lg(a||[],e),h=Array.isArray(r.target)?r.target[0]:r.target,u=Array.isArray(h.selector)?h.selector[0]:h.selector,c=(u==null?void 0:u.type)==="FragmentSelector"?Xm(u,t.invertY):(u==null?void 0:u.type)==="SvgSelector"?Km(u):void 0;return c||!t.strict?{parsed:{...o,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:Nh(i),updated:n?new Date(n):void 0,...Array.isArray(o.target)?o.target[0]:o.target,annotation:e,selector:c||u}}}:{error:Error(`Invalid selector: ${JSON.stringify(u)}`)}},kg=(r,t,e={strict:!0,invertY:!1})=>{const{selector:i,creator:s,created:n,updated:a,updatedBy:o,...l}=r.target;let h;try{h=i.type==Nt.RECTANGLE?Wm(i.geometry):Zm(i)}catch(c){if(e.strict)throw c;h=i}const u={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:Fg(r.bodies),created:n==null?void 0:n.toISOString(),creator:s,modified:a==null?void 0:a.toISOString(),target:{...l,source:t,selector:h}};return delete u.bodies,"annotation"in u.target&&delete u.target.annotation,u};function Uh(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function kh(r){let t,e;return t=new Yi({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Wt(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){be(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(yt(t.$$.fragment,i),e=!0)},o(i){Et(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function Gg(r){let t,e,i,s,n,a,o,l,h,u,c,d=hi(r[4].points),p=[];for(let g=0;g<d.length;g+=1)p[g]=kh(Uh(r,d,g));const f=g=>Et(p[g],1,1,()=>{p[g]=null});return{c(){t=St("polygon"),s=Ie(),n=St("polygon"),o=Ie();for(let g=0;g<p.length;g+=1)p[g].c();l=Re(),N(t,"class","a9s-outer"),N(t,"style",e=r[1]?"display:none;":void 0),N(t,"points",i=r[4].points.map(Gh).join(" ")),N(n,"class","a9s-inner a9s-shape-handle"),N(n,"style",r[1]),N(n,"points",a=r[4].points.map(Hh).join(" "))},m(g,y){mt(g,t,y),mt(g,s,y),mt(g,n,y),mt(g,o,y);for(let m=0;m<p.length;m+=1)p[m]&&p[m].m(g,y);mt(g,l,y),h=!0,u||(c=[Gt(t,"pointerdown",function(){Wt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Gt(n,"pointerdown",function(){Wt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],u=!0)},p(g,y){if(r=g,(!h||y&2&&e!==(e=r[1]?"display:none;":void 0))&&N(t,"style",e),(!h||y&16&&i!==(i=r[4].points.map(Gh).join(" ")))&&N(t,"points",i),(!h||y&2)&&N(n,"style",r[1]),(!h||y&16&&a!==(a=r[4].points.map(Hh).join(" ")))&&N(n,"points",a),y&536){d=hi(r[4].points);let m;for(m=0;m<d.length;m+=1){const _=Uh(r,d,m);p[m]?(p[m].p(_,y),yt(p[m],1)):(p[m]=kh(_),p[m].c(),yt(p[m],1),p[m].m(l.parentNode,l))}for(Pe(),m=d.length;m<p.length;m+=1)f(m);Me()}},i(g){if(!h){for(let y=0;y<d.length;y+=1)yt(p[y]);h=!0}},o(g){p=p.filter(Boolean);for(let y=0;y<p.length;y+=1)Et(p[y]);h=!1},d(g){g&&(ft(t),ft(s),ft(n),ft(o),ft(l)),aa(p,g),u=!1,We(c)}}}function Hg(r){let t,e;return t=new jh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Gg,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){be(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(yt(t.$$.fragment,i),e=!0)},o(i){Et(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}const Gh=r=>r.join(","),Hh=r=>r.join(",");function $g(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:a}=t,{viewportScale:o=1}=t;const l=(d,p,f)=>{let g;const y=d.geometry;p==="SHAPE"?g=y.points.map(([_,v])=>[_+f[0],v+f[1]]):g=y.points.map(([_,v],x)=>p===`HANDLE-${x}`?[_+f[0],v+f[1]]:[_,v]);const m=Ps(g);return{...d,geometry:{points:g,bounds:m}}};function h(d){ur.call(this,r,d)}function u(d){ur.call(this,r,d)}function c(d){ur.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,a=d.transform),"viewportScale"in d&&e(3,o=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,a,o,i,l,h,u,c]}class Vg extends Te{constructor(t){super(),we(this,t,$g,Hg,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const va=(r,t)=>{const e=Math.abs(t[0]-r[0]),i=Math.abs(t[1]-r[1]);return Math.sqrt(Math.pow(e,2)+Math.pow(i,2))},di=[];function Xg(r,t=Lt){let e;const i=new Set;function s(o){if(te(r,o)&&(r=o,e)){const l=!di.length;for(const h of i)h[1](),di.push(h,r);if(l){for(let h=0;h<di.length;h+=2)di[h][0](di[h+1]);di.length=0}}}function n(o){s(o(r))}function a(o,l=Lt){const h=[o,l];return i.add(h),i.size===1&&(e=t(s,n)||Lt),o(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:a}}const Wg=(r,t)=>{const{naturalWidth:e,naturalHeight:i}=r;if(!e&&!i){const{width:s,height:n}=r;t.setAttribute("viewBox",`0 0 ${s} ${n}`),r.addEventListener("load",a=>{const o=a.target;t.setAttribute("viewBox",`0 0 ${o.naturalWidth} ${o.naturalHeight}`)})}else t.setAttribute("viewBox",`0 0 ${e} ${i}`)},zg=(r,t)=>{Wg(r,t);const{subscribe:e,set:i}=Xg(1);let s;return window.ResizeObserver&&(s=new ResizeObserver(()=>{const n=t.getBoundingClientRect(),{width:a,height:o}=t.viewBox.baseVal,l=Math.max(n.width/a,n.height/o);i(l)}),s.observe(t.parentElement)),{destroy:()=>{s&&s.disconnect()},subscribe:e}},$h=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function jg(r){let t,e,i,s,n,a;return{c(){t=St("rect"),N(t,"class",e=Cs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),N(t,"x",i=r[0]-r[5]/2),N(t,"y",s=r[1]-r[5]/2),N(t,"width",r[5]),N(t,"height",r[5])},m(o,l){mt(o,t,l),n||(a=Gt(t,"pointerdown",r[11]),n=!0)},p(o,l){l&256&&e!==(e=Cs(`a9s-handle ${o[8].class||""}`.trim())+" svelte-1sgkh33")&&N(t,"class",e),l&33&&i!==(i=o[0]-o[5]/2)&&N(t,"x",i),l&34&&s!==(s=o[1]-o[5]/2)&&N(t,"y",s),l&32&&N(t,"width",o[5]),l&32&&N(t,"height",o[5])},d(o){o&&ft(t),n=!1,a()}}}function Yg(r){let t,e,i,s,n,a,o,l,h;return{c(){t=St("g"),e=St("circle"),s=St("rect"),N(e,"cx",r[0]),N(e,"cy",r[1]),N(e,"r",i=r[3]/r[2]),N(e,"class","a9s-touch-halo svelte-1sgkh33"),Tr(e,"touched",r[4]),N(s,"class",n=Cs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),N(s,"x",a=r[0]-r[5]/2),N(s,"y",o=r[1]-r[5]/2),N(s,"width",r[5]),N(s,"height",r[5]),N(t,"class","a9s-touch-handle")},m(u,c){mt(u,t,c),ze(t,e),ze(t,s),l||(h=[Gt(e,"pointerdown",r[10]),Gt(e,"pointerdown",r[6]),Gt(e,"pointerup",r[7]),Gt(s,"pointerdown",r[9]),Gt(s,"pointerdown",r[6]),Gt(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&N(e,"cx",u[0]),c&2&&N(e,"cy",u[1]),c&12&&i!==(i=u[3]/u[2])&&N(e,"r",i),c&16&&Tr(e,"touched",u[4]),c&256&&n!==(n=Cs(`a9s-handle ${u[8].class||""}`.trim())+" svelte-1sgkh33")&&N(s,"class",n),c&33&&a!==(a=u[0]-u[5]/2)&&N(s,"x",a),c&34&&o!==(o=u[1]-u[5]/2)&&N(s,"y",o),c&32&&N(s,"width",u[5]),c&32&&N(s,"height",u[5])},d(u){u&&ft(t),l=!1,We(h)}}}function qg(r){let t;function e(s,n){return $h?Yg:jg}let i=e()(r);return{c(){i.c(),t=Re()},m(s,n){i.m(s,n),mt(s,t,n)},p(s,[n]){i.p(s,n)},i:Lt,o:Lt,d(s){s&&ft(t),i.d(s)}}}function Kg(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:a}=t,{radius:o=30}=t,l=!1;const h=f=>{f.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(f){ur.call(this,r,f)}function d(f){ur.call(this,r,f)}function p(f){ur.call(this,r,f)}return r.$$set=f=>{e(8,t=sa(sa({},t),Th(f))),"x"in f&&e(0,s=f.x),"y"in f&&e(1,n=f.y),"scale"in f&&e(2,a=f.scale),"radius"in f&&e(3,o=f.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/a)},t=Th(t),[s,n,a,o,l,i,h,u,t,c,d,p]}class Yi extends Te{constructor(t){super(),we(this,t,Kg,qg,te,{x:0,y:1,scale:2,radius:3})}}function Zg(r){let t,e,i,s,n,a,o,l,h,u,c,d,p,f,g,y,m,_,v,x,b,R,w,D,U,M,F,S,I,H,j,A,C,T,k,E,P,B,G,z,$,K,Q;return T=new Yi({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),T.$on("pointerdown",function(){Wt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),E=new Yi({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),E.$on("pointerdown",function(){Wt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),B=new Yi({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),B.$on("pointerdown",function(){Wt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),z=new Yi({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),z.$on("pointerdown",function(){Wt(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=St("rect"),o=Ie(),l=St("rect"),p=Ie(),f=St("rect"),_=Ie(),v=St("rect"),w=Ie(),D=St("rect"),S=Ie(),I=St("rect"),C=Ie(),be(T.$$.fragment),k=Ie(),be(E.$$.fragment),P=Ie(),be(B.$$.fragment),G=Ie(),be(z.$$.fragment),N(t,"class","a9s-outer"),N(t,"style",e=r[1]?"display:none;":void 0),N(t,"x",i=r[4].x),N(t,"y",s=r[4].y),N(t,"width",n=r[4].w),N(t,"height",a=r[4].h),N(l,"class","a9s-inner a9s-shape-handle"),N(l,"style",r[1]),N(l,"x",h=r[4].x),N(l,"y",u=r[4].y),N(l,"width",c=r[4].w),N(l,"height",d=r[4].h),N(f,"class","a9s-edge-handle a9s-edge-handle-top"),N(f,"x",g=r[4].x),N(f,"y",y=r[4].y),N(f,"height",1),N(f,"width",m=r[4].w),N(v,"class","a9s-edge-handle a9s-edge-handle-right"),N(v,"x",x=r[4].x+r[4].w),N(v,"y",b=r[4].y),N(v,"height",R=r[4].h),N(v,"width",1),N(D,"class","a9s-edge-handle a9s-edge-handle-bottom"),N(D,"x",U=r[4].x),N(D,"y",M=r[4].y+r[4].h),N(D,"height",1),N(D,"width",F=r[4].w),N(I,"class","a9s-edge-handle a9s-edge-handle-left"),N(I,"x",H=r[4].x),N(I,"y",j=r[4].y),N(I,"height",A=r[4].h),N(I,"width",1)},m(O,L){mt(O,t,L),mt(O,o,L),mt(O,l,L),mt(O,p,L),mt(O,f,L),mt(O,_,L),mt(O,v,L),mt(O,w,L),mt(O,D,L),mt(O,S,L),mt(O,I,L),mt(O,C,L),fe(T,O,L),mt(O,k,L),fe(E,O,L),mt(O,P,L),fe(B,O,L),mt(O,G,L),fe(z,O,L),$=!0,K||(Q=[Gt(t,"pointerdown",function(){Wt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Gt(l,"pointerdown",function(){Wt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Gt(f,"pointerdown",function(){Wt(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Gt(v,"pointerdown",function(){Wt(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Gt(D,"pointerdown",function(){Wt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Gt(I,"pointerdown",function(){Wt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],K=!0)},p(O,L){r=O,(!$||L&2&&e!==(e=r[1]?"display:none;":void 0))&&N(t,"style",e),(!$||L&16&&i!==(i=r[4].x))&&N(t,"x",i),(!$||L&16&&s!==(s=r[4].y))&&N(t,"y",s),(!$||L&16&&n!==(n=r[4].w))&&N(t,"width",n),(!$||L&16&&a!==(a=r[4].h))&&N(t,"height",a),(!$||L&2)&&N(l,"style",r[1]),(!$||L&16&&h!==(h=r[4].x))&&N(l,"x",h),(!$||L&16&&u!==(u=r[4].y))&&N(l,"y",u),(!$||L&16&&c!==(c=r[4].w))&&N(l,"width",c),(!$||L&16&&d!==(d=r[4].h))&&N(l,"height",d),(!$||L&16&&g!==(g=r[4].x))&&N(f,"x",g),(!$||L&16&&y!==(y=r[4].y))&&N(f,"y",y),(!$||L&16&&m!==(m=r[4].w))&&N(f,"width",m),(!$||L&16&&x!==(x=r[4].x+r[4].w))&&N(v,"x",x),(!$||L&16&&b!==(b=r[4].y))&&N(v,"y",b),(!$||L&16&&R!==(R=r[4].h))&&N(v,"height",R),(!$||L&16&&U!==(U=r[4].x))&&N(D,"x",U),(!$||L&16&&M!==(M=r[4].y+r[4].h))&&N(D,"y",M),(!$||L&16&&F!==(F=r[4].w))&&N(D,"width",F),(!$||L&16&&H!==(H=r[4].x))&&N(I,"x",H),(!$||L&16&&j!==(j=r[4].y))&&N(I,"y",j),(!$||L&16&&A!==(A=r[4].h))&&N(I,"height",A);const Y={};L&16&&(Y.x=r[4].x),L&16&&(Y.y=r[4].y),L&8&&(Y.scale=r[3]),T.$set(Y);const tt={};L&16&&(tt.x=r[4].x+r[4].w),L&16&&(tt.y=r[4].y),L&8&&(tt.scale=r[3]),E.$set(tt);const st={};L&16&&(st.x=r[4].x+r[4].w),L&16&&(st.y=r[4].y+r[4].h),L&8&&(st.scale=r[3]),B.$set(st);const lt={};L&16&&(lt.x=r[4].x),L&16&&(lt.y=r[4].y+r[4].h),L&8&&(lt.scale=r[3]),z.$set(lt)},i(O){$||(yt(T.$$.fragment,O),yt(E.$$.fragment,O),yt(B.$$.fragment,O),yt(z.$$.fragment,O),$=!0)},o(O){Et(T.$$.fragment,O),Et(E.$$.fragment,O),Et(B.$$.fragment,O),Et(z.$$.fragment,O),$=!1},d(O){O&&(ft(t),ft(o),ft(l),ft(p),ft(f),ft(_),ft(v),ft(w),ft(D),ft(S),ft(I),ft(C),ft(k),ft(P),ft(G)),pe(T,O),pe(E,O),pe(B,O),pe(z,O),K=!1,We(Q)}}}function Jg(r){let t,e;return t=new jh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Zg,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){be(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(yt(t.$$.fragment,i),e=!0)},o(i){Et(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function Qg(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:a}=t,{viewportScale:o=1}=t;const l=(d,p,f)=>{const g=d.geometry.bounds;let[y,m]=[g.minX,g.minY],[_,v]=[g.maxX,g.maxY];const[x,b]=f;if(p==="SHAPE")y+=x,_+=x,m+=b,v+=b;else{switch(p){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{m+=b;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{v+=b;break}}switch(p){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{y+=x;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{_+=x;break}}}const R=Math.min(y,_),w=Math.min(m,v),D=Math.abs(_-y),U=Math.abs(v-m);return{...d,geometry:{x:R,y:w,w:D,h:U,bounds:{minX:R,minY:w,maxX:R+D,maxY:w+U}}}};function h(d){ur.call(this,r,d)}function u(d){ur.call(this,r,d)}function c(d){ur.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,a=d.transform),"viewportScale"in d&&e(3,o=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,a,o,i,l,h,u,c]}class ty extends Te{constructor(t){super(),we(this,t,Qg,Jg,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const Vh=new Map([[Nt.RECTANGLE,ty],[Nt.POLYGON,Vg]]),Xh=r=>Vh.get(r.type),Wh=(r,t)=>Vh.set(r,t),ey=r=>({}),zh=r=>({grab:r[0]});function ry(r){let t,e,i,s;const n=r[7].default,a=Im(n,r,r[6],zh);return{c(){t=St("g"),a&&a.c(),N(t,"class","a9s-annotation selected")},m(o,l){mt(o,t,l),a&&a.m(t,null),e=!0,i||(s=[Gt(t,"pointerup",r[2]),Gt(t,"pointermove",r[1])],i=!0)},p(o,[l]){a&&a.p&&(!e||l&64)&&Pm(a,n,o,o[6],e?Rm(n,o[6],l,ey):Mm(o[6]),zh)},i(o){e||(yt(a,o),e=!0)},o(o){Et(a,o),e=!1},d(o){o&&ft(t),a&&a.d(o),i=!1,We(s)}}}function iy(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=ni();let{shape:a}=t,{editor:o}=t,{transform:l}=t,h,u,c;const d=g=>y=>{h=g,u=l.elementToImage(y.offsetX,y.offsetY),c=a,y.target.setPointerCapture(y.pointerId),n("grab",y)},p=g=>{if(h){const[y,m]=l.elementToImage(g.offsetX,g.offsetY),_=[y-u[0],m-u[1]];e(3,a=o(c,h,_)),n("change",a)}},f=g=>{g.target.releasePointerCapture(g.pointerId),h=void 0,c=a,n("release",g)};return r.$$set=g=>{"shape"in g&&e(3,a=g.shape),"editor"in g&&e(4,o=g.editor),"transform"in g&&e(5,l=g.transform),"$$scope"in g&&e(6,s=g.$$scope)},[d,p,f,a,o,l,s,i]}class jh extends Te{constructor(t){super(),we(this,t,iy,ry,te,{shape:3,editor:4,transform:5})}}const Bs=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:a,strokeOpacity:o}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${a||"1"};`,l+=`stroke-opacity:${o||"1"};`),l}};function sy(r,t,e){let i;const s=ni();let{annotation:n}=t,{editor:a}=t,{style:o}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return ji(()=>(e(6,c=new a({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,a=d.editor),"style"in d&&e(2,o=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=Bs(n,o)),r.$$.dirty&65&&n&&(c==null||c.$set({shape:n.target.selector})),r.$$.dirty&80&&c&&c.$set({transform:h}),r.$$.dirty&96&&c&&c.$set({viewportScale:u}),r.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[n,a,o,l,h,u,c,i]}class ny extends Te{constructor(t){super(),we(this,t,sy,null,te,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function ay(r,t,e){const i=ni();let{drawingMode:s}=t,{target:n}=t,{tool:a}=t,{transform:o}=t,{viewportScale:l}=t,h;return ji(()=>{const u=n.closest("svg"),c=[],d=(p,f,g)=>{u==null||u.addEventListener(p,f,g),c.push(()=>u==null?void 0:u.removeEventListener(p,f,g))};return e(5,h=new a({target:n,props:{addEventListener:d,drawingMode:s,transform:o,viewportScale:l}})),h.$on("create",p=>i("create",p.detail)),()=>{c.forEach(p=>p()),h.$destroy()}}),r.$$set=u=>{"drawingMode"in u&&e(0,s=u.drawingMode),"target"in u&&e(1,n=u.target),"tool"in u&&e(2,a=u.tool),"transform"in u&&e(3,o=u.transform),"viewportScale"in u&&e(4,l=u.viewportScale)},r.$$.update=()=>{r.$$.dirty&40&&h&&h.$set({transform:o}),r.$$.dirty&48&&h&&h.$set({viewportScale:l})},[s,n,a,o,l,h]}class oy extends Te{constructor(t){super(),we(this,t,ay,null,te,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function Yh(r){let t,e;return{c(){t=St("rect"),e=St("rect"),N(t,"class","a9s-outer"),N(t,"x",r[1]),N(t,"y",r[2]),N(t,"width",r[3]),N(t,"height",r[4]),N(e,"class","a9s-inner"),N(e,"x",r[1]),N(e,"y",r[2]),N(e,"width",r[3]),N(e,"height",r[4])},m(i,s){mt(i,t,s),mt(i,e,s)},p(i,s){s&2&&N(t,"x",i[1]),s&4&&N(t,"y",i[2]),s&8&&N(t,"width",i[3]),s&16&&N(t,"height",i[4]),s&2&&N(e,"x",i[1]),s&4&&N(e,"y",i[2]),s&8&&N(e,"width",i[3]),s&16&&N(e,"height",i[4])},d(i){i&&(ft(t),ft(e))}}}function ly(r){let t,e=r[0]&&Yh(r);return{c(){t=St("g"),e&&e.c(),N(t,"class","a9s-annotation a9s-rubberband")},m(i,s){mt(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=Yh(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Lt,o:Lt,d(i){i&&ft(t),e&&e.d()}}}function hy(r,t,e){const i=ni();let{addEventListener:s}=t,{drawingMode:n}=t,{transform:a}=t,o,l,h,u,c,d,p;const f=_=>{const v=_;o=performance.now(),n==="drag"&&(e(0,l=a.elementToImage(v.offsetX,v.offsetY)),h=l,e(1,u=l[0]),e(2,c=l[1]),e(3,d=1),e(4,p=1))},g=_=>{const v=_;l&&(h=a.elementToImage(v.offsetX,v.offsetY),e(1,u=Math.min(h[0],l[0])),e(2,c=Math.min(h[1],l[1])),e(3,d=Math.abs(h[0]-l[0])),e(4,p=Math.abs(h[1]-l[1])))},y=_=>{const v=_,x=performance.now()-o;if(n==="click"){if(x>300)return;l?m():(e(0,l=a.elementToImage(v.offsetX,v.offsetY)),h=l,e(1,u=l[0]),e(2,c=l[1]),e(3,d=1),e(4,p=1))}else l&&(x>300||d*p>100?(v.stopPropagation(),m()):(e(0,l=void 0),h=void 0))},m=()=>{if(d*p>15){const _={type:Nt.RECTANGLE,geometry:{bounds:{minX:u,minY:c,maxX:u+d,maxY:c+p},x:u,y:c,w:d,h:p}};i("create",_)}e(0,l=void 0),h=void 0};return ji(()=>{s("pointerdown",f),s("pointermove",g),s("pointerup",y,!0)}),r.$$set=_=>{"addEventListener"in _&&e(5,s=_.addEventListener),"drawingMode"in _&&e(6,n=_.drawingMode),"transform"in _&&e(7,a=_.transform)},[l,u,c,d,p,s,n,a]}class uy extends Te{constructor(t){super(),we(this,t,hy,ly,te,{addEventListener:5,drawingMode:6,transform:7})}}function xa(r){const t=r.slice(),e=(t[2]?t[0]:[...t[0],t[1]]).map(i=>i.join(",")).join(" ");return t[16]=e,t}function qh(r){let t,e,i,s,n,a=r[2]&&Kh(r);return{c(){t=St("polygon"),i=St("polygon"),a&&a.c(),n=Re(),N(t,"class","a9s-outer"),N(t,"points",e=r[16]),N(i,"class","a9s-inner"),N(i,"points",s=r[16])},m(o,l){mt(o,t,l),mt(o,i,l),a&&a.m(o,l),mt(o,n,l)},p(o,l){l&7&&e!==(e=o[16])&&N(t,"points",e),l&7&&s!==(s=o[16])&&N(i,"points",s),o[2]?a?a.p(o,l):(a=Kh(o),a.c(),a.m(n.parentNode,n)):a&&(a.d(1),a=null)},d(o){o&&(ft(t),ft(i),ft(n)),a&&a.d(o)}}}function Kh(r){let t,e,i;return{c(){t=St("rect"),N(t,"class","a9s-handle"),N(t,"x",e=r[0][0][0]-r[3]/2),N(t,"y",i=r[0][0][1]-r[3]/2),N(t,"height",r[3]),N(t,"width",r[3])},m(s,n){mt(s,t,n)},p(s,n){n&9&&e!==(e=s[0][0][0]-s[3]/2)&&N(t,"x",e),n&9&&i!==(i=s[0][0][1]-s[3]/2)&&N(t,"y",i),n&8&&N(t,"height",s[3]),n&8&&N(t,"width",s[3])},d(s){s&&ft(t)}}}function cy(r){let t,e=r[1]&&qh(xa(r));return{c(){t=St("g"),e&&e.c(),N(t,"class","a9s-annotation a9s-rubberband")},m(i,s){mt(i,t,s),e&&e.m(t,null)},p(i,[s]){i[1]?e?e.p(xa(i),s):(e=qh(xa(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Lt,o:Lt,d(i){i&&ft(t),e&&e.d()}}}const dy=20,fy=1500;function py(r,t,e){let i;const s=ni();let{addEventListener:n}=t,{drawingMode:a}=t,{transform:o}=t,{viewportScale:l=1}=t,h,u=[],c,d,p=!1;const f=v=>{const x=v,{timeStamp:b,offsetX:R,offsetY:w}=x;if(h={timeStamp:b,offsetX:R,offsetY:w},a==="drag"&&u.length===0){const D=o.elementToImage(x.offsetX,x.offsetY);u.push(D),e(1,c=D)}},g=v=>{const x=v;if(d&&clearTimeout(d),u.length>0){if(e(1,c=o.elementToImage(x.offsetX,x.offsetY)),u.length>2){const b=va(c,u[0])*l;e(2,p=b<dy)}x.pointerType==="touch"&&(d=setTimeout(()=>{m()},fy))}},y=v=>{const x=v;if(d&&clearTimeout(d),a==="click"){const b=x.timeStamp-h.timeStamp,R=va([h.offsetX,h.offsetY],[x.offsetX,x.offsetY]);if(b>300||R>15)return;if(p)_();else if(u.length===0){const w=o.elementToImage(x.offsetX,x.offsetY);u.push(w),e(1,c=w)}else u.push(c)}else{if(u.length===1&&va(u[0],c)<=4){e(0,u=[]),e(1,c=void 0);return}x.stopImmediatePropagation(),p?_():u.push(c)}},m=()=>{if(!c)return;const v=[...u,c],x={type:Nt.POLYGON,geometry:{bounds:Ps(v),points:v}};da(x)>4&&(e(0,u=[]),e(1,c=void 0),s("create",x))},_=()=>{const v={type:Nt.POLYGON,geometry:{bounds:Ps(u),points:[...u]}};e(0,u=[]),e(1,c=void 0),s("create",v)};return ji(()=>{n("pointerdown",f,!0),n("pointermove",g),n("pointerup",y,!0),n("dblclick",m,!0)}),r.$$set=v=>{"addEventListener"in v&&e(4,n=v.addEventListener),"drawingMode"in v&&e(5,a=v.drawingMode),"transform"in v&&e(6,o=v.transform),"viewportScale"in v&&e(7,l=v.viewportScale)},r.$$.update=()=>{r.$$.dirty&128&&e(3,i=10/l)},[u,c,p,i,n,a,o,l]}class my extends Te{constructor(t){super(),we(this,t,py,cy,te,{addEventListener:4,drawingMode:5,transform:6,viewportScale:7})}}const ba=new Map([["rectangle",{tool:uy}],["polygon",{tool:my}]]),Os=()=>[...ba.keys()],Ls=r=>ba.get(r),Zh=(r,t,e)=>ba.set(r,{tool:t,opts:e});function gy(r){let t,e,i,s,n;return{c(){t=St("g"),e=St("ellipse"),s=St("ellipse"),N(e,"class","a9s-outer"),N(e,"style",i=r[1]?"display:none;":void 0),N(e,"cx",r[2]),N(e,"cy",r[3]),N(e,"rx",r[4]),N(e,"ry",r[5]),N(s,"class","a9s-inner"),N(s,"style",r[1]),N(s,"cx",r[2]),N(s,"cy",r[3]),N(s,"rx",r[4]),N(s,"ry",r[5]),N(t,"class","a9s-annotation"),N(t,"data-id",n=r[0].id)},m(a,o){mt(a,t,o),ze(t,e),ze(t,s)},p(a,[o]){o&2&&i!==(i=a[1]?"display:none;":void 0)&&N(e,"style",i),o&2&&N(s,"style",a[1]),o&1&&n!==(n=a[0].id)&&N(t,"data-id",n)},i:Lt,o:Lt,d(a){a&&ft(t)}}}function yy(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:a}=t;const{cx:o,cy:l,rx:h,ry:u}=n;return r.$$set=c=>{"annotation"in c&&e(0,s=c.annotation),"geom"in c&&e(6,n=c.geom),"style"in c&&e(7,a=c.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=Bs(s,a))},[s,i,o,l,h,u,n,a]}class _y extends Te{constructor(t){super(),we(this,t,yy,gy,te,{annotation:0,geom:6,style:7})}}function vy(r){let t,e,i,s,n;return{c(){t=St("g"),e=St("polygon"),s=St("polygon"),N(e,"class","a9s-outer"),N(e,"style",i=r[1]?"display:none;":void 0),N(e,"points",r[2].map(xy).join(" ")),N(s,"class","a9s-inner"),N(s,"style",r[1]),N(s,"points",r[2].map(by).join(" ")),N(t,"class","a9s-annotation"),N(t,"data-id",n=r[0].id)},m(a,o){mt(a,t,o),ze(t,e),ze(t,s)},p(a,[o]){o&2&&i!==(i=a[1]?"display:none;":void 0)&&N(e,"style",i),o&2&&N(s,"style",a[1]),o&1&&n!==(n=a[0].id)&&N(t,"data-id",n)},i:Lt,o:Lt,d(a){a&&ft(t)}}}const xy=r=>r.join(","),by=r=>r.join(",");function wy(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:a}=t;const{points:o}=n;return r.$$set=l=>{"annotation"in l&&e(0,s=l.annotation),"geom"in l&&e(3,n=l.geom),"style"in l&&e(4,a=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=Bs(s,a))},[s,i,o,n,a]}class Ty extends Te{constructor(t){super(),we(this,t,wy,vy,te,{annotation:0,geom:3,style:4})}}function Ey(r){let t,e,i,s,n;return{c(){t=St("g"),e=St("rect"),s=St("rect"),N(e,"class","a9s-outer"),N(e,"style",i=r[5]?"display:none;":void 0),N(e,"x",r[4]),N(e,"y",r[3]),N(e,"width",r[2]),N(e,"height",r[1]),N(s,"class","a9s-inner"),N(s,"style",r[5]),N(s,"x",r[4]),N(s,"y",r[3]),N(s,"width",r[2]),N(s,"height",r[1]),N(t,"class","a9s-annotation"),N(t,"data-id",n=r[0].id)},m(a,o){mt(a,t,o),ze(t,e),ze(t,s)},p(a,[o]){o&32&&i!==(i=a[5]?"display:none;":void 0)&&N(e,"style",i),o&16&&N(e,"x",a[4]),o&8&&N(e,"y",a[3]),o&4&&N(e,"width",a[2]),o&2&&N(e,"height",a[1]),o&32&&N(s,"style",a[5]),o&16&&N(s,"x",a[4]),o&8&&N(s,"y",a[3]),o&4&&N(s,"width",a[2]),o&2&&N(s,"height",a[1]),o&1&&n!==(n=a[0].id)&&N(t,"data-id",n)},i:Lt,o:Lt,d(a){a&&ft(t)}}}function Ay(r,t,e){let i,s,n,a,o,{annotation:l}=t,{geom:h}=t,{style:u}=t;return r.$$set=c=>{"annotation"in c&&e(0,l=c.annotation),"geom"in c&&e(6,h=c.geom),"style"in c&&e(7,u=c.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=Bs(l,u)),r.$$.dirty&64&&e(4,{x:s,y:n,w:a,h:o}=h,s,(e(3,n),e(6,h)),(e(2,a),e(6,h)),(e(1,o),e(6,h)))},[l,o,a,n,s,i,h,u]}class Sy extends Te{constructor(t){super(),we(this,t,Ay,Ey,te,{annotation:0,geom:6,style:7})}}const Cy=r=>({elementToImage:(t,e)=>{const i=r.getBoundingClientRect(),s=r.createSVGPoint();s.x=t+i.x,s.y=e+i.y;const{x:n,y:a}=s.matrixTransform(r.getScreenCTM().inverse());return[n,a]}}),Iy=250,Ry=(r,t)=>{const e=ni();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<Iy){const{x:n,y:a}=Jh(s,r),o=t.getAt(n,a);o?e("click",{originalEvent:s,annotation:o}):e("click",{originalEvent:s})}}}},Jh=(r,t)=>{const e=t.createSVGPoint(),i=t.getBoundingClientRect(),s=r.clientX-i.x,n=r.clientY-i.y,{left:a,top:o}=t.getBoundingClientRect();return e.x=s+a,e.y=n+o,e.matrixTransform(t.getScreenCTM().inverse())};function Qh(r,t,e){const i=r.slice();i[39]=t[e];const s=i[24](i[39].target.selector);return i[40]=s,i}function tu(r,t,e){const i=r.slice();return i[43]=t[e],i}function wa(r){const t=r.slice(),e=t[43].target.selector;return t[46]=e,t}function eu(r){let t=r[43].id,e,i,s=ru(r);return{c(){s.c(),e=Re()},m(n,a){s.m(n,a),mt(n,e,a),i=!0},p(n,a){a[0]&65536&&te(t,t=n[43].id)?(Pe(),Et(s,1,1,Lt),Me(),s=ru(n),s.c(),yt(s,1),s.m(e.parentNode,e)):s.p(n,a)},i(n){i||(yt(s),i=!0)},o(n){Et(s),i=!1},d(n){n&&ft(e),s.d(n)}}}function Py(r){let t,e;return t=new Ty({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){be(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(yt(t.$$.fragment,i),e=!0)},o(i){Et(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function My(r){let t,e;return t=new Sy({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){be(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(yt(t.$$.fragment,i),e=!0)},o(i){Et(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function Dy(r){var t;let e,i;return e=new _y({props:{annotation:r[43],geom:(t=r[46])==null?void 0:t.geometry,style:r[1]}}),{c(){be(e.$$.fragment)},m(s,n){fe(e,s,n),i=!0},p(s,n){var a;const o={};n[0]&65536&&(o.annotation=s[43]),n[0]&65536&&(o.geom=(a=s[46])==null?void 0:a.geometry),n[0]&2&&(o.style=s[1]),e.$set(o)},i(s){i||(yt(e.$$.fragment,s),i=!0)},o(s){Et(e.$$.fragment,s),i=!1},d(s){pe(e,s)}}}function ru(r){let t,e,i,s;const n=[Dy,My,Py],a=[];function o(l,h){var u,c,d;return((u=l[46])==null?void 0:u.type)===Nt.ELLIPSE?0:((c=l[46])==null?void 0:c.type)===Nt.RECTANGLE?1:((d=l[46])==null?void 0:d.type)===Nt.POLYGON?2:-1}return~(t=o(r))&&(e=a[t]=n[t](r)),{c(){e&&e.c(),i=Re()},m(l,h){~t&&a[t].m(l,h),mt(l,i,h),s=!0},p(l,h){let u=t;t=o(l),t===u?~t&&a[t].p(l,h):(e&&(Pe(),Et(a[u],1,1,()=>{a[u]=null}),Me()),~t?(e=a[t],e?e.p(l,h):(e=a[t]=n[t](l),e.c()),yt(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(yt(e),s=!0)},o(l){Et(e),s=!1},d(l){l&&ft(i),~t&&a[t].d(l)}}}function iu(r){let t=ui(r[43])&&!r[9](r[43]),e,i,s=t&&eu(wa(r));return{c(){s&&s.c(),e=Re()},m(n,a){s&&s.m(n,a),mt(n,e,a),i=!0},p(n,a){a[0]&66048&&(t=ui(n[43])&&!n[9](n[43])),t?s?(s.p(wa(n),a),a[0]&66048&&yt(s,1)):(s=eu(wa(n)),s.c(),yt(s,1),s.m(e.parentNode,e)):s&&(Pe(),Et(s,1,1,()=>{s=null}),Me())},i(n){i||(yt(s),i=!0)},o(n){Et(s),i=!1},d(n){n&&ft(e),s&&s.d(n)}}}function su(r){let t,e,i,s;const n=[Oy,By],a=[];function o(l,h){return l[8]?0:l[14]&&l[0]?1:-1}return~(t=o(r))&&(e=a[t]=n[t](r)),{c(){e&&e.c(),i=Re()},m(l,h){~t&&a[t].m(l,h),mt(l,i,h),s=!0},p(l,h){let u=t;t=o(l),t===u?~t&&a[t].p(l,h):(e&&(Pe(),Et(a[u],1,1,()=>{a[u]=null}),Me()),~t?(e=a[t],e?e.p(l,h):(e=a[t]=n[t](l),e.c()),yt(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(yt(e),s=!0)},o(l){Et(e),s=!1},d(l){l&&ft(i),~t&&a[t].d(l)}}}function By(r){let t=`${r[2]}-${r[5]}`,e,i,s=nu(r);return{c(){s.c(),e=Re()},m(n,a){s.m(n,a),mt(n,e,a),i=!0},p(n,a){a[0]&36&&te(t,t=`${n[2]}-${n[5]}`)?(Pe(),Et(s,1,1,Lt),Me(),s=nu(n),s.c(),yt(s,1),s.m(e.parentNode,e)):s.p(n,a)},i(n){i||(yt(s),i=!0)},o(n){Et(s),i=!1},d(n){n&&ft(e),s.d(n)}}}function Oy(r){let t,e,i=hi(r[8]),s=[];for(let a=0;a<i.length;a+=1)s[a]=lu(Qh(r,i,a));const n=a=>Et(s[a],1,1,()=>{s[a]=null});return{c(){for(let a=0;a<s.length;a+=1)s[a].c();t=Re()},m(a,o){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(a,o);mt(a,t,o),e=!0},p(a,o){if(o[0]&21107010){i=hi(a[8]);let l;for(l=0;l<i.length;l+=1){const h=Qh(a,i,l);s[l]?(s[l].p(h,o),yt(s[l],1)):(s[l]=lu(h),s[l].c(),yt(s[l],1),s[l].m(t.parentNode,t))}for(Pe(),l=i.length;l<s.length;l+=1)n(l);Me()}},i(a){if(!e){for(let o=0;o<i.length;o+=1)yt(s[o]);e=!0}},o(a){s=s.filter(Boolean);for(let o=0;o<s.length;o+=1)Et(s[o]);e=!1},d(a){a&&ft(t),aa(s,a)}}}function nu(r){let t,e;return t=new oy({props:{target:r[6],tool:r[14],drawingMode:r[13],transform:r[12],viewportScale:r[17]}}),t.$on("create",r[21]),{c(){be(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){const n={};s[0]&64&&(n.target=i[6]),s[0]&16384&&(n.tool=i[14]),s[0]&8192&&(n.drawingMode=i[13]),s[0]&4096&&(n.transform=i[12]),s[0]&131072&&(n.viewportScale=i[17]),t.$set(n)},i(i){e||(yt(t.$$.fragment,i),e=!0)},o(i){Et(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function au(r){let t=r[39].id,e,i,s=ou(r);return{c(){s.c(),e=Re()},m(n,a){s.m(n,a),mt(n,e,a),i=!0},p(n,a){a[0]&256&&te(t,t=n[39].id)?(Pe(),Et(s,1,1,Lt),Me(),s=ou(n),s.c(),yt(s,1),s.m(e.parentNode,e)):s.p(n,a)},i(n){i||(yt(s),i=!0)},o(n){Et(s),i=!1},d(n){n&&ft(e),s.d(n)}}}function ou(r){let t,e;return t=new ny({props:{target:r[6],editor:r[24](r[39].target.selector),annotation:r[39],style:r[1],transform:r[12],viewportScale:r[17]}}),t.$on("change",function(){Wt(r[22](r[39]))&&r[22](r[39]).apply(this,arguments)}),{c(){be(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&64&&(n.target=r[6]),s[0]&256&&(n.editor=r[24](r[39].target.selector)),s[0]&256&&(n.annotation=r[39]),s[0]&2&&(n.style=r[1]),s[0]&4096&&(n.transform=r[12]),s[0]&131072&&(n.viewportScale=r[17]),t.$set(n)},i(i){e||(yt(t.$$.fragment,i),e=!0)},o(i){Et(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function lu(r){let t,e,i=r[40]&&au(r);return{c(){i&&i.c(),t=Re()},m(s,n){i&&i.m(s,n),mt(s,t,n),e=!0},p(s,n){s[40]?i?(i.p(s,n),n[0]&256&&yt(i,1)):(i=au(s),i.c(),yt(i,1),i.m(t.parentNode,t)):i&&(Pe(),Et(i,1,1,()=>{i=null}),Me())},i(s){e||(yt(i),e=!0)},o(s){Et(i),e=!1},d(s){s&&ft(t),i&&i.d(s)}}}function Ly(r){let t,e,i,s,n,a,o=hi(r[16].filter(r[34])),l=[];for(let c=0;c<o.length;c+=1)l[c]=iu(tu(r,o,c));const h=c=>Et(l[c],1,1,()=>{l[c]=null});let u=r[6]&&su(r);return{c(){t=St("svg"),e=St("g");for(let c=0;c<l.length;c+=1)l[c].c();i=St("g"),u&&u.c(),N(i,"class","drawing"),N(t,"class","a9s-annotationlayer"),Tr(t,"drawing",r[14]),Tr(t,"hidden",!r[3]),Tr(t,"hover",r[15])},m(c,d){mt(c,t,d),ze(t,e);for(let p=0;p<l.length;p+=1)l[p]&&l[p].m(e,null);ze(t,i),u&&u.m(i,null),r[35](i),r[36](t),s=!0,n||(a=[Gt(t,"pointerup",function(){Wt(r[10])&&r[10].apply(this,arguments)}),Gt(t,"pointerdown",function(){Wt(r[11])&&r[11].apply(this,arguments)}),Gt(t,"pointermove",r[23])],n=!0)},p(c,d){if(r=c,d[0]&66050){o=hi(r[16].filter(r[34]));let p;for(p=0;p<o.length;p+=1){const f=tu(r,o,p);l[p]?(l[p].p(f,d),yt(l[p],1)):(l[p]=iu(f),l[p].c(),yt(l[p],1),l[p].m(e,null))}for(Pe(),p=o.length;p<l.length;p+=1)h(p);Me()}r[6]?u?(u.p(r,d),d[0]&64&&yt(u,1)):(u=su(r),u.c(),yt(u,1),u.m(i,null)):u&&(Pe(),Et(u,1,1,()=>{u=null}),Me()),(!s||d[0]&16384)&&Tr(t,"drawing",r[14]),(!s||d[0]&8)&&Tr(t,"hidden",!r[3]),(!s||d[0]&32768)&&Tr(t,"hover",r[15])},i(c){if(!s){for(let d=0;d<o.length;d+=1)yt(l[d]);yt(u),s=!0}},o(c){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)Et(l[d]);Et(u),s=!1},d(c){c&&ft(t),aa(l,c),u&&u.d(),r[35](null),r[36](null),n=!1,We(a)}}}function Fy(r,t,e){let i,s,n,a,o,l,h,u,c,d,p,f=Lt,g=()=>(f(),f=bh(H,O=>e(17,p=O)),H);r.$$.on_destroy.push(()=>f());let{drawingEnabled:y}=t,{image:m}=t,{preferredDrawingMode:_}=t,{state:v}=t,{style:x=void 0}=t,{toolName:b=Os()[0]}=t,{user:R}=t,{visible:w=!0}=t,D=0;const U=()=>e(5,D+=1),M=()=>b,F=()=>y;let S,I,H;ji(()=>g(e(7,H=zg(m,I))));const{hover:j,selection:A,store:C}=v;na(r,j,O=>e(15,u=O)),na(r,A,O=>e(33,c=O)),na(r,C,O=>e(16,d=O));let T,k;const E=O=>{T&&C.unobserve(T);const L=O.filter(({editable:Y})=>Y).map(({id:Y})=>Y);L.length>0?(e(8,k=L.map(Y=>C.getAnnotation(Y)).filter(Y=>Y&&ui(Y))),T=Y=>{const{updated:tt}=Y.changes;e(8,k=tt==null?void 0:tt.map(st=>st.newValue))},C.observe(T,{annotations:L})):e(8,k=void 0)},P=O=>{const L=Mh(),Y={id:L,bodies:[],target:{annotation:L,selector:O.detail,creator:R,created:new Date}};C.addAnnotation(Y),A.setSelected(Y.id)},B=O=>L=>{var Y;const{target:tt}=O,st=10*60*1e3,lt=((Y=tt.creator)==null?void 0:Y.id)!==R.id||!tt.created||new Date().getTime()-tt.created.getTime()>st;C.updateTarget({...tt,selector:L.detail,created:lt?tt.created:new Date,updated:lt?new Date:void 0,updatedBy:lt?R:void 0})},G=O=>{const{x:L,y:Y}=Jh(O,I),tt=C.getAt(L,Y);tt?u!==tt.id&&j.set(tt.id):j.set(void 0)},z=O=>Xh(O),$=O=>ui(O);function K(O){Is[O?"unshift":"push"](()=>{S=O,e(6,S)})}function Q(O){Is[O?"unshift":"push"](()=>{I=O,e(4,I)})}return r.$$set=O=>{"drawingEnabled"in O&&e(0,y=O.drawingEnabled),"image"in O&&e(25,m=O.image),"preferredDrawingMode"in O&&e(26,_=O.preferredDrawingMode),"state"in O&&e(27,v=O.state),"style"in O&&e(1,x=O.style),"toolName"in O&&e(2,b=O.toolName),"user"in O&&e(28,R=O.user),"visible"in O&&e(3,w=O.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(14,{tool:i,opts:s}=Ls(b)||{tool:void 0,opts:void 0},i,(e(32,s),e(2,b))),r.$$.dirty[0]&67108864|r.$$.dirty[1]&2&&e(13,n=(s==null?void 0:s.drawingMode)||_),r.$$.dirty[0]&16&&e(12,a=Cy(I)),r.$$.dirty[0]&16&&e(11,{onPointerDown:o,onPointerUp:l}=Ry(I,C),o,(e(10,l),e(4,I))),r.$$.dirty[1]&4&&e(9,h=O=>c.selected.find(L=>L.id===O.id&&L.editable)),r.$$.dirty[1]&4&&E(c.selected)},[y,x,b,w,I,D,S,H,k,h,l,o,a,n,i,u,d,p,j,A,C,P,B,G,z,m,_,v,R,U,M,F,s,c,$,K,Q]}class Ny extends Te{constructor(t){super(),we(this,t,Fy,Ly,te,{drawingEnabled:0,image:25,preferredDrawingMode:26,state:27,style:1,toolName:2,user:28,visible:3,cancelDrawing:29,getDrawingTool:30,isDrawingEnabled:31},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[29]}get getDrawingTool(){return this.$$.ctx[30]}get isDrawingEnabled(){return this.$$.ctx[31]}}function hu(r,t,e=0,i=r.length-1,s=Uy){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,u=Math.log(l),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(l-c)/l)*(h-l/2<0?-1:1),p=Math.max(e,Math.floor(t-h*c/l+d)),f=Math.min(i,Math.floor(t+(l-h)*c/l+d));hu(r,t,p,f,s)}const n=r[t];let a=e,o=i;for(qi(r,e,t),s(r[i],n)>0&&qi(r,e,i);a<o;){for(qi(r,a,o),a++,o--;s(r[a],n)<0;)a++;for(;s(r[o],n)>0;)o--}s(r[e],n)===0?qi(r,e,o):(o++,qi(r,o,i)),o<=t&&(e=o+1),t<=o&&(i=o-1)}}function qi(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function Uy(r,t){return r<t?-1:r>t?1:0}class ky{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!Ns(t,e))return i;const s=this.toBBox,n=[];for(;e;){for(let a=0;a<e.children.length;a++){const o=e.children[a],l=e.leaf?s(o):o;Ns(t,l)&&(e.leaf?i.push(o):Ea(t,l)?this._all(o,i):n.push(o))}e=n.pop()}return i}collides(t){let e=this.data;if(!Ns(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const n=e.children[s],a=e.leaf?this.toBBox(n):n;if(Ns(t,a)){if(e.leaf||Ea(t,a))return!0;i.push(n)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=pi([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),n=[],a=[];let o,l,h;for(;i||n.length;){if(i||(i=n.pop(),l=n[n.length-1],o=a.pop(),h=!0),i.leaf){const u=Gy(t,i.children,e);if(u!==-1)return i.children.splice(u,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&Ea(i,s)?(n.push(i),a.push(o),o=0,l=i,i=i.children[0]):l?(o++,i=l.children[o],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const n=i-e+1;let a=this._maxEntries,o;if(n<=a)return o=pi(t.slice(e,i+1)),fi(o,this.toBBox),o;s||(s=Math.ceil(Math.log(n)/Math.log(a)),a=Math.ceil(n/Math.pow(a,s-1))),o=pi([]),o.leaf=!1,o.height=s;const l=Math.ceil(n/a),h=l*Math.ceil(Math.sqrt(a));uu(t,e,i,h,this.compareMinX);for(let u=e;u<=i;u+=h){const c=Math.min(u+h-1,i);uu(t,u,c,l,this.compareMinY);for(let d=u;d<=c;d+=l){const p=Math.min(d+l-1,c);o.children.push(this._build(t,d,p,s-1))}}return fi(o,this.toBBox),o}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let n=1/0,a=1/0,o;for(let l=0;l<e.children.length;l++){const h=e.children[l],u=Ta(h),c=Vy(t,h)-u;c<a?(a=c,n=u<n?u:n,o=h):c===a&&u<n&&(n=u,o=h)}e=o||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),n=[],a=this._chooseSubtree(s,this.data,e,n);for(a.children.push(t),Zi(a,s);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(s,n,e)}_split(t,e){const i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);const a=this._chooseSplitIndex(i,n,s),o=pi(i.children.splice(a,i.children.length-a));o.height=i.height,o.leaf=i.leaf,fi(i,this.toBBox),fi(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(i,o)}_splitRoot(t,e){this.data=pi([t,e]),this.data.height=t.height+1,this.data.leaf=!1,fi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,n=1/0,a=1/0;for(let o=e;o<=i-e;o++){const l=Ki(t,0,o,this.toBBox),h=Ki(t,o,i,this.toBBox),u=Xy(l,h),c=Ta(l)+Ta(h);u<n?(n=u,s=o,a=c<a?c:a):u===n&&c<a&&(a=c,s=o)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:Hy,n=t.leaf?this.compareMinY:$y,a=this._allDistMargin(t,e,i,s),o=this._allDistMargin(t,e,i,n);a<o&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const n=this.toBBox,a=Ki(t,0,e,n),o=Ki(t,i-e,i,n);let l=Fs(a)+Fs(o);for(let h=e;h<i-e;h++){const u=t.children[h];Zi(a,t.leaf?n(u):u),l+=Fs(a)}for(let h=i-e-1;h>=e;h--){const u=t.children[h];Zi(o,t.leaf?n(u):u),l+=Fs(o)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)Zi(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():fi(t[e],this.toBBox)}}function Gy(r,t,e){if(!e)return t.indexOf(r);for(let i=0;i<t.length;i++)if(e(r,t[i]))return i;return-1}function fi(r,t){Ki(r,0,r.children.length,t,r)}function Ki(r,t,e,i,s){s||(s=pi(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let n=t;n<e;n++){const a=r.children[n];Zi(s,r.leaf?i(a):a)}return s}function Zi(r,t){return r.minX=Math.min(r.minX,t.minX),r.minY=Math.min(r.minY,t.minY),r.maxX=Math.max(r.maxX,t.maxX),r.maxY=Math.max(r.maxY,t.maxY),r}function Hy(r,t){return r.minX-t.minX}function $y(r,t){return r.minY-t.minY}function Ta(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function Fs(r){return r.maxX-r.minX+(r.maxY-r.minY)}function Vy(r,t){return(Math.max(t.maxX,r.maxX)-Math.min(t.minX,r.minX))*(Math.max(t.maxY,r.maxY)-Math.min(t.minY,r.minY))}function Xy(r,t){const e=Math.max(r.minX,t.minX),i=Math.max(r.minY,t.minY),s=Math.min(r.maxX,t.maxX),n=Math.min(r.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,n-i)}function Ea(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function Ns(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function pi(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function uu(r,t,e,i,s){const n=[t,e];for(;n.length;){if(e=n.pop(),t=n.pop(),e-t<=i)continue;const a=t+Math.ceil((e-t)/i/2)*i;hu(r,a,t,e,s),n.push(t,a,a,e)}}const Wy=()=>{const r=new ky,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=a=>{if(!Ms(a))return;const{minX:o,minY:l,maxX:h,maxY:u}=a.selector.geometry.bounds,c={minX:o,minY:l,maxX:h,maxY:u,target:a};r.insert(c),t.set(a.annotation,c)},n=a=>{if(!Ms(a))return;const o=t.get(a.annotation);o&&r.remove(o),t.delete(a.annotation)};return{all:e,clear:i,getAt:(a,o)=>{const l=r.search({minX:a,minY:o,maxX:a,maxY:o}).map(h=>h.target).filter(h=>h.selector.type===Nt.RECTANGLE||Gm(h.selector,a,o));if(l.length>0)return l.sort((h,u)=>da(h.selector)-da(u.selector)),l[0]},getIntersecting:(a,o,l,h)=>r.search({minX:a,minY:o,maxX:a+l,maxY:o+h}).map(u=>u.target),insert:s,remove:n,set:(a,o=!0)=>{o&&i();const l=a.reduce((h,u)=>{if(Ms(u)){const{minX:c,minY:d,maxX:p,maxY:f}=u.selector.geometry.bounds;return[...h,{minX:c,minY:d,maxX:p,maxY:f,target:u}]}else return h},[]);l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(a,o)=>{n(a),s(o)}}},cu=r=>{const t=yg(),e=Wy(),i=sg(t,r.userSelectAction,r.adapter),s=ig(t),n=wg();return t.observe(({changes:a})=>{e.set((a.created||[]).map(o=>o.target),!1),(a.deleted||[]).forEach(o=>e.remove(o.target)),(a.updated||[]).forEach(({oldValue:o,newValue:l})=>e.update(o.target,l.target))}),{store:{...t,getAt:(a,o)=>{const l=e.getAt(a,o);return l?t.getAnnotation(l.annotation):void 0},getIntersecting:(a,o,l,h)=>e.getIntersecting(a,o,l,h).map(u=>t.getAnnotation(u.annotation))},selection:i,hover:s,viewport:n}},zy=r=>{const t=cu(r);return{...t,store:_g(t.store)}},jy=r=>{let t,e;if(r.nodeName==="CANVAS")t=r,e=t.getContext("2d",{willReadFrequently:!0});else{const s=r;t=document.createElement("canvas"),t.width=s.width,t.height=s.height,e=t.getContext("2d",{willReadFrequently:!0}),e.drawImage(s,0,0,s.width,s.height)}let i=0;for(let s=1;s<10;s++)for(let n=1;n<10;n++){const a=Math.round(n*t.width/10),o=Math.round(s*t.height/10),l=e.getImageData(a,o,1,1).data,h=(.299*l[0]+.587*l[1]+.114*l[2])/255;i+=h}return i/81},du=r=>{const t=jy(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},fu=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?du(r):e),pu=(r,t)=>({...r,drawingEnabled:r.drawingEnabled===void 0?t.drawingEnabled:r.drawingEnabled,drawingMode:r.drawingMode||t.drawingMode,userSelectAction:r.userSelectAction||t.userSelectAction,theme:r.theme||t.theme}),mu=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,gu=(r,t)=>{const e=t||document,i=a=>{const o=a;o.key==="z"&&o.ctrlKey?r.undo():o.key==="y"&&o.ctrlKey&&r.redo()},s=a=>{const o=a;o.key==="z"&&o.metaKey&&(o.shiftKey?r.redo():r.undo())},n=()=>{mu?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return mu?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},Yy=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=pu(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:Bh.EDIT,theme:"light"}),s=zy(i),{selection:n,store:a}=s,o=bg(a,i.initialHistory),l=Tg(s,o,i.adapter,i.autoSave),h=document.createElement("DIV");h.style.position="relative",h.style.display="inline-block",e.style.display="block",e.parentNode.insertBefore(h,e),h.appendChild(e);const u=gu(o);let c=Bg();fu(e,h,i.theme);const d=new Ny({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:c}});d.$on("click",S=>{const{originalEvent:I,annotation:H}=S.detail;H?n.userSelect(H.id,I):n.isEmpty()||n.clear()});const p=Ag(s,o,i.adapter),f=()=>d.cancelDrawing(),g=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),u.destroy(),o.destroy()},y=()=>d.getDrawingTool(),m=()=>c,_=()=>d.isDrawingEnabled(),v=(S,I,H)=>Zh(S,I,H),x=(S,I)=>Wh(S,I),b=S=>{if(!Ls(S))throw`No drawing tool named ${S}`;d.$set({toolName:S})},R=S=>d.$set({drawingEnabled:S}),w=S=>{console.warn("Filter not implemented yet")},D=S=>d.$set({style:S}),U=S=>fu(e,h,S),M=S=>{c=S,d.$set({user:S})},F=S=>d.$set({visible:S});return{...p,cancelDrawing:f,destroy:g,getDrawingTool:y,getUser:m,isDrawingEnabled:_,listDrawingTools:Os,on:l.on,off:l.off,registerDrawingTool:v,registerShapeEditor:x,setDrawingEnabled:R,setDrawingTool:b,setFilter:w,setStyle:D,setTheme:U,setUser:M,setVisible:F,element:h,state:s}};function je(){}function Aa(r,t){for(const e in t)r[e]=t[e];return r}function yu(r){return r()}function _u(){return Object.create(null)}function cr(r){r.forEach(yu)}function ee(r){return typeof r=="function"}function ae(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function qy(r){return Object.keys(r).length===0}function Ky(r,...t){if(r==null){for(const i of t)i(void 0);return je}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Sa(r,t,e){r.$$.on_destroy.push(Ky(t,e))}function vu(r,t,e,i){if(r){const s=xu(r,t,e,i);return r[0](s)}}function xu(r,t,e,i){return r[1]&&i?Aa(e.ctx.slice(),r[1](i(t))):e.ctx}function bu(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],a=Math.max(t.dirty.length,s.length);for(let o=0;o<a;o+=1)n[o]=t.dirty[o]|s[o];return n}return t.dirty|s}return t.dirty}function wu(r,t,e,i,s,n){if(s){const a=xu(t,e,i,n);r.p(a,s)}}function Tu(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function Eu(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Us(r){return r??""}const Zy=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function dr(r,t){r.appendChild(t)}function Tt(r,t,e){r.insertBefore(t,e||null)}function bt(r){r.parentNode&&r.parentNode.removeChild(r)}function Ca(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function Dt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Ia(r){return document.createTextNode(r)}function De(){return Ia(" ")}function fr(){return Ia("")}function Zt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function W(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Jy(r){return Array.from(r.childNodes)}function Qy(r,t){t=""+t,r.data!==t&&(r.data=t)}function ks(r,t,e){r.classList.toggle(t,!!e)}function t_(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Ji;function Qi(r){Ji=r}function Au(){if(!Ji)throw new Error("Function called outside component initialization");return Ji}function e_(r){Au().$$.on_destroy.push(r)}function Gs(){const r=Au();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=t_(t,e,{cancelable:i});return s.slice().forEach(a=>{a.call(r,n)}),!n.defaultPrevented}return!0}}function pr(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const mi=[],Hs=[];let gi=[];const Su=[],r_=Promise.resolve();let Ra=!1;function i_(){Ra||(Ra=!0,r_.then(Cu))}function Pa(r){gi.push(r)}const Ma=new Set;let yi=0;function Cu(){if(yi!==0)return;const r=Ji;do{try{for(;yi<mi.length;){const t=mi[yi];yi++,Qi(t),s_(t.$$)}}catch(t){throw mi.length=0,yi=0,t}for(Qi(null),mi.length=0,yi=0;Hs.length;)Hs.pop()();for(let t=0;t<gi.length;t+=1){const e=gi[t];Ma.has(e)||(Ma.add(e),e())}gi.length=0}while(mi.length);for(;Su.length;)Su.pop()();Ra=!1,Ma.clear(),Qi(r)}function s_(r){if(r.fragment!==null){r.update(),cr(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Pa)}}function n_(r){const t=[],e=[];gi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),gi=t}const $s=new Set;let Gr;function Ye(){Gr={r:0,c:[],p:Gr}}function qe(){Gr.r||cr(Gr.c),Gr=Gr.p}function gt(r,t){r&&r.i&&($s.delete(r),r.i(t))}function wt(r,t,e,i){if(r&&r.o){if($s.has(r))return;$s.add(r),Gr.c.push(()=>{$s.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function _i(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function oe(r){r&&r.c()}function re(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),Pa(()=>{const n=r.$$.on_mount.map(yu).filter(ee);r.$$.on_destroy?r.$$.on_destroy.push(...n):cr(n),r.$$.on_mount=[]}),s.forEach(Pa)}function ie(r,t){const e=r.$$;e.fragment!==null&&(n_(e.after_update),cr(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function a_(r,t){r.$$.dirty[0]===-1&&(mi.push(r),i_(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function me(r,t,e,i,s,n,a=null,o=[-1]){const l=Ji;Qi(r);const h=r.$$={fragment:null,ctx:[],props:n,update:je,not_equal:s,bound:_u(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:_u(),dirty:o,skip_bound:!1,root:t.target||l.$$.root};a&&a(h.root);let u=!1;if(h.ctx=e?e(r,t.props||{},(c,d,...p)=>{const f=p.length?p[0]:d;return h.ctx&&s(h.ctx[c],h.ctx[c]=f)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](f),u&&a_(r,c)),d}):[],h.update(),u=!0,cr(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=Jy(t.target);h.fragment&&h.fragment.l(c),c.forEach(bt)}else h.fragment&&h.fragment.c();t.intro&&gt(r.$$.fragment),re(r,t.target,t.anchor),Cu()}Qi(l)}class ge{constructor(){lh(this,"$$");lh(this,"$$set")}$destroy(){ie(this,1),this.$destroy=je}$on(t,e){if(!ee(e))return je;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!qy(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const o_="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(o_);var Hr=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(Hr||{}),Da=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Da||{}),Ba=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(Ba||{}),q=(r=>(r[r.NORMAL=0]="NORMAL",r[r.ADD=1]="ADD",r[r.MULTIPLY=2]="MULTIPLY",r[r.SCREEN=3]="SCREEN",r[r.OVERLAY=4]="OVERLAY",r[r.DARKEN=5]="DARKEN",r[r.LIGHTEN=6]="LIGHTEN",r[r.COLOR_DODGE=7]="COLOR_DODGE",r[r.COLOR_BURN=8]="COLOR_BURN",r[r.HARD_LIGHT=9]="HARD_LIGHT",r[r.SOFT_LIGHT=10]="SOFT_LIGHT",r[r.DIFFERENCE=11]="DIFFERENCE",r[r.EXCLUSION=12]="EXCLUSION",r[r.HUE=13]="HUE",r[r.SATURATION=14]="SATURATION",r[r.COLOR=15]="COLOR",r[r.LUMINOSITY=16]="LUMINOSITY",r[r.NORMAL_NPM=17]="NORMAL_NPM",r[r.ADD_NPM=18]="ADD_NPM",r[r.SCREEN_NPM=19]="SCREEN_NPM",r[r.NONE=20]="NONE",r[r.SRC_OVER=0]="SRC_OVER",r[r.SRC_IN=21]="SRC_IN",r[r.SRC_OUT=22]="SRC_OUT",r[r.SRC_ATOP=23]="SRC_ATOP",r[r.DST_OVER=24]="DST_OVER",r[r.DST_IN=25]="DST_IN",r[r.DST_OUT=26]="DST_OUT",r[r.DST_ATOP=27]="DST_ATOP",r[r.ERASE=26]="ERASE",r[r.SUBTRACT=28]="SUBTRACT",r[r.XOR=29]="XOR",r))(q||{}),Be=(r=>(r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r))(Be||{}),Z=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(Z||{}),vi=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(vi||{}),ut=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(ut||{}),nt=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(nt||{}),Oe=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(Oe||{}),mr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(mr||{}),Ke=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(Ke||{}),ce=(r=>(r[r.NPM=0]="NPM",r[r.UNPACK=1]="UNPACK",r[r.PMA=2]="PMA",r[r.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",r[r.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",r[r.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",r))(ce||{}),Ze=(r=>(r[r.NO=0]="NO",r[r.YES=1]="YES",r[r.AUTO=2]="AUTO",r[r.BLEND=0]="BLEND",r[r.CLEAR=1]="CLEAR",r[r.BLIT=2]="BLIT",r))(Ze||{}),Oa=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(Oa||{}),Ee=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(Ee||{}),Vt=(r=>(r[r.NONE=0]="NONE",r[r.SCISSOR=1]="SCISSOR",r[r.STENCIL=2]="STENCIL",r[r.SPRITE=3]="SPRITE",r[r.COLOR=4]="COLOR",r))(Vt||{}),Ht=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Ht||{}),Je=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Je||{});const et={ADAPTER:{createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")},RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var La=/iPhone/i,Iu=/iPod/i,Ru=/iPad/i,Pu=/\biOS-universal(?:.+)Mac\b/i,Fa=/\bAndroid(?:.+)Mobile\b/i,Mu=/Android/i,xi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Vs=/Silk/i,gr=/Windows Phone/i,Du=/\bWindows(?:.+)ARM\b/i,Bu=/BlackBerry/i,Ou=/BB10/i,Lu=/Opera Mini/i,Fu=/\b(CriOS|Chrome)(?:.+)Mobile/i,Nu=/Mobile(?:.+)Firefox\b/i,Uu=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function l_(r){return function(t){return t.test(r)}}function ku(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var s=l_(e),n={apple:{phone:s(La)&&!s(gr),ipod:s(Iu),tablet:!s(La)&&(s(Ru)||Uu(t))&&!s(gr),universal:s(Pu),device:(s(La)||s(Iu)||s(Ru)||s(Pu)||Uu(t))&&!s(gr)},amazon:{phone:s(xi),tablet:!s(xi)&&s(Vs),device:s(xi)||s(Vs)},android:{phone:!s(gr)&&s(xi)||!s(gr)&&s(Fa),tablet:!s(gr)&&!s(xi)&&!s(Fa)&&(s(Vs)||s(Mu)),device:!s(gr)&&(s(xi)||s(Vs)||s(Fa)||s(Mu))||s(/\bokhttp\b/i)},windows:{phone:s(gr),tablet:s(Du),device:s(gr)||s(Du)},other:{blackberry:s(Bu),blackberry10:s(Ou),opera:s(Lu),firefox:s(Nu),chrome:s(Fu),device:s(Bu)||s(Ou)||s(Lu)||s(Nu)||s(Fu)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const h_=ku.default??ku,Qe=h_(globalThis.navigator);et.RETINA_PREFIX=/@([0-9\.]+)x/,et.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Xs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Gu(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function u_(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var Na={exports:{}},Hu;function c_(){return Hu||(Hu=1,function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,h,u){this.fn=l,this.context=h,this.once=u||!1}function n(l,h,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var p=new s(u,c||l,d),f=e?e+h:h;return l._events[f]?l._events[f].fn?l._events[f]=[l._events[f],p]:l._events[f].push(p):(l._events[f]=p,l._eventsCount++),l}function a(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var h=[],u,c;if(this._eventsCount===0)return h;for(c in u=this._events)t.call(u,c)&&h.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(u)):h},o.prototype.listeners=function(h){var u=e?e+h:h,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,p=c.length,f=new Array(p);d<p;d++)f[d]=c[d].fn;return f},o.prototype.listenerCount=function(h){var u=e?e+h:h,c=this._events[u];return c?c.fn?1:c.length:0},o.prototype.emit=function(h,u,c,d,p,f){var g=e?e+h:h;if(!this._events[g])return!1;var y=this._events[g],m=arguments.length,_,v;if(y.fn){switch(y.once&&this.removeListener(h,y.fn,void 0,!0),m){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,u),!0;case 3:return y.fn.call(y.context,u,c),!0;case 4:return y.fn.call(y.context,u,c,d),!0;case 5:return y.fn.call(y.context,u,c,d,p),!0;case 6:return y.fn.call(y.context,u,c,d,p,f),!0}for(v=1,_=new Array(m-1);v<m;v++)_[v-1]=arguments[v];y.fn.apply(y.context,_)}else{var x=y.length,b;for(v=0;v<x;v++)switch(y[v].once&&this.removeListener(h,y[v].fn,void 0,!0),m){case 1:y[v].fn.call(y[v].context);break;case 2:y[v].fn.call(y[v].context,u);break;case 3:y[v].fn.call(y[v].context,u,c);break;case 4:y[v].fn.call(y[v].context,u,c,d);break;default:if(!_)for(b=1,_=new Array(m-1);b<m;b++)_[b-1]=arguments[b];y[v].fn.apply(y[v].context,_)}}return!0},o.prototype.on=function(h,u,c){return n(this,h,u,c,!1)},o.prototype.once=function(h,u,c){return n(this,h,u,c,!0)},o.prototype.removeListener=function(h,u,c,d){var p=e?e+h:h;if(!this._events[p])return this;if(!u)return a(this,p),this;var f=this._events[p];if(f.fn)f.fn===u&&(!d||f.once)&&(!c||f.context===c)&&a(this,p);else{for(var g=0,y=[],m=f.length;g<m;g++)(f[g].fn!==u||d&&!f[g].once||c&&f[g].context!==c)&&y.push(f[g]);y.length?this._events[p]=y.length===1?y[0]:y:a(this,p)}return this},o.prototype.removeAllListeners=function(h){var u;return h?(u=e?e+h:h,this._events[u]&&a(this,u)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,r.exports=o}(Na)),Na.exports}var d_=c_();const bi=Gu(d_);var Ws={exports:{}},$u;function f_(){if($u)return Ws.exports;$u=1,Ws.exports=r,Ws.exports.default=r;function r(A,C,T){T=T||2;var k=C&&C.length,E=k?C[0]*T:A.length,P=t(A,0,E,T,!0),B=[];if(!P||P.next===P.prev)return B;var G,z,$,K,Q,O,L;if(k&&(P=l(A,C,P,T)),A.length>80*T){G=$=A[0],z=K=A[1];for(var Y=T;Y<E;Y+=T)Q=A[Y],O=A[Y+1],Q<G&&(G=Q),O<z&&(z=O),Q>$&&($=Q),O>K&&(K=O);L=Math.max($-G,K-z),L=L!==0?32767/L:0}return i(P,B,T,G,z,L,0),B}function t(A,C,T,k,E){var P,B;if(E===j(A,C,T,k)>0)for(P=C;P<T;P+=k)B=S(P,A[P],A[P+1],B);else for(P=T-k;P>=C;P-=k)B=S(P,A[P],A[P+1],B);return B&&x(B,B.next)&&(I(B),B=B.next),B}function e(A,C){if(!A)return A;C||(C=A);var T=A,k;do if(k=!1,!T.steiner&&(x(T,T.next)||v(T.prev,T,T.next)===0)){if(I(T),T=C=T.prev,T===T.next)break;k=!0}else T=T.next;while(k||T!==C);return C}function i(A,C,T,k,E,P,B){if(A){!B&&P&&p(A,k,E,P);for(var G=A,z,$;A.prev!==A.next;){if(z=A.prev,$=A.next,P?n(A,k,E,P):s(A)){C.push(z.i/T|0),C.push(A.i/T|0),C.push($.i/T|0),I(A),A=$.next,G=$.next;continue}if(A=$,A===G){B?B===1?(A=a(e(A),C,T),i(A,C,T,k,E,P,2)):B===2&&o(A,C,T,k,E,P):i(e(A),C,T,k,E,P,1);break}}}}function s(A){var C=A.prev,T=A,k=A.next;if(v(C,T,k)>=0)return!1;for(var E=C.x,P=T.x,B=k.x,G=C.y,z=T.y,$=k.y,K=E<P?E<B?E:B:P<B?P:B,Q=G<z?G<$?G:$:z<$?z:$,O=E>P?E>B?E:B:P>B?P:B,L=G>z?G>$?G:$:z>$?z:$,Y=k.next;Y!==C;){if(Y.x>=K&&Y.x<=O&&Y.y>=Q&&Y.y<=L&&m(E,G,P,z,B,$,Y.x,Y.y)&&v(Y.prev,Y,Y.next)>=0)return!1;Y=Y.next}return!0}function n(A,C,T,k){var E=A.prev,P=A,B=A.next;if(v(E,P,B)>=0)return!1;for(var G=E.x,z=P.x,$=B.x,K=E.y,Q=P.y,O=B.y,L=G<z?G<$?G:$:z<$?z:$,Y=K<Q?K<O?K:O:Q<O?Q:O,tt=G>z?G>$?G:$:z>$?z:$,st=K>Q?K>O?K:O:Q>O?Q:O,lt=g(L,Y,C,T,k),At=g(tt,st,C,T,k),ht=A.prevZ,at=A.nextZ;ht&&ht.z>=lt&&at&&at.z<=At;){if(ht.x>=L&&ht.x<=tt&&ht.y>=Y&&ht.y<=st&&ht!==E&&ht!==B&&m(G,K,z,Q,$,O,ht.x,ht.y)&&v(ht.prev,ht,ht.next)>=0||(ht=ht.prevZ,at.x>=L&&at.x<=tt&&at.y>=Y&&at.y<=st&&at!==E&&at!==B&&m(G,K,z,Q,$,O,at.x,at.y)&&v(at.prev,at,at.next)>=0))return!1;at=at.nextZ}for(;ht&&ht.z>=lt;){if(ht.x>=L&&ht.x<=tt&&ht.y>=Y&&ht.y<=st&&ht!==E&&ht!==B&&m(G,K,z,Q,$,O,ht.x,ht.y)&&v(ht.prev,ht,ht.next)>=0)return!1;ht=ht.prevZ}for(;at&&at.z<=At;){if(at.x>=L&&at.x<=tt&&at.y>=Y&&at.y<=st&&at!==E&&at!==B&&m(G,K,z,Q,$,O,at.x,at.y)&&v(at.prev,at,at.next)>=0)return!1;at=at.nextZ}return!0}function a(A,C,T){var k=A;do{var E=k.prev,P=k.next.next;!x(E,P)&&b(E,k,k.next,P)&&U(E,P)&&U(P,E)&&(C.push(E.i/T|0),C.push(k.i/T|0),C.push(P.i/T|0),I(k),I(k.next),k=A=P),k=k.next}while(k!==A);return e(k)}function o(A,C,T,k,E,P){var B=A;do{for(var G=B.next.next;G!==B.prev;){if(B.i!==G.i&&_(B,G)){var z=F(B,G);B=e(B,B.next),z=e(z,z.next),i(B,C,T,k,E,P,0),i(z,C,T,k,E,P,0);return}G=G.next}B=B.next}while(B!==A)}function l(A,C,T,k){var E=[],P,B,G,z,$;for(P=0,B=C.length;P<B;P++)G=C[P]*k,z=P<B-1?C[P+1]*k:A.length,$=t(A,G,z,k,!1),$===$.next&&($.steiner=!0),E.push(y($));for(E.sort(h),P=0;P<E.length;P++)T=u(E[P],T);return T}function h(A,C){return A.x-C.x}function u(A,C){var T=c(A,C);if(!T)return C;var k=F(T,A);return e(k,k.next),e(T,T.next)}function c(A,C){var T=C,k=A.x,E=A.y,P=-1/0,B;do{if(E<=T.y&&E>=T.next.y&&T.next.y!==T.y){var G=T.x+(E-T.y)*(T.next.x-T.x)/(T.next.y-T.y);if(G<=k&&G>P&&(P=G,B=T.x<T.next.x?T:T.next,G===k))return B}T=T.next}while(T!==C);if(!B)return null;var z=B,$=B.x,K=B.y,Q=1/0,O;T=B;do k>=T.x&&T.x>=$&&k!==T.x&&m(E<K?k:P,E,$,K,E<K?P:k,E,T.x,T.y)&&(O=Math.abs(E-T.y)/(k-T.x),U(T,A)&&(O<Q||O===Q&&(T.x>B.x||T.x===B.x&&d(B,T)))&&(B=T,Q=O)),T=T.next;while(T!==z);return B}function d(A,C){return v(A.prev,A,C.prev)<0&&v(C.next,A,A.next)<0}function p(A,C,T,k){var E=A;do E.z===0&&(E.z=g(E.x,E.y,C,T,k)),E.prevZ=E.prev,E.nextZ=E.next,E=E.next;while(E!==A);E.prevZ.nextZ=null,E.prevZ=null,f(E)}function f(A){var C,T,k,E,P,B,G,z,$=1;do{for(T=A,A=null,P=null,B=0;T;){for(B++,k=T,G=0,C=0;C<$&&(G++,k=k.nextZ,!!k);C++);for(z=$;G>0||z>0&&k;)G!==0&&(z===0||!k||T.z<=k.z)?(E=T,T=T.nextZ,G--):(E=k,k=k.nextZ,z--),P?P.nextZ=E:A=E,E.prevZ=P,P=E;T=k}P.nextZ=null,$*=2}while(B>1);return A}function g(A,C,T,k,E){return A=(A-T)*E|0,C=(C-k)*E|0,A=(A|A<<8)&16711935,A=(A|A<<4)&252645135,A=(A|A<<2)&858993459,A=(A|A<<1)&1431655765,C=(C|C<<8)&16711935,C=(C|C<<4)&252645135,C=(C|C<<2)&858993459,C=(C|C<<1)&1431655765,A|C<<1}function y(A){var C=A,T=A;do(C.x<T.x||C.x===T.x&&C.y<T.y)&&(T=C),C=C.next;while(C!==A);return T}function m(A,C,T,k,E,P,B,G){return(E-B)*(C-G)>=(A-B)*(P-G)&&(A-B)*(k-G)>=(T-B)*(C-G)&&(T-B)*(P-G)>=(E-B)*(k-G)}function _(A,C){return A.next.i!==C.i&&A.prev.i!==C.i&&!D(A,C)&&(U(A,C)&&U(C,A)&&M(A,C)&&(v(A.prev,A,C.prev)||v(A,C.prev,C))||x(A,C)&&v(A.prev,A,A.next)>0&&v(C.prev,C,C.next)>0)}function v(A,C,T){return(C.y-A.y)*(T.x-C.x)-(C.x-A.x)*(T.y-C.y)}function x(A,C){return A.x===C.x&&A.y===C.y}function b(A,C,T,k){var E=w(v(A,C,T)),P=w(v(A,C,k)),B=w(v(T,k,A)),G=w(v(T,k,C));return!!(E!==P&&B!==G||E===0&&R(A,T,C)||P===0&&R(A,k,C)||B===0&&R(T,A,k)||G===0&&R(T,C,k))}function R(A,C,T){return C.x<=Math.max(A.x,T.x)&&C.x>=Math.min(A.x,T.x)&&C.y<=Math.max(A.y,T.y)&&C.y>=Math.min(A.y,T.y)}function w(A){return A>0?1:A<0?-1:0}function D(A,C){var T=A;do{if(T.i!==A.i&&T.next.i!==A.i&&T.i!==C.i&&T.next.i!==C.i&&b(T,T.next,A,C))return!0;T=T.next}while(T!==A);return!1}function U(A,C){return v(A.prev,A,A.next)<0?v(A,C,A.next)>=0&&v(A,A.prev,C)>=0:v(A,C,A.prev)<0||v(A,A.next,C)<0}function M(A,C){var T=A,k=!1,E=(A.x+C.x)/2,P=(A.y+C.y)/2;do T.y>P!=T.next.y>P&&T.next.y!==T.y&&E<(T.next.x-T.x)*(P-T.y)/(T.next.y-T.y)+T.x&&(k=!k),T=T.next;while(T!==A);return k}function F(A,C){var T=new H(A.i,A.x,A.y),k=new H(C.i,C.x,C.y),E=A.next,P=C.prev;return A.next=C,C.prev=A,T.next=E,E.prev=T,k.next=T,T.prev=k,P.next=k,k.prev=P,k}function S(A,C,T,k){var E=new H(A,C,T);return k?(E.next=k.next,E.prev=k,k.next.prev=E,k.next=E):(E.prev=E,E.next=E),E}function I(A){A.next.prev=A.prev,A.prev.next=A.next,A.prevZ&&(A.prevZ.nextZ=A.nextZ),A.nextZ&&(A.nextZ.prevZ=A.prevZ)}function H(A,C,T){this.i=A,this.x=C,this.y=T,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}r.deviation=function(A,C,T,k){var E=C&&C.length,P=E?C[0]*T:A.length,B=Math.abs(j(A,0,P,T));if(E)for(var G=0,z=C.length;G<z;G++){var $=C[G]*T,K=G<z-1?C[G+1]*T:A.length;B-=Math.abs(j(A,$,K,T))}var Q=0;for(G=0;G<k.length;G+=3){var O=k[G]*T,L=k[G+1]*T,Y=k[G+2]*T;Q+=Math.abs((A[O]-A[Y])*(A[L+1]-A[O+1])-(A[O]-A[L])*(A[Y+1]-A[O+1]))}return B===0&&Q===0?0:Math.abs((Q-B)/B)};function j(A,C,T,k){for(var E=0,P=C,B=T-k;P<T;P+=k)E+=(A[B]-A[P])*(A[P+1]+A[B+1]),B=P;return E}return r.flatten=function(A){for(var C=A[0][0].length,T={vertices:[],holes:[],dimensions:C},k=0,E=0;E<A.length;E++){for(var P=0;P<A[E].length;P++)for(var B=0;B<C;B++)T.vertices.push(A[E][P][B]);E>0&&(k+=A[E-1].length,T.holes.push(k))}return T},Ws.exports}var p_=f_();const Vu=Gu(p_);var $r={},ts={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var m_=ts.exports,Xu;function g_(){return Xu||(Xu=1,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=!r.nodeType&&r,n=typeof Xs=="object"&&Xs;(n.global===n||n.window===n||n.self===n)&&(e=n);var a,o=2147483647,l=36,h=1,u=26,c=38,d=700,p=72,f=128,g="-",y=/^xn--/,m=/[^\x20-\x7E]/,_=/[\x2E\u3002\uFF0E\uFF61]/g,v={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},x=l-h,b=Math.floor,R=String.fromCharCode,w;function D(E){throw new RangeError(v[E])}function U(E,P){for(var B=E.length,G=[];B--;)G[B]=P(E[B]);return G}function M(E,P){var B=E.split("@"),G="";B.length>1&&(G=B[0]+"@",E=B[1]),E=E.replace(_,".");var z=E.split("."),$=U(z,P).join(".");return G+$}function F(E){for(var P=[],B=0,G=E.length,z,$;B<G;)z=E.charCodeAt(B++),z>=55296&&z<=56319&&B<G?($=E.charCodeAt(B++),($&64512)==56320?P.push(((z&1023)<<10)+($&1023)+65536):(P.push(z),B--)):P.push(z);return P}function S(E){return U(E,function(P){var B="";return P>65535&&(P-=65536,B+=R(P>>>10&1023|55296),P=56320|P&1023),B+=R(P),B}).join("")}function I(E){return E-48<10?E-22:E-65<26?E-65:E-97<26?E-97:l}function H(E,P){return E+22+75*(E<26)-((P!=0)<<5)}function j(E,P,B){var G=0;for(E=B?b(E/d):E>>1,E+=b(E/P);E>x*u>>1;G+=l)E=b(E/x);return b(G+(x+1)*E/(E+c))}function A(E){var P=[],B=E.length,G,z=0,$=f,K=p,Q,O,L,Y,tt,st,lt,At,ht;for(Q=E.lastIndexOf(g),Q<0&&(Q=0),O=0;O<Q;++O)E.charCodeAt(O)>=128&&D("not-basic"),P.push(E.charCodeAt(O));for(L=Q>0?Q+1:0;L<B;){for(Y=z,tt=1,st=l;L>=B&&D("invalid-input"),lt=I(E.charCodeAt(L++)),(lt>=l||lt>b((o-z)/tt))&&D("overflow"),z+=lt*tt,At=st<=K?h:st>=K+u?u:st-K,!(lt<At);st+=l)ht=l-At,tt>b(o/ht)&&D("overflow"),tt*=ht;G=P.length+1,K=j(z-Y,G,Y==0),b(z/G)>o-$&&D("overflow"),$+=b(z/G),z%=G,P.splice(z++,0,$)}return S(P)}function C(E){var P,B,G,z,$,K,Q,O,L,Y,tt,st=[],lt,At,ht,at;for(E=F(E),lt=E.length,P=f,B=0,$=p,K=0;K<lt;++K)tt=E[K],tt<128&&st.push(R(tt));for(G=z=st.length,z&&st.push(g);G<lt;){for(Q=o,K=0;K<lt;++K)tt=E[K],tt>=P&&tt<Q&&(Q=tt);for(At=G+1,Q-P>b((o-B)/At)&&D("overflow"),B+=(Q-P)*At,P=Q,K=0;K<lt;++K)if(tt=E[K],tt<P&&++B>o&&D("overflow"),tt==P){for(O=B,L=l;Y=L<=$?h:L>=$+u?u:L-$,!(O<Y);L+=l)at=O-Y,ht=l-Y,st.push(R(H(Y+at%ht,0))),O=b(at/ht);st.push(R(H(O,0))),$=j(B,At,G==z),B=0,++G}++B,++P}return st.join("")}function T(E){return M(E,function(P){return y.test(P)?A(P.slice(4).toLowerCase()):P})}function k(E){return M(E,function(P){return m.test(P)?"xn--"+C(P):P})}if(a={version:"1.4.1",ucs2:{decode:F,encode:S},decode:A,encode:C,toASCII:k,toUnicode:T},i&&s)if(r.exports==i)s.exports=a;else for(w in a)a.hasOwnProperty(w)&&(i[w]=a[w]);else e.punycode=a})(m_)}(ts,ts.exports)),ts.exports}var Ua,Wu;function wi(){return Wu||(Wu=1,Ua=TypeError),Ua}const y_=u_(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ka,zu;function zs(){if(zu)return ka;zu=1;var r=typeof Map=="function"&&Map.prototype,t=Object.getOwnPropertyDescriptor&&r?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,e=r&&t&&typeof t.get=="function"?t.get:null,i=r&&Map.prototype.forEach,s=typeof Set=="function"&&Set.prototype,n=Object.getOwnPropertyDescriptor&&s?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,a=s&&n&&typeof n.get=="function"?n.get:null,o=s&&Set.prototype.forEach,l=typeof WeakMap=="function"&&WeakMap.prototype,h=l?WeakMap.prototype.has:null,u=typeof WeakSet=="function"&&WeakSet.prototype,c=u?WeakSet.prototype.has:null,d=typeof WeakRef=="function"&&WeakRef.prototype,p=d?WeakRef.prototype.deref:null,f=Boolean.prototype.valueOf,g=Object.prototype.toString,y=Function.prototype.toString,m=String.prototype.match,_=String.prototype.slice,v=String.prototype.replace,x=String.prototype.toUpperCase,b=String.prototype.toLowerCase,R=RegExp.prototype.test,w=Array.prototype.concat,D=Array.prototype.join,U=Array.prototype.slice,M=Math.floor,F=typeof BigInt=="function"?BigInt.prototype.valueOf:null,S=Object.getOwnPropertySymbols,I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,H=typeof Symbol=="function"&&typeof Symbol.iterator=="object",j=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===H||!0)?Symbol.toStringTag:null,A=Object.prototype.propertyIsEnumerable,C=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(V){return V.__proto__}:null);function T(V,X){if(V===1/0||V===-1/0||V!==V||V&&V>-1e3&&V<1e3||R.call(/e/,X))return X;var It=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof V=="number"){var Pt=V<0?-M(-V):M(V);if(Pt!==V){var Mt=String(Pt),xt=_.call(X,Mt.length+1);return v.call(Mt,It,"$&_")+"."+v.call(v.call(xt,/([0-9]{3})/g,"$&_"),/_$/,"")}}return v.call(X,It,"$&_")}var k=y_,E=k.custom,P=lt(E)?E:null,B={__proto__:null,double:'"',single:"'"},G={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};ka=function V(X,It,Pt,Mt){var xt=It||{};if(at(xt,"quoteStyle")&&!at(B,xt.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(at(xt,"maxStringLength")&&(typeof xt.maxStringLength=="number"?xt.maxStringLength<0&&xt.maxStringLength!==1/0:xt.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Lr=at(xt,"customInspect")?xt.customInspect:!0;if(typeof Lr!="boolean"&&Lr!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(at(xt,"indent")&&xt.indent!==null&&xt.indent!==" "&&!(parseInt(xt.indent,10)===xt.indent&&xt.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(at(xt,"numericSeparator")&&typeof xt.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var si=xt.numericSeparator;if(typeof X>"u")return"undefined";if(X===null)return"null";if(typeof X=="boolean")return X?"true":"false";if(typeof X=="string")return kp(X,xt);if(typeof X=="number"){if(X===0)return 1/0/X>0?"0":"-0";var ve=String(X);return si?T(X,ve):ve}if(typeof X=="bigint"){var Fr=String(X)+"n";return si?T(X,Fr):Fr}var eh=typeof xt.depth>"u"?5:xt.depth;if(typeof Pt>"u"&&(Pt=0),Pt>=eh&&eh>0&&typeof X=="object")return K(X)?"[Array]":"[Object]";var ki=Hw(xt,Pt);if(typeof Mt>"u")Mt=[];else if(ri(Mt,X)>=0)return"[Circular]";function Ve(Gi,qn,Vw){if(qn&&(Mt=U.call(Mt),Mt.push(qn)),Vw){var Yp={depth:xt.depth};return at(xt,"quoteStyle")&&(Yp.quoteStyle=xt.quoteStyle),V(Gi,Yp,Pt+1,Mt)}return V(Gi,xt,Pt+1,Mt)}if(typeof X=="function"&&!O(X)){var Hp=Ce(X),$p=jn(X,Ve);return"[Function"+(Hp?": "+Hp:" (anonymous)")+"]"+($p.length>0?" { "+D.call($p,", ")+" }":"")}if(lt(X)){var Vp=H?v.call(String(X),/^(Symbol\(.*\))_[^)]*$/,"$1"):I.call(X);return typeof X=="object"&&!H?xs(Vp):Vp}if(Uw(X)){for(var bs="<"+b.call(String(X.nodeName)),rh=X.attributes||[],Yn=0;Yn<rh.length;Yn++)bs+=" "+rh[Yn].name+"="+z($(rh[Yn].value),"double",xt);return bs+=">",X.childNodes&&X.childNodes.length&&(bs+="..."),bs+="</"+b.call(String(X.nodeName))+">",bs}if(K(X)){if(X.length===0)return"[]";var ih=jn(X,Ve);return ki&&!Gw(ih)?"["+th(ih,ki)+"]":"[ "+D.call(ih,", ")+" ]"}if(L(X)){var sh=jn(X,Ve);return!("cause"in Error.prototype)&&"cause"in X&&!A.call(X,"cause")?"{ ["+String(X)+"] "+D.call(w.call("[cause]: "+Ve(X.cause),sh),", ")+" }":sh.length===0?"["+String(X)+"]":"{ ["+String(X)+"] "+D.call(sh,", ")+" }"}if(typeof X=="object"&&Lr){if(P&&typeof X[P]=="function"&&k)return k(X,{depth:eh-Pt});if(Lr!=="symbol"&&typeof X.inspect=="function")return X.inspect()}if(ii(X)){var Xp=[];return i&&i.call(X,function(Gi,qn){Xp.push(Ve(qn,X,!0)+" => "+Ve(Gi,X))}),Gp("Map",e.call(X),Xp,ki)}if(Ni(X)){var Wp=[];return o&&o.call(X,function(Gi){Wp.push(Ve(Gi,X))}),Gp("Set",a.call(X),Wp,ki)}if($e(X))return Ql("WeakMap");if(Ui(X))return Ql("WeakSet");if(Fi(X))return Ql("WeakRef");if(tt(X))return xs(Ve(Number(X)));if(At(X))return xs(Ve(F.call(X)));if(st(X))return xs(f.call(X));if(Y(X))return xs(Ve(String(X)));if(typeof window<"u"&&X===window)return"{ [object Window] }";if(typeof globalThis<"u"&&X===globalThis||typeof Xs<"u"&&X===Xs)return"{ [object globalThis] }";if(!Q(X)&&!O(X)){var nh=jn(X,Ve),zp=C?C(X)===Object.prototype:X instanceof Object||X.constructor===Object,ah=X instanceof Object?"":"null prototype",jp=!zp&&j&&Object(X)===X&&j in X?_.call($t(X),8,-1):ah?"Object":"",$w=zp||typeof X.constructor!="function"?"":X.constructor.name?X.constructor.name+" ":"",oh=$w+(jp||ah?"["+D.call(w.call([],jp||[],ah||[]),": ")+"] ":"");return nh.length===0?oh+"{}":ki?oh+"{"+th(nh,ki)+"}":oh+"{ "+D.call(nh,", ")+" }"}return String(X)};function z(V,X,It){var Pt=It.quoteStyle||X,Mt=B[Pt];return Mt+V+Mt}function $(V){return v.call(String(V),/"/g,"&quot;")}function K(V){return $t(V)==="[object Array]"&&(!j||!(typeof V=="object"&&j in V))}function Q(V){return $t(V)==="[object Date]"&&(!j||!(typeof V=="object"&&j in V))}function O(V){return $t(V)==="[object RegExp]"&&(!j||!(typeof V=="object"&&j in V))}function L(V){return $t(V)==="[object Error]"&&(!j||!(typeof V=="object"&&j in V))}function Y(V){return $t(V)==="[object String]"&&(!j||!(typeof V=="object"&&j in V))}function tt(V){return $t(V)==="[object Number]"&&(!j||!(typeof V=="object"&&j in V))}function st(V){return $t(V)==="[object Boolean]"&&(!j||!(typeof V=="object"&&j in V))}function lt(V){if(H)return V&&typeof V=="object"&&V instanceof Symbol;if(typeof V=="symbol")return!0;if(!V||typeof V!="object"||!I)return!1;try{return I.call(V),!0}catch{}return!1}function At(V){if(!V||typeof V!="object"||!F)return!1;try{return F.call(V),!0}catch{}return!1}var ht=Object.prototype.hasOwnProperty||function(V){return V in this};function at(V,X){return ht.call(V,X)}function $t(V){return g.call(V)}function Ce(V){if(V.name)return V.name;var X=m.call(y.call(V),/^function\s*([\w$]+)/);return X?X[1]:null}function ri(V,X){if(V.indexOf)return V.indexOf(X);for(var It=0,Pt=V.length;It<Pt;It++)if(V[It]===X)return It;return-1}function ii(V){if(!e||!V||typeof V!="object")return!1;try{e.call(V);try{a.call(V)}catch{return!0}return V instanceof Map}catch{}return!1}function $e(V){if(!h||!V||typeof V!="object")return!1;try{h.call(V,h);try{c.call(V,c)}catch{return!0}return V instanceof WeakMap}catch{}return!1}function Fi(V){if(!p||!V||typeof V!="object")return!1;try{return p.call(V),!0}catch{}return!1}function Ni(V){if(!a||!V||typeof V!="object")return!1;try{a.call(V);try{e.call(V)}catch{return!0}return V instanceof Set}catch{}return!1}function Ui(V){if(!c||!V||typeof V!="object")return!1;try{c.call(V,c);try{h.call(V,h)}catch{return!0}return V instanceof WeakSet}catch{}return!1}function Uw(V){return!V||typeof V!="object"?!1:typeof HTMLElement<"u"&&V instanceof HTMLElement?!0:typeof V.nodeName=="string"&&typeof V.getAttribute=="function"}function kp(V,X){if(V.length>X.maxStringLength){var It=V.length-X.maxStringLength,Pt="... "+It+" more character"+(It>1?"s":"");return kp(_.call(V,0,X.maxStringLength),X)+Pt}var Mt=G[X.quoteStyle||"single"];Mt.lastIndex=0;var xt=v.call(v.call(V,Mt,"\\$1"),/[\x00-\x1f]/g,kw);return z(xt,"single",X)}function kw(V){var X=V.charCodeAt(0),It={8:"b",9:"t",10:"n",12:"f",13:"r"}[X];return It?"\\"+It:"\\x"+(X<16?"0":"")+x.call(X.toString(16))}function xs(V){return"Object("+V+")"}function Ql(V){return V+" { ? }"}function Gp(V,X,It,Pt){var Mt=Pt?th(It,Pt):D.call(It,", ");return V+" ("+X+") {"+Mt+"}"}function Gw(V){for(var X=0;X<V.length;X++)if(ri(V[X],`
2
+ `)>=0)return!1;return!0}function Hw(V,X){var It;if(V.indent===" ")It=" ";else if(typeof V.indent=="number"&&V.indent>0)It=D.call(Array(V.indent+1)," ");else return null;return{base:It,prev:D.call(Array(X+1),It)}}function th(V,X){if(V.length===0)return"";var It=`
3
+ `+X.prev+X.base;return It+D.call(V,","+It)+`
4
+ `+X.prev}function jn(V,X){var It=K(V),Pt=[];if(It){Pt.length=V.length;for(var Mt=0;Mt<V.length;Mt++)Pt[Mt]=at(V,Mt)?X(V[Mt],V):""}var xt=typeof S=="function"?S(V):[],Lr;if(H){Lr={};for(var si=0;si<xt.length;si++)Lr["$"+xt[si]]=xt[si]}for(var ve in V)at(V,ve)&&(It&&String(Number(ve))===ve&&ve<V.length||H&&Lr["$"+ve]instanceof Symbol||(R.call(/[^\w$]/,ve)?Pt.push(X(ve,V)+": "+X(V[ve],V)):Pt.push(ve+": "+X(V[ve],V))));if(typeof S=="function")for(var Fr=0;Fr<xt.length;Fr++)A.call(V,xt[Fr])&&Pt.push("["+X(xt[Fr])+"]: "+X(V[xt[Fr]],V));return Pt}return ka}var Ga,ju;function __(){if(ju)return Ga;ju=1;var r=zs(),t=wi(),e=function(o,l,h){for(var u=o,c;(c=u.next)!=null;u=c)if(c.key===l)return u.next=c.next,h||(c.next=o.next,o.next=c),c},i=function(o,l){if(o){var h=e(o,l);return h&&h.value}},s=function(o,l,h){var u=e(o,l);u?u.value=h:o.next={key:l,next:o.next,value:h}},n=function(o,l){return o?!!e(o,l):!1},a=function(o,l){if(o)return e(o,l,!0)};return Ga=function(){var l,h={assert:function(u){if(!h.has(u))throw new t("Side channel does not contain "+r(u))},delete:function(u){var c=l&&l.next,d=a(l,u);return d&&c&&c===d&&(l=void 0),!!d},get:function(u){return i(l,u)},has:function(u){return n(l,u)},set:function(u,c){l||(l={next:void 0}),s(l,u,c)}};return h},Ga}var Ha,Yu;function qu(){return Yu||(Yu=1,Ha=Object),Ha}var $a,Ku;function v_(){return Ku||(Ku=1,$a=Error),$a}var Va,Zu;function x_(){return Zu||(Zu=1,Va=EvalError),Va}var Xa,Ju;function b_(){return Ju||(Ju=1,Xa=RangeError),Xa}var Wa,Qu;function w_(){return Qu||(Qu=1,Wa=ReferenceError),Wa}var za,tc;function T_(){return tc||(tc=1,za=SyntaxError),za}var ja,ec;function E_(){return ec||(ec=1,ja=URIError),ja}var Ya,rc;function A_(){return rc||(rc=1,Ya=Math.abs),Ya}var qa,ic;function S_(){return ic||(ic=1,qa=Math.floor),qa}var Ka,sc;function C_(){return sc||(sc=1,Ka=Math.max),Ka}var Za,nc;function I_(){return nc||(nc=1,Za=Math.min),Za}var Ja,ac;function R_(){return ac||(ac=1,Ja=Math.pow),Ja}var Qa,oc;function P_(){return oc||(oc=1,Qa=Math.round),Qa}var to,lc;function M_(){return lc||(lc=1,to=Number.isNaN||function(t){return t!==t}),to}var eo,hc;function D_(){if(hc)return eo;hc=1;var r=M_();return eo=function(e){return r(e)||e===0?e:e<0?-1:1},eo}var ro,uc;function B_(){return uc||(uc=1,ro=Object.getOwnPropertyDescriptor),ro}var io,cc;function dc(){if(cc)return io;cc=1;var r=B_();if(r)try{r([],"length")}catch{r=null}return io=r,io}var so,fc;function O_(){if(fc)return so;fc=1;var r=Object.defineProperty||!1;if(r)try{r({},"a",{value:1})}catch{r=!1}return so=r,so}var no,pc;function L_(){return pc||(pc=1,no=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;t[e]=s;for(var n in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var a=Object.getOwnPropertySymbols(t);if(a.length!==1||a[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(t,e);if(o.value!==s||o.enumerable!==!0)return!1}return!0}),no}var ao,mc;function F_(){if(mc)return ao;mc=1;var r=typeof Symbol<"u"&&Symbol,t=L_();return ao=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},ao}var oo,gc;function yc(){return gc||(gc=1,oo=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),oo}var lo,_c;function vc(){if(_c)return lo;_c=1;var r=qu();return lo=r.getPrototypeOf||null,lo}var ho,xc;function N_(){if(xc)return ho;xc=1;var r="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,e=Math.max,i="[object Function]",s=function(l,h){for(var u=[],c=0;c<l.length;c+=1)u[c]=l[c];for(var d=0;d<h.length;d+=1)u[d+l.length]=h[d];return u},n=function(l,h){for(var u=[],c=h,d=0;c<l.length;c+=1,d+=1)u[d]=l[c];return u},a=function(o,l){for(var h="",u=0;u<o.length;u+=1)h+=o[u],u+1<o.length&&(h+=l);return h};return ho=function(l){var h=this;if(typeof h!="function"||t.apply(h)!==i)throw new TypeError(r+h);for(var u=n(arguments,1),c,d=function(){if(this instanceof c){var m=h.apply(this,s(u,arguments));return Object(m)===m?m:this}return h.apply(l,s(u,arguments))},p=e(0,h.length-u.length),f=[],g=0;g<p;g++)f[g]="$"+g;if(c=Function("binder","return function ("+a(f,",")+"){ return binder.apply(this,arguments); }")(d),h.prototype){var y=function(){};y.prototype=h.prototype,c.prototype=new y,y.prototype=null}return c},ho}var uo,bc;function js(){if(bc)return uo;bc=1;var r=N_();return uo=Function.prototype.bind||r,uo}var co,wc;function fo(){return wc||(wc=1,co=Function.prototype.call),co}var po,Tc;function Ec(){return Tc||(Tc=1,po=Function.prototype.apply),po}var mo,Ac;function U_(){return Ac||(Ac=1,mo=typeof Reflect<"u"&&Reflect&&Reflect.apply),mo}var go,Sc;function k_(){if(Sc)return go;Sc=1;var r=js(),t=Ec(),e=fo(),i=U_();return go=i||r.call(e,t),go}var yo,Cc;function Ic(){if(Cc)return yo;Cc=1;var r=js(),t=wi(),e=fo(),i=k_();return yo=function(n){if(n.length<1||typeof n[0]!="function")throw new t("a function is required");return i(r,e,n)},yo}var _o,Rc;function G_(){if(Rc)return _o;Rc=1;var r=Ic(),t=dc(),e;try{e=[].__proto__===Array.prototype}catch(a){if(!a||typeof a!="object"||!("code"in a)||a.code!=="ERR_PROTO_ACCESS")throw a}var i=!!e&&t&&t(Object.prototype,"__proto__"),s=Object,n=s.getPrototypeOf;return _o=i&&typeof i.get=="function"?r([i.get]):typeof n=="function"?function(o){return n(o==null?o:s(o))}:!1,_o}var vo,Pc;function H_(){if(Pc)return vo;Pc=1;var r=yc(),t=vc(),e=G_();return vo=r?function(s){return r(s)}:t?function(s){if(!s||typeof s!="object"&&typeof s!="function")throw new TypeError("getProto: not an object");return t(s)}:e?function(s){return e(s)}:null,vo}var xo,Mc;function $_(){if(Mc)return xo;Mc=1;var r=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=js();return xo=e.call(r,t),xo}var bo,Dc;function wo(){if(Dc)return bo;Dc=1;var r,t=qu(),e=v_(),i=x_(),s=b_(),n=w_(),a=T_(),o=wi(),l=E_(),h=A_(),u=S_(),c=C_(),d=I_(),p=R_(),f=P_(),g=D_(),y=Function,m=function(L){try{return y('"use strict"; return ('+L+").constructor;")()}catch{}},_=dc(),v=O_(),x=function(){throw new o},b=_?function(){try{return arguments.callee,x}catch{try{return _(arguments,"callee").get}catch{return x}}}():x,R=F_()(),w=H_(),D=vc(),U=yc(),M=Ec(),F=fo(),S={},I=typeof Uint8Array>"u"||!w?r:w(Uint8Array),H={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?r:ArrayBuffer,"%ArrayIteratorPrototype%":R&&w?w([][Symbol.iterator]()):r,"%AsyncFromSyncIteratorPrototype%":r,"%AsyncFunction%":S,"%AsyncGenerator%":S,"%AsyncGeneratorFunction%":S,"%AsyncIteratorPrototype%":S,"%Atomics%":typeof Atomics>"u"?r:Atomics,"%BigInt%":typeof BigInt>"u"?r:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?r:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?r:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?r:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":e,"%eval%":eval,"%EvalError%":i,"%Float32Array%":typeof Float32Array>"u"?r:Float32Array,"%Float64Array%":typeof Float64Array>"u"?r:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?r:FinalizationRegistry,"%Function%":y,"%GeneratorFunction%":S,"%Int8Array%":typeof Int8Array>"u"?r:Int8Array,"%Int16Array%":typeof Int16Array>"u"?r:Int16Array,"%Int32Array%":typeof Int32Array>"u"?r:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":R&&w?w(w([][Symbol.iterator]())):r,"%JSON%":typeof JSON=="object"?JSON:r,"%Map%":typeof Map>"u"?r:Map,"%MapIteratorPrototype%":typeof Map>"u"||!R||!w?r:w(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":t,"%Object.getOwnPropertyDescriptor%":_,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?r:Promise,"%Proxy%":typeof Proxy>"u"?r:Proxy,"%RangeError%":s,"%ReferenceError%":n,"%Reflect%":typeof Reflect>"u"?r:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?r:Set,"%SetIteratorPrototype%":typeof Set>"u"||!R||!w?r:w(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":R&&w?w(""[Symbol.iterator]()):r,"%Symbol%":R?Symbol:r,"%SyntaxError%":a,"%ThrowTypeError%":b,"%TypedArray%":I,"%TypeError%":o,"%Uint8Array%":typeof Uint8Array>"u"?r:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?r:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?r:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?r:Uint32Array,"%URIError%":l,"%WeakMap%":typeof WeakMap>"u"?r:WeakMap,"%WeakRef%":typeof WeakRef>"u"?r:WeakRef,"%WeakSet%":typeof WeakSet>"u"?r:WeakSet,"%Function.prototype.call%":F,"%Function.prototype.apply%":M,"%Object.defineProperty%":v,"%Object.getPrototypeOf%":D,"%Math.abs%":h,"%Math.floor%":u,"%Math.max%":c,"%Math.min%":d,"%Math.pow%":p,"%Math.round%":f,"%Math.sign%":g,"%Reflect.getPrototypeOf%":U};if(w)try{null.error}catch(L){var j=w(w(L));H["%Error.prototype%"]=j}var A=function L(Y){var tt;if(Y==="%AsyncFunction%")tt=m("async function () {}");else if(Y==="%GeneratorFunction%")tt=m("function* () {}");else if(Y==="%AsyncGeneratorFunction%")tt=m("async function* () {}");else if(Y==="%AsyncGenerator%"){var st=L("%AsyncGeneratorFunction%");st&&(tt=st.prototype)}else if(Y==="%AsyncIteratorPrototype%"){var lt=L("%AsyncGenerator%");lt&&w&&(tt=w(lt.prototype))}return H[Y]=tt,tt},C={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},T=js(),k=$_(),E=T.call(F,Array.prototype.concat),P=T.call(M,Array.prototype.splice),B=T.call(F,String.prototype.replace),G=T.call(F,String.prototype.slice),z=T.call(F,RegExp.prototype.exec),$=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,K=/\\(\\)?/g,Q=function(Y){var tt=G(Y,0,1),st=G(Y,-1);if(tt==="%"&&st!=="%")throw new a("invalid intrinsic syntax, expected closing `%`");if(st==="%"&&tt!=="%")throw new a("invalid intrinsic syntax, expected opening `%`");var lt=[];return B(Y,$,function(At,ht,at,$t){lt[lt.length]=at?B($t,K,"$1"):ht||At}),lt},O=function(Y,tt){var st=Y,lt;if(k(C,st)&&(lt=C[st],st="%"+lt[0]+"%"),k(H,st)){var At=H[st];if(At===S&&(At=A(st)),typeof At>"u"&&!tt)throw new o("intrinsic "+Y+" exists, but is not available. Please file an issue!");return{alias:lt,name:st,value:At}}throw new a("intrinsic "+Y+" does not exist!")};return bo=function(Y,tt){if(typeof Y!="string"||Y.length===0)throw new o("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof tt!="boolean")throw new o('"allowMissing" argument must be a boolean');if(z(/^%?[^%]*%?$/,Y)===null)throw new a("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var st=Q(Y),lt=st.length>0?st[0]:"",At=O("%"+lt+"%",tt),ht=At.name,at=At.value,$t=!1,Ce=At.alias;Ce&&(lt=Ce[0],P(st,E([0,1],Ce)));for(var ri=1,ii=!0;ri<st.length;ri+=1){var $e=st[ri],Fi=G($e,0,1),Ni=G($e,-1);if((Fi==='"'||Fi==="'"||Fi==="`"||Ni==='"'||Ni==="'"||Ni==="`")&&Fi!==Ni)throw new a("property names with quotes must have matching quotes");if(($e==="constructor"||!ii)&&($t=!0),lt+="."+$e,ht="%"+lt+"%",k(H,ht))at=H[ht];else if(at!=null){if(!($e in at)){if(!tt)throw new o("base intrinsic for "+Y+" exists, but the property is not available.");return}if(_&&ri+1>=st.length){var Ui=_(at,$e);ii=!!Ui,ii&&"get"in Ui&&!("originalValue"in Ui.get)?at=Ui.get:at=at[$e]}else ii=k(at,$e),at=at[$e];ii&&!$t&&(H[ht]=at)}}return at},bo}var To,Bc;function Oc(){if(Bc)return To;Bc=1;var r=wo(),t=Ic(),e=t([r("%String.prototype.indexOf%")]);return To=function(s,n){var a=r(s,!!n);return typeof a=="function"&&e(s,".prototype.")>-1?t([a]):a},To}var Eo,Lc;function Fc(){if(Lc)return Eo;Lc=1;var r=wo(),t=Oc(),e=zs(),i=wi(),s=r("%Map%",!0),n=t("Map.prototype.get",!0),a=t("Map.prototype.set",!0),o=t("Map.prototype.has",!0),l=t("Map.prototype.delete",!0),h=t("Map.prototype.size",!0);return Eo=!!s&&function(){var c,d={assert:function(p){if(!d.has(p))throw new i("Side channel does not contain "+e(p))},delete:function(p){if(c){var f=l(c,p);return h(c)===0&&(c=void 0),f}return!1},get:function(p){if(c)return n(c,p)},has:function(p){return c?o(c,p):!1},set:function(p,f){c||(c=new s),a(c,p,f)}};return d},Eo}var Ao,Nc;function V_(){if(Nc)return Ao;Nc=1;var r=wo(),t=Oc(),e=zs(),i=Fc(),s=wi(),n=r("%WeakMap%",!0),a=t("WeakMap.prototype.get",!0),o=t("WeakMap.prototype.set",!0),l=t("WeakMap.prototype.has",!0),h=t("WeakMap.prototype.delete",!0);return Ao=n?function(){var c,d,p={assert:function(f){if(!p.has(f))throw new s("Side channel does not contain "+e(f))},delete:function(f){if(n&&f&&(typeof f=="object"||typeof f=="function")){if(c)return h(c,f)}else if(i&&d)return d.delete(f);return!1},get:function(f){return n&&f&&(typeof f=="object"||typeof f=="function")&&c?a(c,f):d&&d.get(f)},has:function(f){return n&&f&&(typeof f=="object"||typeof f=="function")&&c?l(c,f):!!d&&d.has(f)},set:function(f,g){n&&f&&(typeof f=="object"||typeof f=="function")?(c||(c=new n),o(c,f,g)):i&&(d||(d=i()),d.set(f,g))}};return p}:i,Ao}var So,Uc;function X_(){if(Uc)return So;Uc=1;var r=wi(),t=zs(),e=__(),i=Fc(),s=V_(),n=s||i||e;return So=function(){var o,l={assert:function(h){if(!l.has(h))throw new r("Side channel does not contain "+t(h))},delete:function(h){return!!o&&o.delete(h)},get:function(h){return o&&o.get(h)},has:function(h){return!!o&&o.has(h)},set:function(h,u){o||(o=n()),o.set(h,u)}};return l},So}var Co,kc;function Io(){if(kc)return Co;kc=1;var r=String.prototype.replace,t=/%20/g,e={RFC1738:"RFC1738",RFC3986:"RFC3986"};return Co={default:e.RFC3986,formatters:{RFC1738:function(i){return r.call(i,t,"+")},RFC3986:function(i){return String(i)}},RFC1738:e.RFC1738,RFC3986:e.RFC3986},Co}var Ro,Gc;function Hc(){if(Gc)return Ro;Gc=1;var r=Io(),t=Object.prototype.hasOwnProperty,e=Array.isArray,i=function(){for(var y=[],m=0;m<256;++m)y.push("%"+((m<16?"0":"")+m.toString(16)).toUpperCase());return y}(),s=function(m){for(;m.length>1;){var _=m.pop(),v=_.obj[_.prop];if(e(v)){for(var x=[],b=0;b<v.length;++b)typeof v[b]<"u"&&x.push(v[b]);_.obj[_.prop]=x}}},n=function(m,_){for(var v=_&&_.plainObjects?{__proto__:null}:{},x=0;x<m.length;++x)typeof m[x]<"u"&&(v[x]=m[x]);return v},a=function y(m,_,v){if(!_)return m;if(typeof _!="object"&&typeof _!="function"){if(e(m))m.push(_);else if(m&&typeof m=="object")(v&&(v.plainObjects||v.allowPrototypes)||!t.call(Object.prototype,_))&&(m[_]=!0);else return[m,_];return m}if(!m||typeof m!="object")return[m].concat(_);var x=m;return e(m)&&!e(_)&&(x=n(m,v)),e(m)&&e(_)?(_.forEach(function(b,R){if(t.call(m,R)){var w=m[R];w&&typeof w=="object"&&b&&typeof b=="object"?m[R]=y(w,b,v):m.push(b)}else m[R]=b}),m):Object.keys(_).reduce(function(b,R){var w=_[R];return t.call(b,R)?b[R]=y(b[R],w,v):b[R]=w,b},x)},o=function(m,_){return Object.keys(_).reduce(function(v,x){return v[x]=_[x],v},m)},l=function(y,m,_){var v=y.replace(/\+/g," ");if(_==="iso-8859-1")return v.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(v)}catch{return v}},h=1024,u=function(m,_,v,x,b){if(m.length===0)return m;var R=m;if(typeof m=="symbol"?R=Symbol.prototype.toString.call(m):typeof m!="string"&&(R=String(m)),v==="iso-8859-1")return escape(R).replace(/%u[0-9a-f]{4}/gi,function(I){return"%26%23"+parseInt(I.slice(2),16)+"%3B"});for(var w="",D=0;D<R.length;D+=h){for(var U=R.length>=h?R.slice(D,D+h):R,M=[],F=0;F<U.length;++F){var S=U.charCodeAt(F);if(S===45||S===46||S===95||S===126||S>=48&&S<=57||S>=65&&S<=90||S>=97&&S<=122||b===r.RFC1738&&(S===40||S===41)){M[M.length]=U.charAt(F);continue}if(S<128){M[M.length]=i[S];continue}if(S<2048){M[M.length]=i[192|S>>6]+i[128|S&63];continue}if(S<55296||S>=57344){M[M.length]=i[224|S>>12]+i[128|S>>6&63]+i[128|S&63];continue}F+=1,S=65536+((S&1023)<<10|U.charCodeAt(F)&1023),M[M.length]=i[240|S>>18]+i[128|S>>12&63]+i[128|S>>6&63]+i[128|S&63]}w+=M.join("")}return w},c=function(m){for(var _=[{obj:{o:m},prop:"o"}],v=[],x=0;x<_.length;++x)for(var b=_[x],R=b.obj[b.prop],w=Object.keys(R),D=0;D<w.length;++D){var U=w[D],M=R[U];typeof M=="object"&&M!==null&&v.indexOf(M)===-1&&(_.push({obj:R,prop:U}),v.push(M))}return s(_),m},d=function(m){return Object.prototype.toString.call(m)==="[object RegExp]"},p=function(m){return!m||typeof m!="object"?!1:!!(m.constructor&&m.constructor.isBuffer&&m.constructor.isBuffer(m))},f=function(m,_){return[].concat(m,_)},g=function(m,_){if(e(m)){for(var v=[],x=0;x<m.length;x+=1)v.push(_(m[x]));return v}return _(m)};return Ro={arrayToObject:n,assign:o,combine:f,compact:c,decode:l,encode:u,isBuffer:p,isRegExp:d,maybeMap:g,merge:a},Ro}var Po,$c;function W_(){if($c)return Po;$c=1;var r=X_(),t=Hc(),e=Io(),i=Object.prototype.hasOwnProperty,s={brackets:function(y){return y+"[]"},comma:"comma",indices:function(y,m){return y+"["+m+"]"},repeat:function(y){return y}},n=Array.isArray,a=Array.prototype.push,o=function(g,y){a.apply(g,n(y)?y:[y])},l=Date.prototype.toISOString,h=e.default,u={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:t.encode,encodeValuesOnly:!1,filter:void 0,format:h,formatter:e.formatters[h],indices:!1,serializeDate:function(y){return l.call(y)},skipNulls:!1,strictNullHandling:!1},c=function(y){return typeof y=="string"||typeof y=="number"||typeof y=="boolean"||typeof y=="symbol"||typeof y=="bigint"},d={},p=function g(y,m,_,v,x,b,R,w,D,U,M,F,S,I,H,j,A,C){for(var T=y,k=C,E=0,P=!1;(k=k.get(d))!==void 0&&!P;){var B=k.get(y);if(E+=1,typeof B<"u"){if(B===E)throw new RangeError("Cyclic object value");P=!0}typeof k.get(d)>"u"&&(E=0)}if(typeof U=="function"?T=U(m,T):T instanceof Date?T=S(T):_==="comma"&&n(T)&&(T=t.maybeMap(T,function(ht){return ht instanceof Date?S(ht):ht})),T===null){if(b)return D&&!j?D(m,u.encoder,A,"key",I):m;T=""}if(c(T)||t.isBuffer(T)){if(D){var G=j?m:D(m,u.encoder,A,"key",I);return[H(G)+"="+H(D(T,u.encoder,A,"value",I))]}return[H(m)+"="+H(String(T))]}var z=[];if(typeof T>"u")return z;var $;if(_==="comma"&&n(T))j&&D&&(T=t.maybeMap(T,D)),$=[{value:T.length>0?T.join(",")||null:void 0}];else if(n(U))$=U;else{var K=Object.keys(T);$=M?K.sort(M):K}var Q=w?String(m).replace(/\./g,"%2E"):String(m),O=v&&n(T)&&T.length===1?Q+"[]":Q;if(x&&n(T)&&T.length===0)return O+"[]";for(var L=0;L<$.length;++L){var Y=$[L],tt=typeof Y=="object"&&Y&&typeof Y.value<"u"?Y.value:T[Y];if(!(R&&tt===null)){var st=F&&w?String(Y).replace(/\./g,"%2E"):String(Y),lt=n(T)?typeof _=="function"?_(O,st):O:O+(F?"."+st:"["+st+"]");C.set(y,E);var At=r();At.set(d,C),o(z,g(tt,lt,_,v,x,b,R,w,_==="comma"&&j&&n(T)?null:D,U,M,F,S,I,H,j,A,At))}}return z},f=function(y){if(!y)return u;if(typeof y.allowEmptyArrays<"u"&&typeof y.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof y.encodeDotInKeys<"u"&&typeof y.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(y.encoder!==null&&typeof y.encoder<"u"&&typeof y.encoder!="function")throw new TypeError("Encoder has to be a function.");var m=y.charset||u.charset;if(typeof y.charset<"u"&&y.charset!=="utf-8"&&y.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var _=e.default;if(typeof y.format<"u"){if(!i.call(e.formatters,y.format))throw new TypeError("Unknown format option provided.");_=y.format}var v=e.formatters[_],x=u.filter;(typeof y.filter=="function"||n(y.filter))&&(x=y.filter);var b;if(y.arrayFormat in s?b=y.arrayFormat:"indices"in y?b=y.indices?"indices":"repeat":b=u.arrayFormat,"commaRoundTrip"in y&&typeof y.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var R=typeof y.allowDots>"u"?y.encodeDotInKeys===!0?!0:u.allowDots:!!y.allowDots;return{addQueryPrefix:typeof y.addQueryPrefix=="boolean"?y.addQueryPrefix:u.addQueryPrefix,allowDots:R,allowEmptyArrays:typeof y.allowEmptyArrays=="boolean"?!!y.allowEmptyArrays:u.allowEmptyArrays,arrayFormat:b,charset:m,charsetSentinel:typeof y.charsetSentinel=="boolean"?y.charsetSentinel:u.charsetSentinel,commaRoundTrip:!!y.commaRoundTrip,delimiter:typeof y.delimiter>"u"?u.delimiter:y.delimiter,encode:typeof y.encode=="boolean"?y.encode:u.encode,encodeDotInKeys:typeof y.encodeDotInKeys=="boolean"?y.encodeDotInKeys:u.encodeDotInKeys,encoder:typeof y.encoder=="function"?y.encoder:u.encoder,encodeValuesOnly:typeof y.encodeValuesOnly=="boolean"?y.encodeValuesOnly:u.encodeValuesOnly,filter:x,format:_,formatter:v,serializeDate:typeof y.serializeDate=="function"?y.serializeDate:u.serializeDate,skipNulls:typeof y.skipNulls=="boolean"?y.skipNulls:u.skipNulls,sort:typeof y.sort=="function"?y.sort:null,strictNullHandling:typeof y.strictNullHandling=="boolean"?y.strictNullHandling:u.strictNullHandling}};return Po=function(g,y){var m=g,_=f(y),v,x;typeof _.filter=="function"?(x=_.filter,m=x("",m)):n(_.filter)&&(x=_.filter,v=x);var b=[];if(typeof m!="object"||m===null)return"";var R=s[_.arrayFormat],w=R==="comma"&&_.commaRoundTrip;v||(v=Object.keys(m)),_.sort&&v.sort(_.sort);for(var D=r(),U=0;U<v.length;++U){var M=v[U],F=m[M];_.skipNulls&&F===null||o(b,p(F,M,R,w,_.allowEmptyArrays,_.strictNullHandling,_.skipNulls,_.encodeDotInKeys,_.encode?_.encoder:null,_.filter,_.sort,_.allowDots,_.serializeDate,_.format,_.formatter,_.encodeValuesOnly,_.charset,D))}var S=b.join(_.delimiter),I=_.addQueryPrefix===!0?"?":"";return _.charsetSentinel&&(_.charset==="iso-8859-1"?I+="utf8=%26%2310003%3B&":I+="utf8=%E2%9C%93&"),S.length>0?I+S:""},Po}var Mo,Vc;function z_(){if(Vc)return Mo;Vc=1;var r=Hc(),t=Object.prototype.hasOwnProperty,e=Array.isArray,i={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:r.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},s=function(d){return d.replace(/&#(\d+);/g,function(p,f){return String.fromCharCode(parseInt(f,10))})},n=function(d,p,f){if(d&&typeof d=="string"&&p.comma&&d.indexOf(",")>-1)return d.split(",");if(p.throwOnLimitExceeded&&f>=p.arrayLimit)throw new RangeError("Array limit exceeded. Only "+p.arrayLimit+" element"+(p.arrayLimit===1?"":"s")+" allowed in an array.");return d},a="utf8=%26%2310003%3B",o="utf8=%E2%9C%93",l=function(p,f){var g={__proto__:null},y=f.ignoreQueryPrefix?p.replace(/^\?/,""):p;y=y.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var m=f.parameterLimit===1/0?void 0:f.parameterLimit,_=y.split(f.delimiter,f.throwOnLimitExceeded?m+1:m);if(f.throwOnLimitExceeded&&_.length>m)throw new RangeError("Parameter limit exceeded. Only "+m+" parameter"+(m===1?"":"s")+" allowed.");var v=-1,x,b=f.charset;if(f.charsetSentinel)for(x=0;x<_.length;++x)_[x].indexOf("utf8=")===0&&(_[x]===o?b="utf-8":_[x]===a&&(b="iso-8859-1"),v=x,x=_.length);for(x=0;x<_.length;++x)if(x!==v){var R=_[x],w=R.indexOf("]="),D=w===-1?R.indexOf("="):w+1,U,M;D===-1?(U=f.decoder(R,i.decoder,b,"key"),M=f.strictNullHandling?null:""):(U=f.decoder(R.slice(0,D),i.decoder,b,"key"),M=r.maybeMap(n(R.slice(D+1),f,e(g[U])?g[U].length:0),function(S){return f.decoder(S,i.decoder,b,"value")})),M&&f.interpretNumericEntities&&b==="iso-8859-1"&&(M=s(String(M))),R.indexOf("[]=")>-1&&(M=e(M)?[M]:M);var F=t.call(g,U);F&&f.duplicates==="combine"?g[U]=r.combine(g[U],M):(!F||f.duplicates==="last")&&(g[U]=M)}return g},h=function(d,p,f,g){var y=0;if(d.length>0&&d[d.length-1]==="[]"){var m=d.slice(0,-1).join("");y=Array.isArray(p)&&p[m]?p[m].length:0}for(var _=g?p:n(p,f,y),v=d.length-1;v>=0;--v){var x,b=d[v];if(b==="[]"&&f.parseArrays)x=f.allowEmptyArrays&&(_===""||f.strictNullHandling&&_===null)?[]:r.combine([],_);else{x=f.plainObjects?{__proto__:null}:{};var R=b.charAt(0)==="["&&b.charAt(b.length-1)==="]"?b.slice(1,-1):b,w=f.decodeDotInKeys?R.replace(/%2E/g,"."):R,D=parseInt(w,10);!f.parseArrays&&w===""?x={0:_}:!isNaN(D)&&b!==w&&String(D)===w&&D>=0&&f.parseArrays&&D<=f.arrayLimit?(x=[],x[D]=_):w!=="__proto__"&&(x[w]=_)}_=x}return _},u=function(p,f,g,y){if(p){var m=g.allowDots?p.replace(/\.([^.[]+)/g,"[$1]"):p,_=/(\[[^[\]]*])/,v=/(\[[^[\]]*])/g,x=g.depth>0&&_.exec(m),b=x?m.slice(0,x.index):m,R=[];if(b){if(!g.plainObjects&&t.call(Object.prototype,b)&&!g.allowPrototypes)return;R.push(b)}for(var w=0;g.depth>0&&(x=v.exec(m))!==null&&w<g.depth;){if(w+=1,!g.plainObjects&&t.call(Object.prototype,x[1].slice(1,-1))&&!g.allowPrototypes)return;R.push(x[1])}if(x){if(g.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+g.depth+" and strictDepth is true");R.push("["+m.slice(x.index)+"]")}return h(R,f,g,y)}},c=function(p){if(!p)return i;if(typeof p.allowEmptyArrays<"u"&&typeof p.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof p.decodeDotInKeys<"u"&&typeof p.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(p.decoder!==null&&typeof p.decoder<"u"&&typeof p.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof p.charset<"u"&&p.charset!=="utf-8"&&p.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(typeof p.throwOnLimitExceeded<"u"&&typeof p.throwOnLimitExceeded!="boolean")throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var f=typeof p.charset>"u"?i.charset:p.charset,g=typeof p.duplicates>"u"?i.duplicates:p.duplicates;if(g!=="combine"&&g!=="first"&&g!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var y=typeof p.allowDots>"u"?p.decodeDotInKeys===!0?!0:i.allowDots:!!p.allowDots;return{allowDots:y,allowEmptyArrays:typeof p.allowEmptyArrays=="boolean"?!!p.allowEmptyArrays:i.allowEmptyArrays,allowPrototypes:typeof p.allowPrototypes=="boolean"?p.allowPrototypes:i.allowPrototypes,allowSparse:typeof p.allowSparse=="boolean"?p.allowSparse:i.allowSparse,arrayLimit:typeof p.arrayLimit=="number"?p.arrayLimit:i.arrayLimit,charset:f,charsetSentinel:typeof p.charsetSentinel=="boolean"?p.charsetSentinel:i.charsetSentinel,comma:typeof p.comma=="boolean"?p.comma:i.comma,decodeDotInKeys:typeof p.decodeDotInKeys=="boolean"?p.decodeDotInKeys:i.decodeDotInKeys,decoder:typeof p.decoder=="function"?p.decoder:i.decoder,delimiter:typeof p.delimiter=="string"||r.isRegExp(p.delimiter)?p.delimiter:i.delimiter,depth:typeof p.depth=="number"||p.depth===!1?+p.depth:i.depth,duplicates:g,ignoreQueryPrefix:p.ignoreQueryPrefix===!0,interpretNumericEntities:typeof p.interpretNumericEntities=="boolean"?p.interpretNumericEntities:i.interpretNumericEntities,parameterLimit:typeof p.parameterLimit=="number"?p.parameterLimit:i.parameterLimit,parseArrays:p.parseArrays!==!1,plainObjects:typeof p.plainObjects=="boolean"?p.plainObjects:i.plainObjects,strictDepth:typeof p.strictDepth=="boolean"?!!p.strictDepth:i.strictDepth,strictNullHandling:typeof p.strictNullHandling=="boolean"?p.strictNullHandling:i.strictNullHandling,throwOnLimitExceeded:typeof p.throwOnLimitExceeded=="boolean"?p.throwOnLimitExceeded:!1}};return Mo=function(d,p){var f=c(p);if(d===""||d===null||typeof d>"u")return f.plainObjects?{__proto__:null}:{};for(var g=typeof d=="string"?l(d,f):d,y=f.plainObjects?{__proto__:null}:{},m=Object.keys(g),_=0;_<m.length;++_){var v=m[_],x=u(v,g[v],f,typeof d=="string");y=r.merge(y,x,f)}return f.allowSparse===!0?y:r.compact(y)},Mo}var Do,Xc;function j_(){if(Xc)return Do;Xc=1;var r=W_(),t=z_(),e=Io();return Do={formats:e,parse:t,stringify:r},Do}var Wc;function Y_(){if(Wc)return $r;Wc=1;var r=g_();function t(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var e=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,s=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,n=["<",">",'"',"`"," ","\r",`
5
+ `," "],a=["{","}","|","\\","^","`"].concat(n),o=["'"].concat(a),l=["%","/","?",";","#"].concat(o),h=["/","?","#"],u=255,c=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,p={javascript:!0,"javascript:":!0},f={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=j_();function m(b,R,w){if(b&&typeof b=="object"&&b instanceof t)return b;var D=new t;return D.parse(b,R,w),D}t.prototype.parse=function(b,R,w){if(typeof b!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof b);var D=b.indexOf("?"),U=D!==-1&&D<b.indexOf("#")?"?":"#",M=b.split(U),F=/\\/g;M[0]=M[0].replace(F,"/"),b=M.join(U);var S=b;if(S=S.trim(),!w&&b.split("#").length===1){var I=s.exec(S);if(I)return this.path=S,this.href=S,this.pathname=I[1],I[2]?(this.search=I[2],R?this.query=y.parse(this.search.substr(1)):this.query=this.search.substr(1)):R&&(this.search="",this.query={}),this}var H=e.exec(S);if(H){H=H[0];var j=H.toLowerCase();this.protocol=j,S=S.substr(H.length)}if(w||H||S.match(/^\/\/[^@/]+@[^@/]+/)){var A=S.substr(0,2)==="//";A&&!(H&&f[H])&&(S=S.substr(2),this.slashes=!0)}if(!f[H]&&(A||H&&!g[H])){for(var C=-1,T=0;T<h.length;T++){var k=S.indexOf(h[T]);k!==-1&&(C===-1||k<C)&&(C=k)}var E,P;C===-1?P=S.lastIndexOf("@"):P=S.lastIndexOf("@",C),P!==-1&&(E=S.slice(0,P),S=S.slice(P+1),this.auth=decodeURIComponent(E)),C=-1;for(var T=0;T<l.length;T++){var k=S.indexOf(l[T]);k!==-1&&(C===-1||k<C)&&(C=k)}C===-1&&(C=S.length),this.host=S.slice(0,C),S=S.slice(C),this.parseHost(),this.hostname=this.hostname||"";var B=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!B)for(var G=this.hostname.split(/\./),T=0,z=G.length;T<z;T++){var $=G[T];if($&&!$.match(c)){for(var K="",Q=0,O=$.length;Q<O;Q++)$.charCodeAt(Q)>127?K+="x":K+=$[Q];if(!K.match(c)){var L=G.slice(0,T),Y=G.slice(T+1),tt=$.match(d);tt&&(L.push(tt[1]),Y.unshift(tt[2])),Y.length&&(S="/"+Y.join(".")+S),this.hostname=L.join(".");break}}}this.hostname.length>u?this.hostname="":this.hostname=this.hostname.toLowerCase(),B||(this.hostname=r.toASCII(this.hostname));var st=this.port?":"+this.port:"",lt=this.hostname||"";this.host=lt+st,this.href+=this.host,B&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),S[0]!=="/"&&(S="/"+S))}if(!p[j])for(var T=0,z=o.length;T<z;T++){var At=o[T];if(S.indexOf(At)!==-1){var ht=encodeURIComponent(At);ht===At&&(ht=escape(At)),S=S.split(At).join(ht)}}var at=S.indexOf("#");at!==-1&&(this.hash=S.substr(at),S=S.slice(0,at));var $t=S.indexOf("?");if($t!==-1?(this.search=S.substr($t),this.query=S.substr($t+1),R&&(this.query=y.parse(this.query)),S=S.slice(0,$t)):R&&(this.search="",this.query={}),S&&(this.pathname=S),g[j]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var st=this.pathname||"",Ce=this.search||"";this.path=st+Ce}return this.href=this.format(),this};function _(b){return typeof b=="string"&&(b=m(b)),b instanceof t?b.format():t.prototype.format.call(b)}t.prototype.format=function(){var b=this.auth||"";b&&(b=encodeURIComponent(b),b=b.replace(/%3A/i,":"),b+="@");var R=this.protocol||"",w=this.pathname||"",D=this.hash||"",U=!1,M="";this.host?U=b+this.host:this.hostname&&(U=b+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(U+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(M=y.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var F=this.search||M&&"?"+M||"";return R&&R.substr(-1)!==":"&&(R+=":"),this.slashes||(!R||g[R])&&U!==!1?(U="//"+(U||""),w&&w.charAt(0)!=="/"&&(w="/"+w)):U||(U=""),D&&D.charAt(0)!=="#"&&(D="#"+D),F&&F.charAt(0)!=="?"&&(F="?"+F),w=w.replace(/[?#]/g,function(S){return encodeURIComponent(S)}),F=F.replace("#","%23"),R+U+w+F+D};function v(b,R){return m(b,!1,!0).resolve(R)}t.prototype.resolve=function(b){return this.resolveObject(m(b,!1,!0)).format()};function x(b,R){return b?m(b,!1,!0).resolveObject(R):R}return t.prototype.resolveObject=function(b){if(typeof b=="string"){var R=new t;R.parse(b,!1,!0),b=R}for(var w=new t,D=Object.keys(this),U=0;U<D.length;U++){var M=D[U];w[M]=this[M]}if(w.hash=b.hash,b.href==="")return w.href=w.format(),w;if(b.slashes&&!b.protocol){for(var F=Object.keys(b),S=0;S<F.length;S++){var I=F[S];I!=="protocol"&&(w[I]=b[I])}return g[w.protocol]&&w.hostname&&!w.pathname&&(w.pathname="/",w.path=w.pathname),w.href=w.format(),w}if(b.protocol&&b.protocol!==w.protocol){if(!g[b.protocol]){for(var H=Object.keys(b),j=0;j<H.length;j++){var A=H[j];w[A]=b[A]}return w.href=w.format(),w}if(w.protocol=b.protocol,!b.host&&!f[b.protocol]){for(var z=(b.pathname||"").split("/");z.length&&!(b.host=z.shift()););b.host||(b.host=""),b.hostname||(b.hostname=""),z[0]!==""&&z.unshift(""),z.length<2&&z.unshift(""),w.pathname=z.join("/")}else w.pathname=b.pathname;if(w.search=b.search,w.query=b.query,w.host=b.host||"",w.auth=b.auth,w.hostname=b.hostname||b.host,w.port=b.port,w.pathname||w.search){var C=w.pathname||"",T=w.search||"";w.path=C+T}return w.slashes=w.slashes||b.slashes,w.href=w.format(),w}var k=w.pathname&&w.pathname.charAt(0)==="/",E=b.host||b.pathname&&b.pathname.charAt(0)==="/",P=E||k||w.host&&b.pathname,B=P,G=w.pathname&&w.pathname.split("/")||[],z=b.pathname&&b.pathname.split("/")||[],$=w.protocol&&!g[w.protocol];if($&&(w.hostname="",w.port=null,w.host&&(G[0]===""?G[0]=w.host:G.unshift(w.host)),w.host="",b.protocol&&(b.hostname=null,b.port=null,b.host&&(z[0]===""?z[0]=b.host:z.unshift(b.host)),b.host=null),P=P&&(z[0]===""||G[0]==="")),E)w.host=b.host||b.host===""?b.host:w.host,w.hostname=b.hostname||b.hostname===""?b.hostname:w.hostname,w.search=b.search,w.query=b.query,G=z;else if(z.length)G||(G=[]),G.pop(),G=G.concat(z),w.search=b.search,w.query=b.query;else if(b.search!=null){if($){w.host=G.shift(),w.hostname=w.host;var K=w.host&&w.host.indexOf("@")>0?w.host.split("@"):!1;K&&(w.auth=K.shift(),w.hostname=K.shift(),w.host=w.hostname)}return w.search=b.search,w.query=b.query,(w.pathname!==null||w.search!==null)&&(w.path=(w.pathname?w.pathname:"")+(w.search?w.search:"")),w.href=w.format(),w}if(!G.length)return w.pathname=null,w.search?w.path="/"+w.search:w.path=null,w.href=w.format(),w;for(var Q=G.slice(-1)[0],O=(w.host||b.host||G.length>1)&&(Q==="."||Q==="..")||Q==="",L=0,Y=G.length;Y>=0;Y--)Q=G[Y],Q==="."?G.splice(Y,1):Q===".."?(G.splice(Y,1),L++):L&&(G.splice(Y,1),L--);if(!P&&!B)for(;L--;L)G.unshift("..");P&&G[0]!==""&&(!G[0]||G[0].charAt(0)!=="/")&&G.unshift(""),O&&G.join("/").substr(-1)!=="/"&&G.push("");var tt=G[0]===""||G[0]&&G[0].charAt(0)==="/";if($){w.hostname=tt?"":G.length?G.shift():"",w.host=w.hostname;var K=w.host&&w.host.indexOf("@")>0?w.host.split("@"):!1;K&&(w.auth=K.shift(),w.hostname=K.shift(),w.host=w.hostname)}return P=P||w.host&&G.length,P&&!tt&&G.unshift(""),G.length>0?w.pathname=G.join("/"):(w.pathname=null,w.path=null),(w.pathname!==null||w.search!==null)&&(w.path=(w.pathname?w.pathname:"")+(w.search?w.search:"")),w.auth=b.auth||w.auth,w.slashes=w.slashes||b.slashes,w.href=w.format(),w},t.prototype.parseHost=function(){var b=this.host,R=i.exec(b);R&&(R=R[0],R!==":"&&(this.port=R.substr(1)),b=b.substr(0,b.length-R.length)),b&&(this.hostname=b)},$r.parse=m,$r.resolve=v,$r.resolveObject=x,$r.format=_,$r.Url=t,$r}var Bo=Y_();const zc={};function ct(r,t,e=3){if(zc[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
6
6
  Deprecated since v${r}`):(i=i.split(`
7
7
  `).splice(e).join(`
8
8
  `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
9
9
  Deprecated since v${r}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
10
- Deprecated since v${r}`),console.warn(i))),od[t]=!0}const Gx={get parse(){return et("7.3.0","utils.url.parse is deprecated, use native URL API instead."),Nx},get format(){return et("7.3.0","utils.url.format is deprecated, use native URL API instead."),kx},get resolve(){return et("7.3.0","utils.url.resolve is deprecated, use native URL API instead."),Ux}};function Pe(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function gs(r){return r.split("?")[0].split("#")[0]}function Hx(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $x(r,t,e){return r.replace(new RegExp(Hx(t),"g"),e)}function Vx(r,t){let e="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const Ut={toPosix(r){return $x(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){Pe(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(Pe(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=gs(this.toPosix(t??z.ADAPTER.getBaseUrl())),s=gs(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?Ut.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(Pe(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=Vx(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Pe(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let t;for(let e=0;e<r.length;++e){const i=r[e];if(Pe(i),i.length>0)if(t===void 0)t=i;else{const s=r[e-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(Pe(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!s){i=a;break}}else s=!1;return i===-1?e?"/":this.isUrl(o)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){Pe(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){Pe(r),t&&Pe(t),r=gs(this.toPosix(r));let e=0,i=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){Pe(r),r=gs(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}i===-1&&(s=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){Pe(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=gs(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let s;t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,o=0,a=-1,l=!0,h=r.length-1,u=0;for(;h>=s;--h){if(e=r.charCodeAt(h),e===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),e===46?n===-1?n=h:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||a===-1||u===0||u===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?t.base=t.name=r.slice(1,a):t.base=t.name=r.slice(o,a)):(o===0&&i?(t.name=r.slice(1,n),t.base=r.slice(1,a)):(t.name=r.slice(o,n),t.base=r.slice(o,a)),t.ext=r.slice(n,a)),t.dir=this.dirname(r),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let Qa;async function ad(){return Qa??(Qa=(async()=>{var n;const r=document.createElement("canvas").getContext("webgl");if(!r)return ae.UNPACK;const t=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!t)return ae.UNPACK;const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e);const i=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.deleteFramebuffer(i),r.deleteTexture(e),(n=r.getExtension("WEBGL_lose_context"))==null||n.loseContext(),s[0]<=s[3]?ae.PMA:ae.UNPACK})()),Qa}function Xx(){et("7.0.0","skipHello is deprecated, please use settings.RENDER_OPTIONS.hello")}function Wx(){et("7.0.0",`sayHello is deprecated, please use Renderer's "hello" option`)}let tl;function ld(){return typeof tl>"u"&&(tl=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:z.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!z.ADAPTER.getWebGLRenderingContext())return!1;const e=z.ADAPTER.createCanvas();let i=e.getContext("webgl",r)||e.getContext("experimental-webgl",r);const s=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,s}catch{return!1}}()),tl}var zx={grad:.9,turn:360,rad:360/(2*Math.PI)},yr=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},$t=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},xe=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},hd=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},ud=function(r){return{r:xe(r.r,0,255),g:xe(r.g,0,255),b:xe(r.b,0,255),a:xe(r.a)}},el=function(r){return{r:$t(r.r),g:$t(r.g),b:$t(r.b),a:$t(r.a,3)}},jx=/^#([0-9a-f]{3,8})$/i,An=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},cd=function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},dd=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),l=i*(1-(1-t+n)*e),h=n%6;return{r:255*[i,a,o,o,l,i][h],g:255*[l,i,i,a,o,o][h],b:255*[o,o,l,i,i,a][h],a:s}},fd=function(r){return{h:hd(r.h),s:xe(r.s,0,100),l:xe(r.l,0,100),a:xe(r.a)}},pd=function(r){return{h:$t(r.h),s:$t(r.s),l:$t(r.l),a:$t(r.a,3)}},md=function(r){return dd((e=(t=r).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},ys=function(r){return{h:(t=cd(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},Yx=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qx=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Kx=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zx=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rl={string:[[function(r){var t=jx.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?$t(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?$t(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=Kx.exec(r)||Zx.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:ud({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=Yx.exec(r)||qx.exec(r);if(!t)return null;var e,i,s=fd({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(zx[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return md(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return yr(t)&&yr(e)&&yr(i)?ud({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!yr(t)||!yr(e)||!yr(i))return null;var o=fd({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return md(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!yr(t)||!yr(e)||!yr(i))return null;var o=function(a){return{h:hd(a.h),s:xe(a.s,0,100),v:xe(a.v,0,100),a:xe(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return dd(o)},"hsv"]]},gd=function(r,t){for(var e=0;e<t.length;e++){var i=t[e][0](r);if(i)return[i,t[e][1]]}return[null,void 0]},Jx=function(r){return typeof r=="string"?gd(r.trim(),rl.string):typeof r=="object"&&r!==null?gd(r,rl.object):[null,void 0]},il=function(r,t){var e=ys(r);return{h:e.h,s:xe(e.s+100*t,0,100),l:e.l,a:e.a}},sl=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},yd=function(r,t){var e=ys(r);return{h:e.h,s:e.s,l:xe(e.l+100*t,0,100),a:e.a}},nl=function(){function r(t){this.parsed=Jx(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return $t(sl(this.rgba),2)},r.prototype.isDark=function(){return sl(this.rgba)<.5},r.prototype.isLight=function(){return sl(this.rgba)>=.5},r.prototype.toHex=function(){return t=el(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?An($t(255*n)):"","#"+An(e)+An(i)+An(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return el(this.rgba)},r.prototype.toRgbString=function(){return t=el(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return pd(ys(this.rgba))},r.prototype.toHslString=function(){return t=pd(ys(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=cd(this.rgba),{h:$t(t.h),s:$t(t.s),v:$t(t.v),a:$t(t.a,3)};var t},r.prototype.invert=function(){return Ke({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),Ke(il(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),Ke(il(this.rgba,-t))},r.prototype.grayscale=function(){return Ke(il(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),Ke(yd(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),Ke(yd(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?Ke({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):$t(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=ys(this.rgba);return typeof t=="number"?Ke({h:t,s:e.s,l:e.l,a:e.a}):$t(e.h)},r.prototype.isEqual=function(t){return this.toHex()===Ke(t).toHex()},r}(),Ke=function(r){return r instanceof nl?r:new nl(r)},_d=[],Qx=function(r){r.forEach(function(t){_d.indexOf(t)<0&&(t(nl,rl),_d.push(t))})};function tb(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var s in e)i[e[s]]=s;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=i[this.toHex()];if(h)return h;if(o!=null&&o.closest){var u=this.toRgb(),c=1/0,d="black";if(!n.length)for(var p in e)n[p]=new r(e[p]).toRgb();for(var f in e){var m=(a=u,l=n[f],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));m<c&&(c=m,d=f)}return d}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new r(l).toRgb():null},"name"])}Qx([tb]);const Di=class Ao{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof Ao)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,s]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toRgbArray(t){t=t??[];const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=Ao.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,s]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(s*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}normalize(t){let e,i,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,s,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Ao.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Ke(t);o.isValid()&&({r:e,g:i,b:s,a:n}=o.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=s,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}};Di.shared=new Di,Di.temp=new Di,Di.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let ut=Di;function eb(r,t=[]){return et("7.2.0","utils.hex2rgb is deprecated, use Color#toRgbArray instead"),ut.shared.setValue(r).toRgbArray(t)}function vd(r){return et("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),ut.shared.setValue(r).toHex()}function rb(r){return et("7.2.0","utils.string2hex is deprecated, use Color#toNumber instead"),ut.shared.setValue(r).toNumber()}function xd(r){return et("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),ut.shared.setValue(r).toNumber()}function ib(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[U.NORMAL_NPM]=U.NORMAL,r[U.ADD_NPM]=U.ADD,r[U.SCREEN_NPM]=U.SCREEN,t[U.NORMAL]=U.NORMAL_NPM,t[U.ADD]=U.ADD_NPM,t[U.SCREEN]=U.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const ol=ib();function al(r,t){return ol[t?1:0][r]}function sb(r,t,e,i=!0){return et("7.2.0","utils.premultiplyRgba has moved to Color.premultiply"),ut.shared.setValue(r).premultiply(t,i).toArray(e??new Float32Array(4))}function nb(r,t){return et("7.2.0","utils.premultiplyTint has moved to Color.toPremultiplied"),ut.shared.setValue(r).toPremultiplied(t)}function ob(r,t,e,i=!0){return et("7.2.0","utils.premultiplyTintToRgba has moved to Color.premultiply"),ut.shared.setValue(r).premultiply(t,i).toArray(e??new Float32Array(4))}const bd=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function wd(r,t=null){const e=r*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}function Sn(r){if(r.BYTES_PER_ELEMENT===4)return r instanceof Float32Array?"Float32Array":r instanceof Uint32Array?"Uint32Array":"Int32Array";if(r.BYTES_PER_ELEMENT===2){if(r instanceof Uint16Array)return"Uint16Array"}else if(r.BYTES_PER_ELEMENT===1&&r instanceof Uint8Array)return"Uint8Array";return null}const ab={Float32Array,Uint32Array,Int32Array,Uint8Array};function lb(r,t){let e=0,i=0;const s={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let l=0;l<r.length;l++){const h=t[l],u=r[l],c=Sn(u);s[c]||(s[c]=new ab[c](n)),o=s[c];for(let d=0;d<u.length;d++){const p=(d/h|0)*i+a,f=d%h;o[p+f]=u[d]}a+=h}return new Float32Array(n)}function _s(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function ll(r){return!(r&r-1)&&!!r}function hl(r){let t=(r>65535?1:0)<<4;r>>>=t;let e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function Yr(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}function _r(r){return r===0?0:r<0?-1:1}let hb=0;function Cr(){return++hb}const ul=class{constructor(r,t,e,i){this.left=r,this.top=t,this.right=e,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};ul.EMPTY=new ul(0,0,0,0);let cl=ul;const dl={},se=Object.create(null),fe=Object.create(null);function ub(){let r;for(r in se)se[r].destroy();for(r in fe)fe[r].destroy()}function cb(){let r;for(r in se)delete se[r];for(r in fe)delete fe[r]}class vs{constructor(t,e,i){this._canvas=z.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||z.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function Td(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function Ed(r,t,e,i,s){const n=4*t;for(let o=i,a=i*n+4*e;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function Ad(r){const{width:t,height:e}=r,i=r.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const s=i.getImageData(0,0,t,e).data;let n=0,o=0,a=t-1,l=e-1;for(;o<e&&Td(s,t,o);)++o;if(o===e)return cl.EMPTY;for(;Td(s,t,l);)--l;for(;Ed(s,t,n,o,l);)++n;for(;Ed(s,t,a,o,l);)--a;return++a,++l,new cl(n,o,a,l)}function Sd(r){const t=Ad(r),{width:e,height:i}=t;let s=null;if(!t.isEmpty()){const n=r.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:s}}function db(r){const t=bd.exec(r);if(t)return{mediaType:t[1]?t[1].toLowerCase():void 0,subType:t[2]?t[2].toLowerCase():void 0,charset:t[3]?t[3].toLowerCase():void 0,encoding:t[4]?t[4].toLowerCase():void 0,data:t[5]}}function Cd(r,t=globalThis.location){if(r.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function Ze(r,t=1){var i;const e=(i=z.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}const fb=Object.freeze(Object.defineProperty({__proto__:null,BaseTextureCache:fe,BoundingBox:cl,CanvasRenderTarget:vs,DATA_URI:bd,EventEmitter:wi,ProgramCache:dl,TextureCache:se,clearTextureCache:cb,correctBlendMode:al,createIndicesForQuads:wd,decomposeDataUri:db,deprecation:et,destroyTextureCache:ub,detectVideoAlphaMode:ad,determineCrossOrigin:Cd,earcut:ic,getBufferType:Sn,getCanvasBoundingBox:Ad,getResolutionOfUrl:Ze,hex2rgb:eb,hex2string:vd,interleaveTypedArrays:lb,isMobile:ze,isPow2:ll,isWebGLSupported:ld,log2:hl,nextPow2:_s,path:Ut,premultiplyBlendMode:ol,premultiplyRgba:sb,premultiplyTint:nb,premultiplyTintToRgba:ob,removeItems:Yr,rgb2hex:xd,sayHello:Wx,sign:_r,skipHello:Xx,string2hex:rb,trimCanvas:Sd,uid:Cr,url:Gx},Symbol.toStringTag,{value:"Module"}));var X=(r=>(r.Renderer="renderer",r.Application="application",r.RendererSystem="renderer-webgl-system",r.RendererPlugin="renderer-webgl-plugin",r.CanvasRendererSystem="renderer-canvas-system",r.CanvasRendererPlugin="renderer-canvas-plugin",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r))(X||{});const fl=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},Id=(r,t)=>fl(r).priority??t,j={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(fl).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(fl).forEach(t=>{t.type.forEach(e=>{var n,o;const i=this._addHandlers,s=this._queue;i[e]?(n=i[e])==null||n.call(i,t):(s[e]=s[e]||[],(o=s[e])==null||o.push(t))})}),this},handle(r,t,e){var o;const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=t,s[r]=e;const n=this._queue;return n[r]&&((o=n[r])==null||o.forEach(a=>t(a)),delete n[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>Id(n,e)-Id(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class pl{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const pb=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
11
- `);function mb(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
12
- else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function gb(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=pb.replace(/%forloop%/gi,mb(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const ml=0,gl=1,yl=2,_l=3,vl=4,xl=5;class Je{constructor(){this.data=0,this.blendMode=U.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<ml)}set blend(t){!!(this.data&1<<ml)!==t&&(this.data^=1<<ml)}get offsets(){return!!(this.data&1<<gl)}set offsets(t){!!(this.data&1<<gl)!==t&&(this.data^=1<<gl)}get culling(){return!!(this.data&1<<yl)}set culling(t){!!(this.data&1<<yl)!==t&&(this.data^=1<<yl)}get depthTest(){return!!(this.data&1<<_l)}set depthTest(t){!!(this.data&1<<_l)!==t&&(this.data^=1<<_l)}get depthMask(){return!!(this.data&1<<xl)}set depthMask(t){!!(this.data&1<<xl)!==t&&(this.data^=1<<xl)}get clockwiseFrontFace(){return!!(this.data&1<<vl)}set clockwiseFrontFace(t){!!(this.data&1<<vl)!==t&&(this.data^=1<<vl)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==U.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Je;return t.depthTest=!1,t.blend=!0,t}}Je.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const bl=[];function Rd(r,t){if(!r)return null;let e="";if(typeof r=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(r);i&&(e=i[1].toLowerCase())}for(let i=bl.length-1;i>=0;--i){const s=bl[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class Me{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,s,n,o,a,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:u}=this;this._aliasCount++;for(let c=0,d=u.length;c<d;c++)u[c][h](t,e,i,s,n,o,a,l);return u===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(Me.prototype,{dispatch:{value:Me.prototype.emit},run:{value:Me.prototype.emit}});class xs{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new Me("setRealSize"),this.onUpdate=new Me("update"),this.onError=new Me("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class Cn extends xs{constructor(t,e){const{width:i,height:s}=e||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const s=t.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===ae.UNPACK);const n=e.realWidth,o=e.realHeight;return i.width===n&&i.height===o?s.texSubImage2D(e.target,0,0,0,n,o,e.format,i.type,this.data):(i.width=n,i.height=o,s.texImage2D(e.target,0,i.internalFormat,n,o,0,e.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const yb={scaleMode:Ie.NEAREST,alphaMode:ae.NPM},wl=class Wi extends wi{constructor(t=null,e=null){super(),e=Object.assign({},Wi.defaultOptions,e);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:l,wrapMode:h,format:u,type:c,target:d,resolution:p,resourceOptions:f}=e;t&&!(t instanceof xs)&&(t=Rd(t,f),t.internal=!0),this.resolution=p||z.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=h,this._scaleMode=o,this.format=u,this.type=c,this.target=d,this.alphaMode=i,this.uid=Cr(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=a>0&&l>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(t)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let i;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,i=!0),i&&this.dirtyStyleId++,this}setSize(t,e,i){return i=i||this.resolution,this.setRealSize(t*i,e*i,i)}setRealSize(t,e,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=ll(this.realWidth)&&ll(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete fe[this.cacheId],delete se[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),Wi.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,e,i=z.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${Cr()}`}n=t._pixiId}let o=fe[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new Wi(t,e),o.cacheId=n,Wi.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new Cn(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let o,a;return t instanceof Float32Array?(o=$.RGBA,a=J.FLOAT):t instanceof Int32Array?(o=$.RGBA_INTEGER,a=J.INT):t instanceof Uint32Array?(o=$.RGBA_INTEGER,a=J.UNSIGNED_INT):t instanceof Int16Array?(o=$.RGBA_INTEGER,a=J.SHORT):t instanceof Uint16Array?(o=$.RGBA_INTEGER,a=J.UNSIGNED_SHORT):t instanceof Int8Array?(o=$.RGBA,a=J.BYTE):(o=$.RGBA,a=J.UNSIGNED_BYTE),n.internal=!0,new Wi(n,Object.assign({},yb,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),fe[e]&&fe[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),fe[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=fe[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete fe[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete fe[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};wl.defaultOptions={mipmap:Ve.POW2,anisotropicLevel:0,scaleMode:Ie.LINEAR,wrapMode:pr.CLAMP,alphaMode:ae.UNPACK,target:xi.TEXTURE_2D,format:$.RGBA,type:J.UNSIGNED_BYTE},wl._globalBatch=0;let st=wl;class Tl{constructor(){this.texArray=null,this.blend=0,this.type=Ce.TRIANGLES,this.start=0,this.size=0,this.data=null}}let _b=0;class Bt{constructor(t,e=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=e,this.id=_b++,this.disposeRunner=new Me("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?We.ELEMENT_ARRAY_BUFFER:We.ARRAY_BUFFER}get index(){return this.type===We.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Bt(t)}}class In{constructor(t,e=0,i=!1,s=J.FLOAT,n,o,a,l=1){this.buffer=t,this.size=e,this.normalized=i,this.type=s,this.stride=n,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(t,e,i,s,n){return new In(t,e,i,s,n)}}const vb={Float32Array,Uint32Array,Int32Array,Uint8Array};function xb(r,t){let e=0,i=0;const s={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let l=0;l<r.length;l++){const h=t[l],u=r[l],c=Sn(u);s[c]||(s[c]=new vb[c](n)),o=s[c];for(let d=0;d<u.length;d++){const p=(d/h|0)*i+a,f=d%h;o[p+f]=u[d]}a+=h}return new Float32Array(n)}const Pd={5126:4,5123:2,5121:1};let bb=0;const wb={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class Ir{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=bb++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new Me("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,s=!1,n,o,a,l=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Bt||(e instanceof Array&&(e=new Float32Array(e)),e=new Bt(e));const h=t.split("|");if(h.length>1){for(let c=0;c<h.length;c++)this.addAttribute(h[c],e,i,s,n);return this}let u=this.buffers.indexOf(e);return u===-1&&(this.buffers.push(e),u=this.buffers.length-1),this.attributes[t]=new In(u,i,s,n,o,a,l),this.instanced=this.instanced||l,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof Bt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Bt(t)),t.type=We.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],i=new Bt;let s;for(s in this.attributes){const n=this.attributes[s],o=this.buffers[n.buffer];t.push(o.data),e.push(n.size*Pd[n.type]/4),n.buffer=0}for(i.data=xb(t,e),s=0;s<this.buffers.length;s++)this.buffers[s]!==this.indexBuffer&&this.buffers[s].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new Ir;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new Bt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new In(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=We.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Ir,i=[],s=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)s[l]=s[l]||0,s[l]+=o.buffers[l].data.length,n[l]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new wb[Sn(o.buffers[a].data)](s[a]),e.buffers[a]=new Bt(i[a]);for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)i[l].set(o.buffers[l].data,n[l]),n[l]+=o.buffers[l].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=We.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,u=0;for(let c=0;c<o.buffers.length;c++)if(o.buffers[c]!==o.indexBuffer){u=c;break}for(const c in o.attributes){const d=o.attributes[c];(d.buffer|0)===u&&(l+=d.size*Pd[d.type]/4)}for(let c=0;c<t.length;c++){const d=t[c].indexBuffer.data;for(let p=0;p<d.length;p++)e.indexBuffer.data[p+h]+=a;a+=t[c].buffers[u].data.length/l,h+=d.length}}return e}}class Md extends Ir{constructor(t=!1){super(),this._buffer=new Bt(null,t,!1),this._indexBuffer=new Bt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,J.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,J.FLOAT).addAttribute("aColor",this._buffer,4,!0,J.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,J.FLOAT).addIndex(this._indexBuffer)}}const Rn=Math.PI*2,Tb=180/Math.PI,Eb=Math.PI/180;var Tt=(r=>(r[r.POLY=0]="POLY",r[r.RECT=1]="RECT",r[r.CIRC=2]="CIRC",r[r.ELIP=3]="ELIP",r[r.RREC=4]="RREC",r))(Tt||{});class dt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new dt(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}dt.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Pn=[new dt,new dt,new dt,new dt];class at{constructor(t=0,e=0,i=0,s=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s),this.type=Tt.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new at(0,0,0,0)}clone(){return new at(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const A=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=A)return!1;const M=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>M}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=Pn[0].set(t.left,t.top),l=Pn[1].set(t.left,t.bottom),h=Pn[2].set(t.right,t.top),u=Pn[3].set(t.right,t.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(a,a),e.apply(l,l),e.apply(h,h),e.apply(u,u),Math.max(a.x,l.x,h.x,u.x)<=i||Math.min(a.x,l.x,h.x,u.x)>=s||Math.max(a.y,l.y,h.y,u.y)<=n||Math.min(a.y,l.y,h.y,u.y)>=o))return!1;const d=c*(l.y-a.y),p=c*(a.x-l.x),f=d*i+p*n,m=d*s+p*n,_=d*i+p*o,g=d*s+p*o;if(Math.max(f,m,_,g)<=d*a.x+p*a.y||Math.min(f,m,_,g)>=d*u.x+p*u.y)return!1;const v=c*(a.y-h.y),y=c*(h.x-a.x),x=v*i+y*n,b=v*s+y*n,E=v*i+y*o,T=v*s+y*o;return!(Math.max(x,b,E,T)<=v*a.x+y*a.y||Math.min(x,b,E,T)>=v*u.x+y*u.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=s-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=n-s,this}}at.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Mn{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Tt.CIRC}clone(){return new Mn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}getBounds(){return new at(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}Mn.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Dn{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=Tt.ELIP}clone(){return new Dn(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,s=(e-this.y)/this.height;return i*=i,s*=s,i+s<=1}getBounds(){return new at(this.x-this.width,this.y-this.height,this.width,this.height)}}Dn.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class qr{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.type=Tt.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new qr(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],l=this.points[n*2+1],h=this.points[o*2],u=this.points[o*2+1];l>e!=u>e&&t<(h-a)*((e-l)/(u-l))+a&&(i=!i)}return i}}qr.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class Bn{constructor(t=0,e=0,i=0,s=0,n=20){this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n,this.type=Tt.RREC}clone(){return new Bn(this.x,this.y,this.width,this.height,this.radius)}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let s=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i),s*s+n*n<=o)||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i),s*s+n*n<=o))return!0}return!1}}Bn.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class wt{constructor(t=1,e=0,i=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new dt;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new dt;const i=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}setTransform(t,e,i,s,n,o,a,l,h){return this.a=Math.cos(a+h)*n,this.b=Math.sin(a+h)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),l=Math.atan2(i,e),h=Math.abs(a+l);return h<1e-5||Math.abs(Rn-h)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(t*this.ty-e*n)/o,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new wt;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new wt}static get TEMP_MATRIX(){return new wt}}wt.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const Kr=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Zr=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Jr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Qr=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],El=[],Dd=[],On=Math.sign;function Ab(){for(let r=0;r<16;r++){const t=[];El.push(t);for(let e=0;e<16;e++){const i=On(Kr[r]*Kr[e]+Jr[r]*Zr[e]),s=On(Zr[r]*Kr[e]+Qr[r]*Zr[e]),n=On(Kr[r]*Jr[e]+Jr[r]*Qr[e]),o=On(Zr[r]*Jr[e]+Qr[r]*Qr[e]);for(let a=0;a<16;a++)if(Kr[a]===i&&Zr[a]===s&&Jr[a]===n&&Qr[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new wt;t.set(Kr[r],Zr[r],Jr[r],Qr[r],0,0),Dd.push(t)}}Ab();const St={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>Kr[r],uY:r=>Zr[r],vX:r=>Jr[r],vY:r=>Qr[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>El[r][t],sub:(r,t)=>El[r][St.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?St.S:St.N:Math.abs(t)*2<=Math.abs(r)?r>0?St.E:St.W:t>0?r>0?St.SE:St.SW:r>0?St.NE:St.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=Dd[St.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class vr{constructor(t,e,i=0,s=0){this._x=i,this._y=s,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new vr(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}vr.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Al=class{constructor(){this.worldTransform=new wt,this.localTransform=new wt,this.position=new vr(this.onChange,this,0,0),this.scale=new vr(this.onChange,this,1,1),this.pivot=new vr(this.onChange,this,0,0),this.skew=new vr(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const r=this.localTransform;this._localID!==this._currentLocalID&&(r.a=this._cx*this.scale.x,r.b=this._sx*this.scale.x,r.c=this._cy*this.scale.y,r.d=this._sy*this.scale.y,r.tx=this.position.x-(this.pivot.x*r.a+this.pivot.y*r.c),r.ty=this.position.y-(this.pivot.x*r.b+this.pivot.y*r.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(r){const t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==r._worldID){const e=r.worldTransform,i=this.worldTransform;i.a=t.a*e.a+t.b*e.c,i.b=t.a*e.b+t.b*e.d,i.c=t.c*e.a+t.d*e.c,i.d=t.c*e.b+t.d*e.d,i.tx=t.tx*e.a+t.ty*e.c+e.tx,i.ty=t.tx*e.b+t.ty*e.d+e.ty,this._parentID=r._worldID,this._worldID++}}setFromMatrix(r){r.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(r){this._rotation!==r&&(this._rotation=r,this.updateSkew())}};Al.IDENTITY=new Al;let Ln=Al;Ln.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var Sb=`varying vec2 vTextureCoord;
10
+ Deprecated since v${r}`),console.warn(i))),zc[t]=!0}const q_={get parse(){return ct("7.3.0","utils.url.parse is deprecated, use native URL API instead."),Bo.parse},get format(){return ct("7.3.0","utils.url.format is deprecated, use native URL API instead."),Bo.format},get resolve(){return ct("7.3.0","utils.url.resolve is deprecated, use native URL API instead."),Bo.resolve}};function Le(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function es(r){return r.split("?")[0].split("#")[0]}function K_(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Z_(r,t,e){return r.replace(new RegExp(K_(t),"g"),e)}function J_(r,t){let e="",i=0,s=-1,n=0,a=-1;for(let o=0;o<=r.length;++o){if(o<r.length)a=r.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(s===o-1||n===1))if(s!==o-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=o,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=o,n=0;continue}}}else e.length>0?e+=`/${r.slice(s+1,o)}`:e=r.slice(s+1,o),i=o-s-1;s=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}const Xt={toPosix(r){return Z_(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){Le(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(Le(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=es(this.toPosix(t??et.ADAPTER.getBaseUrl())),s=es(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?Xt.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(Le(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=J_(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Le(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let t;for(let e=0;e<r.length;++e){const i=r[e];if(Le(i),i.length>0)if(t===void 0)t=i;else{const s=r[e-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(Le(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),a=r;r=r.slice(n.length);for(let o=r.length-1;o>=1;--o)if(t=r.charCodeAt(o),t===47){if(!s){i=o;break}}else s=!1;return i===-1?e?"/":this.isUrl(a)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){Le(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){Le(r),t&&Le(t),r=es(this.toPosix(r));let e=0,i=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let a=t.length-1,o=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!s){e=n+1;break}}else o===-1&&(s=!1,o=n+1),a>=0&&(l===t.charCodeAt(a)?--a===-1&&(i=n):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){Le(r),r=es(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let a=r.length-1;a>=0;--a){const o=r.charCodeAt(a);if(o===47){if(!s){e=a+1;break}continue}i===-1&&(s=!1,i=a+1),o===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){Le(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=es(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let s;t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,a=0,o=-1,l=!0,h=r.length-1,u=0;for(;h>=s;--h){if(e=r.charCodeAt(h),e===47){if(!l){a=h+1;break}continue}o===-1&&(l=!1,o=h+1),e===46?n===-1?n=h:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||o===-1||u===0||u===1&&n===o-1&&n===a+1?o!==-1&&(a===0&&i?t.base=t.name=r.slice(1,o):t.base=t.name=r.slice(a,o)):(a===0&&i?(t.name=r.slice(1,n),t.base=r.slice(1,o)):(t.name=r.slice(a,n),t.base=r.slice(a,o)),t.ext=r.slice(n,o)),t.dir=this.dirname(r),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let Oo;async function jc(){return Oo??(Oo=(async()=>{var n;const r=document.createElement("canvas").getContext("webgl");if(!r)return ce.UNPACK;const t=await new Promise(a=>{const o=document.createElement("video");o.onloadeddata=()=>a(o),o.onerror=()=>a(null),o.autoplay=!1,o.crossOrigin="anonymous",o.preload="auto",o.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",o.load()});if(!t)return ce.UNPACK;const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e);const i=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.deleteFramebuffer(i),r.deleteTexture(e),(n=r.getExtension("WEBGL_lose_context"))==null||n.loseContext(),s[0]<=s[3]?ce.PMA:ce.UNPACK})()),Oo}function Q_(){ct("7.0.0","skipHello is deprecated, please use settings.RENDER_OPTIONS.hello")}function tv(){ct("7.0.0",`sayHello is deprecated, please use Renderer's "hello" option`)}let Lo;function Yc(){return typeof Lo>"u"&&(Lo=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:et.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!et.ADAPTER.getWebGLRenderingContext())return!1;const e=et.ADAPTER.createCanvas();let i=e.getContext("webgl",r)||e.getContext("experimental-webgl",r);const s=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,s}catch{return!1}}()),Lo}var ev={grad:.9,turn:360,rad:360/(2*Math.PI)},yr=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},zt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},Ae=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},qc=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Kc=function(r){return{r:Ae(r.r,0,255),g:Ae(r.g,0,255),b:Ae(r.b,0,255),a:Ae(r.a)}},Fo=function(r){return{r:zt(r.r),g:zt(r.g),b:zt(r.b),a:zt(r.a,3)}},rv=/^#([0-9a-f]{3,8})$/i,Ys=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},Zc=function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=Math.max(t,e,i),a=n-Math.min(t,e,i),o=a?n===t?(e-i)/a:n===e?2+(i-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:s}},Jc=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),a=i*(1-e),o=i*(1-(t-n)*e),l=i*(1-(1-t+n)*e),h=n%6;return{r:255*[i,o,a,a,l,i][h],g:255*[l,i,i,o,a,a][h],b:255*[a,a,l,i,i,o][h],a:s}},Qc=function(r){return{h:qc(r.h),s:Ae(r.s,0,100),l:Ae(r.l,0,100),a:Ae(r.a)}},td=function(r){return{h:zt(r.h),s:zt(r.s),l:zt(r.l),a:zt(r.a,3)}},ed=function(r){return Jc((e=(t=r).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},rs=function(r){return{h:(t=Zc(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},iv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,sv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,nv=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,av=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,No={string:[[function(r){var t=rv.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?zt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?zt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=nv.exec(r)||av.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:Kc({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=iv.exec(r)||sv.exec(r);if(!t)return null;var e,i,s=Qc({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(ev[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return ed(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return yr(t)&&yr(e)&&yr(i)?Kc({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!yr(t)||!yr(e)||!yr(i))return null;var a=Qc({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return ed(a)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!yr(t)||!yr(e)||!yr(i))return null;var a=function(o){return{h:qc(o.h),s:Ae(o.s,0,100),v:Ae(o.v,0,100),a:Ae(o.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Jc(a)},"hsv"]]},rd=function(r,t){for(var e=0;e<t.length;e++){var i=t[e][0](r);if(i)return[i,t[e][1]]}return[null,void 0]},ov=function(r){return typeof r=="string"?rd(r.trim(),No.string):typeof r=="object"&&r!==null?rd(r,No.object):[null,void 0]},Uo=function(r,t){var e=rs(r);return{h:e.h,s:Ae(e.s+100*t,0,100),l:e.l,a:e.a}},ko=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},id=function(r,t){var e=rs(r);return{h:e.h,s:e.s,l:Ae(e.l+100*t,0,100),a:e.a}},Go=function(){function r(t){this.parsed=ov(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return zt(ko(this.rgba),2)},r.prototype.isDark=function(){return ko(this.rgba)<.5},r.prototype.isLight=function(){return ko(this.rgba)>=.5},r.prototype.toHex=function(){return t=Fo(this.rgba),e=t.r,i=t.g,s=t.b,a=(n=t.a)<1?Ys(zt(255*n)):"","#"+Ys(e)+Ys(i)+Ys(s)+a;var t,e,i,s,n,a},r.prototype.toRgb=function(){return Fo(this.rgba)},r.prototype.toRgbString=function(){return t=Fo(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return td(rs(this.rgba))},r.prototype.toHslString=function(){return t=td(rs(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=Zc(this.rgba),{h:zt(t.h),s:zt(t.s),v:zt(t.v),a:zt(t.a,3)};var t},r.prototype.invert=function(){return tr({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),tr(Uo(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),tr(Uo(this.rgba,-t))},r.prototype.grayscale=function(){return tr(Uo(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),tr(id(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),tr(id(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?tr({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):zt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=rs(this.rgba);return typeof t=="number"?tr({h:t,s:e.s,l:e.l,a:e.a}):zt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===tr(t).toHex()},r}(),tr=function(r){return r instanceof Go?r:new Go(r)},sd=[],lv=function(r){r.forEach(function(t){sd.indexOf(t)<0&&(t(Go,No),sd.push(t))})};function hv(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var s in e)i[e[s]]=s;var n={};r.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,l,h=i[this.toHex()];if(h)return h;if(a!=null&&a.closest){var u=this.toRgb(),c=1/0,d="black";if(!n.length)for(var p in e)n[p]=new r(e[p]).toRgb();for(var f in e){var g=(o=u,l=n[f],Math.pow(o.r-l.r,2)+Math.pow(o.g-l.g,2)+Math.pow(o.b-l.b,2));g<c&&(c=g,d=f)}return d}},t.string.push([function(a){var o=a.toLowerCase(),l=o==="transparent"?"#0000":e[o];return l?new r(l).toRgb():null},"name"])}lv([hv]);const Ti=class Kn{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof Kn)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,s]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toRgbArray(t){t=t??[];const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=Kn.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,s]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(s*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}normalize(t){let e,i,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(a>>8&255)/255,s=(a&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,s,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=Kn.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=tr(t);a.isValid()&&({r:e,g:i,b:s,a:n}=a.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=s,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}};Ti.shared=new Ti,Ti.temp=new Ti,Ti.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let _t=Ti;function uv(r,t=[]){return ct("7.2.0","utils.hex2rgb is deprecated, use Color#toRgbArray instead"),_t.shared.setValue(r).toRgbArray(t)}function nd(r){return ct("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),_t.shared.setValue(r).toHex()}function cv(r){return ct("7.2.0","utils.string2hex is deprecated, use Color#toNumber instead"),_t.shared.setValue(r).toNumber()}function ad(r){return ct("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),_t.shared.setValue(r).toNumber()}function dv(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[q.NORMAL_NPM]=q.NORMAL,r[q.ADD_NPM]=q.ADD,r[q.SCREEN_NPM]=q.SCREEN,t[q.NORMAL]=q.NORMAL_NPM,t[q.ADD]=q.ADD_NPM,t[q.SCREEN]=q.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const Ho=dv();function $o(r,t){return Ho[t?1:0][r]}function fv(r,t,e,i=!0){return ct("7.2.0","utils.premultiplyRgba has moved to Color.premultiply"),_t.shared.setValue(r).premultiply(t,i).toArray(e??new Float32Array(4))}function pv(r,t){return ct("7.2.0","utils.premultiplyTint has moved to Color.toPremultiplied"),_t.shared.setValue(r).toPremultiplied(t)}function mv(r,t,e,i=!0){return ct("7.2.0","utils.premultiplyTintToRgba has moved to Color.premultiply"),_t.shared.setValue(r).premultiply(t,i).toArray(e??new Float32Array(4))}const od=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function ld(r,t=null){const e=r*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}function qs(r){if(r.BYTES_PER_ELEMENT===4)return r instanceof Float32Array?"Float32Array":r instanceof Uint32Array?"Uint32Array":"Int32Array";if(r.BYTES_PER_ELEMENT===2){if(r instanceof Uint16Array)return"Uint16Array"}else if(r.BYTES_PER_ELEMENT===1&&r instanceof Uint8Array)return"Uint8Array";return null}const gv={Float32Array,Uint32Array,Int32Array,Uint8Array};function yv(r,t){let e=0,i=0;const s={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const n=new ArrayBuffer(e*4);let a=null,o=0;for(let l=0;l<r.length;l++){const h=t[l],u=r[l],c=qs(u);s[c]||(s[c]=new gv[c](n)),a=s[c];for(let d=0;d<u.length;d++){const p=(d/h|0)*i+o,f=d%h;a[p+f]=u[d]}o+=h}return new Float32Array(n)}function is(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function Vo(r){return!(r&r-1)&&!!r}function Xo(r){let t=(r>65535?1:0)<<4;r>>>=t;let e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function Vr(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}function _r(r){return r===0?0:r<0?-1:1}let _v=0;function Ar(){return++_v}const Wo=class{constructor(r,t,e,i){this.left=r,this.top=t,this.right=e,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};Wo.EMPTY=new Wo(0,0,0,0);let zo=Wo;const jo={},le=Object.create(null),ye=Object.create(null);function vv(){let r;for(r in le)le[r].destroy();for(r in ye)ye[r].destroy()}function xv(){let r;for(r in le)delete le[r];for(r in ye)delete ye[r]}class ss{constructor(t,e,i){this._canvas=et.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||et.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function hd(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function ud(r,t,e,i,s){const n=4*t;for(let a=i,o=i*n+4*e;a<=s;++a,o+=n)if(r[o+3]!==0)return!1;return!0}function cd(r){const{width:t,height:e}=r,i=r.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const s=i.getImageData(0,0,t,e).data;let n=0,a=0,o=t-1,l=e-1;for(;a<e&&hd(s,t,a);)++a;if(a===e)return zo.EMPTY;for(;hd(s,t,l);)--l;for(;ud(s,t,n,a,l);)++n;for(;ud(s,t,o,a,l);)--o;return++o,++l,new zo(n,a,o,l)}function dd(r){const t=cd(r),{width:e,height:i}=t;let s=null;if(!t.isEmpty()){const n=r.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:s}}function bv(r){const t=od.exec(r);if(t)return{mediaType:t[1]?t[1].toLowerCase():void 0,subType:t[2]?t[2].toLowerCase():void 0,charset:t[3]?t[3].toLowerCase():void 0,encoding:t[4]?t[4].toLowerCase():void 0,data:t[5]}}function fd(r,t=globalThis.location){if(r.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function er(r,t=1){var i;const e=(i=et.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}const wv=Object.freeze(Object.defineProperty({__proto__:null,BaseTextureCache:ye,BoundingBox:zo,CanvasRenderTarget:ss,DATA_URI:od,EventEmitter:bi,ProgramCache:jo,TextureCache:le,clearTextureCache:xv,correctBlendMode:$o,createIndicesForQuads:ld,decomposeDataUri:bv,deprecation:ct,destroyTextureCache:vv,detectVideoAlphaMode:jc,determineCrossOrigin:fd,earcut:Vu,getBufferType:qs,getCanvasBoundingBox:cd,getResolutionOfUrl:er,hex2rgb:uv,hex2string:nd,interleaveTypedArrays:yv,isMobile:Qe,isPow2:Vo,isWebGLSupported:Yc,log2:Xo,nextPow2:is,path:Xt,premultiplyBlendMode:Ho,premultiplyRgba:fv,premultiplyTint:pv,premultiplyTintToRgba:mv,removeItems:Vr,rgb2hex:ad,sayHello:tv,sign:_r,skipHello:Q_,string2hex:cv,trimCanvas:dd,uid:Ar,url:q_},Symbol.toStringTag,{value:"Module"}));var J=(r=>(r.Renderer="renderer",r.Application="application",r.RendererSystem="renderer-webgl-system",r.RendererPlugin="renderer-webgl-plugin",r.CanvasRendererSystem="renderer-canvas-system",r.CanvasRendererPlugin="renderer-canvas-plugin",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r))(J||{});const Yo=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},pd=(r,t)=>Yo(r).priority??t,rt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Yo).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(Yo).forEach(t=>{t.type.forEach(e=>{var n,a;const i=this._addHandlers,s=this._queue;i[e]?(n=i[e])==null||n.call(i,t):(s[e]=s[e]||[],(a=s[e])==null||a.push(t))})}),this},handle(r,t,e){var a;const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=t,s[r]=e;const n=this._queue;return n[r]&&((a=n[r])==null||a.forEach(o=>t(o)),delete n[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>pd(n,e)-pd(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class qo{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const Tv=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
11
+ `);function Ev(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
12
+ else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function Av(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=Tv.replace(/%forloop%/gi,Ev(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const Ko=0,Zo=1,Jo=2,Qo=3,tl=4,el=5;class rr{constructor(){this.data=0,this.blendMode=q.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Ko)}set blend(t){!!(this.data&1<<Ko)!==t&&(this.data^=1<<Ko)}get offsets(){return!!(this.data&1<<Zo)}set offsets(t){!!(this.data&1<<Zo)!==t&&(this.data^=1<<Zo)}get culling(){return!!(this.data&1<<Jo)}set culling(t){!!(this.data&1<<Jo)!==t&&(this.data^=1<<Jo)}get depthTest(){return!!(this.data&1<<Qo)}set depthTest(t){!!(this.data&1<<Qo)!==t&&(this.data^=1<<Qo)}get depthMask(){return!!(this.data&1<<el)}set depthMask(t){!!(this.data&1<<el)!==t&&(this.data^=1<<el)}get clockwiseFrontFace(){return!!(this.data&1<<tl)}set clockwiseFrontFace(t){!!(this.data&1<<tl)!==t&&(this.data^=1<<tl)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==q.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new rr;return t.depthTest=!1,t.blend=!0,t}}rr.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const rl=[];function md(r,t){if(!r)return null;let e="";if(typeof r=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(r);i&&(e=i[1].toLowerCase())}for(let i=rl.length-1;i>=0;--i){const s=rl[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class Fe{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,s,n,a,o,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:u}=this;this._aliasCount++;for(let c=0,d=u.length;c<d;c++)u[c][h](t,e,i,s,n,a,o,l);return u===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(Fe.prototype,{dispatch:{value:Fe.prototype.emit},run:{value:Fe.prototype.emit}});class ns{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new Fe("setRealSize"),this.onUpdate=new Fe("update"),this.onError=new Fe("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class Ks extends ns{constructor(t,e){const{width:i,height:s}=e||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const s=t.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===ce.UNPACK);const n=e.realWidth,a=e.realHeight;return i.width===n&&i.height===a?s.texSubImage2D(e.target,0,0,0,n,a,e.format,i.type,this.data):(i.width=n,i.height=a,s.texImage2D(e.target,0,i.internalFormat,n,a,0,e.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const Sv={scaleMode:Oe.NEAREST,alphaMode:ce.NPM},il=class Hi extends bi{constructor(t=null,e=null){super(),e=Object.assign({},Hi.defaultOptions,e);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:a,width:o,height:l,wrapMode:h,format:u,type:c,target:d,resolution:p,resourceOptions:f}=e;t&&!(t instanceof ns)&&(t=md(t,f),t.internal=!0),this.resolution=p||et.RESOLUTION,this.width=Math.round((o||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=h,this._scaleMode=a,this.format=u,this.type=c,this.target=d,this.alphaMode=i,this.uid=Ar(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=o>0&&l>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(t)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let i;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,i=!0),i&&this.dirtyStyleId++,this}setSize(t,e,i){return i=i||this.resolution,this.setRealSize(t*i,e*i,i)}setRealSize(t,e,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Vo(this.realWidth)&&Vo(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete ye[this.cacheId],delete le[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),Hi.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,e,i=et.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else{if(!t._pixiId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${o}_${Ar()}`}n=t._pixiId}let a=ye[n];if(s&&i&&!a)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return a||(a=new Hi(t,e),a.cacheId=n,Hi.addToCache(a,n)),a}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new Ks(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let a,o;return t instanceof Float32Array?(a=Z.RGBA,o=ut.FLOAT):t instanceof Int32Array?(a=Z.RGBA_INTEGER,o=ut.INT):t instanceof Uint32Array?(a=Z.RGBA_INTEGER,o=ut.UNSIGNED_INT):t instanceof Int16Array?(a=Z.RGBA_INTEGER,o=ut.SHORT):t instanceof Uint16Array?(a=Z.RGBA_INTEGER,o=ut.UNSIGNED_SHORT):t instanceof Int8Array?(a=Z.RGBA,o=ut.BYTE):(a=Z.RGBA,o=ut.UNSIGNED_BYTE),n.internal=!0,new Hi(n,Object.assign({},Sv,{type:o,format:a},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),ye[e]&&ye[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),ye[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=ye[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete ye[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete ye[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};il.defaultOptions={mipmap:Ke.POW2,anisotropicLevel:0,scaleMode:Oe.LINEAR,wrapMode:mr.CLAMP,alphaMode:ce.UNPACK,target:vi.TEXTURE_2D,format:Z.RGBA,type:ut.UNSIGNED_BYTE},il._globalBatch=0;let dt=il;class sl{constructor(){this.texArray=null,this.blend=0,this.type=Be.TRIANGLES,this.start=0,this.size=0,this.data=null}}let Cv=0;class kt{constructor(t,e=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=e,this.id=Cv++,this.disposeRunner=new Fe("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Je.ELEMENT_ARRAY_BUFFER:Je.ARRAY_BUFFER}get index(){return this.type===Je.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new kt(t)}}class Zs{constructor(t,e=0,i=!1,s=ut.FLOAT,n,a,o,l=1){this.buffer=t,this.size=e,this.normalized=i,this.type=s,this.stride=n,this.start=a,this.instance=o,this.divisor=l}destroy(){this.buffer=null}static from(t,e,i,s,n){return new Zs(t,e,i,s,n)}}const Iv={Float32Array,Uint32Array,Int32Array,Uint8Array};function Rv(r,t){let e=0,i=0;const s={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const n=new ArrayBuffer(e*4);let a=null,o=0;for(let l=0;l<r.length;l++){const h=t[l],u=r[l],c=qs(u);s[c]||(s[c]=new Iv[c](n)),a=s[c];for(let d=0;d<u.length;d++){const p=(d/h|0)*i+o,f=d%h;a[p+f]=u[d]}o+=h}return new Float32Array(n)}const gd={5126:4,5123:2,5121:1};let Pv=0;const Mv={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class Sr{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=Pv++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new Fe("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,s=!1,n,a,o,l=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof kt||(e instanceof Array&&(e=new Float32Array(e)),e=new kt(e));const h=t.split("|");if(h.length>1){for(let c=0;c<h.length;c++)this.addAttribute(h[c],e,i,s,n);return this}let u=this.buffers.indexOf(e);return u===-1&&(this.buffers.push(e),u=this.buffers.length-1),this.attributes[t]=new Zs(u,i,s,n,a,o,l),this.instanced=this.instanced||l,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof kt||(t instanceof Array&&(t=new Uint16Array(t)),t=new kt(t)),t.type=Je.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],i=new kt;let s;for(s in this.attributes){const n=this.attributes[s],a=this.buffers[n.buffer];t.push(a.data),e.push(n.size*gd[n.type]/4),n.buffer=0}for(i.data=Rv(t,e),s=0;s<this.buffers.length;s++)this.buffers[s]!==this.indexBuffer&&this.buffers[s].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new Sr;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new kt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new Zs(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Je.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Sr,i=[],s=[],n=[];let a;for(let o=0;o<t.length;o++){a=t[o];for(let l=0;l<a.buffers.length;l++)s[l]=s[l]||0,s[l]+=a.buffers[l].data.length,n[l]=0}for(let o=0;o<a.buffers.length;o++)i[o]=new Mv[qs(a.buffers[o].data)](s[o]),e.buffers[o]=new kt(i[o]);for(let o=0;o<t.length;o++){a=t[o];for(let l=0;l<a.buffers.length;l++)i[l].set(a.buffers[l].data,n[l]),n[l]+=a.buffers[l].data.length}if(e.attributes=a.attributes,a.indexBuffer){e.indexBuffer=e.buffers[a.buffers.indexOf(a.indexBuffer)],e.indexBuffer.type=Je.ELEMENT_ARRAY_BUFFER;let o=0,l=0,h=0,u=0;for(let c=0;c<a.buffers.length;c++)if(a.buffers[c]!==a.indexBuffer){u=c;break}for(const c in a.attributes){const d=a.attributes[c];(d.buffer|0)===u&&(l+=d.size*gd[d.type]/4)}for(let c=0;c<t.length;c++){const d=t[c].indexBuffer.data;for(let p=0;p<d.length;p++)e.indexBuffer.data[p+h]+=o;o+=t[c].buffers[u].data.length/l,h+=d.length}}return e}}class yd extends Sr{constructor(t=!1){super(),this._buffer=new kt(null,t,!1),this._indexBuffer=new kt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,ut.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,ut.FLOAT).addAttribute("aColor",this._buffer,4,!0,ut.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,ut.FLOAT).addIndex(this._indexBuffer)}}const Js=Math.PI*2,Dv=180/Math.PI,Bv=Math.PI/180;var Rt=(r=>(r[r.POLY=0]="POLY",r[r.RECT=1]="RECT",r[r.CIRC=2]="CIRC",r[r.ELIP=3]="ELIP",r[r.RREC=4]="RREC",r))(Rt||{});class vt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new vt(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}vt.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Qs=[new vt,new vt,new vt,new vt];class pt{constructor(t=0,e=0,i=0,s=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s),this.type=Rt.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new pt(0,0,0,0)}clone(){return new pt(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const D=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=D)return!1;const U=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>U}const i=this.left,s=this.right,n=this.top,a=this.bottom;if(s<=i||a<=n)return!1;const o=Qs[0].set(t.left,t.top),l=Qs[1].set(t.left,t.bottom),h=Qs[2].set(t.right,t.top),u=Qs[3].set(t.right,t.bottom);if(h.x<=o.x||l.y<=o.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(o,o),e.apply(l,l),e.apply(h,h),e.apply(u,u),Math.max(o.x,l.x,h.x,u.x)<=i||Math.min(o.x,l.x,h.x,u.x)>=s||Math.max(o.y,l.y,h.y,u.y)<=n||Math.min(o.y,l.y,h.y,u.y)>=a))return!1;const d=c*(l.y-o.y),p=c*(o.x-l.x),f=d*i+p*n,g=d*s+p*n,y=d*i+p*a,m=d*s+p*a;if(Math.max(f,g,y,m)<=d*o.x+p*o.y||Math.min(f,g,y,m)>=d*u.x+p*u.y)return!1;const _=c*(o.y-h.y),v=c*(h.x-o.x),x=_*i+v*n,b=_*s+v*n,R=_*i+v*a,w=_*s+v*a;return!(Math.max(x,b,R,w)<=_*o.x+v*o.y||Math.min(x,b,R,w)>=_*u.x+v*u.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=s-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=n-s,this}}pt.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class tn{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Rt.CIRC}clone(){return new tn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}getBounds(){return new pt(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}tn.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class en{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=Rt.ELIP}clone(){return new en(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,s=(e-this.y)/this.height;return i*=i,s*=s,i+s<=1}getBounds(){return new pt(this.x-this.width,this.y-this.height,this.width,this.height)}}en.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Xr{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.type=Rt.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Xr(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,a=s-1;n<s;a=n++){const o=this.points[n*2],l=this.points[n*2+1],h=this.points[a*2],u=this.points[a*2+1];l>e!=u>e&&t<(h-o)*((e-l)/(u-l))+o&&(i=!i)}return i}}Xr.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class rn{constructor(t=0,e=0,i=0,s=0,n=20){this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n,this.type=Rt.RREC}clone(){return new rn(this.x,this.y,this.width,this.height,this.radius)}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let s=t-(this.x+i),n=e-(this.y+i);const a=i*i;if(s*s+n*n<=a||(s=t-(this.x+this.width-i),s*s+n*n<=a)||(n=e-(this.y+this.height-i),s*s+n*n<=a)||(s=t-(this.x+i),s*s+n*n<=a))return!0}return!1}}rn.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class Ct{constructor(t=1,e=0,i=0,s=1,n=0,a=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=a}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,s,n,a){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=a,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new vt;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new vt;const i=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,a=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=a*e-this.ty*i,this.ty=a*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}setTransform(t,e,i,s,n,a,o,l,h){return this.a=Math.cos(o+h)*n,this.b=Math.sin(o+h)*n,this.c=-Math.sin(o-l)*a,this.d=Math.cos(o-l)*a,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,a=t.pivot,o=-Math.atan2(-s,n),l=Math.atan2(i,e),h=Math.abs(o+l);return h<1e-5||Math.abs(Js-h)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=l),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(a.x*e+a.y*s),t.position.y=this.ty+(a.x*i+a.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,a=t*s-e*i;return this.a=s/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-s*n)/a,this.ty=-(t*this.ty-e*n)/a,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new Ct;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new Ct}static get TEMP_MATRIX(){return new Ct}}Ct.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const Wr=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],zr=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],jr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Yr=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],nl=[],_d=[],sn=Math.sign;function Ov(){for(let r=0;r<16;r++){const t=[];nl.push(t);for(let e=0;e<16;e++){const i=sn(Wr[r]*Wr[e]+jr[r]*zr[e]),s=sn(zr[r]*Wr[e]+Yr[r]*zr[e]),n=sn(Wr[r]*jr[e]+jr[r]*Yr[e]),a=sn(zr[r]*jr[e]+Yr[r]*Yr[e]);for(let o=0;o<16;o++)if(Wr[o]===i&&zr[o]===s&&jr[o]===n&&Yr[o]===a){t.push(o);break}}}for(let r=0;r<16;r++){const t=new Ct;t.set(Wr[r],zr[r],jr[r],Yr[r],0,0),_d.push(t)}}Ov();const Bt={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>Wr[r],uY:r=>zr[r],vX:r=>jr[r],vY:r=>Yr[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>nl[r][t],sub:(r,t)=>nl[r][Bt.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?Bt.S:Bt.N:Math.abs(t)*2<=Math.abs(r)?r>0?Bt.E:Bt.W:t>0?r>0?Bt.SE:Bt.SW:r>0?Bt.NE:Bt.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=_d[Bt.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class vr{constructor(t,e,i=0,s=0){this._x=i,this._y=s,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new vr(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}vr.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const al=class{constructor(){this.worldTransform=new Ct,this.localTransform=new Ct,this.position=new vr(this.onChange,this,0,0),this.scale=new vr(this.onChange,this,1,1),this.pivot=new vr(this.onChange,this,0,0),this.skew=new vr(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const r=this.localTransform;this._localID!==this._currentLocalID&&(r.a=this._cx*this.scale.x,r.b=this._sx*this.scale.x,r.c=this._cy*this.scale.y,r.d=this._sy*this.scale.y,r.tx=this.position.x-(this.pivot.x*r.a+this.pivot.y*r.c),r.ty=this.position.y-(this.pivot.x*r.b+this.pivot.y*r.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(r){const t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==r._worldID){const e=r.worldTransform,i=this.worldTransform;i.a=t.a*e.a+t.b*e.c,i.b=t.a*e.b+t.b*e.d,i.c=t.c*e.a+t.d*e.c,i.d=t.c*e.b+t.d*e.d,i.tx=t.tx*e.a+t.ty*e.c+e.tx,i.ty=t.tx*e.b+t.ty*e.d+e.ty,this._parentID=r._worldID,this._worldID++}}setFromMatrix(r){r.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(r){this._rotation!==r&&(this._rotation=r,this.updateSkew())}};al.IDENTITY=new al;let nn=al;nn.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var Lv=`varying vec2 vTextureCoord;
13
13
 
14
14
  uniform sampler2D uSampler;
15
15
 
16
16
  void main(void){
17
17
  gl_FragColor *= texture2D(uSampler, vTextureCoord);
18
- }`,Cb=`attribute vec2 aVertexPosition;
18
+ }`,Fv=`attribute vec2 aVertexPosition;
19
19
  attribute vec2 aTextureCoord;
20
20
 
21
21
  uniform mat3 projectionMatrix;
@@ -26,7 +26,7 @@ void main(void){
26
26
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
27
27
  vTextureCoord = aTextureCoord;
28
28
  }
29
- `;function Bd(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function Sl(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Od(r,t){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Sl(2*t);case"bvec3":return Sl(3*t);case"bvec4":return Sl(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Bi=[{test:r=>r.type==="float"&&r.size===1&&!r.isArray,code:r=>`
29
+ `;function vd(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function ol(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function xd(r,t){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return ol(2*t);case"bvec3":return ol(3*t);case"bvec4":return ol(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Ei=[{test:r=>r.type==="float"&&r.size===1&&!r.isArray,code:r=>`
30
30
  if(uv["${r}"] !== ud["${r}"].value)
31
31
  {
32
32
  ud["${r}"].value = uv["${r}"]
@@ -146,7 +146,7 @@ void main(void){
146
146
  cv[3] = v[3];
147
147
 
148
148
  gl.uniform4f(ud["${r}"].location, v[0], v[1], v[2], v[3])
149
- }`}],Ib={float:`
149
+ }`}],Nv={float:`
150
150
  if (cv !== v)
151
151
  {
152
152
  cu.value = v;
@@ -282,7 +282,7 @@ void main(void){
282
282
  cu.value = v;
283
283
 
284
284
  gl.uniform1i(location, v);
285
- }`},Rb={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function Pb(r,t){var i;const e=[`
285
+ }`},Uv={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function kv(r,t){var i;const e=[`
286
286
  var v = null;
287
287
  var cv = null;
288
288
  var cu = null;
@@ -292,18 +292,18 @@ void main(void){
292
292
  renderer.shader.syncUniformBufferGroup(uv.${s}, '${s}');
293
293
  `):e.push(`
294
294
  renderer.shader.syncUniformGroup(uv.${s}, syncData);
295
- `));continue}const o=r.uniforms[s];let a=!1;for(let l=0;l<Bi.length;l++)if(Bi[l].test(n,o)){e.push(Bi[l].code(s,o)),a=!0;break}if(!a){const l=(n.size===1&&!n.isArray?Ib:Rb)[n.type].replace("location",`ud["${s}"].location`);e.push(`
295
+ `));continue}const a=r.uniforms[s];let o=!1;for(let l=0;l<Ei.length;l++)if(Ei[l].test(n,a)){e.push(Ei[l].code(s,a)),o=!0;break}if(!o){const l=(n.size===1&&!n.isArray?Nv:Uv)[n.type].replace("location",`ud["${s}"].location`);e.push(`
296
296
  cu = ud["${s}"];
297
297
  cv = cu.value;
298
298
  v = uv["${s}"];
299
299
  ${l};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
300
- `))}const Ld={};let Oi=Ld;function Mb(){if(Oi===Ld||Oi!=null&&Oi.isContextLost()){const r=z.ADAPTER.createCanvas();let t;z.PREFER_ENV>=Vr.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Oi=t}return Oi}let Fn;function Db(){if(!Fn){Fn=ve.MEDIUM;const r=Mb();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(Fn=t.precision?ve.HIGH:ve.MEDIUM)}}return Fn}function Fd(r,t){const e=r.getShaderSource(t).split(`
300
+ `))}const bd={};let Ai=bd;function Gv(){if(Ai===bd||Ai!=null&&Ai.isContextLost()){const r=et.ADAPTER.createCanvas();let t;et.PREFER_ENV>=Hr.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Ai=t}return Ai}let an;function Hv(){if(!an){an=Ee.MEDIUM;const r=Gv();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(an=t.precision?Ee.HIGH:Ee.MEDIUM)}}return an}function wd(r,t){const e=r.getShaderSource(t).split(`
301
301
  `).map((h,u)=>`${u}: ${h}`),i=r.getShaderInfoLog(t),s=i.split(`
302
- `),n={},o=s.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!n[h]?(n[h]=!0,!0):!1),a=[""];o.forEach(h=>{e[h-1]=`%c${e[h-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=e.join(`
303
- `);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Bb(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Fd(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Fd(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const Ob={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function Nd(r){return Ob[r]}let Nn=null;const Ud={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function kd(r,t){if(!Nn){const e=Object.keys(Ud);Nn={};for(let i=0;i<e.length;++i){const s=e[i];Nn[r[s]]=Ud[s]}}return Nn[t]}function Gd(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===ve.HIGH&&e!==ve.HIGH&&(i=ve.MEDIUM),`precision ${i} float;
304
- ${r}`}else if(e!==ve.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let bs;function Lb(){if(typeof bs=="boolean")return bs;try{bs=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{bs=!1}return bs}let Fb=0;const Un={},Cl=class zi{constructor(t,e,i="pixi-shader",s={}){this.extra={},this.id=Fb++,this.vertexSrc=t||zi.defaultVertexSrc,this.fragmentSrc=e||zi.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=s,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),Un[i]?(Un[i]++,i+=`-${Un[i]}`):Un[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
302
+ `),n={},a=s.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!n[h]?(n[h]=!0,!0):!1),o=[""];a.forEach(h=>{e[h-1]=`%c${e[h-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=e.join(`
303
+ `);o[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}function $v(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||wd(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||wd(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const Vv={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function Td(r){return Vv[r]}let on=null;const Ed={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function Ad(r,t){if(!on){const e=Object.keys(Ed);on={};for(let i=0;i<e.length;++i){const s=e[i];on[r[s]]=Ed[s]}}return on[t]}function Sd(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===Ee.HIGH&&e!==Ee.HIGH&&(i=Ee.MEDIUM),`precision ${i} float;
304
+ ${r}`}else if(e!==Ee.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let as;function Xv(){if(typeof as=="boolean")return as;try{as=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{as=!1}return as}let Wv=0;const ln={},ll=class $i{constructor(t,e,i="pixi-shader",s={}){this.extra={},this.id=Wv++,this.vertexSrc=t||$i.defaultVertexSrc,this.fragmentSrc=e||$i.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=s,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),ln[i]?(ln[i]++,i+=`-${ln[i]}`):ln[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
305
305
  ${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
306
- ${this.fragmentSrc}`,this.vertexSrc=Gd(this.vertexSrc,zi.defaultVertexPrecision,ve.HIGH),this.fragmentSrc=Gd(this.fragmentSrc,zi.defaultFragmentPrecision,Db())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return Cb}static get defaultFragmentSrc(){return Sb}static from(t,e,i){const s=t+e;let n=dl[s];return n||(dl[s]=n=new zi(t,e,i)),n}};Cl.defaultVertexPrecision=ve.HIGH,Cl.defaultFragmentPrecision=ze.apple.device?ve.HIGH:ve.MEDIUM;let xr=Cl,Nb=0;class De{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=Nb++,this.static=!!e,this.ubo=!!i,t instanceof Bt?(this.buffer=t,this.buffer.type=We.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Bt(new Float32Array(1)),this.buffer.type=We.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,i){if(!this.ubo)this.uniforms[t]=new De(e,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,i){return new De(t,e,i)}static uboFrom(t,e){return new De(t,e??!0,!0)}}class Qe{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof De?this.uniformGroup=e:this.uniformGroup=new De(e):this.uniformGroup=new De({}),this.disposeRunner=new Me("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const s=e.uniforms[i];if(s.group===!0&&this.checkUniformExists(t,s))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,i){const s=xr.from(t,e);return new Qe(s,i)}}class Ub{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;this.defaultGroupCache[t]=De.from({uSamplers:i},!0);let s=this.fragTemplate;s=s.replace(/%count%/gi,`${t}`),s=s.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new xr(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new wt,default:this.defaultGroupCache[t]};return new Qe(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
306
+ ${this.fragmentSrc}`,this.vertexSrc=Sd(this.vertexSrc,$i.defaultVertexPrecision,Ee.HIGH),this.fragmentSrc=Sd(this.fragmentSrc,$i.defaultFragmentPrecision,Hv())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return Fv}static get defaultFragmentSrc(){return Lv}static from(t,e,i){const s=t+e;let n=jo[s];return n||(jo[s]=n=new $i(t,e,i)),n}};ll.defaultVertexPrecision=Ee.HIGH,ll.defaultFragmentPrecision=Qe.apple.device?Ee.HIGH:Ee.MEDIUM;let xr=ll,zv=0;class Ne{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=zv++,this.static=!!e,this.ubo=!!i,t instanceof kt?(this.buffer=t,this.buffer.type=Je.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new kt(new Float32Array(1)),this.buffer.type=Je.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,i){if(!this.ubo)this.uniforms[t]=new Ne(e,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,i){return new Ne(t,e,i)}static uboFrom(t,e){return new Ne(t,e??!0,!0)}}class ir{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof Ne?this.uniformGroup=e:this.uniformGroup=new Ne(e):this.uniformGroup=new Ne({}),this.disposeRunner=new Fe("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const s=e.uniforms[i];if(s.group===!0&&this.checkUniformExists(t,s))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,i){const s=xr.from(t,e);return new ir(s,i)}}class jv{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;this.defaultGroupCache[t]=Ne.from({uSamplers:i},!0);let s=this.fragTemplate;s=s.replace(/%count%/gi,`${t}`),s=s.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new xr(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new Ct,default:this.defaultGroupCache[t]};return new ir(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
307
307
  `,e+=`
308
308
  `;for(let i=0;i<t;i++)i>0&&(e+=`
309
309
  else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
@@ -311,7 +311,7 @@ else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
311
311
  color = texture2D(uSamplers[${i}], vTextureCoord);`,e+=`
312
312
  }`;return e+=`
313
313
  `,e+=`
314
- `,e}}class Il{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}function kb(){return!ze.apple.device}function Gb(r){let t=!0;const e=z.ADAPTER.getNavigator();if(ze.tablet||ze.phone){if(ze.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(ze.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class kn{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var Hb=`varying vec2 vTextureCoord;
314
+ `,e}}class hl{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}function Yv(){return!Qe.apple.device}function qv(r){let t=!0;const e=et.ADAPTER.getNavigator();if(Qe.tablet||Qe.phone){if(Qe.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(Qe.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class hn{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var Kv=`varying vec2 vTextureCoord;
315
315
  varying vec4 vColor;
316
316
  varying float vTextureId;
317
317
  uniform sampler2D uSamplers[%count%];
@@ -321,7 +321,7 @@ void main(void){
321
321
  %forloop%
322
322
  gl_FragColor = color * vColor;
323
323
  }
324
- `,$b=`precision highp float;
324
+ `,Zv=`precision highp float;
325
325
  attribute vec2 aVertexPosition;
326
326
  attribute vec2 aTextureCoord;
327
327
  attribute vec4 aColor;
@@ -342,14 +342,14 @@ void main(void){
342
342
  vTextureId = aTextureId;
343
343
  vColor = aColor * tint;
344
344
  }
345
- `;const ws=class Ne extends kn{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Md,this.vertexSize=6,this.state=Je.for2d(),this.size=Ne.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),t.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??Gb(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??kb(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return et("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return $b}static get defaultFragmentTemplate(){return Hb}setShaderGenerator({vertex:t=Ne.defaultVertexSrc,fragment:e=Ne.defaultFragmentTemplate}={}){this.shaderGenerator=new Ub(t,e)}contextChange(){const t=this.renderer.gl;z.PREFER_ENV===Vr.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Ne.defaultMaxTextures),this.maxTextures=gb(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:e}=Ne,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new Tl);for(;e.length<s;)e.push(new Il);for(let n=0;n<this.maxTextures;n++)this._tempBoundTextures[n]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,i=Ne._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++st._globalBatch,l=0,h=i[0],u=0;s.copyBoundTextures(n,e);for(let c=0;c<this._bufferSize;++c){const d=t[c];t[c]=null,d._batchEnabled!==a&&(h.count>=e&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,u,c),u=c,h=i[++l],++a),d._batchEnabled=a,d.touched=o,h.elements[h.count++]=d)}h.count>0&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,u,this._bufferSize),++l,++a);for(let c=0;c<n.length;c++)n[c]=null;st._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=Ne._drawCallPool;let h=this._dcIndex,u=this._aIndex,c=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=t;for(let p=e;p<i;++p){const f=s[p],m=f._texture.baseTexture,_=ol[m.alphaMode?1:0][f.blendMode];s[p]=null,e<p&&d.blend!==_&&(d.size=c-d.start,e=p,d=l[++h],d.texArray=t,d.start=c),this.packInterleavedGeometry(f,n,o,u,c),u+=f.vertexData.length/2*a,c+=f.indices.length,d.blend=_}e<i&&(d.size=c-d.start,++h),this._dcIndex=h,this._aIndex=u,this._iIndex=c}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:i}=this;Ne.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:i}=this.renderer,s=Ne._drawCallPool;let n=null;for(let o=0;o<t;o++){const{texArray:a,type:l,size:h,start:u,blend:c}=s[o];n!==a&&(n=a,this.bindAndClearTexArray(a)),this.state.blendMode=c,i.set(this.state),e.drawElements(l,h,e.UNSIGNED_SHORT,u*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),Ne.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(t){const e=_s(Math.ceil(t/8)),i=hl(e),s=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._aBuffers[s];return n||(this._aBuffers[s]=n=new pl(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=_s(Math.ceil(t/12)),i=hl(e),s=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._iBuffers[i];return n||(this._iBuffers[i]=n=new Uint16Array(s)),n}packInterleavedGeometry(t,e,i,s,n){const{uint32View:o,float32View:a}=e,l=s/this.vertexSize,h=t.uvs,u=t.indices,c=t.vertexData,d=t._texture.baseTexture._batchLocation,p=Math.min(t.worldAlpha,1),f=ut.shared.setValue(t._tintRGB).toPremultiplied(p,t._texture.baseTexture.alphaMode>0);for(let m=0;m<c.length;m+=2)a[s++]=c[m],a[s++]=c[m+1],a[s++]=h[m],a[s++]=h[m+1],o[s++]=f,a[s++]=d;for(let m=0;m<u.length;m++)i[n++]=l+u[m]}};ws.defaultBatchSize=4096,ws.extension={name:"batch",type:X.RendererPlugin},ws._drawCallPool=[],ws._textureArrayPool=[];let ti=ws;j.add(ti);var Vb=`varying vec2 vTextureCoord;
345
+ `;const os=class Xe extends hn{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=yd,this.vertexSize=6,this.state=rr.for2d(),this.size=Xe.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),t.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??qv(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??Yv(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return ct("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Zv}static get defaultFragmentTemplate(){return Kv}setShaderGenerator({vertex:t=Xe.defaultVertexSrc,fragment:e=Xe.defaultFragmentTemplate}={}){this.shaderGenerator=new jv(t,e)}contextChange(){const t=this.renderer.gl;et.PREFER_ENV===Hr.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Xe.defaultMaxTextures),this.maxTextures=Av(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:e}=Xe,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new sl);for(;e.length<s;)e.push(new hl);for(let n=0;n<this.maxTextures;n++)this._tempBoundTextures[n]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,i=Xe._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,a=this.renderer.textureGC.count;let o=++dt._globalBatch,l=0,h=i[0],u=0;s.copyBoundTextures(n,e);for(let c=0;c<this._bufferSize;++c){const d=t[c];t[c]=null,d._batchEnabled!==o&&(h.count>=e&&(s.boundArray(h,n,o,e),this.buildDrawCalls(h,u,c),u=c,h=i[++l],++o),d._batchEnabled=o,d.touched=a,h.elements[h.count++]=d)}h.count>0&&(s.boundArray(h,n,o,e),this.buildDrawCalls(h,u,this._bufferSize),++l,++o);for(let c=0;c<n.length;c++)n[c]=null;dt._globalBatch=o}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:a,vertexSize:o}=this,l=Xe._drawCallPool;let h=this._dcIndex,u=this._aIndex,c=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=t;for(let p=e;p<i;++p){const f=s[p],g=f._texture.baseTexture,y=Ho[g.alphaMode?1:0][f.blendMode];s[p]=null,e<p&&d.blend!==y&&(d.size=c-d.start,e=p,d=l[++h],d.texArray=t,d.start=c),this.packInterleavedGeometry(f,n,a,u,c),u+=f.vertexData.length/2*o,c+=f.indices.length,d.blend=y}e<i&&(d.size=c-d.start,++h),this._dcIndex=h,this._aIndex=u,this._iIndex=c}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:i}=this;Xe.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:i}=this.renderer,s=Xe._drawCallPool;let n=null;for(let a=0;a<t;a++){const{texArray:o,type:l,size:h,start:u,blend:c}=s[a];n!==o&&(n=o,this.bindAndClearTexArray(o)),this.state.blendMode=c,i.set(this.state),e.drawElements(l,h,e.UNSIGNED_SHORT,u*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),Xe.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(t){const e=is(Math.ceil(t/8)),i=Xo(e),s=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._aBuffers[s];return n||(this._aBuffers[s]=n=new qo(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=is(Math.ceil(t/12)),i=Xo(e),s=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._iBuffers[i];return n||(this._iBuffers[i]=n=new Uint16Array(s)),n}packInterleavedGeometry(t,e,i,s,n){const{uint32View:a,float32View:o}=e,l=s/this.vertexSize,h=t.uvs,u=t.indices,c=t.vertexData,d=t._texture.baseTexture._batchLocation,p=Math.min(t.worldAlpha,1),f=_t.shared.setValue(t._tintRGB).toPremultiplied(p,t._texture.baseTexture.alphaMode>0);for(let g=0;g<c.length;g+=2)o[s++]=c[g],o[s++]=c[g+1],o[s++]=h[g],o[s++]=h[g+1],a[s++]=f,o[s++]=d;for(let g=0;g<u.length;g++)i[n++]=l+u[g]}};os.defaultBatchSize=4096,os.extension={name:"batch",type:J.RendererPlugin},os._drawCallPool=[],os._textureArrayPool=[];let qr=os;rt.add(qr);var Jv=`varying vec2 vTextureCoord;
346
346
 
347
347
  uniform sampler2D uSampler;
348
348
 
349
349
  void main(void){
350
350
  gl_FragColor = texture2D(uSampler, vTextureCoord);
351
351
  }
352
- `,Xb=`attribute vec2 aVertexPosition;
352
+ `,Qv=`attribute vec2 aVertexPosition;
353
353
 
354
354
  uniform mat3 projectionMatrix;
355
355
 
@@ -375,7 +375,7 @@ void main(void)
375
375
  gl_Position = filterVertexPosition();
376
376
  vTextureCoord = filterTextureCoord();
377
377
  }
378
- `;const Rl=class Fs extends Qe{constructor(t,e,i){const s=xr.from(t||Fs.defaultVertexSrc,e||Fs.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=Fs.defaultResolution,this.multisample=Fs.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Je}apply(t,e,i,s,n){t.applyFilter(this,e,i,s)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return Xb}static get defaultFragmentSrc(){return Vb}};Rl.defaultResolution=1,Rl.defaultMultisample=Lt.NONE;let ne=Rl;class Gn{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new ut(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:s}=t,n=i??e;n!==void 0&&(this.color=n),this.alpha=s}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}Gn.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Gn.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"background"},j.add(Gn);class Hd{constructor(t){this.renderer=t,this.emptyRenderer=new kn(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:i}=this.renderer.texture;for(let s=e-1;s>=0;--s)t[s]=i[s]||null,t[s]&&(t[s]._batchLocation=s)}boundArray(t,e,i,s){const{elements:n,ids:o,count:a}=t;let l=0;for(let h=0;h<a;h++){const u=n[h],c=u._batchLocation;if(c>=0&&c<s&&e[c]===u){o[h]=c;continue}for(;l<s;){const d=e[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,u._batchLocation=l,e[l]=u;break}}}destroy(){this.renderer=null}}Hd.extension={type:X.RendererSystem,name:"batch"},j.add(Hd);let $d=0;class Hn{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=$d++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=$d++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let i;if(z.PREFER_ENV>=Vr.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=s,s||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}Hn.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},Hn.extension={type:X.RendererSystem,name:"context"},j.add(Hn);class Pl{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new Me("disposeFramebuffer"),this.multisample=Lt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new st(null,{scaleMode:Ie.NEAREST,resolution:1,mipmap:Ve.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new st(null,{scaleMode:Ie.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Ve.OFF,format:$.DEPTH_COMPONENT,type:J.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const s=this.colorTextures[i],n=s.resolution;s.setSize(t/n,e/n)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Ml extends st{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],s=arguments[2],n=arguments[3];t={width:e,height:i,scaleMode:s,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=Lt.NONE),super(null,t),this.mipmap=Ve.OFF,this.valid=!0,this._clear=new ut([0,0,0,0]),this.framebuffer=new Pl(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class br extends xs{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.displayWidth||e.width,s=e.naturalHeight||e.videoHeight||e.displayHeight||e.height;super(i,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=Cd(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,s){const n=t.gl,o=e.realWidth,a=e.realHeight;if(s=s||this.source,typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement){if(!s.complete||s.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement&&s.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===ae.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&i.width===o&&i.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,i.type,s):(i.width=o,i.height=a,n.texImage2D(e.target,0,i.internalFormat,e.format,i.type,s)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class Vd extends br{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;br.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??z.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,i)=>{const s=this.source;this.url=s.src;const n=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};s.complete&&s.src?n():(s.onload=n,s.onerror=o=>{i(o),this.onError.emit(o)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(s=>s.blob()).then(s=>e(s,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===ae.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==i&&a.dirtyId!==e.dirtyId){s=!1;break}}s&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class Dl{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const s=e.width,n=e.height;if(i){const o=t.width/2/s,a=t.height/2/n,l=t.x/s+o,h=t.y/n+a;i=St.add(i,St.NW),this.x0=l+o*St.uX(i),this.y0=h+a*St.uY(i),i=St.add(i,2),this.x1=l+o*St.uX(i),this.y1=h+a*St.uY(i),i=St.add(i,2),this.x2=l+o*St.uX(i),this.y2=h+a*St.uY(i),i=St.add(i,2),this.x3=l+o*St.uX(i),this.y3=h+a*St.uY(i)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Dl.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const Xd=new Dl;function $n(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class Y extends wi{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new at(0,0,1,1)),t instanceof Y&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=Xd,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=o?new dt(o.x,o.y):new dt(0,0),this.defaultBorders=a,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;e!=null&&e.url&&se[e.url]&&Y.removeFromCache(e.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,Y.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var s;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),i=new Y(this.baseTexture,!this.noFrame&&t,e,(s=this.trim)==null?void 0:s.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===Xd&&(this._uvs=new Dl),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=z.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof st){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${Cr()}`,st.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${Cr()}`}n=t._pixiId}let o=se[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof st)?(e.resolution||(e.resolution=Ze(t)),o=new Y(new st(t,e)),o.baseTexture.cacheId=n,st.addToCache(o.baseTexture,n),Y.addToCache(o,n)):!o&&t instanceof st&&(o=new Y(t),Y.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=Y.from(t,Object.assign({resourceOptions:i},e),!1),n=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):n.load().then(()=>Promise.resolve(s))}static fromBuffer(t,e,i,s){return new Y(st.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new st(t,Object.assign({scaleMode:st.defaultOptions.scaleMode,resolution:Ze(e)},s)),{resource:o}=n;o instanceof Vd&&(o.url=e);const a=new Y(n);return i||(i=e),st.addToCache(a.baseTexture,i),Y.addToCache(a,i),i!==e&&(st.addToCache(a.baseTexture,e),Y.addToCache(a,e)),a.baseTexture.valid?Promise.resolve(a):new Promise(l=>{a.baseTexture.once("loaded",()=>l(a))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),se[e]&&se[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),se[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=se[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete se[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)se[t.textureCacheIds[e]]===t&&delete se[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:s,height:n}=t,o=e+s>this.baseTexture.width,a=i+n>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,u=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${u}`)}this.valid=s&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return Y._EMPTY||(Y._EMPTY=new Y(new st),$n(Y._EMPTY),$n(Y._EMPTY.baseTexture)),Y._EMPTY}static get WHITE(){if(!Y._WHITE){const t=z.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),Y._WHITE=new Y(st.from(t)),$n(Y._WHITE),$n(Y._WHITE.baseTexture)}return Y._WHITE}}class tr extends Y{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,i=!0){const s=this.baseTexture.resolution,n=Math.round(t*s)/s,o=Math.round(e*s)/s;this.valid=n>0&&o>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=o,i&&this.baseTexture.resize(n,o),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new tr(new Ml(t))}}class Wd{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=Lt.NONE){const s=new Ml(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new tr(s)}getOptimalTexture(t,e,i=1,s=Lt.NONE){let n;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=_s(t),e=_s(e),n=((t&65535)<<16|e&65535)>>>0,s>1&&(n+=s*4294967296)):n=s>1?-s:-1,this.texturePool[n]||(this.texturePool[n]=[]);let o=this.texturePool[n].pop();return o||(o=this.createTexture(t,e,s)),o.filterPoolKey=n,o.setResolution(i),o}getFilterTexture(t,e,i){const s=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||Lt.NONE);return s.filterFrame=t.filterFrame,s}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const e in this.texturePool){const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Wd.SCREEN_KEY=-1;class Wb extends Ir{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class zd extends Ir{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new Bt(this.vertices),this.uvBuffer=new Bt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,s=0;return this.uvs[0]=i,this.uvs[1]=s,this.uvs[2]=i+e.width/t.width,this.uvs[3]=s,this.uvs[4]=i+e.width/t.width,this.uvs[5]=s+e.height/t.height,this.uvs[6]=i,this.uvs[7]=s+e.height/t.height,i=e.x,s=e.y,this.vertices[0]=i,this.vertices[1]=s,this.vertices[2]=i+e.width,this.vertices[3]=s,this.vertices[4]=i+e.width,this.vertices[5]=s+e.height,this.vertices[6]=i,this.vertices[7]=s+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class zb{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Lt.NONE,this.sourceFrame=new at,this.destinationFrame=new at,this.bindingSourceFrame=new at,this.bindingDestinationFrame=new at,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Vn=[new dt,new dt,new dt,new dt],Bl=new wt;class jd{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Wd,this.statePool=[],this.quad=new Wb,this.quadUv=new zd,this.tempRect=new at,this.activeState={},this.globalUniforms=new De({outputFrame:new at,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new zb,o=i.renderTexture;let a,l;if(o.current){const _=o.current;a=_.resolution,l=_.multisample}else a=i.resolution,l=i.multisample;let h=e[0].resolution||a,u=e[0].multisample??l,c=e[0].padding,d=e[0].autoFit,p=e[0].legacy??!0;for(let _=1;_<e.length;_++){const g=e[_];h=Math.min(h,g.resolution||a),u=Math.min(u,g.multisample??l),c=this.useMaxPadding?Math.max(c,g.padding):c+g.padding,d=d&&g.autoFit,p=p||(g.legacy??!0)}s.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),s.push(n),n.resolution=h,n.multisample=u,n.legacy=p,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(c);const f=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(Bl.copyFrom(i.projection.transform).invert(),f),d?(n.sourceFrame.fit(f),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(f)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,h,u),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const m=this.tempRect;m.x=0,m.y=0,m.width=n.sourceFrame.width,m.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(o.sourceFrame),n.bindingDestinationFrame.copyFrom(o.destinationFrame),n.transform=i.projection.transform,i.projection.transform=null,o.bind(n.renderTexture,n.sourceFrame,m),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const s=this.globalUniforms.uniforms;s.outputFrame=e.sourceFrame,s.resolution=e.resolution;const n=s.inputSize,o=s.inputPixel,a=s.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],o[0]=Math.round(n[0]*e.resolution),o[1]=Math.round(n[1]*e.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=e.sourceFrame.width*n[2]-.5*o[2],a[3]=e.sourceFrame.height*n[3]-.5*o[3],e.legacy){const h=s.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,s.filterClamp=s.inputClamp}this.globalUniforms.update();const l=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,l.renderTexture,Xe.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,u=this.getOptimalFilterTexture(h.width,h.height,e.resolution);u.filterFrame=h.filterFrame;let c=0;for(c=0;c<i.length-1;++c){c===1&&e.multisample>1&&(u=this.getOptimalFilterTexture(h.width,h.height,e.resolution),u.filterFrame=h.filterFrame),i[c].apply(this,h,u,Xe.CLEAR,e);const d=h;h=u,u=d}i[c].apply(this,h,l.renderTexture,Xe.BLEND,e),c>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(u)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=Xe.CLEAR){const{renderTexture:i,state:s}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t==null?void 0:t.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=t.filterFrame.width,o.height=t.filterFrame.height,i.bind(t,t.filterFrame,o)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=s.stateId&1||this.forceClear;(e===Xe.CLEAR||e===Xe.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,s){const n=this.renderer;n.state.set(t.state),this.bindAndClear(i,s),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(Ce.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(Ce.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:s}=this.activeState,{orig:n}=e._texture,o=t.set(s.width,0,0,s.height,i.x,i.y),a=e.worldTransform.copyTo(wt.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/n.width,1/n.height),o.translate(e.anchor.x,e.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,s=Lt.NONE){return this.texturePool.getOptimalTexture(t,e,i,s)}getFilterTexture(t,e,i){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const s=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||Lt.NONE);return s.filterFrame=t.filterFrame,s}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=Vn[0],s=Vn[1],n=Vn[2],o=Vn[3];i.set(e.left,e.top),s.set(e.left,e.bottom),n.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(i,i),t.apply(s,s),t.apply(n,n),t.apply(o,o);const a=Math.min(i.x,s.x,n.x,o.x),l=Math.min(i.y,s.y,n.y,o.y),h=Math.max(i.x,s.x,n.x,o.x),u=Math.max(i.y,s.y,n.y,o.y);e.x=a,e.y=l,e.width=h-a,e.height=u-l}roundFrame(t,e,i,s,n){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(n){const{a:o,b:a,c:l,d:h}=n;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(h)>1e-4))return}n=n?Bl.copyFrom(n):Bl.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}jd.extension={type:X.RendererSystem,name:"filter"},j.add(jd);class jb{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Lt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const Yb=new at;class Yd{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Pl(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new at,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;z.PREFER_ENV===Vr.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=s=>e.drawBuffersWEBGL(s):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=0){const{gl:s}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=i),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let o=0;o<t.colorTextures.length;o++){const a=t.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const o=e.width>>i,a=e.height>>i,l=o/e.width;this.setViewport(e.x*l,e.y*l,o,a)}else{const o=t.width>>i,a=t.height>>i;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,s.bindFramebuffer(s.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,i,s){const n=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),s=Math.round(s),(n.width!==i||n.height!==s||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=i,n.height=s,this.gl.viewport(t,e,i,s))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,i,s,n=ha.COLOR|ha.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new jb(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){e.bindRenderbuffer(e.RENDERBUFFER,i.stencil);let o;this.renderer.context.webGLVersion===1?o=e.DEPTH_STENCIL:t.depth&&t.stencil?o=e.DEPTH24_STENCIL8:t.depth?o=e.DEPTH_COMPONENT24:o=e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,o,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,o,t.width,t.height)}const s=t.colorTextures;let n=s.length;e.drawBuffers||(n=Math.min(n,1));for(let o=0;o<n;o++){const a=s[o],l=a.parentTextureArray||a;this.renderer.texture.bind(l,0),o===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,s=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;i.drawBuffers||(o=Math.min(o,1)),s.multisample>1&&this.canMultisampleFramebuffer(t)?s.msaaBuffer=s.msaaBuffer||i.createRenderbuffer():s.msaaBuffer&&(i.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=n[l],u=h.parentTextureArray||h;this.renderer.texture.bind(u,0),l===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,u._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,s.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,u._glTextures[this.CONTEXT_UID].texture,e),a.push(i.COLOR_ATTACHMENT0+l))}if(a.length>1&&i.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):t.depth&&t.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):t.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,h,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,h,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,s.stencil)}else s.stencil&&(i.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=Lt.NONE;if(t<=1||e===null)return i;for(let s=0;s<e.length;s++)if(e[s]<=t){i=e[s];break}return i===1&&(i=Lt.NONE),i}blit(t,e,i){const{current:s,renderer:n,gl:o,CONTEXT_UID:a}=this;if(n.context.webGLVersion!==2||!s)return;const l=s.glFramebuffers[a];if(!l)return;if(!t){if(!l.msaaBuffer)return;const u=s.colorTextures[0];if(!u)return;l.blitFramebuffer||(l.blitFramebuffer=new Pl(s.width,s.height),l.blitFramebuffer.addColorTexture(0,u)),t=l.blitFramebuffer,t.colorTextures[0]!==u&&(t.colorTextures[0]=u,t.dirtyId++,t.dirtyFormat++),(t.width!==s.width||t.height!==s.height)&&(t.width=s.width,t.height=s.height,t.dirtyId++,t.dirtySize++)}e||(e=Yb,e.width=s.width,e.height=s.height),i||(i=e);const h=e.width===i.width&&e.height===i.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,h?o.NEAREST:o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],s=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(s.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&s.deleteRenderbuffer(i.msaaBuffer),i.stencil&&s.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,s=t.height,n=this.gl,o=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH_STENCIL):t.depth?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH24_STENCIL8):(a=n.STENCIL_ATTACHMENT,l=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,l,i,s):n.renderbufferStorage(n.RENDERBUFFER,l,i,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new at}destroy(){this.renderer=null}}Yd.extension={type:X.RendererSystem,name:"framebuffer"},j.add(Yd);const Ol={5126:4,5123:2,5121:1};class qd{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;z.PREFER_ENV===Vr.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=s=>i.bindVertexArrayOES(s),t.deleteVertexArray=s=>i.deleteVertexArrayOES(s)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n),t.drawElementsInstanced=(s,n,o,a,l)=>i.drawElementsInstancedANGLE(s,n,o,a,l),t.drawArraysInstanced=(s,n,o,a)=>i.drawArraysInstancedANGLE(s,n,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=this;let s=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;s||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=s={},n=!0);const o=s[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==o&&(this._activeVao=o,this.hasVao?i.bindVertexArray(o):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.update(s)}}checkCompatibility(t,e){const i=t.attributes,s=e.attributeData;for(const n in s)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,s=e.attributeData,n=["g",t.id];for(const o in i)s[o]&&n.push(o,s[o].location);return n.join("-")}initGeometryVao(t,e,i=!0){const s=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const l=this.getSignature(t,a),h=t.glVertexArrayObjects[this.CONTEXT_UID];let u=h[l];if(u)return h[a.id]=u,u;const c=t.buffers,d=t.attributes,p={},f={};for(const m in c)p[m]=0,f[m]=0;for(const m in d)!d[m].size&&a.attributeData[m]?d[m].size=a.attributeData[m].size:d[m].size||console.warn(`PIXI Geometry attribute '${m}' size cannot be determined (likely the bound shader does not have the attribute)`),p[d[m].buffer]+=d[m].size*Ol[d[m].type];for(const m in d){const _=d[m],g=_.size;_.stride===void 0&&(p[_.buffer]===g*Ol[_.type]?_.stride=0:_.stride=p[_.buffer]),_.start===void 0&&(_.start=f[_.buffer],f[_.buffer]+=g*Ol[_.type])}u=s.createVertexArray(),s.bindVertexArray(u);for(let m=0;m<c.length;m++){const _=c[m];o.bind(_),i&&_._glBuffers[n].refCount++}return this.activateVao(t,a),h[a.id]=u,h[l]=u,s.bindVertexArray(null),o.unbind(We.ARRAY_BUFFER),u}disposeGeometry(t,e){var a;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,o=(a=this.renderer)==null?void 0:a.buffer;if(t.disposeRunner.remove(this),!!i){if(o)for(let l=0;l<n.length;l++){const h=n[l]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&o.dispose(n[l],e))}if(!e){for(const l in i)if(l[0]==="g"){const h=i[l];this._activeVao===h&&this.unbind(),s.deleteVertexArray(h)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,s=this.CONTEXT_UID,n=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let l=null;for(const h in a){const u=a[h],c=o[u.buffer],d=c._glBuffers[s];if(e.attributeData[h]){l!==d&&(n.bind(c),l=d);const p=e.attributeData[h].location;if(i.enableVertexAttribArray(p),i.vertexAttribPointer(p,u.size,u.type||i.FLOAT,u.normalized,u.stride,u.start),u.instance)if(this.hasInstance)i.vertexAttribDivisor(p,u.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,s){const{gl:n}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,l,(i||0)*a,s||1):n.drawElements(t,e||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?n.drawArraysInstanced(t,i,e||o.getSize(),s||1):n.drawArrays(t,i,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}qd.extension={type:X.RendererSystem,name:"geometry"},j.add(qd);const Kd=new wt;class Ll{constructor(t,e){this._texture=t,this.mapCoord=new wt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],o=t[s+1];e[s]=n*i.a+o*i.c+i.tx,e[s+1]=n*i.b+o*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const s=e.orig,n=e.trim;n&&(Kd.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Kd));const o=e.baseTexture,a=this.uClampFrame,l=this.clampMargin/o.resolution,h=this.clampOffset;return a[0]=(e._frame.x+l+h)/o.width,a[1]=(e._frame.y+l+h)/o.height,a[2]=(e._frame.x+e._frame.width-l+h)/o.width,a[3]=(e._frame.y+e._frame.height-l+h)/o.height,this.uClampOffset[0]=h/o.realWidth,this.uClampOffset[1]=h/o.realHeight,this.isSimple=e._frame.width===o.width&&e._frame.height===o.height&&e.rotate===0,!0}}var qb=`varying vec2 vMaskCoord;
378
+ `;const ul=class ws extends ir{constructor(t,e,i){const s=xr.from(t||ws.defaultVertexSrc,e||ws.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=ws.defaultResolution,this.multisample=ws.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new rr}apply(t,e,i,s,n){t.applyFilter(this,e,i,s)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return Qv}static get defaultFragmentSrc(){return Jv}};ul.defaultResolution=1,ul.defaultMultisample=Ht.NONE;let he=ul;class un{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new _t(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:s}=t,n=i??e;n!==void 0&&(this.color=n),this.alpha=s}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}un.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},un.extension={type:[J.RendererSystem,J.CanvasRendererSystem],name:"background"},rt.add(un);class Cd{constructor(t){this.renderer=t,this.emptyRenderer=new hn(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:i}=this.renderer.texture;for(let s=e-1;s>=0;--s)t[s]=i[s]||null,t[s]&&(t[s]._batchLocation=s)}boundArray(t,e,i,s){const{elements:n,ids:a,count:o}=t;let l=0;for(let h=0;h<o;h++){const u=n[h],c=u._batchLocation;if(c>=0&&c<s&&e[c]===u){a[h]=c;continue}for(;l<s;){const d=e[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}a[h]=l,u._batchLocation=l,e[l]=u;break}}}destroy(){this.renderer=null}}Cd.extension={type:J.RendererSystem,name:"batch"},rt.add(Cd);let Id=0;class cn{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=Id++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=Id++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let i;if(et.PREFER_ENV>=Hr.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=s,s||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}cn.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},cn.extension={type:J.RendererSystem,name:"context"},rt.add(cn);class cl{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new Fe("disposeFramebuffer"),this.multisample=Ht.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new dt(null,{scaleMode:Oe.NEAREST,resolution:1,mipmap:Ke.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new dt(null,{scaleMode:Oe.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Ke.OFF,format:Z.DEPTH_COMPONENT,type:ut.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const s=this.colorTextures[i],n=s.resolution;s.setSize(t/n,e/n)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class dl extends dt{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],s=arguments[2],n=arguments[3];t={width:e,height:i,scaleMode:s,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=Ht.NONE),super(null,t),this.mipmap=Ke.OFF,this.valid=!0,this._clear=new _t([0,0,0,0]),this.framebuffer=new cl(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class br extends ns{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.displayWidth||e.width,s=e.naturalHeight||e.videoHeight||e.displayHeight||e.height;super(i,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=fd(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,s){const n=t.gl,a=e.realWidth,o=e.realHeight;if(s=s||this.source,typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement){if(!s.complete||s.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement&&s.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===ce.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&i.width===a&&i.height===o?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,i.type,s):(i.width=a,i.height=o,n.texImage2D(e.target,0,i.internalFormat,e.format,i.type,s)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class Rd extends br{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;br.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??et.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,i)=>{const s=this.source;this.url=s.src;const n=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};s.complete&&s.src?n():(s.onload=n,s.onerror=a=>{i(a),this.onError.emit(a)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(s=>s.blob()).then(s=>e(s,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===ce.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const a in n){const o=n[a];if(o!==i&&o.dirtyId!==e.dirtyId){s=!1;break}}s&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class fl{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const s=e.width,n=e.height;if(i){const a=t.width/2/s,o=t.height/2/n,l=t.x/s+a,h=t.y/n+o;i=Bt.add(i,Bt.NW),this.x0=l+a*Bt.uX(i),this.y0=h+o*Bt.uY(i),i=Bt.add(i,2),this.x1=l+a*Bt.uX(i),this.y1=h+o*Bt.uY(i),i=Bt.add(i,2),this.x2=l+a*Bt.uX(i),this.y2=h+o*Bt.uY(i),i=Bt.add(i,2),this.x3=l+a*Bt.uX(i),this.y3=h+o*Bt.uY(i)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}fl.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const Pd=new fl;function dn(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class it extends bi{constructor(t,e,i,s,n,a,o){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new pt(0,0,1,1)),t instanceof it&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=Pd,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=a?new vt(a.x,a.y):new vt(0,0),this.defaultBorders=o,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;e!=null&&e.url&&le[e.url]&&it.removeFromCache(e.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,it.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var s;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),i=new it(this.baseTexture,!this.noFrame&&t,e,(s=this.trim)==null?void 0:s.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===Pd&&(this._uvs=new fl),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=et.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof dt){if(!t.cacheId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${o}-${Ar()}`,dt.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${o}_${Ar()}`}n=t._pixiId}let a=le[n];if(s&&i&&!a)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!a&&!(t instanceof dt)?(e.resolution||(e.resolution=er(t)),a=new it(new dt(t,e)),a.baseTexture.cacheId=n,dt.addToCache(a.baseTexture,n),it.addToCache(a,n)):!a&&t instanceof dt&&(a=new it(t),it.addToCache(a,n)),a}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=it.from(t,Object.assign({resourceOptions:i},e),!1),n=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):n.load().then(()=>Promise.resolve(s))}static fromBuffer(t,e,i,s){return new it(dt.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new dt(t,Object.assign({scaleMode:dt.defaultOptions.scaleMode,resolution:er(e)},s)),{resource:a}=n;a instanceof Rd&&(a.url=e);const o=new it(n);return i||(i=e),dt.addToCache(o.baseTexture,i),it.addToCache(o,i),i!==e&&(dt.addToCache(o.baseTexture,e),it.addToCache(o,e)),o.baseTexture.valid?Promise.resolve(o):new Promise(l=>{o.baseTexture.once("loaded",()=>l(o))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),le[e]&&le[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),le[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=le[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete le[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)le[t.textureCacheIds[e]]===t&&delete le[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:s,height:n}=t,a=e+s>this.baseTexture.width,o=i+n>this.baseTexture.height;if(a||o){const l=a&&o?"and":"or",h=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,u=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${u}`)}this.valid=s&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return it._EMPTY||(it._EMPTY=new it(new dt),dn(it._EMPTY),dn(it._EMPTY.baseTexture)),it._EMPTY}static get WHITE(){if(!it._WHITE){const t=et.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),it._WHITE=new it(dt.from(t)),dn(it._WHITE),dn(it._WHITE.baseTexture)}return it._WHITE}}class sr extends it{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,i=!0){const s=this.baseTexture.resolution,n=Math.round(t*s)/s,a=Math.round(e*s)/s;this.valid=n>0&&a>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=a,i&&this.baseTexture.resize(n,a),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new sr(new dl(t))}}class Md{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=Ht.NONE){const s=new dl(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new sr(s)}getOptimalTexture(t,e,i=1,s=Ht.NONE){let n;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=is(t),e=is(e),n=((t&65535)<<16|e&65535)>>>0,s>1&&(n+=s*4294967296)):n=s>1?-s:-1,this.texturePool[n]||(this.texturePool[n]=[]);let a=this.texturePool[n].pop();return a||(a=this.createTexture(t,e,s)),a.filterPoolKey=n,a.setResolution(i),a}getFilterTexture(t,e,i){const s=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||Ht.NONE);return s.filterFrame=t.filterFrame,s}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const e in this.texturePool){const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Md.SCREEN_KEY=-1;class t0 extends Sr{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Dd extends Sr{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new kt(this.vertices),this.uvBuffer=new kt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,s=0;return this.uvs[0]=i,this.uvs[1]=s,this.uvs[2]=i+e.width/t.width,this.uvs[3]=s,this.uvs[4]=i+e.width/t.width,this.uvs[5]=s+e.height/t.height,this.uvs[6]=i,this.uvs[7]=s+e.height/t.height,i=e.x,s=e.y,this.vertices[0]=i,this.vertices[1]=s,this.vertices[2]=i+e.width,this.vertices[3]=s,this.vertices[4]=i+e.width,this.vertices[5]=s+e.height,this.vertices[6]=i,this.vertices[7]=s+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class e0{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Ht.NONE,this.sourceFrame=new pt,this.destinationFrame=new pt,this.bindingSourceFrame=new pt,this.bindingDestinationFrame=new pt,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const fn=[new vt,new vt,new vt,new vt],pl=new Ct;class Bd{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Md,this.statePool=[],this.quad=new t0,this.quadUv=new Dd,this.tempRect=new pt,this.activeState={},this.globalUniforms=new Ne({outputFrame:new pt,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new e0,a=i.renderTexture;let o,l;if(a.current){const y=a.current;o=y.resolution,l=y.multisample}else o=i.resolution,l=i.multisample;let h=e[0].resolution||o,u=e[0].multisample??l,c=e[0].padding,d=e[0].autoFit,p=e[0].legacy??!0;for(let y=1;y<e.length;y++){const m=e[y];h=Math.min(h,m.resolution||o),u=Math.min(u,m.multisample??l),c=this.useMaxPadding?Math.max(c,m.padding):c+m.padding,d=d&&m.autoFit,p=p||(m.legacy??!0)}s.length===1&&(this.defaultFilterStack[0].renderTexture=a.current),s.push(n),n.resolution=h,n.multisample=u,n.legacy=p,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(c);const f=this.tempRect.copyFrom(a.sourceFrame);i.projection.transform&&this.transformAABB(pl.copyFrom(i.projection.transform).invert(),f),d?(n.sourceFrame.fit(f),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(f)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,a.current?a.current.resolution:i.resolution,a.sourceFrame,a.destinationFrame,i.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,h,u),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const g=this.tempRect;g.x=0,g.y=0,g.width=n.sourceFrame.width,g.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(a.sourceFrame),n.bindingDestinationFrame.copyFrom(a.destinationFrame),n.transform=i.projection.transform,i.projection.transform=null,a.bind(n.renderTexture,n.sourceFrame,g),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const s=this.globalUniforms.uniforms;s.outputFrame=e.sourceFrame,s.resolution=e.resolution;const n=s.inputSize,a=s.inputPixel,o=s.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],a[0]=Math.round(n[0]*e.resolution),a[1]=Math.round(n[1]*e.resolution),a[2]=1/a[0],a[3]=1/a[1],o[0]=.5*a[2],o[1]=.5*a[3],o[2]=e.sourceFrame.width*n[2]-.5*a[2],o[3]=e.sourceFrame.height*n[3]-.5*a[3],e.legacy){const h=s.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,s.filterClamp=s.inputClamp}this.globalUniforms.update();const l=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,l.renderTexture,Ze.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,u=this.getOptimalFilterTexture(h.width,h.height,e.resolution);u.filterFrame=h.filterFrame;let c=0;for(c=0;c<i.length-1;++c){c===1&&e.multisample>1&&(u=this.getOptimalFilterTexture(h.width,h.height,e.resolution),u.filterFrame=h.filterFrame),i[c].apply(this,h,u,Ze.CLEAR,e);const d=h;h=u,u=d}i[c].apply(this,h,l.renderTexture,Ze.BLEND,e),c>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(u)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=Ze.CLEAR){const{renderTexture:i,state:s}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t==null?void 0:t.filterFrame){const a=this.tempRect;a.x=0,a.y=0,a.width=t.filterFrame.width,a.height=t.filterFrame.height,i.bind(t,t.filterFrame,a)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=s.stateId&1||this.forceClear;(e===Ze.CLEAR||e===Ze.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,s){const n=this.renderer;n.state.set(t.state),this.bindAndClear(i,s),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(Be.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(Be.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:s}=this.activeState,{orig:n}=e._texture,a=t.set(s.width,0,0,s.height,i.x,i.y),o=e.worldTransform.copyTo(Ct.TEMP_MATRIX);return o.invert(),a.prepend(o),a.scale(1/n.width,1/n.height),a.translate(e.anchor.x,e.anchor.y),a}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,s=Ht.NONE){return this.texturePool.getOptimalTexture(t,e,i,s)}getFilterTexture(t,e,i){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const s=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||Ht.NONE);return s.filterFrame=t.filterFrame,s}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=fn[0],s=fn[1],n=fn[2],a=fn[3];i.set(e.left,e.top),s.set(e.left,e.bottom),n.set(e.right,e.top),a.set(e.right,e.bottom),t.apply(i,i),t.apply(s,s),t.apply(n,n),t.apply(a,a);const o=Math.min(i.x,s.x,n.x,a.x),l=Math.min(i.y,s.y,n.y,a.y),h=Math.max(i.x,s.x,n.x,a.x),u=Math.max(i.y,s.y,n.y,a.y);e.x=o,e.y=l,e.width=h-o,e.height=u-l}roundFrame(t,e,i,s,n){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(n){const{a,b:o,c:l,d:h}=n;if((Math.abs(o)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(a)>1e-4||Math.abs(h)>1e-4))return}n=n?pl.copyFrom(n):pl.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}Bd.extension={type:J.RendererSystem,name:"filter"},rt.add(Bd);class r0{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Ht.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const i0=new pt;class Od{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new cl(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new pt,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;et.PREFER_ENV===Hr.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=s=>e.drawBuffersWEBGL(s):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=0){const{gl:s}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=i),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let a=0;a<t.colorTextures.length;a++){const o=t.colorTextures[a];this.renderer.texture.unbind(o.parentTextureArray||o)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const a=e.width>>i,o=e.height>>i,l=a/e.width;this.setViewport(e.x*l,e.y*l,a,o)}else{const a=t.width>>i,o=t.height>>i;this.setViewport(0,0,a,o)}}else this.current&&(this.current=null,s.bindFramebuffer(s.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,i,s){const n=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),s=Math.round(s),(n.width!==i||n.height!==s||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=i,n.height=s,this.gl.viewport(t,e,i,s))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,i,s,n=Ba.COLOR|Ba.DEPTH){const{gl:a}=this;a.clearColor(t,e,i,s),a.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new r0(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){e.bindRenderbuffer(e.RENDERBUFFER,i.stencil);let a;this.renderer.context.webGLVersion===1?a=e.DEPTH_STENCIL:t.depth&&t.stencil?a=e.DEPTH24_STENCIL8:t.depth?a=e.DEPTH_COMPONENT24:a=e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,a,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,a,t.width,t.height)}const s=t.colorTextures;let n=s.length;e.drawBuffers||(n=Math.min(n,1));for(let a=0;a<n;a++){const o=s[a],l=o.parentTextureArray||o;this.renderer.texture.bind(l,0),a===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,s=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let a=n.length;i.drawBuffers||(a=Math.min(a,1)),s.multisample>1&&this.canMultisampleFramebuffer(t)?s.msaaBuffer=s.msaaBuffer||i.createRenderbuffer():s.msaaBuffer&&(i.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const o=[];for(let l=0;l<a;l++){const h=n[l],u=h.parentTextureArray||h;this.renderer.texture.bind(u,0),l===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,u._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,s.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,u._glTextures[this.CONTEXT_UID].texture,e),o.push(i.COLOR_ATTACHMENT0+l))}if(o.length>1&&i.drawBuffers(o),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):t.depth&&t.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):t.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,h,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,h,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,s.stencil)}else s.stencil&&(i.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=Ht.NONE;if(t<=1||e===null)return i;for(let s=0;s<e.length;s++)if(e[s]<=t){i=e[s];break}return i===1&&(i=Ht.NONE),i}blit(t,e,i){const{current:s,renderer:n,gl:a,CONTEXT_UID:o}=this;if(n.context.webGLVersion!==2||!s)return;const l=s.glFramebuffers[o];if(!l)return;if(!t){if(!l.msaaBuffer)return;const u=s.colorTextures[0];if(!u)return;l.blitFramebuffer||(l.blitFramebuffer=new cl(s.width,s.height),l.blitFramebuffer.addColorTexture(0,u)),t=l.blitFramebuffer,t.colorTextures[0]!==u&&(t.colorTextures[0]=u,t.dirtyId++,t.dirtyFormat++),(t.width!==s.width||t.height!==s.height)&&(t.width=s.width,t.height=s.height,t.dirtyId++,t.dirtySize++)}e||(e=i0,e.width=s.width,e.height=s.height),i||(i=e);const h=e.width===i.width&&e.height===i.height;this.bind(t),a.bindFramebuffer(a.READ_FRAMEBUFFER,l.framebuffer),a.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,a.COLOR_BUFFER_BIT,h?a.NEAREST:a.LINEAR),a.bindFramebuffer(a.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],s=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(s.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&s.deleteRenderbuffer(i.msaaBuffer),i.stencil&&s.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,s=t.height,n=this.gl,a=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,a);let o,l;this.renderer.context.webGLVersion===1?(o=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH_STENCIL):t.depth?(o=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH24_STENCIL8):(o=n.STENCIL_ATTACHMENT,l=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,l,i,s):n.renderbufferStorage(n.RENDERBUFFER,l,i,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,o,n.RENDERBUFFER,a)}reset(){this.current=this.unknownFramebuffer,this.viewport=new pt}destroy(){this.renderer=null}}Od.extension={type:J.RendererSystem,name:"framebuffer"},rt.add(Od);const ml={5126:4,5123:2,5121:1};class Ld{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;et.PREFER_ENV===Hr.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=s=>i.bindVertexArrayOES(s),t.deleteVertexArray=s=>i.deleteVertexArrayOES(s)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n),t.drawElementsInstanced=(s,n,a,o,l)=>i.drawElementsInstancedANGLE(s,n,a,o,l),t.drawArraysInstanced=(s,n,a,o)=>i.drawArraysInstancedANGLE(s,n,a,o)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=this;let s=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;s||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=s={},n=!0);const a=s[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==a&&(this._activeVao=a,this.hasVao?i.bindVertexArray(a):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.update(s)}}checkCompatibility(t,e){const i=t.attributes,s=e.attributeData;for(const n in s)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,s=e.attributeData,n=["g",t.id];for(const a in i)s[a]&&n.push(a,s[a].location);return n.join("-")}initGeometryVao(t,e,i=!0){const s=this.gl,n=this.CONTEXT_UID,a=this.renderer.buffer,o=e.program;o.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,o);const l=this.getSignature(t,o),h=t.glVertexArrayObjects[this.CONTEXT_UID];let u=h[l];if(u)return h[o.id]=u,u;const c=t.buffers,d=t.attributes,p={},f={};for(const g in c)p[g]=0,f[g]=0;for(const g in d)!d[g].size&&o.attributeData[g]?d[g].size=o.attributeData[g].size:d[g].size||console.warn(`PIXI Geometry attribute '${g}' size cannot be determined (likely the bound shader does not have the attribute)`),p[d[g].buffer]+=d[g].size*ml[d[g].type];for(const g in d){const y=d[g],m=y.size;y.stride===void 0&&(p[y.buffer]===m*ml[y.type]?y.stride=0:y.stride=p[y.buffer]),y.start===void 0&&(y.start=f[y.buffer],f[y.buffer]+=m*ml[y.type])}u=s.createVertexArray(),s.bindVertexArray(u);for(let g=0;g<c.length;g++){const y=c[g];a.bind(y),i&&y._glBuffers[n].refCount++}return this.activateVao(t,o),h[o.id]=u,h[l]=u,s.bindVertexArray(null),a.unbind(Je.ARRAY_BUFFER),u}disposeGeometry(t,e){var o;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,a=(o=this.renderer)==null?void 0:o.buffer;if(t.disposeRunner.remove(this),!!i){if(a)for(let l=0;l<n.length;l++){const h=n[l]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&a.dispose(n[l],e))}if(!e){for(const l in i)if(l[0]==="g"){const h=i[l];this._activeVao===h&&this.unbind(),s.deleteVertexArray(h)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,s=this.CONTEXT_UID,n=this.renderer.buffer,a=t.buffers,o=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let l=null;for(const h in o){const u=o[h],c=a[u.buffer],d=c._glBuffers[s];if(e.attributeData[h]){l!==d&&(n.bind(c),l=d);const p=e.attributeData[h].location;if(i.enableVertexAttribArray(p),i.vertexAttribPointer(p,u.size,u.type||i.FLOAT,u.normalized,u.stride,u.start),u.instance)if(this.hasInstance)i.vertexAttribDivisor(p,u.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,s){const{gl:n}=this,a=this._activeGeometry;if(a.indexBuffer){const o=a.indexBuffer.data.BYTES_PER_ELEMENT,l=o===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;o===2||o===4&&this.canUseUInt32ElementIndex?a.instanced?n.drawElementsInstanced(t,e||a.indexBuffer.data.length,l,(i||0)*o,s||1):n.drawElements(t,e||a.indexBuffer.data.length,l,(i||0)*o):console.warn("unsupported index buffer type: uint32")}else a.instanced?n.drawArraysInstanced(t,i,e||a.getSize(),s||1):n.drawArrays(t,i,e||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}Ld.extension={type:J.RendererSystem,name:"geometry"},rt.add(Ld);const Fd=new Ct;class gl{constructor(t,e){this._texture=t,this.mapCoord=new Ct,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],a=t[s+1];e[s]=n*i.a+a*i.c+i.tx,e[s+1]=n*i.b+a*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const s=e.orig,n=e.trim;n&&(Fd.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Fd));const a=e.baseTexture,o=this.uClampFrame,l=this.clampMargin/a.resolution,h=this.clampOffset;return o[0]=(e._frame.x+l+h)/a.width,o[1]=(e._frame.y+l+h)/a.height,o[2]=(e._frame.x+e._frame.width-l+h)/a.width,o[3]=(e._frame.y+e._frame.height-l+h)/a.height,this.uClampOffset[0]=h/a.realWidth,this.uClampOffset[1]=h/a.realHeight,this.isSimple=e._frame.width===a.width&&e._frame.height===a.height&&e.rotate===0,!0}}var s0=`varying vec2 vMaskCoord;
379
379
  varying vec2 vTextureCoord;
380
380
 
381
381
  uniform sampler2D uSampler;
@@ -400,7 +400,7 @@ void main(void)
400
400
 
401
401
  gl_FragColor = original;
402
402
  }
403
- `,Kb=`attribute vec2 aVertexPosition;
403
+ `,n0=`attribute vec2 aVertexPosition;
404
404
  attribute vec2 aTextureCoord;
405
405
 
406
406
  uniform mat3 projectionMatrix;
@@ -416,7 +416,7 @@ void main(void)
416
416
  vTextureCoord = aTextureCoord;
417
417
  vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
418
418
  }
419
- `;class Zb extends ne{constructor(t,e,i){let s=null;typeof t!="string"&&e===void 0&&i===void 0&&(s=t,t=void 0,e=void 0,i=void 0),super(t||Kb,e||qb,i),this.maskSprite=s,this.maskMatrix=new wt}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,s){const n=this._maskSprite,o=n._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new Ll(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,t.applyFilter(this,e,i,s))}}class Jb{constructor(t=null){this.type=Ft.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=ne.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=Ft.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class Zd{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const n=this.maskDataPool.pop()||new Jb;n.pooled=!0,n.maskObject=e,i=n}const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(s),i._colorMask=s?s._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==Ft.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case Ft.SCISSOR:this.renderer.scissor.push(i);break;case Ft.STENCIL:this.renderer.stencil.push(i);break;case Ft.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case Ft.COLOR:this.pushColorMask(i);break}i.type===Ft.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case Ft.SCISSOR:this.renderer.scissor.pop(e);break;case Ft.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case Ft.SPRITE:this.popSpriteMask(e);break;case Ft.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===Ft.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=Ft.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=Ft.SCISSOR:t.type=Ft.STENCIL:t.type=Ft.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let s=t._filters;s||(s=this.alphaMaskPool[this.alphaMaskIndex],s||(s=this.alphaMaskPool[this.alphaMaskIndex]=[new Zb])),s[0].resolution=t.resolution,s[0].multisample=t.multisample,s[0].maskSprite=e;const n=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,s),i.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}Zd.extension={type:X.RendererSystem,name:"mask"},j.add(Zd);class Jd{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const s=this.getStackLength();s!==i&&(s===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const Qd=new wt,tf=[],ef=class So extends Jd{constructor(t){super(t),this.glConst=z.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:s}=this,n=s.renderTexture,o=i.getBounds(!0,tf.pop()??new at);this.roundFrameToPixels(o,n.current?n.current.resolution:s.resolution,n.sourceFrame,n.destinationFrame,s.projection.transform),e&&o.fit(e),t._scissorRectLocal=o}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:s,d:n}=t;return(Math.abs(i)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||So.isMatrixRotated(e.worldTransform)||So.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,s,n){So.isMatrixRotated(n)||(n=n?Qd.copyFrom(n):Qd.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.renderer.filter.transformAABB(n,t),t.fit(s),t.x=Math.round(t.x*e),t.y=Math.round(t.y*e),t.width=Math.round(t.width*e),t.height=Math.round(t.height*e))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&tf.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;this.renderer.renderTexture.current?e=t.y:e=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};ef.extension={type:X.RendererSystem,name:"scissor"};let Qb=ef;j.add(Qb);class rf extends Jd{constructor(t){super(t),this.glConst=z.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:i}=this.renderer,s=t._stencilCounter;s===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,s,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,i.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,s=i?i._colorMask:15;s!==0&&(i._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,s!==0&&(i._colorMask=s,e.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}rf.extension={type:X.RendererSystem,name:"stencil"},j.add(rf);class sf{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return et("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return et("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return et("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events}}})}init(){const t=this.rendererPlugins;for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}sf.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"_plugin"},j.add(sf);class nf{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new wt,this.transform=null}update(t,e,i,s){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,s),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,i,s){const n=this.projectionMatrix,o=s?-1:1;n.identity(),n.a=1/e.width*2,n.d=o*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-o-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}nf.extension={type:X.RendererSystem,name:"projection"},j.add(nf);const t1=new Ln,of=new at;class af{constructor(t){this.renderer=t,this._tempMatrix=new wt}generateTexture(t,e){const{region:i,...s}=e||{},n=(i==null?void 0:i.copyTo(of))||t.getLocalBounds(of,!0),o=s.resolution||this.renderer.resolution;n.width=Math.max(n.width,1/o),n.height=Math.max(n.height,1/o),s.width=n.width,s.height=n.height,s.resolution=o,s.multisample??(s.multisample=this.renderer.multisample);const a=tr.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=t1,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}af.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"textureGenerator"},j.add(af);const ei=new at,Ts=new at;class lf{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new at,this.destinationFrame=new at,this.viewportFrame=new at}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const s=this.renderer;this.current=t;let n,o,a;t?(n=t.baseTexture,a=n.resolution,e||(ei.width=t.frame.width,ei.height=t.frame.height,e=ei),i||(Ts.x=t.frame.x,Ts.y=t.frame.y,Ts.width=e.width,Ts.height=e.height,i=Ts),o=n.framebuffer):(a=s.resolution,e||(ei.width=s._view.screen.width,ei.height=s._view.screen.height,e=ei),i||(i=ei,i.width=e.width,i.height=e.height));const l=this.viewportFrame;l.x=i.x*a,l.y=i.y*a,l.width=i.width*a,l.height=i.height*a,t||(l.y=s.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(o,l),this.renderer.projection.update(i,e,a,!o),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,s=ut.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&s.premultiply(s.alpha);const n=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=n.width!==o.width||n.height!==o.height;if(a){let{x:l,y:h,width:u,height:c}=this.viewportFrame;l=Math.round(l),h=Math.round(h),u=Math.round(u),c=Math.round(c),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,u,c)}this.renderer.framebuffer.clear(s.red,s.green,s.blue,s.alpha,e),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}lf.extension={type:X.RendererSystem,name:"renderTexture"},j.add(lf);class e1{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function r1(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const n=t.getActiveAttrib(r,s);if(n.name.startsWith("gl_"))continue;const o=kd(t,n.type),a={type:o,name:n.name,size:Nd(o),location:t.getAttribLocation(r,n.name)};e[n.name]=a}return e}function i1(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){const n=t.getActiveUniform(r,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=kd(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:Od(l,n.size)}}return e}function s1(r,t){var a;const e=Bd(r,r.VERTEX_SHADER,t.vertexSrc),i=Bd(r,r.FRAGMENT_SHADER,t.fragmentSrc),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=(a=t.extra)==null?void 0:a.transformFeedbackVaryings;if(n&&(typeof r.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||Bb(r,s,e,i),t.attributeData=r1(s,r),t.uniformData=i1(s,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((h,u)=>h>u?1:-1);for(let h=0;h<l.length;h++)t.attributeData[l[h]].location=h,r.bindAttribLocation(s,h,l[h]);r.linkProgram(s)}r.deleteShader(e),r.deleteShader(i);const o={};for(const l in t.uniformData){const h=t.uniformData[l];o[l]={location:r.getUniformLocation(s,l),value:Od(h.type,h.size)}}return new e1(s,o)}function n1(r,t,e,i,s){e.buffer.update(s)}const o1={float:`
419
+ `;class a0 extends he{constructor(t,e,i){let s=null;typeof t!="string"&&e===void 0&&i===void 0&&(s=t,t=void 0,e=void 0,i=void 0),super(t||n0,e||s0,i),this.maskSprite=s,this.maskMatrix=new Ct}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,s){const n=this._maskSprite,a=n._texture;a.valid&&(a.uvMatrix||(a.uvMatrix=new gl(a,0)),a.uvMatrix.update(),this.uniforms.npmAlpha=a.baseTexture.alphaMode?0:1,this.uniforms.mask=a,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(a.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=a.uvMatrix.uClampFrame,t.applyFilter(this,e,i,s))}}class o0{constructor(t=null){this.type=Vt.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=he.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=Vt.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class Nd{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const n=this.maskDataPool.pop()||new o0;n.pooled=!0,n.maskObject=e,i=n}const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(s),i._colorMask=s?s._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==Vt.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case Vt.SCISSOR:this.renderer.scissor.push(i);break;case Vt.STENCIL:this.renderer.stencil.push(i);break;case Vt.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case Vt.COLOR:this.pushColorMask(i);break}i.type===Vt.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case Vt.SCISSOR:this.renderer.scissor.pop(e);break;case Vt.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case Vt.SPRITE:this.popSpriteMask(e);break;case Vt.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===Vt.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=Vt.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=Vt.SCISSOR:t.type=Vt.STENCIL:t.type=Vt.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let s=t._filters;s||(s=this.alphaMaskPool[this.alphaMaskIndex],s||(s=this.alphaMaskPool[this.alphaMaskIndex]=[new a0])),s[0].resolution=t.resolution,s[0].multisample=t.multisample,s[0].maskSprite=e;const n=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,s),i.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}Nd.extension={type:J.RendererSystem,name:"mask"},rt.add(Nd);class Ud{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const s=this.getStackLength();s!==i&&(s===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const kd=new Ct,Gd=[],Hd=class Zn extends Ud{constructor(t){super(t),this.glConst=et.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:s}=this,n=s.renderTexture,a=i.getBounds(!0,Gd.pop()??new pt);this.roundFrameToPixels(a,n.current?n.current.resolution:s.resolution,n.sourceFrame,n.destinationFrame,s.projection.transform),e&&a.fit(e),t._scissorRectLocal=a}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:s,d:n}=t;return(Math.abs(i)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||Zn.isMatrixRotated(e.worldTransform)||Zn.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,s,n){Zn.isMatrixRotated(n)||(n=n?kd.copyFrom(n):kd.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.renderer.filter.transformAABB(n,t),t.fit(s),t.x=Math.round(t.x*e),t.y=Math.round(t.y*e),t.width=Math.round(t.width*e),t.height=Math.round(t.height*e))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&Gd.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;this.renderer.renderTexture.current?e=t.y:e=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};Hd.extension={type:J.RendererSystem,name:"scissor"};let l0=Hd;rt.add(l0);class $d extends Ud{constructor(t){super(t),this.glConst=et.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:i}=this.renderer,s=t._stencilCounter;s===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,s,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,i.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,s=i?i._colorMask:15;s!==0&&(i._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,s!==0&&(i._colorMask=s,e.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}$d.extension={type:J.RendererSystem,name:"stencil"},rt.add($d);class Vd{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return ct("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return ct("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return ct("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events}}})}init(){const t=this.rendererPlugins;for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}Vd.extension={type:[J.RendererSystem,J.CanvasRendererSystem],name:"_plugin"},rt.add(Vd);class Xd{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new Ct,this.transform=null}update(t,e,i,s){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,s),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,i,s){const n=this.projectionMatrix,a=s?-1:1;n.identity(),n.a=1/e.width*2,n.d=a*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-a-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}Xd.extension={type:J.RendererSystem,name:"projection"},rt.add(Xd);const h0=new nn,Wd=new pt;class zd{constructor(t){this.renderer=t,this._tempMatrix=new Ct}generateTexture(t,e){const{region:i,...s}=e||{},n=(i==null?void 0:i.copyTo(Wd))||t.getLocalBounds(Wd,!0),a=s.resolution||this.renderer.resolution;n.width=Math.max(n.width,1/a),n.height=Math.max(n.height,1/a),s.width=n.width,s.height=n.height,s.resolution=a,s.multisample??(s.multisample=this.renderer.multisample);const o=sr.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=h0,this.renderer.render(t,{renderTexture:o,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,o}destroy(){}}zd.extension={type:[J.RendererSystem,J.CanvasRendererSystem],name:"textureGenerator"},rt.add(zd);const Kr=new pt,ls=new pt;class jd{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new pt,this.destinationFrame=new pt,this.viewportFrame=new pt}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const s=this.renderer;this.current=t;let n,a,o;t?(n=t.baseTexture,o=n.resolution,e||(Kr.width=t.frame.width,Kr.height=t.frame.height,e=Kr),i||(ls.x=t.frame.x,ls.y=t.frame.y,ls.width=e.width,ls.height=e.height,i=ls),a=n.framebuffer):(o=s.resolution,e||(Kr.width=s._view.screen.width,Kr.height=s._view.screen.height,e=Kr),i||(i=Kr,i.width=e.width,i.height=e.height));const l=this.viewportFrame;l.x=i.x*o,l.y=i.y*o,l.width=i.width*o,l.height=i.height*o,t||(l.y=s.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(a,l),this.renderer.projection.update(i,e,o,!a),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,s=_t.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&s.premultiply(s.alpha);const n=this.destinationFrame,a=this.current?this.current.baseTexture:this.renderer._view.screen,o=n.width!==a.width||n.height!==a.height;if(o){let{x:l,y:h,width:u,height:c}=this.viewportFrame;l=Math.round(l),h=Math.round(h),u=Math.round(u),c=Math.round(c),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,u,c)}this.renderer.framebuffer.clear(s.red,s.green,s.blue,s.alpha,e),o&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}jd.extension={type:J.RendererSystem,name:"renderTexture"},rt.add(jd);class u0{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function c0(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const n=t.getActiveAttrib(r,s);if(n.name.startsWith("gl_"))continue;const a=Ad(t,n.type),o={type:a,name:n.name,size:Td(a),location:t.getAttribLocation(r,n.name)};e[n.name]=o}return e}function d0(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){const n=t.getActiveUniform(r,s),a=n.name.replace(/\[.*?\]$/,""),o=!!n.name.match(/\[.*?\]$/),l=Ad(t,n.type);e[a]={name:a,index:s,type:l,size:n.size,isArray:o,value:xd(l,n.size)}}return e}function f0(r,t){var o;const e=vd(r,r.VERTEX_SHADER,t.vertexSrc),i=vd(r,r.FRAGMENT_SHADER,t.fragmentSrc),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=(o=t.extra)==null?void 0:o.transformFeedbackVaryings;if(n&&(typeof r.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||$v(r,s,e,i),t.attributeData=c0(s,r),t.uniformData=d0(s,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((h,u)=>h>u?1:-1);for(let h=0;h<l.length;h++)t.attributeData[l[h]].location=h,r.bindAttribLocation(s,h,l[h]);r.linkProgram(s)}r.deleteShader(e),r.deleteShader(i);const a={};for(const l in t.uniformData){const h=t.uniformData[l];a[l]={location:r.getUniformLocation(s,l),value:xd(h.type,h.size)}}return new u0(s,a)}function p0(r,t,e,i,s){e.buffer.update(s)}const m0={float:`
420
420
  data[offset] = v;
421
421
  `,vec2:`
422
422
  data[offset] = v[0];
@@ -454,7 +454,7 @@ void main(void)
454
454
  {
455
455
  data[offset + i] = v[i];
456
456
  }
457
- `},hf={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function a1(r){const t=r.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(e=hf[o.data.type],o.data.size>1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,i%e!==0&&i<16){const a=i%e%16;i+=a,s+=a}i+e>16?(s=Math.ceil(s/16)*16,o.offset=s,s+=e,i=e):(o.offset=s,i+=e,s+=e)}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}function l1(r,t){const e=[];for(const i in r)t[i]&&e.push(t[i]);return e.sort((i,s)=>i.index-s.index),e}function h1(r,t){if(!r.autoManage)return{size:0,syncFunc:n1};const e=l1(r.uniforms,t),{uboElements:i,size:s}=a1(e),n=[`
457
+ `},Yd={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function g0(r){const t=r.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,s=0;for(let n=0;n<t.length;n++){const a=t[n];if(e=Yd[a.data.type],a.data.size>1&&(e=Math.max(e,16)*a.data.size),a.dataLen=e,i%e!==0&&i<16){const o=i%e%16;i+=o,s+=o}i+e>16?(s=Math.ceil(s/16)*16,a.offset=s,s+=e,i=e):(a.offset=s,i+=e,s+=e)}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}function y0(r,t){const e=[];for(const i in r)t[i]&&e.push(t[i]);return e.sort((i,s)=>i.index-s.index),e}function _0(r,t){if(!r.autoManage)return{size:0,syncFunc:p0};const e=y0(r.uniforms,t),{uboElements:i,size:s}=g0(e),n=[`
458
458
  var v = null;
459
459
  var v2 = null;
460
460
  var cv = null;
@@ -462,14 +462,14 @@ void main(void)
462
462
  var gl = renderer.gl
463
463
  var index = 0;
464
464
  var data = buffer.data;
465
- `];for(let o=0;o<i.length;o++){const a=i[o],l=r.uniforms[a.data.name],h=a.data.name;let u=!1;for(let c=0;c<Bi.length;c++){const d=Bi[c];if(d.codeUbo&&d.test(a.data,l)){n.push(`offset = ${a.offset/4};`,Bi[c].codeUbo(a.data.name,l)),u=!0;break}}if(!u)if(a.data.size>1){const c=Nd(a.data.type),d=Math.max(hf[a.data.type]/16,1),p=c/d,f=(4-p%4)%4;n.push(`
465
+ `];for(let a=0;a<i.length;a++){const o=i[a],l=r.uniforms[o.data.name],h=o.data.name;let u=!1;for(let c=0;c<Ei.length;c++){const d=Ei[c];if(d.codeUbo&&d.test(o.data,l)){n.push(`offset = ${o.offset/4};`,Ei[c].codeUbo(o.data.name,l)),u=!0;break}}if(!u)if(o.data.size>1){const c=Td(o.data.type),d=Math.max(Yd[o.data.type]/16,1),p=c/d,f=(4-p%4)%4;n.push(`
466
466
  cv = ud.${h}.value;
467
467
  v = uv.${h};
468
- offset = ${a.offset/4};
468
+ offset = ${o.offset/4};
469
469
 
470
470
  t = 0;
471
471
 
472
- for(var i=0; i < ${a.data.size*d}; i++)
472
+ for(var i=0; i < ${o.data.size*d}; i++)
473
473
  {
474
474
  for(var j = 0; j < ${p}; j++)
475
475
  {
@@ -478,15 +478,15 @@ void main(void)
478
478
  offset += ${f};
479
479
  }
480
480
 
481
- `)}else{const c=o1[a.data.type];n.push(`
481
+ `)}else{const c=m0[o.data.type];n.push(`
482
482
  cv = ud.${h}.value;
483
483
  v = uv.${h};
484
- offset = ${a.offset/4};
484
+ offset = ${o.offset/4};
485
485
  ${c};
486
486
  `)}}return n.push(`
487
487
  renderer.buffer.update(buffer);
488
488
  `),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(`
489
- `))}}let u1=0;const Xn={textureCount:0,uboCount:0};class uf{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=u1++}systemCheck(){if(!Lb())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),e||(Xn.textureCount=0,Xn.uboCount=0,this.syncUniformGroup(t.uniformGroup,Xn)),s}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=Pb(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const s=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),s(i.uniformData,t.uniforms,this.renderer,Xn,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(t,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=h1(t,this.shader.program.uniformData)),t.autoManage){const l=new Float32Array(a.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const s=t.uniforms,n=[`${i}-`];for(const o in s)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,s=s1(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}uf.extension={type:X.RendererSystem,name:"shader"},j.add(uf);class Wn{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}Wn.defaultOptions={hello:!1},Wn.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"startup"},j.add(Wn);function c1(r,t=[]){return t[U.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.ADD]=[r.ONE,r.ONE],t[U.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.NONE]=[0,0],t[U.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[U.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[U.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[U.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[U.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[U.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[U.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[U.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[U.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[U.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[U.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const d1=0,f1=1,p1=2,m1=3,g1=4,y1=5,cf=class bh{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=U.NONE,this._blendEq=!1,this.map=[],this.map[d1]=this.setBlend,this.map[f1]=this.setOffset,this.map[p1]=this.setCullFace,this.map[m1]=this.setDepthTest,this.map[g1]=this.setFrontFace,this.map[y1]=this.setDepthMask,this.checks=[],this.defaultState=new Je,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=c1(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(bh.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(bh.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};cf.extension={type:X.RendererSystem,name:"state"};let _1=cf;j.add(_1);class df extends wi{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(const s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Me(e)})}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(s=>{const n=i.find(o=>this._systemsHash[o]===s);s[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const Es=class Co{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Co.defaultMaxIdle,this.checkCountMax=Co.defaultCheckCountMax,this.mode=Co.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==ua.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!1;for(let s=0;s<e.length;s++){const n=e[s];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[s]=null,i=!0)}if(i){let s=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[s++]=e[n]);e.length=s}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};Es.defaultMode=ua.AUTO,Es.defaultMaxIdle=60*60,Es.defaultCheckCountMax=60*10,Es.extension={type:X.RendererSystem,name:"textureGC"};let ri=Es;j.add(ri);class Fl{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=J.UNSIGNED_BYTE,this.internalFormat=$.RGBA,this.samplerType=0}}function v1(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:q.FLOAT,[r.RGBA]:q.FLOAT,[r.ALPHA]:q.FLOAT,[r.LUMINANCE]:q.FLOAT,[r.LUMINANCE_ALPHA]:q.FLOAT,[r.R8]:q.FLOAT,[r.R8_SNORM]:q.FLOAT,[r.RG8]:q.FLOAT,[r.RG8_SNORM]:q.FLOAT,[r.RGB8]:q.FLOAT,[r.RGB8_SNORM]:q.FLOAT,[r.RGB565]:q.FLOAT,[r.RGBA4]:q.FLOAT,[r.RGB5_A1]:q.FLOAT,[r.RGBA8]:q.FLOAT,[r.RGBA8_SNORM]:q.FLOAT,[r.RGB10_A2]:q.FLOAT,[r.RGB10_A2UI]:q.FLOAT,[r.SRGB8]:q.FLOAT,[r.SRGB8_ALPHA8]:q.FLOAT,[r.R16F]:q.FLOAT,[r.RG16F]:q.FLOAT,[r.RGB16F]:q.FLOAT,[r.RGBA16F]:q.FLOAT,[r.R32F]:q.FLOAT,[r.RG32F]:q.FLOAT,[r.RGB32F]:q.FLOAT,[r.RGBA32F]:q.FLOAT,[r.R11F_G11F_B10F]:q.FLOAT,[r.RGB9_E5]:q.FLOAT,[r.R8I]:q.INT,[r.R8UI]:q.UINT,[r.R16I]:q.INT,[r.R16UI]:q.UINT,[r.R32I]:q.INT,[r.R32UI]:q.UINT,[r.RG8I]:q.INT,[r.RG8UI]:q.UINT,[r.RG16I]:q.INT,[r.RG16UI]:q.UINT,[r.RG32I]:q.INT,[r.RG32UI]:q.UINT,[r.RGB8I]:q.INT,[r.RGB8UI]:q.UINT,[r.RGB16I]:q.INT,[r.RGB16UI]:q.UINT,[r.RGB32I]:q.INT,[r.RGB32UI]:q.UINT,[r.RGBA8I]:q.INT,[r.RGBA8UI]:q.UINT,[r.RGBA16I]:q.INT,[r.RGBA16UI]:q.UINT,[r.RGBA32I]:q.INT,[r.RGBA32UI]:q.UINT,[r.DEPTH_COMPONENT16]:q.FLOAT,[r.DEPTH_COMPONENT24]:q.FLOAT,[r.DEPTH_COMPONENT32F]:q.FLOAT,[r.DEPTH_STENCIL]:q.FLOAT,[r.DEPTH24_STENCIL8]:q.FLOAT,[r.DEPTH32F_STENCIL8]:q.FLOAT}:t={[r.RGB]:q.FLOAT,[r.RGBA]:q.FLOAT,[r.ALPHA]:q.FLOAT,[r.LUMINANCE]:q.FLOAT,[r.LUMINANCE_ALPHA]:q.FLOAT,[r.DEPTH_STENCIL]:q.FLOAT},t}function x1(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[J.UNSIGNED_BYTE]:{[$.RGBA]:r.RGBA8,[$.RGB]:r.RGB8,[$.RG]:r.RG8,[$.RED]:r.R8,[$.RGBA_INTEGER]:r.RGBA8UI,[$.RGB_INTEGER]:r.RGB8UI,[$.RG_INTEGER]:r.RG8UI,[$.RED_INTEGER]:r.R8UI,[$.ALPHA]:r.ALPHA,[$.LUMINANCE]:r.LUMINANCE,[$.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[J.BYTE]:{[$.RGBA]:r.RGBA8_SNORM,[$.RGB]:r.RGB8_SNORM,[$.RG]:r.RG8_SNORM,[$.RED]:r.R8_SNORM,[$.RGBA_INTEGER]:r.RGBA8I,[$.RGB_INTEGER]:r.RGB8I,[$.RG_INTEGER]:r.RG8I,[$.RED_INTEGER]:r.R8I},[J.UNSIGNED_SHORT]:{[$.RGBA_INTEGER]:r.RGBA16UI,[$.RGB_INTEGER]:r.RGB16UI,[$.RG_INTEGER]:r.RG16UI,[$.RED_INTEGER]:r.R16UI,[$.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[J.SHORT]:{[$.RGBA_INTEGER]:r.RGBA16I,[$.RGB_INTEGER]:r.RGB16I,[$.RG_INTEGER]:r.RG16I,[$.RED_INTEGER]:r.R16I},[J.UNSIGNED_INT]:{[$.RGBA_INTEGER]:r.RGBA32UI,[$.RGB_INTEGER]:r.RGB32UI,[$.RG_INTEGER]:r.RG32UI,[$.RED_INTEGER]:r.R32UI,[$.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[J.INT]:{[$.RGBA_INTEGER]:r.RGBA32I,[$.RGB_INTEGER]:r.RGB32I,[$.RG_INTEGER]:r.RG32I,[$.RED_INTEGER]:r.R32I},[J.FLOAT]:{[$.RGBA]:r.RGBA32F,[$.RGB]:r.RGB32F,[$.RG]:r.RG32F,[$.RED]:r.R32F,[$.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[J.HALF_FLOAT]:{[$.RGBA]:r.RGBA16F,[$.RGB]:r.RGB16F,[$.RG]:r.RG16F,[$.RED]:r.R16F},[J.UNSIGNED_SHORT_5_6_5]:{[$.RGB]:r.RGB565},[J.UNSIGNED_SHORT_4_4_4_4]:{[$.RGBA]:r.RGBA4},[J.UNSIGNED_SHORT_5_5_5_1]:{[$.RGBA]:r.RGB5_A1},[J.UNSIGNED_INT_2_10_10_10_REV]:{[$.RGBA]:r.RGB10_A2,[$.RGBA_INTEGER]:r.RGB10_A2UI},[J.UNSIGNED_INT_10F_11F_11F_REV]:{[$.RGB]:r.R11F_G11F_B10F},[J.UNSIGNED_INT_5_9_9_9_REV]:{[$.RGB]:r.RGB9_E5},[J.UNSIGNED_INT_24_8]:{[$.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[J.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[$.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[J.UNSIGNED_BYTE]:{[$.RGBA]:r.RGBA,[$.RGB]:r.RGB,[$.ALPHA]:r.ALPHA,[$.LUMINANCE]:r.LUMINANCE,[$.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[J.UNSIGNED_SHORT_5_6_5]:{[$.RGB]:r.RGB},[J.UNSIGNED_SHORT_4_4_4_4]:{[$.RGBA]:r.RGBA},[J.UNSIGNED_SHORT_5_5_5_1]:{[$.RGBA]:r.RGBA}},t}class ff{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new st,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=x1(t),this.samplerTypes=v1(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};const i=new Fl(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Fl(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[s].samplerType!==q.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Fl(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var i;e.internalFormat=((i=this.internalFormats[t.type])==null?void 0:i[t.format])??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??q.FLOAT,this.webGLVersion===2&&t.type===J.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var s;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const i=this.renderer;if(this.initTextureType(t,e),(s=t.resource)==null?void 0:s.upload(i,t,e))e.samplerType!==q.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,o=t.realHeight,a=i.gl;(e.width!==n||e.height!==o||e.dirtyId<0)&&(e.width=n,e.height=o,a.texImage2D(t.target,0,e.internalFormat,n,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const s=this.managedTextures.indexOf(t);s!==-1&&Yr(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Ve.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=pr.CLAMP:e.wrapMode=t.wrapMode,(i=t.resource)!=null&&i.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==Ve.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Ie.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===Ie.LINEAR){const n=Math.min(t.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Ie.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Ie.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}ff.extension={type:X.RendererSystem,name:"texture"},j.add(ff);class pf{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:s}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[s]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];a&&(i.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&n.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}pf.extension={type:X.RendererSystem,name:"transformFeedback"},j.add(pf);class zn{constructor(t){this.renderer=t}init(t){this.screen=new at(0,0,t.width,t.height),this.element=t.view||z.ADAPTER.createCanvas(),this.resolution=t.resolution||z.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const i=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}zn.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},zn.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"_view"},j.add(zn),z.PREFER_ENV=Vr.WEBGL2,z.STRICT_TEXTURE_CACHE=!1,z.RENDER_OPTIONS={...Hn.defaultOptions,...Gn.defaultOptions,...zn.defaultOptions,...Wn.defaultOptions},Object.defineProperties(z,{WRAP_MODE:{get(){return st.defaultOptions.wrapMode},set(r){et("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),st.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return st.defaultOptions.scaleMode},set(r){et("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),st.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return st.defaultOptions.mipmap},set(r){et("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),st.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return st.defaultOptions.anisotropicLevel},set(r){et("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),st.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return et("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),ne.defaultResolution},set(r){ne.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return et("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),ne.defaultMultisample},set(r){ne.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return ti.defaultMaxTextures},set(r){et("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),ti.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return ti.defaultBatchSize},set(r){et("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),ti.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return ti.canUploadSameBuffer},set(r){et("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),ti.canUploadSameBuffer=r}},GC_MODE:{get(){return ri.defaultMode},set(r){et("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),ri.defaultMode=r}},GC_MAX_IDLE:{get(){return ri.defaultMaxIdle},set(r){et("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),ri.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return ri.defaultCheckCountMax},set(r){et("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),ri.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return xr.defaultVertexPrecision},set(r){et("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),xr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return xr.defaultFragmentPrecision},set(r){et("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),xr.defaultFragmentPrecision=r}}});var ii=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(ii||{});class Nl{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=s}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const mf=class me{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Nl(null,null,1/0),this.deltaMS=1/me.targetFPMS,this.elapsedMS=1/me.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=ii.NORMAL){return this._addListener(new Nl(t,e,i))}addOnce(t,e,i=ii.NORMAL){return this._addListener(new Nl(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*me.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,me.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!me._shared){const t=me._shared=new me;t.autoStart=!0,t._protected=!0}return me._shared}static get system(){if(!me._system){const t=me._system=new me;t.autoStart=!0,t._protected=!0}return me._system}};mf.targetFPMS=.06;let pe=mf;Object.defineProperties(z,{TARGET_FPMS:{get(){return pe.targetFPMS},set(r){et("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),pe.targetFPMS=r}}});class gf{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,ii.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?pe.shared:new pe,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}gf.extension=X.Application,j.add(gf);const yf=[];j.handleByList(X.Renderer,yf);function _f(r){for(const t of yf)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var b1=`attribute vec2 aVertexPosition;
489
+ `))}}let v0=0;const pn={textureCount:0,uboCount:0};class qd{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=v0++}systemCheck(){if(!Xv())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),e||(pn.textureCount=0,pn.uboCount=0,this.syncUniformGroup(t.uniformGroup,pn)),s}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=kv(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const s=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),s(i.uniformData,t.uniforms,this.renderer,pn,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const a=this.getSignature(t,this.shader.program.uniformData,"ubo");let o=this._uboCache[a];if(o||(o=this._uboCache[a]=_0(t,this.shader.program.uniformData)),t.autoManage){const l=new Float32Array(o.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=o.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const s=t.uniforms,n=[`${i}-`];for(const a in s)n.push(a),e[a]&&n.push(e[a].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,s=f0(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}qd.extension={type:J.RendererSystem,name:"shader"},rt.add(qd);class mn{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}mn.defaultOptions={hello:!1},mn.extension={type:[J.RendererSystem,J.CanvasRendererSystem],name:"startup"},rt.add(mn);function x0(r,t=[]){return t[q.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.ADD]=[r.ONE,r.ONE],t[q.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.NONE]=[0,0],t[q.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[q.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[q.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[q.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[q.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[q.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[q.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[q.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[q.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[q.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[q.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const b0=0,w0=1,T0=2,E0=3,A0=4,S0=5,Kd=class hh{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=q.NONE,this._blendEq=!1,this.map=[],this.map[b0]=this.setBlend,this.map[w0]=this.setOffset,this.map[T0]=this.setCullFace,this.map[E0]=this.setDepthTest,this.map[A0]=this.setFrontFace,this.map[S0]=this.setDepthMask,this.checks=[],this.defaultState=new rr,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=x0(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(hh.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(hh.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};Kd.extension={type:J.RendererSystem,name:"state"};let C0=Kd;rt.add(C0);class Zd extends bi{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(const s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Fe(e)})}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(s=>{const n=i.find(a=>this._systemsHash[a]===s);s[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const hs=class Jn{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Jn.defaultMaxIdle,this.checkCountMax=Jn.defaultCheckCountMax,this.mode=Jn.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Oa.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!1;for(let s=0;s<e.length;s++){const n=e[s];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[s]=null,i=!0)}if(i){let s=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[s++]=e[n]);e.length=s}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};hs.defaultMode=Oa.AUTO,hs.defaultMaxIdle=60*60,hs.defaultCheckCountMax=60*10,hs.extension={type:J.RendererSystem,name:"textureGC"};let Zr=hs;rt.add(Zr);class yl{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=ut.UNSIGNED_BYTE,this.internalFormat=Z.RGBA,this.samplerType=0}}function I0(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:nt.FLOAT,[r.RGBA]:nt.FLOAT,[r.ALPHA]:nt.FLOAT,[r.LUMINANCE]:nt.FLOAT,[r.LUMINANCE_ALPHA]:nt.FLOAT,[r.R8]:nt.FLOAT,[r.R8_SNORM]:nt.FLOAT,[r.RG8]:nt.FLOAT,[r.RG8_SNORM]:nt.FLOAT,[r.RGB8]:nt.FLOAT,[r.RGB8_SNORM]:nt.FLOAT,[r.RGB565]:nt.FLOAT,[r.RGBA4]:nt.FLOAT,[r.RGB5_A1]:nt.FLOAT,[r.RGBA8]:nt.FLOAT,[r.RGBA8_SNORM]:nt.FLOAT,[r.RGB10_A2]:nt.FLOAT,[r.RGB10_A2UI]:nt.FLOAT,[r.SRGB8]:nt.FLOAT,[r.SRGB8_ALPHA8]:nt.FLOAT,[r.R16F]:nt.FLOAT,[r.RG16F]:nt.FLOAT,[r.RGB16F]:nt.FLOAT,[r.RGBA16F]:nt.FLOAT,[r.R32F]:nt.FLOAT,[r.RG32F]:nt.FLOAT,[r.RGB32F]:nt.FLOAT,[r.RGBA32F]:nt.FLOAT,[r.R11F_G11F_B10F]:nt.FLOAT,[r.RGB9_E5]:nt.FLOAT,[r.R8I]:nt.INT,[r.R8UI]:nt.UINT,[r.R16I]:nt.INT,[r.R16UI]:nt.UINT,[r.R32I]:nt.INT,[r.R32UI]:nt.UINT,[r.RG8I]:nt.INT,[r.RG8UI]:nt.UINT,[r.RG16I]:nt.INT,[r.RG16UI]:nt.UINT,[r.RG32I]:nt.INT,[r.RG32UI]:nt.UINT,[r.RGB8I]:nt.INT,[r.RGB8UI]:nt.UINT,[r.RGB16I]:nt.INT,[r.RGB16UI]:nt.UINT,[r.RGB32I]:nt.INT,[r.RGB32UI]:nt.UINT,[r.RGBA8I]:nt.INT,[r.RGBA8UI]:nt.UINT,[r.RGBA16I]:nt.INT,[r.RGBA16UI]:nt.UINT,[r.RGBA32I]:nt.INT,[r.RGBA32UI]:nt.UINT,[r.DEPTH_COMPONENT16]:nt.FLOAT,[r.DEPTH_COMPONENT24]:nt.FLOAT,[r.DEPTH_COMPONENT32F]:nt.FLOAT,[r.DEPTH_STENCIL]:nt.FLOAT,[r.DEPTH24_STENCIL8]:nt.FLOAT,[r.DEPTH32F_STENCIL8]:nt.FLOAT}:t={[r.RGB]:nt.FLOAT,[r.RGBA]:nt.FLOAT,[r.ALPHA]:nt.FLOAT,[r.LUMINANCE]:nt.FLOAT,[r.LUMINANCE_ALPHA]:nt.FLOAT,[r.DEPTH_STENCIL]:nt.FLOAT},t}function R0(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[ut.UNSIGNED_BYTE]:{[Z.RGBA]:r.RGBA8,[Z.RGB]:r.RGB8,[Z.RG]:r.RG8,[Z.RED]:r.R8,[Z.RGBA_INTEGER]:r.RGBA8UI,[Z.RGB_INTEGER]:r.RGB8UI,[Z.RG_INTEGER]:r.RG8UI,[Z.RED_INTEGER]:r.R8UI,[Z.ALPHA]:r.ALPHA,[Z.LUMINANCE]:r.LUMINANCE,[Z.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[ut.BYTE]:{[Z.RGBA]:r.RGBA8_SNORM,[Z.RGB]:r.RGB8_SNORM,[Z.RG]:r.RG8_SNORM,[Z.RED]:r.R8_SNORM,[Z.RGBA_INTEGER]:r.RGBA8I,[Z.RGB_INTEGER]:r.RGB8I,[Z.RG_INTEGER]:r.RG8I,[Z.RED_INTEGER]:r.R8I},[ut.UNSIGNED_SHORT]:{[Z.RGBA_INTEGER]:r.RGBA16UI,[Z.RGB_INTEGER]:r.RGB16UI,[Z.RG_INTEGER]:r.RG16UI,[Z.RED_INTEGER]:r.R16UI,[Z.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[ut.SHORT]:{[Z.RGBA_INTEGER]:r.RGBA16I,[Z.RGB_INTEGER]:r.RGB16I,[Z.RG_INTEGER]:r.RG16I,[Z.RED_INTEGER]:r.R16I},[ut.UNSIGNED_INT]:{[Z.RGBA_INTEGER]:r.RGBA32UI,[Z.RGB_INTEGER]:r.RGB32UI,[Z.RG_INTEGER]:r.RG32UI,[Z.RED_INTEGER]:r.R32UI,[Z.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[ut.INT]:{[Z.RGBA_INTEGER]:r.RGBA32I,[Z.RGB_INTEGER]:r.RGB32I,[Z.RG_INTEGER]:r.RG32I,[Z.RED_INTEGER]:r.R32I},[ut.FLOAT]:{[Z.RGBA]:r.RGBA32F,[Z.RGB]:r.RGB32F,[Z.RG]:r.RG32F,[Z.RED]:r.R32F,[Z.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[ut.HALF_FLOAT]:{[Z.RGBA]:r.RGBA16F,[Z.RGB]:r.RGB16F,[Z.RG]:r.RG16F,[Z.RED]:r.R16F},[ut.UNSIGNED_SHORT_5_6_5]:{[Z.RGB]:r.RGB565},[ut.UNSIGNED_SHORT_4_4_4_4]:{[Z.RGBA]:r.RGBA4},[ut.UNSIGNED_SHORT_5_5_5_1]:{[Z.RGBA]:r.RGB5_A1},[ut.UNSIGNED_INT_2_10_10_10_REV]:{[Z.RGBA]:r.RGB10_A2,[Z.RGBA_INTEGER]:r.RGB10_A2UI},[ut.UNSIGNED_INT_10F_11F_11F_REV]:{[Z.RGB]:r.R11F_G11F_B10F},[ut.UNSIGNED_INT_5_9_9_9_REV]:{[Z.RGB]:r.RGB9_E5},[ut.UNSIGNED_INT_24_8]:{[Z.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[ut.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[Z.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[ut.UNSIGNED_BYTE]:{[Z.RGBA]:r.RGBA,[Z.RGB]:r.RGB,[Z.ALPHA]:r.ALPHA,[Z.LUMINANCE]:r.LUMINANCE,[Z.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[ut.UNSIGNED_SHORT_5_6_5]:{[Z.RGB]:r.RGB},[ut.UNSIGNED_SHORT_4_4_4_4]:{[Z.RGBA]:r.RGBA},[ut.UNSIGNED_SHORT_5_5_5_1]:{[Z.RGBA]:r.RGBA}},t}class Jd{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new dt,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=R0(t),this.samplerTypes=I0(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};const i=new yl(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new yl(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let n=t-1;n>=0;--n){const a=e[n];a&&a._glTextures[s].samplerType!==nt.FLOAT&&this.renderer.texture.unbind(a)}}initTexture(t){const e=new yl(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var i;e.internalFormat=((i=this.internalFormats[t.type])==null?void 0:i[t.format])??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??nt.FLOAT,this.webGLVersion===2&&t.type===ut.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var s;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const i=this.renderer;if(this.initTextureType(t,e),(s=t.resource)==null?void 0:s.upload(i,t,e))e.samplerType!==nt.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,a=t.realHeight,o=i.gl;(e.width!==n||e.height!==a||e.dirtyId<0)&&(e.width=n,e.height=a,o.texImage2D(t.target,0,e.internalFormat,n,a,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const s=this.managedTextures.indexOf(t);s!==-1&&Vr(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Ke.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=mr.CLAMP:e.wrapMode=t.wrapMode,(i=t.resource)!=null&&i.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==Ke.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Oe.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===Oe.LINEAR){const n=Math.min(t.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Oe.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Oe.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Jd.extension={type:J.RendererSystem,name:"texture"},rt.add(Jd);class Qd{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:s}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[s]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let a=0;a<t.buffers.length;a++){const o=t.buffers[a];o&&(i.buffer.update(o),o._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,a,o._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let a=0;a<t.buffers.length;a++){const o=t.buffers[a];if(!o)continue;const l=o._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&n.dispose(o,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Qd.extension={type:J.RendererSystem,name:"transformFeedback"},rt.add(Qd);class gn{constructor(t){this.renderer=t}init(t){this.screen=new pt(0,0,t.width,t.height),this.element=t.view||et.ADAPTER.createCanvas(),this.resolution=t.resolution||et.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const i=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}gn.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},gn.extension={type:[J.RendererSystem,J.CanvasRendererSystem],name:"_view"},rt.add(gn),et.PREFER_ENV=Hr.WEBGL2,et.STRICT_TEXTURE_CACHE=!1,et.RENDER_OPTIONS={...cn.defaultOptions,...un.defaultOptions,...gn.defaultOptions,...mn.defaultOptions},Object.defineProperties(et,{WRAP_MODE:{get(){return dt.defaultOptions.wrapMode},set(r){ct("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),dt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return dt.defaultOptions.scaleMode},set(r){ct("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),dt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return dt.defaultOptions.mipmap},set(r){ct("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),dt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return dt.defaultOptions.anisotropicLevel},set(r){ct("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),dt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return ct("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),he.defaultResolution},set(r){he.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return ct("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),he.defaultMultisample},set(r){he.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return qr.defaultMaxTextures},set(r){ct("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),qr.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return qr.defaultBatchSize},set(r){ct("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),qr.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return qr.canUploadSameBuffer},set(r){ct("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),qr.canUploadSameBuffer=r}},GC_MODE:{get(){return Zr.defaultMode},set(r){ct("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Zr.defaultMode=r}},GC_MAX_IDLE:{get(){return Zr.defaultMaxIdle},set(r){ct("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Zr.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return Zr.defaultCheckCountMax},set(r){ct("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Zr.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return xr.defaultVertexPrecision},set(r){ct("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),xr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return xr.defaultFragmentPrecision},set(r){ct("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),xr.defaultFragmentPrecision=r}}});var Jr=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Jr||{});class _l{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=s}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const tf=class xe{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new _l(null,null,1/0),this.deltaMS=1/xe.targetFPMS,this.elapsedMS=1/xe.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=Jr.NORMAL){return this._addListener(new _l(t,e,i))}addOnce(t,e,i=Jr.NORMAL){return this._addListener(new _l(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*xe.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,xe.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!xe._shared){const t=xe._shared=new xe;t.autoStart=!0,t._protected=!0}return xe._shared}static get system(){if(!xe._system){const t=xe._system=new xe;t.autoStart=!0,t._protected=!0}return xe._system}};tf.targetFPMS=.06;let _e=tf;Object.defineProperties(et,{TARGET_FPMS:{get(){return _e.targetFPMS},set(r){ct("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),_e.targetFPMS=r}}});class ef{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Jr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?_e.shared:new _e,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}ef.extension=J.Application,rt.add(ef);const rf=[];rt.handleByList(J.Renderer,rf);function P0(r){for(const t of rf)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var M0=`attribute vec2 aVertexPosition;
490
490
  attribute vec2 aTextureCoord;
491
491
 
492
492
  uniform mat3 projectionMatrix;
@@ -497,7 +497,7 @@ void main(void)
497
497
  {
498
498
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
499
499
  vTextureCoord = aTextureCoord;
500
- }`,w1=`attribute vec2 aVertexPosition;
500
+ }`,D0=`attribute vec2 aVertexPosition;
501
501
 
502
502
  uniform mat3 projectionMatrix;
503
503
 
@@ -523,7 +523,7 @@ void main(void)
523
523
  gl_Position = filterVertexPosition();
524
524
  vTextureCoord = filterTextureCoord();
525
525
  }
526
- `;const T1=b1,vf=w1;class xf{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=Lt.HIGH?this.multisample=Lt.HIGH:e>=Lt.MEDIUM?this.multisample=Lt.MEDIUM:e>=Lt.LOW?this.multisample=Lt.LOW:this.multisample=Lt.NONE}destroy(){}}xf.extension={type:X.RendererSystem,name:"_multisample"},j.add(xf);class E1{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class bf{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,i){const{gl:s,CONTEXT_UID:n}=this;i=i||0;const o=t._glBuffers[n]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,o.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),i&&(e||s.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new E1(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}bf.extension={type:X.RendererSystem,name:"buffer"},j.add(bf);class wf{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let s,n,o,a;if(e&&(s=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(s||(this.lastObjectRendered=t),!a){const l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(n??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}wf.extension={type:X.RendererSystem,name:"objectRenderer"},j.add(wf);const jn=class wh extends df{constructor(t){super(),this.type=la.WEBGL,t=Object.assign({},z.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new De({projectionMatrix:new wt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:wh.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(e),"useContextAlpha"in t&&(et("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=wh.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:ld()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return et("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return et("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return et("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return et("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){et("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return et("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){et("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return et("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};jn.extension={type:X.Renderer,priority:1},jn.__plugins={},jn.__systems={};let Ul=jn;j.handleByMap(X.RendererPlugin,Ul.__plugins),j.handleByMap(X.RendererSystem,Ul.__systems),j.add(Ul);class Tf extends xs{constructor(t,e){const{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const o=new st;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof xs?this.addResourceAt(t[i],i):this.addResourceAt(Rd(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{const{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}}class A1 extends Tf{constructor(t,e){const{width:i,height:s}=e||{};let n,o;Array.isArray(t)?(n=t,o=t.length):o=t,super(o,{width:i,height:s}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=xi.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:s,itemDirtyIds:n,items:o}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,e.format,i.type,null);for(let l=0;l<s;l++){const h=o[l];n[l]<h.dirtyId&&(n[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,i.type,h.resource.source))}return!0}}class Ef extends br{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Af=class Ns extends Tf{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==Ns.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<Ns.SIDES;a++)this.items[a].target=xi.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=xi.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=xi.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){const s=this.itemDirtyIds;for(let n=0;n<Ns.SIDES;n++){const o=this.items[n];(s[n]<o.dirtyId||i.dirtyId<e.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(t,o,i),s[n]=o.dirtyId):s[n]<-1&&(t.gl.texImage2D(o.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Ns.SIDES}};Af.SIDES=6;let S1=Af;class Li extends br{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=Li.EMPTY,s=t,n=!0):(i=t,s=null,n=!1),super(i),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const i=await z.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===ae.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return Li._EMPTY=Li._EMPTY??z.ADAPTER.createCanvas(0,0),Li._EMPTY}}const kl=class Io extends br{constructor(t,e){e=e||{},super(z.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},Io.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const t=new Image;br.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*e,n=this._overrideHeight||this._overrideWidth/e*i),s=Math.round(s),n=Math.round(n);const o=this.source;o.width=s,o.height=n,o._pixiId=`canvas_${Cr()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=Io.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&Io.SVG_XML.test(t)}};kl.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,kl.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Gl=kl;class C1 extends br{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const Hl=class Th extends br{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const s=t[0].src||t[0];br.crossOrigin(i,s,e.crossorigin);for(let n=0;n<t.length;++n){const o=document.createElement("source");let{src:a,mime:l}=t[n];if(a=a||t[n],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),u=h.slice(h.lastIndexOf(".")+1);l=l||Th.MIME_TYPES[u]||`video/${u}`}o.src=a,l&&(o.type=l),i.appendChild(o)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,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._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=pe.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;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._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;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._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}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.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(pe.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(pe.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(pe.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Th.TYPES.includes(e)}};Hl.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Hl.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Sf=Hl;bl.push(Li,Vd,Ef,Sf,C1,Gl,Cn,S1,A1),st.prototype.getDrawableSource=function(){const r=this.resource;return r?r.bitmap||r.source:null},Ml.prototype._canvasRenderTarget=null,Y.prototype.patternCache=null,Y.prototype.tintCache=null;let As;function Cf(r){const t=z.ADAPTER.createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=r,e.fillRect(0,0,6,1),t}function If(){if(typeof document>"u")return!1;if(As!==void 0)return As;const r=Cf("#ff00ff"),t=Cf("#ffff00"),e=z.ADAPTER.createCanvas(6,1).getContext("2d");e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0);const i=e.getImageData(2,0,1,1);if(!i)As=!1;else{const s=i.data;As=s[0]===255&&s[1]===0&&s[2]===0}return As}function I1(r=[]){return If()?(r[U.NORMAL]="source-over",r[U.ADD]="lighter",r[U.MULTIPLY]="multiply",r[U.SCREEN]="screen",r[U.OVERLAY]="overlay",r[U.DARKEN]="darken",r[U.LIGHTEN]="lighten",r[U.COLOR_DODGE]="color-dodge",r[U.COLOR_BURN]="color-burn",r[U.HARD_LIGHT]="hard-light",r[U.SOFT_LIGHT]="soft-light",r[U.DIFFERENCE]="difference",r[U.EXCLUSION]="exclusion",r[U.HUE]="hue",r[U.SATURATION]="saturation",r[U.COLOR]="color",r[U.LUMINOSITY]="luminosity"):(r[U.NORMAL]="source-over",r[U.ADD]="lighter",r[U.MULTIPLY]="source-over",r[U.SCREEN]="source-over",r[U.OVERLAY]="source-over",r[U.DARKEN]="source-over",r[U.LIGHTEN]="source-over",r[U.COLOR_DODGE]="source-over",r[U.COLOR_BURN]="source-over",r[U.HARD_LIGHT]="source-over",r[U.SOFT_LIGHT]="source-over",r[U.DIFFERENCE]="source-over",r[U.EXCLUSION]="source-over",r[U.HUE]="source-over",r[U.SATURATION]="source-over",r[U.COLOR]="source-over",r[U.LUMINOSITY]="source-over"),r[U.NORMAL_NPM]=r[U.NORMAL],r[U.ADD_NPM]=r[U.ADD],r[U.SCREEN_NPM]=r[U.SCREEN],r[U.SRC_IN]="source-in",r[U.SRC_OUT]="source-out",r[U.SRC_ATOP]="source-atop",r[U.DST_OVER]="destination-over",r[U.DST_IN]="destination-in",r[U.DST_OUT]="destination-out",r[U.DST_ATOP]="destination-atop",r[U.XOR]="xor",r[U.SUBTRACT]="source-over",r}const R1=new wt;class Rf{constructor(t){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=I1(),this._activeBlendMode=null,this._projTransform=null,this._outerBlend=!1,this.renderer=t}init(){const t=this.renderer.background.alpha<1;if(this.rootContext=this.renderer.view.getContext("2d",{alpha:t}),this.activeContext=this.rootContext,!this.rootContext.imageSmoothingEnabled){const e=this.rootContext;e.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":e.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":e.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":e.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(t,e,i){let s=t;const n=this._projTransform,o=this.activeResolution;i=i||o,n&&(s=R1,s.copyFrom(t),s.prepend(n)),e?this.activeContext.setTransform(s.a*i,s.b*i,s.c*i,s.d*i,s.tx*o|0,s.ty*o|0):this.activeContext.setTransform(s.a*i,s.b*i,s.c*i,s.d*i,s.tx*o,s.ty*o)}clear(t,e){const{activeContext:i,renderer:s}=this,n=t?ut.shared.setValue(t):this.renderer.background.backgroundColor;i.clearRect(0,0,s.width,s.height),t&&(i.globalAlpha=e??this.renderer.background.alpha,i.fillStyle=n.toHex(),i.fillRect(0,0,s.width,s.height),i.globalAlpha=1)}setBlendMode(t,e){const i=t===U.SRC_IN||t===U.SRC_OUT||t===U.DST_IN||t===U.DST_ATOP;!e&&i&&(t=U.NORMAL),this._activeBlendMode!==t&&(this._activeBlendMode=t,this._outerBlend=i,this.activeContext.globalCompositeOperation=this.blendModes[t])}resize(){this.smoothProperty&&(this.rootContext[this.smoothProperty]=st.defaultOptions.scaleMode===Ie.LINEAR)}invalidateBlendMode(){this._activeBlendMode=this.blendModes.indexOf(this.activeContext.globalCompositeOperation)}destroy(){this.renderer=null,this.rootContext=null,this.activeContext=null,this.smoothProperty=null}}Rf.extension={type:X.CanvasRendererSystem,name:"canvasContext"},j.add(Rf);class Pf{constructor(t){this._foundShapes=[],this.renderer=t}pushMask(t){const e=this.renderer,i=t.maskObject||t;e.canvasContext.activeContext.save();const s=this._foundShapes;if(this.recursiveFindShapes(i,s),s.length>0){const n=e.canvasContext.activeContext;n.beginPath();for(let o=0;o<s.length;o++){const a=s[o],l=a.transform.worldTransform;this.renderer.canvasContext.setContextTransform(l),this.renderGraphicsShape(a)}s.length=0,n.clip()}}recursiveFindShapes(t,e){t.geometry&&t.geometry.graphicsData&&e.push(t);const{children:i}=t;if(i)for(let s=0;s<i.length;s++)this.recursiveFindShapes(i[s],e)}renderGraphicsShape(t){t.finishPoly();const e=this.renderer.canvasContext.activeContext,i=t.geometry.graphicsData,s=i.length;if(s!==0)for(let n=0;n<s;n++){const o=i[n],a=o.shape;if(a.type===Tt.POLY){let l=a.points;const h=o.holes;let u,c,d,p;e.moveTo(l[0],l[1]);for(let f=1;f<l.length/2;f++)e.lineTo(l[f*2],l[f*2+1]);if(h.length>0){u=0,d=l[0],p=l[1];for(let f=2;f+2<l.length;f+=2)u+=(l[f]-d)*(l[f+3]-p)-(l[f+2]-d)*(l[f+1]-p);for(let f=0;f<h.length;f++)if(l=h[f].shape.points,!!l){c=0,d=l[0],p=l[1];for(let m=2;m+2<l.length;m+=2)c+=(l[m]-d)*(l[m+3]-p)-(l[m+2]-d)*(l[m+1]-p);if(c*u<0){e.moveTo(l[0],l[1]);for(let m=2;m<l.length;m+=2)e.lineTo(l[m],l[m+1])}else{e.moveTo(l[l.length-2],l[l.length-1]);for(let m=l.length-4;m>=0;m-=2)e.lineTo(l[m],l[m+1])}h[f].shape.closeStroke&&e.closePath()}}l[0]===l[l.length-2]&&l[1]===l[l.length-1]&&e.closePath()}else if(a.type===Tt.RECT)e.rect(a.x,a.y,a.width,a.height),e.closePath();else if(a.type===Tt.CIRC)e.arc(a.x,a.y,a.radius,0,2*Math.PI),e.closePath();else if(a.type===Tt.ELIP){const l=a.width*2,h=a.height*2,u=a.x-l/2,c=a.y-h/2,d=.5522848,p=l/2*d,f=h/2*d,m=u+l,_=c+h,g=u+l/2,v=c+h/2;e.moveTo(u,v),e.bezierCurveTo(u,v-f,g-p,c,g,c),e.bezierCurveTo(g+p,c,m,v-f,m,v),e.bezierCurveTo(m,v+f,g+p,_,g,_),e.bezierCurveTo(g-p,_,u,v+f,u,v),e.closePath()}else if(a.type===Tt.RREC){const l=a.x,h=a.y,u=a.width,c=a.height;let d=a.radius;const p=Math.min(u,c)/2;d=d>p?p:d,e.moveTo(l,h+d),e.lineTo(l,h+c-d),e.quadraticCurveTo(l,h+c,l+d,h+c),e.lineTo(l+u-d,h+c),e.quadraticCurveTo(l+u,h+c,l+u,h+c-d),e.lineTo(l+u,h+d),e.quadraticCurveTo(l+u,h,l+u-d,h),e.lineTo(l+d,h),e.quadraticCurveTo(l,h,l,h+d),e.closePath()}}}popMask(t){t.canvasContext.activeContext.restore(),t.canvasContext.invalidateBlendMode()}destroy(){}}Pf.extension={type:X.CanvasRendererSystem,name:"mask"},j.add(Pf);class Mf{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;if(!i.view)return;const s=i.canvasContext;let n,o,a,l;e&&(n=e.renderTexture,o=e.clear,a=e.transform,l=e.skipUpdateTransform),this.renderingToScreen=!n,i.emit("prerender");const h=i.resolution;n?(n=n.castToBaseTexture(),n._canvasRenderTarget||(n._canvasRenderTarget=new vs(n.width,n.height,n.resolution),n.resource=new Ef(n._canvasRenderTarget.canvas),n.valid=!0),s.activeContext=n._canvasRenderTarget.context,i.canvasContext.activeResolution=n._canvasRenderTarget.resolution):(s.activeContext=s.rootContext,s.activeResolution=h);const u=s.activeContext;if(s._projTransform=a||null,n||(this.lastObjectRendered=t),!l){const d=t.enableTempParent();t.updateTransform(),t.disableTempParent(d)}if(u.save(),u.setTransform(1,0,0,1,0,0),u.globalAlpha=1,s._activeBlendMode=U.NORMAL,s._outerBlend=!1,u.globalCompositeOperation=s.blendModes[U.NORMAL],o??i.background.clearBeforeRender)if(this.renderingToScreen){u.clearRect(0,0,i.width,i.height);const d=i.background;d.alpha>0&&(u.globalAlpha=d.backgroundColor.alpha,u.fillStyle=d.backgroundColor.toHex(),u.fillRect(0,0,i.width,i.height),u.globalAlpha=1)}else n=n,n._canvasRenderTarget.clear(),n.clear.alpha>0&&(u.globalAlpha=n.clear.alpha,u.fillStyle=n.clear.toHex(),u.fillRect(0,0,n.realWidth,n.realHeight),u.globalAlpha=1);const c=s.activeContext;s.activeContext=u,t.renderCanvas(i),s.activeContext=c,u.restore(),s.activeResolution=h,s._projTransform=null,i.emit("postrender")}destroy(){this.lastObjectRendered=null,this.render=null}}Mf.extension={type:X.CanvasRendererSystem,name:"objectRenderer"},j.add(Mf);const{deprecation:ee}=fb,Yn=class Eh extends df{constructor(t){super(),this.type=la.CANVAS,this.rendererLogId="Canvas",t=Object.assign({},z.RENDER_OPTIONS,t);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Eh.__systems,priority:["textureGenerator","background","_view","_plugin","startup","mask","canvasContext","objectRenderer"]};this.setup(e),"useContextAlpha"in t&&(ee("7.0.0","options.useContextAlpha is deprecated, use options.backgroundAlpha instead"),t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=Eh.__plugins,this.options=t,this.startup.run(this.options)}static test(){return!0}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}reset(){}render(t,e){this.objectRenderer.render(t,e)}clear(){this.canvasContext.clear()}destroy(t){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}resize(t,e){this._view.resizeView(t,e)}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get clearBeforeRender(){return this.background.clearBeforeRender}get blendModes(){return ee("7.0.0","renderer.blendModes has been deprecated, please use renderer.canvasContext.blendModes instead"),this.canvasContext.blendModes}get maskManager(){return ee("7.0.0","renderer.maskManager has been deprecated, please use renderer.mask instead"),this.mask}get refresh(){return ee("7.0.0","renderer.refresh has been deprecated"),!0}get rootContext(){return ee("7.0.0","renderer.rootContext has been deprecated, please use renderer.canvasContext.rootContext instead"),this.canvasContext.rootContext}get context(){return ee("7.0.0","renderer.context has been deprecated, please use renderer.canvasContext.activeContext instead"),this.canvasContext.activeContext}get smoothProperty(){return ee("7.0.0","renderer.smoothProperty has been deprecated, please use renderer.canvasContext.smoothProperty instead"),this.canvasContext.smoothProperty}setBlendMode(t,e){ee("7.0.0","renderer.setBlendMode has been deprecated, use renderer.canvasContext.setBlendMode instead"),this.canvasContext.setBlendMode(t,e)}invalidateBlendMode(){ee("7.0.0","renderer.invalidateBlendMode has been deprecated, use renderer.canvasContext.invalidateBlendMode instead"),this.canvasContext.invalidateBlendMode()}setContextTransform(t,e,i){ee("7.0.0","renderer.setContextTransform has been deprecated, use renderer.canvasContext.setContextTransform instead"),this.canvasContext.setContextTransform(t,e,i)}get backgroundColor(){return ee("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){ee("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return ee("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){ee("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get preserveDrawingBuffer(){return ee("7.0.0","renderer.preserveDrawingBuffer has been deprecated"),!1}get useContextAlpha(){return ee("7.0.0","renderer.useContextAlpha has been deprecated"),!1}};Yn.extension={type:X.Renderer,priority:0},Yn.__plugins={},Yn.__systems={};let qn=Yn;j.handleByMap(X.CanvasRendererPlugin,qn.__plugins),j.handleByMap(X.CanvasRendererSystem,qn.__systems),j.add(qn);const Vt={canvas:null,getTintedCanvas:(r,t)=>{const e=r.texture,i=ut.shared.setValue(t).toHex();e.tintCache=e.tintCache||{};const s=e.tintCache[i];let n;if(s){if(s.tintId===e._updateID)return e.tintCache[i];n=e.tintCache[i]}else n=z.ADAPTER.createCanvas();return Vt.tintMethod(e,t,n),n.tintId=e._updateID,Vt.convertTintToImage||(e.tintCache[i]=n),n},getTintedPattern:(r,t)=>{const e=ut.shared.setValue(t).toHex();r.patternCache=r.patternCache||{};let i=r.patternCache[e];return(i==null?void 0:i.tintId)===r._updateID||(Vt.canvas||(Vt.canvas=z.ADAPTER.createCanvas()),Vt.tintMethod(r,t,Vt.canvas),i=Vt.canvas.getContext("2d").createPattern(Vt.canvas,"repeat"),i.tintId=r._updateID,r.patternCache[e]=i),i},tintWithMultiply:(r,t,e)=>{const i=e.getContext("2d"),s=r._frame.clone(),n=r.baseTexture.resolution;s.x*=n,s.y*=n,s.width*=n,s.height*=n,e.width=Math.ceil(s.width),e.height=Math.ceil(s.height),i.save(),i.fillStyle=ut.shared.setValue(t).toHex(),i.fillRect(0,0,s.width,s.height),i.globalCompositeOperation="multiply";const o=r.baseTexture.getDrawableSource();i.drawImage(o,s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.globalCompositeOperation="destination-atop",i.drawImage(o,s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.restore()},tintWithOverlay:(r,t,e)=>{const i=e.getContext("2d"),s=r._frame.clone(),n=r.baseTexture.resolution;s.x*=n,s.y*=n,s.width*=n,s.height*=n,e.width=Math.ceil(s.width),e.height=Math.ceil(s.height),i.save(),i.globalCompositeOperation="copy",i.fillStyle=`#${`00000${(t|0).toString(16)}`.slice(-6)}`,i.fillRect(0,0,s.width,s.height),i.globalCompositeOperation="destination-atop",i.drawImage(r.baseTexture.getDrawableSource(),s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.restore()},tintWithPerPixel:(r,t,e)=>{const i=e.getContext("2d"),s=r._frame.clone(),n=r.baseTexture.resolution;s.x*=n,s.y*=n,s.width*=n,s.height*=n,e.width=Math.ceil(s.width),e.height=Math.ceil(s.height),i.save(),i.globalCompositeOperation="copy",i.drawImage(r.baseTexture.getDrawableSource(),s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.restore();const[o,a,l]=ut.shared.setValue(t).toArray(),h=i.getImageData(0,0,s.width,s.height),u=h.data;for(let c=0;c<u.length;c+=4)u[c+0]*=o,u[c+1]*=a,u[c+2]*=l;i.putImageData(h,0,0)},roundColor:r=>(et("7.3.0","PIXI.canvasUtils.roundColor is deprecated"),ut.shared.setValue(r).round(Vt.cacheStepsPerColorChannel).toNumber()),cacheStepsPerColorChannel:8,convertTintToImage:!1,canUseMultiply:If(),tintMethod:null};Vt.tintMethod=Vt.canUseMultiply?Vt.tintWithMultiply:Vt.tintWithPerPixel;class Kn{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?at.EMPTY:(t=t||new at(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:i,b:s,c:n,d:o,tx:a,ty:l}=t,h=i*e.x+n*e.y+a,u=s*e.x+o*e.y+l;this.minX=Math.min(this.minX,h),this.maxX=Math.max(this.maxX,h),this.minY=Math.min(this.minY,u),this.maxY=Math.max(this.maxY,u)}addQuad(t){let e=this.minX,i=this.minY,s=this.maxX,n=this.maxY,o=t[0],a=t[1];e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,this.minX=e,this.minY=i,this.maxX=s,this.maxY=n}addFrame(t,e,i,s,n){this.addFrameMatrix(t.worldTransform,e,i,s,n)}addFrameMatrix(t,e,i,s,n){const o=t.a,a=t.b,l=t.c,h=t.d,u=t.tx,c=t.ty;let d=this.minX,p=this.minY,f=this.maxX,m=this.maxY,_=o*e+l*i+u,g=a*e+h*i+c;d=_<d?_:d,p=g<p?g:p,f=_>f?_:f,m=g>m?g:m,_=o*s+l*i+u,g=a*s+h*i+c,d=_<d?_:d,p=g<p?g:p,f=_>f?_:f,m=g>m?g:m,_=o*e+l*n+u,g=a*e+h*n+c,d=_<d?_:d,p=g<p?g:p,f=_>f?_:f,m=g>m?g:m,_=o*s+l*n+u,g=a*s+h*n+c,d=_<d?_:d,p=g<p?g:p,f=_>f?_:f,m=g>m?g:m,this.minX=d,this.minY=p,this.maxX=f,this.maxY=m}addVertexData(t,e,i){let s=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let l=e;l<i;l+=2){const h=t[l],u=t[l+1];s=h<s?h:s,n=u<n?u:n,o=h>o?h:o,a=u>a?u:a}this.minX=s,this.minY=n,this.maxX=o,this.maxY=a}addVertices(t,e,i,s){this.addVerticesMatrix(t.worldTransform,e,i,s)}addVerticesMatrix(t,e,i,s,n=0,o=n){const a=t.a,l=t.b,h=t.c,u=t.d,c=t.tx,d=t.ty;let p=this.minX,f=this.minY,m=this.maxX,_=this.maxY;for(let g=i;g<s;g+=2){const v=e[g],y=e[g+1],x=a*v+h*y+c,b=u*y+l*v+d;p=Math.min(p,x-n),m=Math.max(m,x+n),f=Math.min(f,b-o),_=Math.max(_,b+o)}this.minX=p,this.minY=f,this.maxX=m,this.maxY=_}addBounds(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>s?t.maxX:s,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,s=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>u?o:u}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,s=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,o=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>u?o:u}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,s,n,o){t-=n,e-=o,i+=n,s+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>s?this.maxY:s}}class Ct extends wi{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Ln,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new Kn,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let i=0;i<e.length;++i){const s=e[i];Object.defineProperty(Ct.prototype,s,Object.getOwnPropertyDescriptor(t,s))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new at),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new at),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Kn);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const s=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=s,this._bounds.updateID+=this._boundsID-n,o}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,s){return e&&(t=e.toGlobal(t,i,s)),s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,e=0,i=1,s=1,n=0,o=0,a=0,l=0,h=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=s||1,this.rotation=n,this.skew.x=o,this.skew.y=a,this.pivot.x=l,this.pivot.y=h,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new P1),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*Tb}set angle(t){this.transform.rotation=t*Eb}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class P1 extends Ct{constructor(){super(...arguments),this.sortDirty=null}}Ct.prototype.displayObjectUpdateTransform=Ct.prototype.updateTransform;const M1=new wt;function D1(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const Df=class Ah extends Ct{constructor(){super(),this.children=[],this.sortableChildren=Ah.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),s=this.getChildIndex(e);this.children[i]=e,this.children[s]=t,this.onChildrenChange(i<s?i:s)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);Yr(this.children,i,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],i=this.children.indexOf(e);if(i===-1)return null;e.parent=null,e.transform._parentID=-1,Yr(this.children,i,1),this._boundsID++,this.onChildrenChange(i),e.emit("removed",this),this.emit("childRemoved",e,this,i)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,Yr(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,s=e,n=s-i;let o;if(n>0&&n<=s){o=this.children.splice(i,n);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const s=this.children[e];s._lastSortedIndex=e,!t&&s.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(D1),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(e._bounds,i._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let s=0,n=this.children.length;s<n;++s){const o=this.children[s];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,s;this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==Ah.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=M1.copyFrom(s),s.prepend(n)):s=n),i&&e.intersects(i,s))this._render(t);else if(this.cullArea)return;for(let o=0,a=this.children.length;o<a;++o){const l=this.children[o],h=l.cullable;l.cullable=h||!this.cullArea,l.render(t),l.cullable=h}}render(t){var e;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(e=this.filters)!=null&&e.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let i=0,s=this.children.length;i<s;++i)this.children[i].render(t)}}renderAdvanced(t){var n,o,a;const e=this.filters,i=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let l=0;l<e.length;l++)e[l].enabled&&this._enabledFilters.push(e[l])}const s=e&&((n=this._enabledFilters)==null?void 0:n.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==Ft.NONE));if(s&&t.batch.flush(),e&&((o=this._enabledFilters)!=null&&o.length)&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let l=0,h=this.children.length;l<h;++l)this.children[l].render(t)}s&&t.batch.flush(),i&&t.mask.pop(this),e&&((a=this._enabledFilters)!=null&&a.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t==null?void 0:t.children,i=this.removeChildren(0,this.children.length);if(e)for(let s=0;s<i.length;++s)i[s].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};Df.defaultSortableChildren=!1;let le=Df;le.prototype.containerUpdateTransform=le.prototype.updateTransform,Object.defineProperties(z,{SORTABLE_CHILDREN:{get(){return le.defaultSortableChildren},set(r){et("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),le.defaultSortableChildren=r}}});const Ss=new dt,B1=new Uint16Array([0,1,2,0,2,3]);class er extends le{constructor(t){super(),this._anchor=new vr(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new ut(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=U.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||Y.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=B1,this.pluginName="batch",this.isSprite=!0,this._roundPixels=z.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=_r(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=_r(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this.vertexData,u=t.trim,c=t.orig,d=this._anchor;let p=0,f=0,m=0,_=0;if(u?(f=u.x-d._x*c.width,p=f+u.width,_=u.y-d._y*c.height,m=_+u.height):(f=-d._x*c.width,p=f+c.width,_=-d._y*c.height,m=_+c.height),h[0]=i*f+n*_+a,h[1]=o*_+s*f+l,h[2]=i*p+n*_+a,h[3]=o*_+s*p+l,h[4]=i*p+n*m+a,h[5]=o*m+s*p+l,h[6]=i*f+n*m+a,h[7]=o*m+s*f+l,this._roundPixels){const g=z.RESOLUTION;for(let v=0;v<h.length;++v)h[v]=Math.round(h[v]*g)/g}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,i=t.orig,s=this._anchor,n=this.transform.worldTransform,o=n.a,a=n.b,l=n.c,h=n.d,u=n.tx,c=n.ty,d=-s._x*i.width,p=d+i.width,f=-s._y*i.height,m=f+i.height;if(e[0]=o*d+l*f+u,e[1]=h*f+a*d+c,e[2]=o*p+l*f+u,e[3]=h*f+a*p+c,e[4]=o*p+l*m+u,e[5]=h*m+a*p+c,e[6]=o*d+l*m+u,e[7]=h*m+a*d+c,this._roundPixels){const _=z.RESOLUTION;for(let g=0;g<e.length;++g)e[g]=Math.round(e[g]*_)/_}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new Kn),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new at),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Ss);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return Ss.x>=s&&Ss.x<s+e&&(n=-i*this.anchor.y,Ss.y>=n&&Ss.y<n+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof Y?t:Y.from(t,e);return new er(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=_r(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=_r(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||Y.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Cs=new dt;class $l extends er{constructor(t,e=100,i=100){super(t),this.tileTransform=new Ln,this._width=e,this._height=i,this.uvMatrix=this.texture.uvMatrix||new Ll(t),this.pluginName="tilingSprite",this.uvRespectAnchor=!1}get clampMargin(){return this.uvMatrix.clampMargin}set clampMargin(t){this.uvMatrix.clampMargin=t,this.uvMatrix.update(!0)}get tileScale(){return this.tileTransform.scale}set tileScale(t){this.tileTransform.scale.copyFrom(t)}get tilePosition(){return this.tileTransform.position}set tilePosition(t){this.tileTransform.position.copyFrom(t)}_onTextureUpdate(){this.uvMatrix&&(this.uvMatrix.texture=this._texture),this._cachedTint=16777215}_render(t){const e=this._texture;!e||!e.valid||(this.tileTransform.updateLocalTransform(),this.uvMatrix.update(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this))}_calculateBounds(){const t=this._width*-this._anchor._x,e=this._height*-this._anchor._y,i=this._width*(1-this._anchor._x),s=this._height*(1-this._anchor._y);this._bounds.addFrame(this.transform,t,e,i,s)}getLocalBounds(t){return this.children.length===0?(this._bounds.minX=this._width*-this._anchor._x,this._bounds.minY=this._height*-this._anchor._y,this._bounds.maxX=this._width*(1-this._anchor._x),this._bounds.maxY=this._height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new at),t=this._localBoundsRect),this._bounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Cs);const e=this._width,i=this._height,s=-e*this.anchor._x;if(Cs.x>=s&&Cs.x<s+e){const n=-i*this.anchor._y;if(Cs.y>=n&&Cs.y<n+i)return!0}return!1}destroy(t){super.destroy(t),this.tileTransform=null,this.uvMatrix=null}static from(t,e){const i=t instanceof Y?t:Y.from(t,e);return new $l(i,e.width,e.height)}get width(){return this._width}set width(t){this._width=t}get height(){return this._height}set height(t){this._height=t}}var O1=`#version 300 es
526
+ `;const B0=M0,sf=D0;class nf{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=Ht.HIGH?this.multisample=Ht.HIGH:e>=Ht.MEDIUM?this.multisample=Ht.MEDIUM:e>=Ht.LOW?this.multisample=Ht.LOW:this.multisample=Ht.NONE}destroy(){}}nf.extension={type:J.RendererSystem,name:"_multisample"},rt.add(nf);class O0{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class af{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,i){const{gl:s,CONTEXT_UID:n}=this;i=i||0;const a=t._glBuffers[n]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,a.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),i&&(e||s.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new O0(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}af.extension={type:J.RendererSystem,name:"buffer"},rt.add(af);class of{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let s,n,a,o;if(e&&(s=e.renderTexture,n=e.clear,a=e.transform,o=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=a,!i.context.isLost){if(s||(this.lastObjectRendered=t),!o){const l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(n??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}of.extension={type:J.RendererSystem,name:"objectRenderer"},rt.add(of);const yn=class uh extends Zd{constructor(t){super(),this.type=Da.WEBGL,t=Object.assign({},et.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new Ne({projectionMatrix:new Ct},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:uh.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(e),"useContextAlpha"in t&&(ct("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=uh.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:Yc()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return ct("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return ct("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return ct("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return ct("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){ct("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return ct("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){ct("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return ct("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};yn.extension={type:J.Renderer,priority:1},yn.__plugins={},yn.__systems={};let vl=yn;rt.handleByMap(J.RendererPlugin,vl.__plugins),rt.handleByMap(J.RendererSystem,vl.__systems),rt.add(vl);class lf extends ns{constructor(t,e){const{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const a=new dt;this.items.push(a),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof ns?this.addResourceAt(t[i],i):this.addResourceAt(md(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{const{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}}class L0 extends lf{constructor(t,e){const{width:i,height:s}=e||{};let n,a;Array.isArray(t)?(n=t,a=t.length):a=t,super(a,{width:i,height:s}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=vi.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:s,itemDirtyIds:n,items:a}=this,{gl:o}=t;i.dirtyId<0&&o.texImage3D(o.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,e.format,i.type,null);for(let l=0;l<s;l++){const h=a[l];n[l]<h.dirtyId&&(n[l]=h.dirtyId,h.valid&&o.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,i.type,h.resource.source))}return!0}}class hf extends br{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const uf=class Ts extends lf{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:a}=e||{};if(t&&t.length!==Ts.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let o=0;o<Ts.SIDES;o++)this.items[o].target=vi.TEXTURE_CUBE_MAP_POSITIVE_X+o;this.linkBaseTexture=a!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=vi.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=vi.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){const s=this.itemDirtyIds;for(let n=0;n<Ts.SIDES;n++){const a=this.items[n];(s[n]<a.dirtyId||i.dirtyId<e.dirtyId)&&(a.valid&&a.resource?(a.resource.upload(t,a,i),s[n]=a.dirtyId):s[n]<-1&&(t.gl.texImage2D(a.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Ts.SIDES}};uf.SIDES=6;let F0=uf;class Si extends br{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=Si.EMPTY,s=t,n=!0):(i=t,s=null,n=!1),super(i),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const i=await et.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===ce.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return Si._EMPTY=Si._EMPTY??et.ADAPTER.createCanvas(0,0),Si._EMPTY}}const xl=class Qn extends br{constructor(t,e){e=e||{},super(et.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},Qn.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const t=new Image;br.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*e,n=this._overrideHeight||this._overrideWidth/e*i),s=Math.round(s),n=Math.round(n);const a=this.source;a.width=s,a.height=n,a._pixiId=`canvas_${Ar()}`,a.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=Qn.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&Qn.SVG_XML.test(t)}};xl.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,xl.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let bl=xl;class N0 extends br{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const wl=class ch extends br{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const s=t[0].src||t[0];br.crossOrigin(i,s,e.crossorigin);for(let n=0;n<t.length;++n){const a=document.createElement("source");let{src:o,mime:l}=t[n];if(o=o||t[n],o.startsWith("data:"))l=o.slice(5,o.indexOf(";"));else if(!o.startsWith("blob:")){const h=o.split("?").shift().toLowerCase(),u=h.slice(h.lastIndexOf(".")+1);l=l||ch.MIME_TYPES[u]||`video/${u}`}a.src=o,l&&(a.type=l),i.appendChild(a)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,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._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=_e.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;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._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;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._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}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.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(_e.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(_e.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(_e.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||ch.TYPES.includes(e)}};wl.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],wl.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let cf=wl;rl.push(Si,Rd,hf,cf,N0,bl,Ks,F0,L0),dt.prototype.getDrawableSource=function(){const r=this.resource;return r?r.bitmap||r.source:null},dl.prototype._canvasRenderTarget=null,it.prototype.patternCache=null,it.prototype.tintCache=null;let us;function df(r){const t=et.ADAPTER.createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=r,e.fillRect(0,0,6,1),t}function ff(){if(typeof document>"u")return!1;if(us!==void 0)return us;const r=df("#ff00ff"),t=df("#ffff00"),e=et.ADAPTER.createCanvas(6,1).getContext("2d");e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0);const i=e.getImageData(2,0,1,1);if(!i)us=!1;else{const s=i.data;us=s[0]===255&&s[1]===0&&s[2]===0}return us}function U0(r=[]){return ff()?(r[q.NORMAL]="source-over",r[q.ADD]="lighter",r[q.MULTIPLY]="multiply",r[q.SCREEN]="screen",r[q.OVERLAY]="overlay",r[q.DARKEN]="darken",r[q.LIGHTEN]="lighten",r[q.COLOR_DODGE]="color-dodge",r[q.COLOR_BURN]="color-burn",r[q.HARD_LIGHT]="hard-light",r[q.SOFT_LIGHT]="soft-light",r[q.DIFFERENCE]="difference",r[q.EXCLUSION]="exclusion",r[q.HUE]="hue",r[q.SATURATION]="saturation",r[q.COLOR]="color",r[q.LUMINOSITY]="luminosity"):(r[q.NORMAL]="source-over",r[q.ADD]="lighter",r[q.MULTIPLY]="source-over",r[q.SCREEN]="source-over",r[q.OVERLAY]="source-over",r[q.DARKEN]="source-over",r[q.LIGHTEN]="source-over",r[q.COLOR_DODGE]="source-over",r[q.COLOR_BURN]="source-over",r[q.HARD_LIGHT]="source-over",r[q.SOFT_LIGHT]="source-over",r[q.DIFFERENCE]="source-over",r[q.EXCLUSION]="source-over",r[q.HUE]="source-over",r[q.SATURATION]="source-over",r[q.COLOR]="source-over",r[q.LUMINOSITY]="source-over"),r[q.NORMAL_NPM]=r[q.NORMAL],r[q.ADD_NPM]=r[q.ADD],r[q.SCREEN_NPM]=r[q.SCREEN],r[q.SRC_IN]="source-in",r[q.SRC_OUT]="source-out",r[q.SRC_ATOP]="source-atop",r[q.DST_OVER]="destination-over",r[q.DST_IN]="destination-in",r[q.DST_OUT]="destination-out",r[q.DST_ATOP]="destination-atop",r[q.XOR]="xor",r[q.SUBTRACT]="source-over",r}const k0=new Ct;class pf{constructor(t){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=U0(),this._activeBlendMode=null,this._projTransform=null,this._outerBlend=!1,this.renderer=t}init(){const t=this.renderer.background.alpha<1;if(this.rootContext=this.renderer.view.getContext("2d",{alpha:t}),this.activeContext=this.rootContext,!this.rootContext.imageSmoothingEnabled){const e=this.rootContext;e.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":e.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":e.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":e.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(t,e,i){let s=t;const n=this._projTransform,a=this.activeResolution;i=i||a,n&&(s=k0,s.copyFrom(t),s.prepend(n)),e?this.activeContext.setTransform(s.a*i,s.b*i,s.c*i,s.d*i,s.tx*a|0,s.ty*a|0):this.activeContext.setTransform(s.a*i,s.b*i,s.c*i,s.d*i,s.tx*a,s.ty*a)}clear(t,e){const{activeContext:i,renderer:s}=this,n=t?_t.shared.setValue(t):this.renderer.background.backgroundColor;i.clearRect(0,0,s.width,s.height),t&&(i.globalAlpha=e??this.renderer.background.alpha,i.fillStyle=n.toHex(),i.fillRect(0,0,s.width,s.height),i.globalAlpha=1)}setBlendMode(t,e){const i=t===q.SRC_IN||t===q.SRC_OUT||t===q.DST_IN||t===q.DST_ATOP;!e&&i&&(t=q.NORMAL),this._activeBlendMode!==t&&(this._activeBlendMode=t,this._outerBlend=i,this.activeContext.globalCompositeOperation=this.blendModes[t])}resize(){this.smoothProperty&&(this.rootContext[this.smoothProperty]=dt.defaultOptions.scaleMode===Oe.LINEAR)}invalidateBlendMode(){this._activeBlendMode=this.blendModes.indexOf(this.activeContext.globalCompositeOperation)}destroy(){this.renderer=null,this.rootContext=null,this.activeContext=null,this.smoothProperty=null}}pf.extension={type:J.CanvasRendererSystem,name:"canvasContext"},rt.add(pf);class mf{constructor(t){this._foundShapes=[],this.renderer=t}pushMask(t){const e=this.renderer,i=t.maskObject||t;e.canvasContext.activeContext.save();const s=this._foundShapes;if(this.recursiveFindShapes(i,s),s.length>0){const n=e.canvasContext.activeContext;n.beginPath();for(let a=0;a<s.length;a++){const o=s[a],l=o.transform.worldTransform;this.renderer.canvasContext.setContextTransform(l),this.renderGraphicsShape(o)}s.length=0,n.clip()}}recursiveFindShapes(t,e){t.geometry&&t.geometry.graphicsData&&e.push(t);const{children:i}=t;if(i)for(let s=0;s<i.length;s++)this.recursiveFindShapes(i[s],e)}renderGraphicsShape(t){t.finishPoly();const e=this.renderer.canvasContext.activeContext,i=t.geometry.graphicsData,s=i.length;if(s!==0)for(let n=0;n<s;n++){const a=i[n],o=a.shape;if(o.type===Rt.POLY){let l=o.points;const h=a.holes;let u,c,d,p;e.moveTo(l[0],l[1]);for(let f=1;f<l.length/2;f++)e.lineTo(l[f*2],l[f*2+1]);if(h.length>0){u=0,d=l[0],p=l[1];for(let f=2;f+2<l.length;f+=2)u+=(l[f]-d)*(l[f+3]-p)-(l[f+2]-d)*(l[f+1]-p);for(let f=0;f<h.length;f++)if(l=h[f].shape.points,!!l){c=0,d=l[0],p=l[1];for(let g=2;g+2<l.length;g+=2)c+=(l[g]-d)*(l[g+3]-p)-(l[g+2]-d)*(l[g+1]-p);if(c*u<0){e.moveTo(l[0],l[1]);for(let g=2;g<l.length;g+=2)e.lineTo(l[g],l[g+1])}else{e.moveTo(l[l.length-2],l[l.length-1]);for(let g=l.length-4;g>=0;g-=2)e.lineTo(l[g],l[g+1])}h[f].shape.closeStroke&&e.closePath()}}l[0]===l[l.length-2]&&l[1]===l[l.length-1]&&e.closePath()}else if(o.type===Rt.RECT)e.rect(o.x,o.y,o.width,o.height),e.closePath();else if(o.type===Rt.CIRC)e.arc(o.x,o.y,o.radius,0,2*Math.PI),e.closePath();else if(o.type===Rt.ELIP){const l=o.width*2,h=o.height*2,u=o.x-l/2,c=o.y-h/2,d=.5522848,p=l/2*d,f=h/2*d,g=u+l,y=c+h,m=u+l/2,_=c+h/2;e.moveTo(u,_),e.bezierCurveTo(u,_-f,m-p,c,m,c),e.bezierCurveTo(m+p,c,g,_-f,g,_),e.bezierCurveTo(g,_+f,m+p,y,m,y),e.bezierCurveTo(m-p,y,u,_+f,u,_),e.closePath()}else if(o.type===Rt.RREC){const l=o.x,h=o.y,u=o.width,c=o.height;let d=o.radius;const p=Math.min(u,c)/2;d=d>p?p:d,e.moveTo(l,h+d),e.lineTo(l,h+c-d),e.quadraticCurveTo(l,h+c,l+d,h+c),e.lineTo(l+u-d,h+c),e.quadraticCurveTo(l+u,h+c,l+u,h+c-d),e.lineTo(l+u,h+d),e.quadraticCurveTo(l+u,h,l+u-d,h),e.lineTo(l+d,h),e.quadraticCurveTo(l,h,l,h+d),e.closePath()}}}popMask(t){t.canvasContext.activeContext.restore(),t.canvasContext.invalidateBlendMode()}destroy(){}}mf.extension={type:J.CanvasRendererSystem,name:"mask"},rt.add(mf);class gf{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;if(!i.view)return;const s=i.canvasContext;let n,a,o,l;e&&(n=e.renderTexture,a=e.clear,o=e.transform,l=e.skipUpdateTransform),this.renderingToScreen=!n,i.emit("prerender");const h=i.resolution;n?(n=n.castToBaseTexture(),n._canvasRenderTarget||(n._canvasRenderTarget=new ss(n.width,n.height,n.resolution),n.resource=new hf(n._canvasRenderTarget.canvas),n.valid=!0),s.activeContext=n._canvasRenderTarget.context,i.canvasContext.activeResolution=n._canvasRenderTarget.resolution):(s.activeContext=s.rootContext,s.activeResolution=h);const u=s.activeContext;if(s._projTransform=o||null,n||(this.lastObjectRendered=t),!l){const d=t.enableTempParent();t.updateTransform(),t.disableTempParent(d)}if(u.save(),u.setTransform(1,0,0,1,0,0),u.globalAlpha=1,s._activeBlendMode=q.NORMAL,s._outerBlend=!1,u.globalCompositeOperation=s.blendModes[q.NORMAL],a??i.background.clearBeforeRender)if(this.renderingToScreen){u.clearRect(0,0,i.width,i.height);const d=i.background;d.alpha>0&&(u.globalAlpha=d.backgroundColor.alpha,u.fillStyle=d.backgroundColor.toHex(),u.fillRect(0,0,i.width,i.height),u.globalAlpha=1)}else n=n,n._canvasRenderTarget.clear(),n.clear.alpha>0&&(u.globalAlpha=n.clear.alpha,u.fillStyle=n.clear.toHex(),u.fillRect(0,0,n.realWidth,n.realHeight),u.globalAlpha=1);const c=s.activeContext;s.activeContext=u,t.renderCanvas(i),s.activeContext=c,u.restore(),s.activeResolution=h,s._projTransform=null,i.emit("postrender")}destroy(){this.lastObjectRendered=null,this.render=null}}gf.extension={type:J.CanvasRendererSystem,name:"objectRenderer"},rt.add(gf);const{deprecation:se}=wv,_n=class dh extends Zd{constructor(t){super(),this.type=Da.CANVAS,this.rendererLogId="Canvas",t=Object.assign({},et.RENDER_OPTIONS,t);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:dh.__systems,priority:["textureGenerator","background","_view","_plugin","startup","mask","canvasContext","objectRenderer"]};this.setup(e),"useContextAlpha"in t&&(se("7.0.0","options.useContextAlpha is deprecated, use options.backgroundAlpha instead"),t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=dh.__plugins,this.options=t,this.startup.run(this.options)}static test(){return!0}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}reset(){}render(t,e){this.objectRenderer.render(t,e)}clear(){this.canvasContext.clear()}destroy(t){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}resize(t,e){this._view.resizeView(t,e)}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get clearBeforeRender(){return this.background.clearBeforeRender}get blendModes(){return se("7.0.0","renderer.blendModes has been deprecated, please use renderer.canvasContext.blendModes instead"),this.canvasContext.blendModes}get maskManager(){return se("7.0.0","renderer.maskManager has been deprecated, please use renderer.mask instead"),this.mask}get refresh(){return se("7.0.0","renderer.refresh has been deprecated"),!0}get rootContext(){return se("7.0.0","renderer.rootContext has been deprecated, please use renderer.canvasContext.rootContext instead"),this.canvasContext.rootContext}get context(){return se("7.0.0","renderer.context has been deprecated, please use renderer.canvasContext.activeContext instead"),this.canvasContext.activeContext}get smoothProperty(){return se("7.0.0","renderer.smoothProperty has been deprecated, please use renderer.canvasContext.smoothProperty instead"),this.canvasContext.smoothProperty}setBlendMode(t,e){se("7.0.0","renderer.setBlendMode has been deprecated, use renderer.canvasContext.setBlendMode instead"),this.canvasContext.setBlendMode(t,e)}invalidateBlendMode(){se("7.0.0","renderer.invalidateBlendMode has been deprecated, use renderer.canvasContext.invalidateBlendMode instead"),this.canvasContext.invalidateBlendMode()}setContextTransform(t,e,i){se("7.0.0","renderer.setContextTransform has been deprecated, use renderer.canvasContext.setContextTransform instead"),this.canvasContext.setContextTransform(t,e,i)}get backgroundColor(){return se("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){se("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return se("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){se("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get preserveDrawingBuffer(){return se("7.0.0","renderer.preserveDrawingBuffer has been deprecated"),!1}get useContextAlpha(){return se("7.0.0","renderer.useContextAlpha has been deprecated"),!1}};_n.extension={type:J.Renderer,priority:0},_n.__plugins={},_n.__systems={};let vn=_n;rt.handleByMap(J.CanvasRendererPlugin,vn.__plugins),rt.handleByMap(J.CanvasRendererSystem,vn.__systems),rt.add(vn);const jt={canvas:null,getTintedCanvas:(r,t)=>{const e=r.texture,i=_t.shared.setValue(t).toHex();e.tintCache=e.tintCache||{};const s=e.tintCache[i];let n;if(s){if(s.tintId===e._updateID)return e.tintCache[i];n=e.tintCache[i]}else n=et.ADAPTER.createCanvas();return jt.tintMethod(e,t,n),n.tintId=e._updateID,jt.convertTintToImage||(e.tintCache[i]=n),n},getTintedPattern:(r,t)=>{const e=_t.shared.setValue(t).toHex();r.patternCache=r.patternCache||{};let i=r.patternCache[e];return(i==null?void 0:i.tintId)===r._updateID||(jt.canvas||(jt.canvas=et.ADAPTER.createCanvas()),jt.tintMethod(r,t,jt.canvas),i=jt.canvas.getContext("2d").createPattern(jt.canvas,"repeat"),i.tintId=r._updateID,r.patternCache[e]=i),i},tintWithMultiply:(r,t,e)=>{const i=e.getContext("2d"),s=r._frame.clone(),n=r.baseTexture.resolution;s.x*=n,s.y*=n,s.width*=n,s.height*=n,e.width=Math.ceil(s.width),e.height=Math.ceil(s.height),i.save(),i.fillStyle=_t.shared.setValue(t).toHex(),i.fillRect(0,0,s.width,s.height),i.globalCompositeOperation="multiply";const a=r.baseTexture.getDrawableSource();i.drawImage(a,s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.globalCompositeOperation="destination-atop",i.drawImage(a,s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.restore()},tintWithOverlay:(r,t,e)=>{const i=e.getContext("2d"),s=r._frame.clone(),n=r.baseTexture.resolution;s.x*=n,s.y*=n,s.width*=n,s.height*=n,e.width=Math.ceil(s.width),e.height=Math.ceil(s.height),i.save(),i.globalCompositeOperation="copy",i.fillStyle=`#${`00000${(t|0).toString(16)}`.slice(-6)}`,i.fillRect(0,0,s.width,s.height),i.globalCompositeOperation="destination-atop",i.drawImage(r.baseTexture.getDrawableSource(),s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.restore()},tintWithPerPixel:(r,t,e)=>{const i=e.getContext("2d"),s=r._frame.clone(),n=r.baseTexture.resolution;s.x*=n,s.y*=n,s.width*=n,s.height*=n,e.width=Math.ceil(s.width),e.height=Math.ceil(s.height),i.save(),i.globalCompositeOperation="copy",i.drawImage(r.baseTexture.getDrawableSource(),s.x,s.y,s.width,s.height,0,0,s.width,s.height),i.restore();const[a,o,l]=_t.shared.setValue(t).toArray(),h=i.getImageData(0,0,s.width,s.height),u=h.data;for(let c=0;c<u.length;c+=4)u[c+0]*=a,u[c+1]*=o,u[c+2]*=l;i.putImageData(h,0,0)},roundColor:r=>(ct("7.3.0","PIXI.canvasUtils.roundColor is deprecated"),_t.shared.setValue(r).round(jt.cacheStepsPerColorChannel).toNumber()),cacheStepsPerColorChannel:8,convertTintToImage:!1,canUseMultiply:ff(),tintMethod:null};jt.tintMethod=jt.canUseMultiply?jt.tintWithMultiply:jt.tintWithPerPixel;class xn{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?pt.EMPTY:(t=t||new pt(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:i,b:s,c:n,d:a,tx:o,ty:l}=t,h=i*e.x+n*e.y+o,u=s*e.x+a*e.y+l;this.minX=Math.min(this.minX,h),this.maxX=Math.max(this.maxX,h),this.minY=Math.min(this.minY,u),this.maxY=Math.max(this.maxY,u)}addQuad(t){let e=this.minX,i=this.minY,s=this.maxX,n=this.maxY,a=t[0],o=t[1];e=a<e?a:e,i=o<i?o:i,s=a>s?a:s,n=o>n?o:n,a=t[2],o=t[3],e=a<e?a:e,i=o<i?o:i,s=a>s?a:s,n=o>n?o:n,a=t[4],o=t[5],e=a<e?a:e,i=o<i?o:i,s=a>s?a:s,n=o>n?o:n,a=t[6],o=t[7],e=a<e?a:e,i=o<i?o:i,s=a>s?a:s,n=o>n?o:n,this.minX=e,this.minY=i,this.maxX=s,this.maxY=n}addFrame(t,e,i,s,n){this.addFrameMatrix(t.worldTransform,e,i,s,n)}addFrameMatrix(t,e,i,s,n){const a=t.a,o=t.b,l=t.c,h=t.d,u=t.tx,c=t.ty;let d=this.minX,p=this.minY,f=this.maxX,g=this.maxY,y=a*e+l*i+u,m=o*e+h*i+c;d=y<d?y:d,p=m<p?m:p,f=y>f?y:f,g=m>g?m:g,y=a*s+l*i+u,m=o*s+h*i+c,d=y<d?y:d,p=m<p?m:p,f=y>f?y:f,g=m>g?m:g,y=a*e+l*n+u,m=o*e+h*n+c,d=y<d?y:d,p=m<p?m:p,f=y>f?y:f,g=m>g?m:g,y=a*s+l*n+u,m=o*s+h*n+c,d=y<d?y:d,p=m<p?m:p,f=y>f?y:f,g=m>g?m:g,this.minX=d,this.minY=p,this.maxX=f,this.maxY=g}addVertexData(t,e,i){let s=this.minX,n=this.minY,a=this.maxX,o=this.maxY;for(let l=e;l<i;l+=2){const h=t[l],u=t[l+1];s=h<s?h:s,n=u<n?u:n,a=h>a?h:a,o=u>o?u:o}this.minX=s,this.minY=n,this.maxX=a,this.maxY=o}addVertices(t,e,i,s){this.addVerticesMatrix(t.worldTransform,e,i,s)}addVerticesMatrix(t,e,i,s,n=0,a=n){const o=t.a,l=t.b,h=t.c,u=t.d,c=t.tx,d=t.ty;let p=this.minX,f=this.minY,g=this.maxX,y=this.maxY;for(let m=i;m<s;m+=2){const _=e[m],v=e[m+1],x=o*_+h*v+c,b=u*v+l*_+d;p=Math.min(p,x-n),g=Math.max(g,x+n),f=Math.min(f,b-a),y=Math.max(y,b+a)}this.minX=p,this.minY=f,this.maxX=g,this.maxY=y}addBounds(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>s?t.maxX:s,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,s=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,a=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=n&&s<=a){const o=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<o?i:o,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=a>u?a:u}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,s=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,a=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=n&&s<=a){const o=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<o?i:o,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=a>u?a:u}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,s,n,a){t-=n,e-=a,i+=n,s+=a,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>s?this.maxY:s}}class Ot extends bi{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new nn,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new xn,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let i=0;i<e.length;++i){const s=e[i];Object.defineProperty(Ot.prototype,s,Object.getOwnPropertyDescriptor(t,s))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new pt),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new pt),t=this._localBoundsRect),this._localBounds||(this._localBounds=new xn);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const s=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const a=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=s,this._bounds.updateID+=this._boundsID-n,a}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,s){return e&&(t=e.toGlobal(t,i,s)),s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,e=0,i=1,s=1,n=0,a=0,o=0,l=0,h=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=s||1,this.rotation=n,this.skew.x=a,this.skew.y=o,this.pivot.x=l,this.pivot.y=h,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new G0),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*Dv}set angle(t){this.transform.rotation=t*Bv}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class G0 extends Ot{constructor(){super(...arguments),this.sortDirty=null}}Ot.prototype.displayObjectUpdateTransform=Ot.prototype.updateTransform;const H0=new Ct;function $0(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const yf=class fh extends Ot{constructor(){super(),this.children=[],this.sortableChildren=fh.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),s=this.getChildIndex(e);this.children[i]=e,this.children[s]=t,this.onChildrenChange(i<s?i:s)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);Vr(this.children,i,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],i=this.children.indexOf(e);if(i===-1)return null;e.parent=null,e.transform._parentID=-1,Vr(this.children,i,1),this._boundsID++,this.onChildrenChange(i),e.emit("removed",this),this.emit("childRemoved",e,this,i)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,Vr(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,s=e,n=s-i;let a;if(n>0&&n<=s){a=this.children.splice(i,n);for(let o=0;o<a.length;++o)a[o].parent=null,a[o].transform&&(a[o].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let o=0;o<a.length;++o)a[o].emit("removed",this),this.emit("childRemoved",a[o],this,o);return a}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const s=this.children[e];s._lastSortedIndex=e,!t&&s.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort($0),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(e._bounds,i._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let s=0,n=this.children.length;s<n;++s){const a=this.children[s];a.visible&&a.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,s;this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==fh.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=H0.copyFrom(s),s.prepend(n)):s=n),i&&e.intersects(i,s))this._render(t);else if(this.cullArea)return;for(let a=0,o=this.children.length;a<o;++a){const l=this.children[a],h=l.cullable;l.cullable=h||!this.cullArea,l.render(t),l.cullable=h}}render(t){var e;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(e=this.filters)!=null&&e.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let i=0,s=this.children.length;i<s;++i)this.children[i].render(t)}}renderAdvanced(t){var n,a,o;const e=this.filters,i=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let l=0;l<e.length;l++)e[l].enabled&&this._enabledFilters.push(e[l])}const s=e&&((n=this._enabledFilters)==null?void 0:n.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==Vt.NONE));if(s&&t.batch.flush(),e&&((a=this._enabledFilters)!=null&&a.length)&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let l=0,h=this.children.length;l<h;++l)this.children[l].render(t)}s&&t.batch.flush(),i&&t.mask.pop(this),e&&((o=this._enabledFilters)!=null&&o.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t==null?void 0:t.children,i=this.removeChildren(0,this.children.length);if(e)for(let s=0;s<i.length;++s)i[s].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};yf.defaultSortableChildren=!1;let de=yf;de.prototype.containerUpdateTransform=de.prototype.updateTransform,Object.defineProperties(et,{SORTABLE_CHILDREN:{get(){return de.defaultSortableChildren},set(r){ct("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),de.defaultSortableChildren=r}}});const cs=new vt,V0=new Uint16Array([0,1,2,0,2,3]);class nr extends de{constructor(t){super(),this._anchor=new vr(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new _t(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=q.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||it.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=V0,this.pluginName="batch",this.isSprite=!0,this._roundPixels=et.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=_r(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=_r(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,a=e.d,o=e.tx,l=e.ty,h=this.vertexData,u=t.trim,c=t.orig,d=this._anchor;let p=0,f=0,g=0,y=0;if(u?(f=u.x-d._x*c.width,p=f+u.width,y=u.y-d._y*c.height,g=y+u.height):(f=-d._x*c.width,p=f+c.width,y=-d._y*c.height,g=y+c.height),h[0]=i*f+n*y+o,h[1]=a*y+s*f+l,h[2]=i*p+n*y+o,h[3]=a*y+s*p+l,h[4]=i*p+n*g+o,h[5]=a*g+s*p+l,h[6]=i*f+n*g+o,h[7]=a*g+s*f+l,this._roundPixels){const m=et.RESOLUTION;for(let _=0;_<h.length;++_)h[_]=Math.round(h[_]*m)/m}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,i=t.orig,s=this._anchor,n=this.transform.worldTransform,a=n.a,o=n.b,l=n.c,h=n.d,u=n.tx,c=n.ty,d=-s._x*i.width,p=d+i.width,f=-s._y*i.height,g=f+i.height;if(e[0]=a*d+l*f+u,e[1]=h*f+o*d+c,e[2]=a*p+l*f+u,e[3]=h*f+o*p+c,e[4]=a*p+l*g+u,e[5]=h*g+o*p+c,e[6]=a*d+l*g+u,e[7]=h*g+o*d+c,this._roundPixels){const y=et.RESOLUTION;for(let m=0;m<e.length;++m)e[m]=Math.round(e[m]*y)/y}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new xn),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new pt),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,cs);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return cs.x>=s&&cs.x<s+e&&(n=-i*this.anchor.y,cs.y>=n&&cs.y<n+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof it?t:it.from(t,e);return new nr(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=_r(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=_r(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||it.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const ds=new vt;class Tl extends nr{constructor(t,e=100,i=100){super(t),this.tileTransform=new nn,this._width=e,this._height=i,this.uvMatrix=this.texture.uvMatrix||new gl(t),this.pluginName="tilingSprite",this.uvRespectAnchor=!1}get clampMargin(){return this.uvMatrix.clampMargin}set clampMargin(t){this.uvMatrix.clampMargin=t,this.uvMatrix.update(!0)}get tileScale(){return this.tileTransform.scale}set tileScale(t){this.tileTransform.scale.copyFrom(t)}get tilePosition(){return this.tileTransform.position}set tilePosition(t){this.tileTransform.position.copyFrom(t)}_onTextureUpdate(){this.uvMatrix&&(this.uvMatrix.texture=this._texture),this._cachedTint=16777215}_render(t){const e=this._texture;!e||!e.valid||(this.tileTransform.updateLocalTransform(),this.uvMatrix.update(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this))}_calculateBounds(){const t=this._width*-this._anchor._x,e=this._height*-this._anchor._y,i=this._width*(1-this._anchor._x),s=this._height*(1-this._anchor._y);this._bounds.addFrame(this.transform,t,e,i,s)}getLocalBounds(t){return this.children.length===0?(this._bounds.minX=this._width*-this._anchor._x,this._bounds.minY=this._height*-this._anchor._y,this._bounds.maxX=this._width*(1-this._anchor._x),this._bounds.maxY=this._height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new pt),t=this._localBoundsRect),this._bounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,ds);const e=this._width,i=this._height,s=-e*this.anchor._x;if(ds.x>=s&&ds.x<s+e){const n=-i*this.anchor._y;if(ds.y>=n&&ds.y<n+i)return!0}return!1}destroy(t){super.destroy(t),this.tileTransform=null,this.uvMatrix=null}static from(t,e){const i=t instanceof it?t:it.from(t,e);return new Tl(i,e.width,e.height)}get width(){return this._width}set width(t){this._width=t}get height(){return this._height}set height(t){this._height=t}}var X0=`#version 300 es
527
527
  #define SHADER_NAME Tiling-Sprite-100
528
528
 
529
529
  precision lowp float;
@@ -549,7 +549,7 @@ void main(void)
549
549
 
550
550
  fragmentColor = texSample * uColor;
551
551
  }
552
- `,L1=`#version 300 es
552
+ `,W0=`#version 300 es
553
553
  #define SHADER_NAME Tiling-Sprite-300
554
554
 
555
555
  precision lowp float;
@@ -569,7 +569,7 @@ void main(void)
569
569
 
570
570
  vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
571
571
  }
572
- `,F1=`#version 100
572
+ `,z0=`#version 100
573
573
  #ifdef GL_EXT_shader_texture_lod
574
574
  #extension GL_EXT_shader_texture_lod : enable
575
575
  #endif
@@ -602,7 +602,7 @@ void main(void)
602
602
 
603
603
  gl_FragColor = texSample * uColor;
604
604
  }
605
- `,Bf=`#version 100
605
+ `,_f=`#version 100
606
606
  #define SHADER_NAME Tiling-Sprite-100
607
607
 
608
608
  precision lowp float;
@@ -622,7 +622,7 @@ void main(void)
622
622
 
623
623
  vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
624
624
  }
625
- `,N1=`#version 100
625
+ `,j0=`#version 100
626
626
  #define SHADER_NAME Tiling-Sprite-Simple-100
627
627
 
628
628
  precision lowp float;
@@ -637,7 +637,7 @@ void main(void)
637
637
  vec4 texSample = texture2D(uSampler, vTextureCoord);
638
638
  gl_FragColor = texSample * uColor;
639
639
  }
640
- `;const Zn=new wt;class Of extends kn{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new zd,this.state=Je.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=Qe.from(Bf,N1,e),this.shader=t.context.webGLVersion>1?Qe.from(L1,O1,e):Qe.from(Bf,F1,e)}render(t){const e=this.renderer,i=this.quad;let s=i.vertices;s[0]=s[6]=t._width*-t.anchor.x,s[1]=s[3]=t._height*-t.anchor.y,s[2]=s[4]=t._width*(1-t.anchor.x),s[5]=s[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,o=t.uvRespectAnchor?t.anchor.y:0;s=i.uvs,s[0]=s[6]=-n,s[1]=s[3]=-o,s[2]=s[4]=1-n,s[5]=s[7]=1-o,i.invalidate();const a=t._texture,l=a.baseTexture,h=l.alphaMode>0,u=t.tileTransform.localTransform,c=t.uvMatrix;let d=l.isPowerOfTwo&&a.frame.width===l.width&&a.frame.height===l.height;d&&(l._glTextures[e.CONTEXT_UID]?d=l.wrapMode!==pr.CLAMP:l.wrapMode===pr.CLAMP&&(l.wrapMode=pr.REPEAT));const p=d?this.simpleShader:this.shader,f=a.width,m=a.height,_=t._width,g=t._height;Zn.set(u.a*f/_,u.b*f/g,u.c*m/_,u.d*m/g,u.tx/_,u.ty/g),Zn.invert(),d?Zn.prepend(c.mapCoord):(p.uniforms.uMapCoord=c.mapCoord.toArray(!0),p.uniforms.uClampFrame=c.uClampFrame,p.uniforms.uClampOffset=c.uClampOffset),p.uniforms.uTransform=Zn.toArray(!0),p.uniforms.uColor=ut.shared.setValue(t.tint).premultiply(t.worldAlpha,h).toArray(p.uniforms.uColor),p.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),p.uniforms.uSampler=a,e.shader.bind(p),e.geometry.bind(i),this.state.blendMode=al(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Of.extension={name:"tilingSprite",type:X.RendererPlugin},j.add(Of);const Jn=new wt,Is=new wt,rr=[new dt,new dt,new dt,new dt];$l.prototype._renderCanvas=function(r){const t=this._texture;if(!t.baseTexture.valid)return;const e=r.canvasContext.activeContext,i=this.worldTransform,s=t.baseTexture,n=s.getDrawableSource(),o=s.resolution;if(this._textureID!==this._texture._updateID||this._cachedTint!==this.tintValue){this._textureID=this._texture._updateID;const d=new vs(t._frame.width,t._frame.height,o);this.tintValue!==16777215?(this._tintedCanvas=Vt.getTintedCanvas(this,this.tintValue),d.context.drawImage(this._tintedCanvas,0,0)):d.context.drawImage(n,-t._frame.x*o,-t._frame.y*o),this._cachedTint=this.tintValue,this._canvasPattern=d.context.createPattern(d.canvas,"repeat")}e.globalAlpha=this.worldAlpha,r.canvasContext.setBlendMode(this.blendMode),this.tileTransform.updateLocalTransform();const a=this.tileTransform.localTransform,l=this._width,h=this._height;Jn.identity(),Is.copyFrom(a),this.uvRespectAnchor||Is.translate(-this.anchor.x*l,-this.anchor.y*h),Is.scale(1/o,1/o),Jn.prepend(Is),Jn.prepend(i),r.canvasContext.setContextTransform(Jn),e.fillStyle=this._canvasPattern;const u=this.anchor.x*-l,c=this.anchor.y*-h;rr[0].set(u,c),rr[1].set(u+l,c),rr[2].set(u+l,c+h),rr[3].set(u,c+h);for(let d=0;d<4;d++)Is.applyInverse(rr[d],rr[d]);e.beginPath(),e.moveTo(rr[0].x,rr[0].y);for(let d=1;d<4;d++)e.lineTo(rr[d].x,rr[d].y);e.closePath(),e.fill()};class U1 extends le{constructor(t=1500,e,i=16384,s=!1){super();const n=16384;i>n&&(i=n),this._properties=[!1,!0,!1,!1,!1],this._maxSize=t,this._batchSize=i,this._buffers=null,this._bufferUpdateIDs=[],this._updateID=0,this.interactiveChildren=!1,this.blendMode=U.NORMAL,this.autoResize=s,this.roundPixels=!0,this.baseTexture=null,this.setProperties(e),this._tintColor=new ut(0),this.tintRgb=new Float32Array(3),this.tint=16777215}setProperties(t){t&&(this._properties[0]="vertices"in t||"scale"in t?!!t.vertices||!!t.scale:this._properties[0],this._properties[1]="position"in t?!!t.position:this._properties[1],this._properties[2]="rotation"in t?!!t.rotation:this._properties[2],this._properties[3]="uvs"in t?!!t.uvs:this._properties[3],this._properties[4]="tint"in t||"alpha"in t?!!t.tint||!!t.alpha:this._properties[4])}updateTransform(){this.displayObjectUpdateTransform()}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintColor.toRgbArray(this.tintRgb)}render(t){!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable||(this.baseTexture||(this.baseTexture=this.children[0]._texture.baseTexture,this.baseTexture.valid||this.baseTexture.once("update",()=>this.onChildrenChange(0))),t.batch.setObjectRenderer(t.plugins.particle),t.plugins.particle.render(this))}onChildrenChange(t){const e=Math.floor(t/this._batchSize);for(;this._bufferUpdateIDs.length<e;)this._bufferUpdateIDs.push(0);this._bufferUpdateIDs[e]=++this._updateID}dispose(){if(this._buffers){for(let t=0;t<this._buffers.length;++t)this._buffers[t].destroy();this._buffers=null}}destroy(t){super.destroy(t),this.dispose(),this._properties=null,this._buffers=null,this._bufferUpdateIDs=null}}class Lf{constructor(t,e,i){this.geometry=new Ir,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let s=0;s<t.length;++s){let n=t[s];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||J.FLOAT,offset:n.offset},e[s]?this.dynamicProperties.push(n):this.staticProperties.push(n)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let e=0;this.indexBuffer=new Bt(wd(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];a.offset=e,e+=a.size,this.dynamicStride+=a.size}const i=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(i),this.dynamicDataUint32=new Uint32Array(i),this.dynamicBuffer=new Bt(this.dynamicData,!1,!1);let s=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=s,s+=a.size,this.staticStride+=a.size}const n=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(n),this.staticDataUint32=new Uint32Array(n),this.staticBuffer=new Bt(this.staticData,!0,!1);for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];t.addAttribute(a.attributeName,this.dynamicBuffer,0,a.type===J.UNSIGNED_BYTE,a.type,this.dynamicStride*4,a.offset*4)}for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];t.addAttribute(a.attributeName,this.staticBuffer,0,a.type===J.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(t,e,i){for(let s=0;s<this.dynamicProperties.length;s++){const n=this.dynamicProperties[s];n.uploadFunction(t,e,i,n.type===J.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let s=0;s<this.staticProperties.length;s++){const n=this.staticProperties[s];n.uploadFunction(t,e,i,n.type===J.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,n.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var k1=`varying vec2 vTextureCoord;
640
+ `;const bn=new Ct;class vf extends hn{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new Dd,this.state=rr.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=ir.from(_f,j0,e),this.shader=t.context.webGLVersion>1?ir.from(W0,X0,e):ir.from(_f,z0,e)}render(t){const e=this.renderer,i=this.quad;let s=i.vertices;s[0]=s[6]=t._width*-t.anchor.x,s[1]=s[3]=t._height*-t.anchor.y,s[2]=s[4]=t._width*(1-t.anchor.x),s[5]=s[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,a=t.uvRespectAnchor?t.anchor.y:0;s=i.uvs,s[0]=s[6]=-n,s[1]=s[3]=-a,s[2]=s[4]=1-n,s[5]=s[7]=1-a,i.invalidate();const o=t._texture,l=o.baseTexture,h=l.alphaMode>0,u=t.tileTransform.localTransform,c=t.uvMatrix;let d=l.isPowerOfTwo&&o.frame.width===l.width&&o.frame.height===l.height;d&&(l._glTextures[e.CONTEXT_UID]?d=l.wrapMode!==mr.CLAMP:l.wrapMode===mr.CLAMP&&(l.wrapMode=mr.REPEAT));const p=d?this.simpleShader:this.shader,f=o.width,g=o.height,y=t._width,m=t._height;bn.set(u.a*f/y,u.b*f/m,u.c*g/y,u.d*g/m,u.tx/y,u.ty/m),bn.invert(),d?bn.prepend(c.mapCoord):(p.uniforms.uMapCoord=c.mapCoord.toArray(!0),p.uniforms.uClampFrame=c.uClampFrame,p.uniforms.uClampOffset=c.uClampOffset),p.uniforms.uTransform=bn.toArray(!0),p.uniforms.uColor=_t.shared.setValue(t.tint).premultiply(t.worldAlpha,h).toArray(p.uniforms.uColor),p.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),p.uniforms.uSampler=o,e.shader.bind(p),e.geometry.bind(i),this.state.blendMode=$o(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}vf.extension={name:"tilingSprite",type:J.RendererPlugin},rt.add(vf);const wn=new Ct,fs=new Ct,ar=[new vt,new vt,new vt,new vt];Tl.prototype._renderCanvas=function(r){const t=this._texture;if(!t.baseTexture.valid)return;const e=r.canvasContext.activeContext,i=this.worldTransform,s=t.baseTexture,n=s.getDrawableSource(),a=s.resolution;if(this._textureID!==this._texture._updateID||this._cachedTint!==this.tintValue){this._textureID=this._texture._updateID;const d=new ss(t._frame.width,t._frame.height,a);this.tintValue!==16777215?(this._tintedCanvas=jt.getTintedCanvas(this,this.tintValue),d.context.drawImage(this._tintedCanvas,0,0)):d.context.drawImage(n,-t._frame.x*a,-t._frame.y*a),this._cachedTint=this.tintValue,this._canvasPattern=d.context.createPattern(d.canvas,"repeat")}e.globalAlpha=this.worldAlpha,r.canvasContext.setBlendMode(this.blendMode),this.tileTransform.updateLocalTransform();const o=this.tileTransform.localTransform,l=this._width,h=this._height;wn.identity(),fs.copyFrom(o),this.uvRespectAnchor||fs.translate(-this.anchor.x*l,-this.anchor.y*h),fs.scale(1/a,1/a),wn.prepend(fs),wn.prepend(i),r.canvasContext.setContextTransform(wn),e.fillStyle=this._canvasPattern;const u=this.anchor.x*-l,c=this.anchor.y*-h;ar[0].set(u,c),ar[1].set(u+l,c),ar[2].set(u+l,c+h),ar[3].set(u,c+h);for(let d=0;d<4;d++)fs.applyInverse(ar[d],ar[d]);e.beginPath(),e.moveTo(ar[0].x,ar[0].y);for(let d=1;d<4;d++)e.lineTo(ar[d].x,ar[d].y);e.closePath(),e.fill()};class Y0 extends de{constructor(t=1500,e,i=16384,s=!1){super();const n=16384;i>n&&(i=n),this._properties=[!1,!0,!1,!1,!1],this._maxSize=t,this._batchSize=i,this._buffers=null,this._bufferUpdateIDs=[],this._updateID=0,this.interactiveChildren=!1,this.blendMode=q.NORMAL,this.autoResize=s,this.roundPixels=!0,this.baseTexture=null,this.setProperties(e),this._tintColor=new _t(0),this.tintRgb=new Float32Array(3),this.tint=16777215}setProperties(t){t&&(this._properties[0]="vertices"in t||"scale"in t?!!t.vertices||!!t.scale:this._properties[0],this._properties[1]="position"in t?!!t.position:this._properties[1],this._properties[2]="rotation"in t?!!t.rotation:this._properties[2],this._properties[3]="uvs"in t?!!t.uvs:this._properties[3],this._properties[4]="tint"in t||"alpha"in t?!!t.tint||!!t.alpha:this._properties[4])}updateTransform(){this.displayObjectUpdateTransform()}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintColor.toRgbArray(this.tintRgb)}render(t){!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable||(this.baseTexture||(this.baseTexture=this.children[0]._texture.baseTexture,this.baseTexture.valid||this.baseTexture.once("update",()=>this.onChildrenChange(0))),t.batch.setObjectRenderer(t.plugins.particle),t.plugins.particle.render(this))}onChildrenChange(t){const e=Math.floor(t/this._batchSize);for(;this._bufferUpdateIDs.length<e;)this._bufferUpdateIDs.push(0);this._bufferUpdateIDs[e]=++this._updateID}dispose(){if(this._buffers){for(let t=0;t<this._buffers.length;++t)this._buffers[t].destroy();this._buffers=null}}destroy(t){super.destroy(t),this.dispose(),this._properties=null,this._buffers=null,this._bufferUpdateIDs=null}}class xf{constructor(t,e,i){this.geometry=new Sr,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let s=0;s<t.length;++s){let n=t[s];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||ut.FLOAT,offset:n.offset},e[s]?this.dynamicProperties.push(n):this.staticProperties.push(n)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let e=0;this.indexBuffer=new kt(ld(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let a=0;a<this.dynamicProperties.length;++a){const o=this.dynamicProperties[a];o.offset=e,e+=o.size,this.dynamicStride+=o.size}const i=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(i),this.dynamicDataUint32=new Uint32Array(i),this.dynamicBuffer=new kt(this.dynamicData,!1,!1);let s=0;this.staticStride=0;for(let a=0;a<this.staticProperties.length;++a){const o=this.staticProperties[a];o.offset=s,s+=o.size,this.staticStride+=o.size}const n=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(n),this.staticDataUint32=new Uint32Array(n),this.staticBuffer=new kt(this.staticData,!0,!1);for(let a=0;a<this.dynamicProperties.length;++a){const o=this.dynamicProperties[a];t.addAttribute(o.attributeName,this.dynamicBuffer,0,o.type===ut.UNSIGNED_BYTE,o.type,this.dynamicStride*4,o.offset*4)}for(let a=0;a<this.staticProperties.length;++a){const o=this.staticProperties[a];t.addAttribute(o.attributeName,this.staticBuffer,0,o.type===ut.UNSIGNED_BYTE,o.type,this.staticStride*4,o.offset*4)}}uploadDynamic(t,e,i){for(let s=0;s<this.dynamicProperties.length;s++){const n=this.dynamicProperties[s];n.uploadFunction(t,e,i,n.type===ut.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let s=0;s<this.staticProperties.length;s++){const n=this.staticProperties[s];n.uploadFunction(t,e,i,n.type===ut.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,n.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var q0=`varying vec2 vTextureCoord;
641
641
  varying vec4 vColor;
642
642
 
643
643
  uniform sampler2D uSampler;
@@ -645,7 +645,7 @@ uniform sampler2D uSampler;
645
645
  void main(void){
646
646
  vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
647
647
  gl_FragColor = color;
648
- }`,G1=`attribute vec2 aVertexPosition;
648
+ }`,K0=`attribute vec2 aVertexPosition;
649
649
  attribute vec2 aTextureCoord;
650
650
  attribute vec4 aColor;
651
651
 
@@ -670,8 +670,8 @@ void main(void){
670
670
  vTextureCoord = aTextureCoord;
671
671
  vColor = aColor * uColor;
672
672
  }
673
- `;class Ff extends kn{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new wt,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:J.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=Qe.from(G1,k1,{}),this.state=Je.for2d()}render(t){const e=t.children,i=t._maxSize,s=t._batchSize,n=this.renderer;let o=e.length;if(o===0)return;o>i&&!t.autoResize&&(o=i);let a=t._buffers;a||(a=t._buffers=this.generateBuffers(t));const l=e[0]._texture.baseTexture,h=l.alphaMode>0;this.state.blendMode=al(t.blendMode,h),n.state.set(this.state);const u=n.gl,c=t.worldTransform.copyTo(this.tempMatrix);c.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=ut.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,h).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=l,this.renderer.shader.bind(this.shader);let d=!1;for(let p=0,f=0;p<o;p+=s,f+=1){let m=o-p;m>s&&(m=s),f>=a.length&&a.push(this._generateOneMoreBuffer(t));const _=a[f];_.uploadDynamic(e,p,m);const g=t._bufferUpdateIDs[f]||0;d=d||_._updateID<g,d&&(_._updateID=t._updateID,_.uploadStatic(e,p,m)),n.geometry.bind(_.geometry),u.drawElements(u.TRIANGLES,m*6,u.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,s=t._batchSize,n=t._properties;for(let o=0;o<i;o+=s)e.push(new Lf(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new Lf(this.properties,i,e)}uploadVertices(t,e,i,s,n,o){let a=0,l=0,h=0,u=0;for(let c=0;c<i;++c){const d=t[e+c],p=d._texture,f=d.scale.x,m=d.scale.y,_=p.trim,g=p.orig;_?(l=_.x-d.anchor.x*g.width,a=l+_.width,u=_.y-d.anchor.y*g.height,h=u+_.height):(a=g.width*(1-d.anchor.x),l=g.width*-d.anchor.x,h=g.height*(1-d.anchor.y),u=g.height*-d.anchor.y),s[o]=l*f,s[o+1]=u*m,s[o+n]=a*f,s[o+n+1]=u*m,s[o+n*2]=a*f,s[o+n*2+1]=h*m,s[o+n*3]=l*f,s[o+n*3+1]=h*m,o+=n*4}}uploadPosition(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].position;s[o]=l.x,s[o+1]=l.y,s[o+n]=l.x,s[o+n+1]=l.y,s[o+n*2]=l.x,s[o+n*2+1]=l.y,s[o+n*3]=l.x,s[o+n*3+1]=l.y,o+=n*4}}uploadRotation(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].rotation;s[o]=l,s[o+n]=l,s[o+n*2]=l,s[o+n*3]=l,o+=n*4}}uploadUvs(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a]._texture._uvs;l?(s[o]=l.x0,s[o+1]=l.y0,s[o+n]=l.x1,s[o+n+1]=l.y1,s[o+n*2]=l.x2,s[o+n*2+1]=l.y2,s[o+n*3]=l.x3,s[o+n*3+1]=l.y3,o+=n*4):(s[o]=0,s[o+1]=0,s[o+n]=0,s[o+n+1]=0,s[o+n*2]=0,s[o+n*2+1]=0,s[o+n*3]=0,s[o+n*3+1]=0,o+=n*4)}}uploadTint(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a],h=ut.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);s[o]=h,s[o+n]=h,s[o+n*2]=h,s[o+n*3]=h,o+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Ff.extension={name:"particle",type:X.RendererPlugin},j.add(Ff),U1.prototype.renderCanvas=function(r){if(!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable)return;const t=r.canvasContext.activeContext,e=this.worldTransform;let i=!0,s=0,n=0,o=0,a=0;r.canvasContext.setBlendMode(this.blendMode),t.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(let l=0;l<this.children.length;++l){const h=this.children[l];if(!h.visible||!h._texture.valid)continue;const u=h._texture.frame;if(t.globalAlpha=this.worldAlpha*h.alpha,h.rotation%(Math.PI*2)===0)i&&(r.canvasContext.setContextTransform(e,!1,1),i=!1),s=h.anchor.x*(-u.width*h.scale.x)+h.position.x+.5,n=h.anchor.y*(-u.height*h.scale.y)+h.position.y+.5,o=u.width*h.scale.x,a=u.height*h.scale.y;else{i||(i=!0),h.displayObjectUpdateTransform();const p=h.worldTransform;r.canvasContext.setContextTransform(p,this.roundPixels,1),s=h.anchor.x*-u.width+.5,n=h.anchor.y*-u.height+.5,o=u.width,a=u.height}const c=h._texture.baseTexture.resolution,d=r.canvasContext.activeResolution;t.drawImage(h._texture.baseTexture.getDrawableSource(),u.x*c,u.y*c,u.width*c,u.height*c,s*d,n*d,o*d,a*d)}},le.prototype._renderCanvas=function(r){},le.prototype.renderCanvas=function(r){if(!(!this.visible||this.worldAlpha<=0||!this.renderable)){this._mask&&r.mask.pushMask(this._mask),this._renderCanvas(r);for(let t=0,e=this.children.length;t<e;++t)this.children[t].renderCanvas(r);this._mask&&r.mask.popMask(r)}},Ct.prototype.renderCanvas=function(r){};var Qn=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(Qn||{});const to={willReadFrequently:!0},ir=class Z{static get experimentalLetterSpacingSupported(){let t=Z._experimentalLetterSpacingSupported;if(t!==void 0){const e=z.ADAPTER.getCanvasRenderingContext2D().prototype;t=Z._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,o,a,l,h){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(t,e,i,s=Z._canvas){i=i??e.wordWrap;const n=e.toFontString(),o=Z.measureFont(n);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=s.getContext("2d",to);a.font=n;const l=(i?Z.wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let u=0;for(let f=0;f<l.length;f++){const m=Z._measureText(l[f],e.letterSpacing,a);h[f]=m,u=Math.max(u,m)}let c=u+e.strokeThickness;e.dropShadow&&(c+=e.dropShadowDistance);const d=e.lineHeight||o.fontSize+e.strokeThickness;let p=Math.max(d,o.fontSize+e.strokeThickness*2)+e.leading+(l.length-1)*(d+e.leading);return e.dropShadow&&(p+=e.dropShadowDistance),new Z(t,e,c,p,l,h,d+e.leading,u,o)}static _measureText(t,e,i){let s=!1;Z.experimentalLetterSpacingSupported&&(Z.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(s?n-=e:n+=(Z.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=Z._canvas){const s=i.getContext("2d",to);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:u}=e,c=Z.collapseSpaces(u),d=Z.collapseNewlines(u);let p=!c;const f=e.wordWrapWidth+h,m=Z.tokenize(t);for(let _=0;_<m.length;_++){let g=m[_];if(Z.isNewline(g)){if(!d){a+=Z.addLine(o),p=!c,o="",n=0;continue}g=" "}if(c){const y=Z.isBreakingSpace(g),x=Z.isBreakingSpace(o[o.length-1]);if(y&&x)continue}const v=Z.getFromCache(g,h,l,s);if(v>f)if(o!==""&&(a+=Z.addLine(o),o="",n=0),Z.canBreakWords(g,e.breakWords)){const y=Z.wordWrapSplit(g);for(let x=0;x<y.length;x++){let b=y[x],E=b,T=1;for(;y[x+T];){const M=y[x+T];if(!Z.canBreakChars(E,M,g,x,e.breakWords))b+=M;else break;E=M,T++}x+=T-1;const A=Z.getFromCache(b,h,l,s);A+n>f&&(a+=Z.addLine(o),p=!1,o="",n=0),o+=b,n+=A}}else{o.length>0&&(a+=Z.addLine(o),o="",n=0);const y=_===m.length-1;a+=Z.addLine(g,!y),p=!1,o="",n=0}else v+n>f&&(p=!1,a+=Z.addLine(o),o="",n=0),(o.length>0||!Z.isBreakingSpace(g)||p)&&(o+=g,n+=v)}return a+=Z.addLine(o,!1),a}static addLine(t,e=!0){return t=Z.trimRight(t),t=e?`${t}
674
- `:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=Z._measureText(t,e,s)+e,i[t]=n),n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!Z.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:Z._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:Z._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],o=t[s+1];if(Z.isBreakingSpace(n,o)||Z.isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return Z.graphemeSegmenter(t)}static measureFont(t){if(Z._fonts[t])return Z._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=Z._canvas,s=Z._context;s.font=t;const n=Z.METRICS_STRING+Z.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(Z.BASELINE_SYMBOL).width);const l=Math.ceil(Z.HEIGHT_MULTIPLIER*a);if(a=a*Z.BASELINE_MULTIPLIER|0,o===0||l===0)return Z._fonts[t]=e,e;i.width=o,i.height=l,s.fillStyle="#f00",s.fillRect(0,0,o,l),s.font=t,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,a);const h=s.getImageData(0,0,o,l).data,u=h.length,c=o*4;let d=0,p=0,f=!1;for(d=0;d<a;++d){for(let m=0;m<c;m+=4)if(h[p+m]!==255){f=!0;break}if(!f)p+=c;else break}for(e.ascent=a-d,p=u-c,f=!1,d=l;d>a;--d){for(let m=0;m<c;m+=4)if(h[p+m]!==255){f=!0;break}if(!f)p-=c;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,Z._fonts[t]=e,e}static clearMetrics(t=""){t?delete Z._fonts[t]:Z._fonts={}}static get _canvas(){var t;if(!Z.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",to))!=null&&t.measureText)return Z.__canvas=i,i;e=z.ADAPTER.createCanvas()}catch{e=z.ADAPTER.createCanvas()}e.width=e.height=10,Z.__canvas=e}return Z.__canvas}static get _context(){return Z.__context||(Z.__context=Z._canvas.getContext("2d",to)),Z.__context}};ir.METRICS_STRING="|ÉqÅ",ir.BASELINE_SYMBOL="M",ir.BASELINE_MULTIPLIER=1.4,ir.HEIGHT_MULTIPLIER=2,ir.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>[...r.segment(t)].map(e=>e.segment)}return r=>[...r]})(),ir.experimentalLetterSpacing=!1,ir._fonts={},ir._newlines=[10,13],ir._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Rr=ir;const H1=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Nf=class Us{constructor(t){this.styleID=0,this.reset(),Xl(this,t,t)}clone(){const t={};return Xl(t,this,Us.defaultStyle),new Us(t)}reset(){Xl(this,Us.defaultStyle,Us.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const e=Vl(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const e=Vl(t);this._fill!==e&&(this._fill=e,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){$1(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const e=Vl(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!H1.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};Nf.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Qn.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Pr=Nf;function Vl(r){const t=ut.shared,e=i=>{const s=t.setValue(i);return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(r)?r.map(e):e(r)}function $1(r,t){if(!Array.isArray(r)||!Array.isArray(t)||r.length!==t.length)return!1;for(let e=0;e<r.length;++e)if(r[e]!==t[e])return!1;return!0}function Xl(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const V1={texture:!0,children:!1,baseTexture:!0},Uf=class Sh extends er{constructor(t,e,i){let s=!1;i||(i=z.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=Y.from(i);n.orig=new at,n.trim=new at,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=Sh.defaultResolution??z.RESOLUTION,this._autoResolution=Sh.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=e,this.localStyleID=-1}static get experimentalLetterSpacing(){return Rr.experimentalLetterSpacing}static set experimentalLetterSpacing(t){et("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Rr.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,s=Rr.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=s.width,o=s.height,a=s.lines,l=s.lineHeight,h=s.lineWidths,u=s.maxLineWidth,c=s.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+e.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;let d,p;const f=e.dropShadow?2:1;for(let m=0;m<f;++m){const _=e.dropShadow&&m===0,g=_?Math.ceil(Math.max(1,o)+e.padding*2):0,v=g*this._resolution;if(_){i.fillStyle="black",i.strokeStyle="black";const x=e.dropShadowColor,b=e.dropShadowBlur*this._resolution,E=e.dropShadowDistance*this._resolution;i.shadowColor=ut.shared.setValue(x).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=b,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*E,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*E+v}else i.fillStyle=this._generateFillStyle(e,a,s),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let y=(l-c.fontSize)/2;l-c.fontSize<0&&(y=0);for(let x=0;x<a.length;x++)d=e.strokeThickness/2,p=e.strokeThickness/2+x*l+c.ascent+y,e.align==="right"?d+=u-h[x]:e.align==="center"&&(d+=(u-h[x])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[x],d+e.padding,p+e.padding-g,!0),e.fill&&this.drawLetterSpacing(a[x],d+e.padding,p+e.padding-g)}this.updateTexture()}drawLetterSpacing(t,e,i,s=!1){const n=this._style.letterSpacing;let o=!1;if(Rr.experimentalLetterSpacingSupported&&(Rr.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||o){s?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let a=e;const l=Rr.graphemeSegmenter(t);let h=this.context.measureText(t).width,u=0;for(let c=0;c<l.length;++c){const d=l[c];s?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let p="";for(let f=c+1;f<l.length;++f)p+=l[f];u=this.context.measureText(p).width,a+=h-u+n,h=u}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=Sd(t);o.data&&(t.width=o.width,t.height=o.height,this.context.putImageData(o.data,0,0))}const e=this._texture,i=this._style,s=i.trim?0:i.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-s,e.trim.y=-s,e.orig.width=e._frame.width-s*2,e.orig.height=e._frame.height-s*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const s=t.fill;if(Array.isArray(s)){if(s.length===1)return s[0]}else return s;let n;const o=t.dropShadow?t.dropShadowDistance:0,a=t.padding||0,l=this.canvas.width/this._resolution-o-a*2,h=this.canvas.height/this._resolution-o-a*2,u=s.slice(),c=t.fillGradientStops.slice();if(!c.length){const d=u.length+1;for(let p=1;p<d;++p)c.push(p/d)}if(u.unshift(s[0]),c.unshift(0),u.push(s[s.length-1]),c.push(1),t.fillGradientType===Qn.LINEAR_VERTICAL){n=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let p=0;p<e.length;p++){const f=i.lineHeight*(p-1)+d,m=i.lineHeight*p;let _=m;p>0&&f>m&&(_=(m+f)/2);const g=m+d,v=i.lineHeight*(p+1);let y=g;p+1<e.length&&v<g&&(y=(g+v)/2);const x=(y-_)/h;for(let b=0;b<u.length;b++){let E=0;typeof c[b]=="number"?E=c[b]:E=b/u.length;let T=Math.min(1,Math.max(0,_/h+E*x));T=Number(T.toFixed(5)),n.addColorStop(T,u[b])}}}else{n=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=u.length+1;let p=1;for(let f=0;f<u.length;f++){let m;typeof c[f]=="number"?m=c[f]:m=p/d,n.addColorStop(m,u[f]),p++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},V1,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const e=_r(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const e=_r(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof Pr?this._style=t:this._style=new Pr(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};Uf.defaultAutoResolution=!0;let Wl=Uf;Wl.prototype._renderCanvas=function(r){this._autoResolution&&this._resolution!==r.resolution&&(this._resolution=r.resolution,this.dirty=!0),this.updateText(!0),er.prototype._renderCanvas.call(this,r)};const kf=new wt;Ct.prototype._cacheAsBitmap=!1,Ct.prototype._cacheData=null,Ct.prototype._cacheAsBitmapResolution=null,Ct.prototype._cacheAsBitmapMultisample=null;class X1{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(Ct.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(r){r!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(r){r!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(r){if(this._cacheAsBitmap===r)return;this._cacheAsBitmap=r;let t;r?(this._cacheData||(this._cacheData=new X1),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}}),Ct.prototype._renderCached=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(r),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(r))},Ct.prototype._initCachedDisplayObject=function(r){var d,p;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new at,!0);if((p=this.filters)!=null&&p.length){const f=this.filters[0].padding;e.pad(f)}const i=this.cacheAsBitmapResolution||r.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const s=r.renderTexture.current,n=r.renderTexture.sourceFrame.clone(),o=r.renderTexture.destinationFrame.clone(),a=r.projection.transform,l=tr.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${Cr()}`;this._cacheData.textureCacheId=h,st.addToCache(l.baseTexture,h),Y.addToCache(l,h);const u=this.transform.localTransform.copyTo(kf).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:u,skipUpdateTransform:!1}),r.framebuffer.blit(),r.projection.transform=a,r.renderTexture.bind(s,n,o),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const c=new er(l);c.transform.worldTransform=this.transform.worldTransform,c.anchor.x=-(e.x/e.width),c.anchor.y=-(e.y/e.height),c.alpha=t,c._bounds=this._bounds,this._cacheData.sprite=c,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=c.containsPoint.bind(c)},Ct.prototype._renderCachedCanvas=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(r),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(r))},Ct.prototype._initCachedDisplayObjectCanvas=function(r){var u;if((u=this._cacheData)!=null&&u.sprite)return;const t=this.getLocalBounds(new at,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,s=r._projTransform,n=this.cacheAsBitmapResolution||r.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const o=tr.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${Cr()}`;this._cacheData.textureCacheId=a,st.addToCache(o.baseTexture,a),Y.addToCache(o,a);const l=kf;this.transform.localTransform.copyTo(l),l.invert(),l.tx-=t.x,l.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:o,clear:!0,transform:l,skipUpdateTransform:!1}),r.canvasContext.activeContext=i,r._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const h=new er(o);h.transform.worldTransform=this.transform.worldTransform,h.anchor.x=-(t.x/t.width),h.anchor.y=-(t.y/t.height),h.alpha=e,h._bounds=this._bounds,this._cacheData.sprite=h,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=r._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=h.containsPoint.bind(h)},Ct.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Ct.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Ct.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,st.removeFromCache(this._cacheData.textureCacheId),Y.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Ct.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Ct.prototype.name=null,le.prototype.getChildByName=function(r,t){for(let e=0,i=this.children.length;e<i;e++)if(this.children[e].name===r)return this.children[e];if(t)for(let e=0,i=this.children.length;e<i;e++){const s=this.children[e];if(!s.getChildByName)continue;const n=s.getChildByName(r,!0);if(n)return n}return null},Ct.prototype.getGlobalPosition=function(r=new dt,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var W1=`varying vec2 vTextureCoord;
673
+ `;class bf extends hn{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new Ct,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:ut.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=ir.from(K0,q0,{}),this.state=rr.for2d()}render(t){const e=t.children,i=t._maxSize,s=t._batchSize,n=this.renderer;let a=e.length;if(a===0)return;a>i&&!t.autoResize&&(a=i);let o=t._buffers;o||(o=t._buffers=this.generateBuffers(t));const l=e[0]._texture.baseTexture,h=l.alphaMode>0;this.state.blendMode=$o(t.blendMode,h),n.state.set(this.state);const u=n.gl,c=t.worldTransform.copyTo(this.tempMatrix);c.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=_t.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,h).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=l,this.renderer.shader.bind(this.shader);let d=!1;for(let p=0,f=0;p<a;p+=s,f+=1){let g=a-p;g>s&&(g=s),f>=o.length&&o.push(this._generateOneMoreBuffer(t));const y=o[f];y.uploadDynamic(e,p,g);const m=t._bufferUpdateIDs[f]||0;d=d||y._updateID<m,d&&(y._updateID=t._updateID,y.uploadStatic(e,p,g)),n.geometry.bind(y.geometry),u.drawElements(u.TRIANGLES,g*6,u.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,s=t._batchSize,n=t._properties;for(let a=0;a<i;a+=s)e.push(new xf(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new xf(this.properties,i,e)}uploadVertices(t,e,i,s,n,a){let o=0,l=0,h=0,u=0;for(let c=0;c<i;++c){const d=t[e+c],p=d._texture,f=d.scale.x,g=d.scale.y,y=p.trim,m=p.orig;y?(l=y.x-d.anchor.x*m.width,o=l+y.width,u=y.y-d.anchor.y*m.height,h=u+y.height):(o=m.width*(1-d.anchor.x),l=m.width*-d.anchor.x,h=m.height*(1-d.anchor.y),u=m.height*-d.anchor.y),s[a]=l*f,s[a+1]=u*g,s[a+n]=o*f,s[a+n+1]=u*g,s[a+n*2]=o*f,s[a+n*2+1]=h*g,s[a+n*3]=l*f,s[a+n*3+1]=h*g,a+=n*4}}uploadPosition(t,e,i,s,n,a){for(let o=0;o<i;o++){const l=t[e+o].position;s[a]=l.x,s[a+1]=l.y,s[a+n]=l.x,s[a+n+1]=l.y,s[a+n*2]=l.x,s[a+n*2+1]=l.y,s[a+n*3]=l.x,s[a+n*3+1]=l.y,a+=n*4}}uploadRotation(t,e,i,s,n,a){for(let o=0;o<i;o++){const l=t[e+o].rotation;s[a]=l,s[a+n]=l,s[a+n*2]=l,s[a+n*3]=l,a+=n*4}}uploadUvs(t,e,i,s,n,a){for(let o=0;o<i;++o){const l=t[e+o]._texture._uvs;l?(s[a]=l.x0,s[a+1]=l.y0,s[a+n]=l.x1,s[a+n+1]=l.y1,s[a+n*2]=l.x2,s[a+n*2+1]=l.y2,s[a+n*3]=l.x3,s[a+n*3+1]=l.y3,a+=n*4):(s[a]=0,s[a+1]=0,s[a+n]=0,s[a+n+1]=0,s[a+n*2]=0,s[a+n*2+1]=0,s[a+n*3]=0,s[a+n*3+1]=0,a+=n*4)}}uploadTint(t,e,i,s,n,a){for(let o=0;o<i;++o){const l=t[e+o],h=_t.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);s[a]=h,s[a+n]=h,s[a+n*2]=h,s[a+n*3]=h,a+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}bf.extension={name:"particle",type:J.RendererPlugin},rt.add(bf),Y0.prototype.renderCanvas=function(r){if(!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable)return;const t=r.canvasContext.activeContext,e=this.worldTransform;let i=!0,s=0,n=0,a=0,o=0;r.canvasContext.setBlendMode(this.blendMode),t.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(let l=0;l<this.children.length;++l){const h=this.children[l];if(!h.visible||!h._texture.valid)continue;const u=h._texture.frame;if(t.globalAlpha=this.worldAlpha*h.alpha,h.rotation%(Math.PI*2)===0)i&&(r.canvasContext.setContextTransform(e,!1,1),i=!1),s=h.anchor.x*(-u.width*h.scale.x)+h.position.x+.5,n=h.anchor.y*(-u.height*h.scale.y)+h.position.y+.5,a=u.width*h.scale.x,o=u.height*h.scale.y;else{i||(i=!0),h.displayObjectUpdateTransform();const p=h.worldTransform;r.canvasContext.setContextTransform(p,this.roundPixels,1),s=h.anchor.x*-u.width+.5,n=h.anchor.y*-u.height+.5,a=u.width,o=u.height}const c=h._texture.baseTexture.resolution,d=r.canvasContext.activeResolution;t.drawImage(h._texture.baseTexture.getDrawableSource(),u.x*c,u.y*c,u.width*c,u.height*c,s*d,n*d,a*d,o*d)}},de.prototype._renderCanvas=function(r){},de.prototype.renderCanvas=function(r){if(!(!this.visible||this.worldAlpha<=0||!this.renderable)){this._mask&&r.mask.pushMask(this._mask),this._renderCanvas(r);for(let t=0,e=this.children.length;t<e;++t)this.children[t].renderCanvas(r);this._mask&&r.mask.popMask(r)}},Ot.prototype.renderCanvas=function(r){};var Tn=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(Tn||{});const En={willReadFrequently:!0},or=class ot{static get experimentalLetterSpacingSupported(){let t=ot._experimentalLetterSpacingSupported;if(t!==void 0){const e=et.ADAPTER.getCanvasRenderingContext2D().prototype;t=ot._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,a,o,l,h){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=l,this.fontProperties=h}static measureText(t,e,i,s=ot._canvas){i=i??e.wordWrap;const n=e.toFontString(),a=ot.measureFont(n);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);const o=s.getContext("2d",En);o.font=n;const l=(i?ot.wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let u=0;for(let f=0;f<l.length;f++){const g=ot._measureText(l[f],e.letterSpacing,o);h[f]=g,u=Math.max(u,g)}let c=u+e.strokeThickness;e.dropShadow&&(c+=e.dropShadowDistance);const d=e.lineHeight||a.fontSize+e.strokeThickness;let p=Math.max(d,a.fontSize+e.strokeThickness*2)+e.leading+(l.length-1)*(d+e.leading);return e.dropShadow&&(p+=e.dropShadowDistance),new ot(t,e,c,p,l,h,d+e.leading,u,a)}static _measureText(t,e,i){let s=!1;ot.experimentalLetterSpacingSupported&&(ot.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(s?n-=e:n+=(ot.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=ot._canvas){const s=i.getContext("2d",En);let n=0,a="",o="";const l=Object.create(null),{letterSpacing:h,whiteSpace:u}=e,c=ot.collapseSpaces(u),d=ot.collapseNewlines(u);let p=!c;const f=e.wordWrapWidth+h,g=ot.tokenize(t);for(let y=0;y<g.length;y++){let m=g[y];if(ot.isNewline(m)){if(!d){o+=ot.addLine(a),p=!c,a="",n=0;continue}m=" "}if(c){const v=ot.isBreakingSpace(m),x=ot.isBreakingSpace(a[a.length-1]);if(v&&x)continue}const _=ot.getFromCache(m,h,l,s);if(_>f)if(a!==""&&(o+=ot.addLine(a),a="",n=0),ot.canBreakWords(m,e.breakWords)){const v=ot.wordWrapSplit(m);for(let x=0;x<v.length;x++){let b=v[x],R=b,w=1;for(;v[x+w];){const U=v[x+w];if(!ot.canBreakChars(R,U,m,x,e.breakWords))b+=U;else break;R=U,w++}x+=w-1;const D=ot.getFromCache(b,h,l,s);D+n>f&&(o+=ot.addLine(a),p=!1,a="",n=0),a+=b,n+=D}}else{a.length>0&&(o+=ot.addLine(a),a="",n=0);const v=y===g.length-1;o+=ot.addLine(m,!v),p=!1,a="",n=0}else _+n>f&&(p=!1,o+=ot.addLine(a),a="",n=0),(a.length>0||!ot.isBreakingSpace(m)||p)&&(a+=m,n+=_)}return o+=ot.addLine(a,!1),o}static addLine(t,e=!0){return t=ot.trimRight(t),t=e?`${t}
674
+ `:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=ot._measureText(t,e,s)+e,i[t]=n),n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!ot.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:ot._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:ot._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],a=t[s+1];if(ot.isBreakingSpace(n,a)||ot.isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return ot.graphemeSegmenter(t)}static measureFont(t){if(ot._fonts[t])return ot._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=ot._canvas,s=ot._context;s.font=t;const n=ot.METRICS_STRING+ot.BASELINE_SYMBOL,a=Math.ceil(s.measureText(n).width);let o=Math.ceil(s.measureText(ot.BASELINE_SYMBOL).width);const l=Math.ceil(ot.HEIGHT_MULTIPLIER*o);if(o=o*ot.BASELINE_MULTIPLIER|0,a===0||l===0)return ot._fonts[t]=e,e;i.width=a,i.height=l,s.fillStyle="#f00",s.fillRect(0,0,a,l),s.font=t,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,o);const h=s.getImageData(0,0,a,l).data,u=h.length,c=a*4;let d=0,p=0,f=!1;for(d=0;d<o;++d){for(let g=0;g<c;g+=4)if(h[p+g]!==255){f=!0;break}if(!f)p+=c;else break}for(e.ascent=o-d,p=u-c,f=!1,d=l;d>o;--d){for(let g=0;g<c;g+=4)if(h[p+g]!==255){f=!0;break}if(!f)p-=c;else break}return e.descent=d-o,e.fontSize=e.ascent+e.descent,ot._fonts[t]=e,e}static clearMetrics(t=""){t?delete ot._fonts[t]:ot._fonts={}}static get _canvas(){var t;if(!ot.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",En))!=null&&t.measureText)return ot.__canvas=i,i;e=et.ADAPTER.createCanvas()}catch{e=et.ADAPTER.createCanvas()}e.width=e.height=10,ot.__canvas=e}return ot.__canvas}static get _context(){return ot.__context||(ot.__context=ot._canvas.getContext("2d",En)),ot.__context}};or.METRICS_STRING="|ÉqÅ",or.BASELINE_SYMBOL="M",or.BASELINE_MULTIPLIER=1.4,or.HEIGHT_MULTIPLIER=2,or.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>[...r.segment(t)].map(e=>e.segment)}return r=>[...r]})(),or.experimentalLetterSpacing=!1,or._fonts={},or._newlines=[10,13],or._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Cr=or;const Z0=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],wf=class Es{constructor(t){this.styleID=0,this.reset(),Al(this,t,t)}clone(){const t={};return Al(t,this,Es.defaultStyle),new Es(t)}reset(){Al(this,Es.defaultStyle,Es.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const e=El(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const e=El(t);this._fill!==e&&(this._fill=e,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){J0(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const e=El(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!Z0.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};wf.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Tn.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Ir=wf;function El(r){const t=_t.shared,e=i=>{const s=t.setValue(i);return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(r)?r.map(e):e(r)}function J0(r,t){if(!Array.isArray(r)||!Array.isArray(t)||r.length!==t.length)return!1;for(let e=0;e<r.length;++e)if(r[e]!==t[e])return!1;return!0}function Al(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const Q0={texture:!0,children:!1,baseTexture:!0},Tf=class ph extends nr{constructor(t,e,i){let s=!1;i||(i=et.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=it.from(i);n.orig=new pt,n.trim=new pt,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=ph.defaultResolution??et.RESOLUTION,this._autoResolution=ph.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=e,this.localStyleID=-1}static get experimentalLetterSpacing(){return Cr.experimentalLetterSpacing}static set experimentalLetterSpacing(t){ct("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Cr.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,s=Cr.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=s.width,a=s.height,o=s.lines,l=s.lineHeight,h=s.lineWidths,u=s.maxLineWidth,c=s.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,a)+e.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;let d,p;const f=e.dropShadow?2:1;for(let g=0;g<f;++g){const y=e.dropShadow&&g===0,m=y?Math.ceil(Math.max(1,a)+e.padding*2):0,_=m*this._resolution;if(y){i.fillStyle="black",i.strokeStyle="black";const x=e.dropShadowColor,b=e.dropShadowBlur*this._resolution,R=e.dropShadowDistance*this._resolution;i.shadowColor=_t.shared.setValue(x).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=b,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*R,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*R+_}else i.fillStyle=this._generateFillStyle(e,o,s),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let v=(l-c.fontSize)/2;l-c.fontSize<0&&(v=0);for(let x=0;x<o.length;x++)d=e.strokeThickness/2,p=e.strokeThickness/2+x*l+c.ascent+v,e.align==="right"?d+=u-h[x]:e.align==="center"&&(d+=(u-h[x])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(o[x],d+e.padding,p+e.padding-m,!0),e.fill&&this.drawLetterSpacing(o[x],d+e.padding,p+e.padding-m)}this.updateTexture()}drawLetterSpacing(t,e,i,s=!1){const n=this._style.letterSpacing;let a=!1;if(Cr.experimentalLetterSpacingSupported&&(Cr.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,a=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||a){s?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let o=e;const l=Cr.graphemeSegmenter(t);let h=this.context.measureText(t).width,u=0;for(let c=0;c<l.length;++c){const d=l[c];s?this.context.strokeText(d,o,i):this.context.fillText(d,o,i);let p="";for(let f=c+1;f<l.length;++f)p+=l[f];u=this.context.measureText(p).width,o+=h-u+n,h=u}}updateTexture(){const t=this.canvas;if(this._style.trim){const a=dd(t);a.data&&(t.width=a.width,t.height=a.height,this.context.putImageData(a.data,0,0))}const e=this._texture,i=this._style,s=i.trim?0:i.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-s,e.trim.y=-s,e.orig.width=e._frame.width-s*2,e.orig.height=e._frame.height-s*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const s=t.fill;if(Array.isArray(s)){if(s.length===1)return s[0]}else return s;let n;const a=t.dropShadow?t.dropShadowDistance:0,o=t.padding||0,l=this.canvas.width/this._resolution-a-o*2,h=this.canvas.height/this._resolution-a-o*2,u=s.slice(),c=t.fillGradientStops.slice();if(!c.length){const d=u.length+1;for(let p=1;p<d;++p)c.push(p/d)}if(u.unshift(s[0]),c.unshift(0),u.push(s[s.length-1]),c.push(1),t.fillGradientType===Tn.LINEAR_VERTICAL){n=this.context.createLinearGradient(l/2,o,l/2,h+o);const d=i.fontProperties.fontSize+t.strokeThickness;for(let p=0;p<e.length;p++){const f=i.lineHeight*(p-1)+d,g=i.lineHeight*p;let y=g;p>0&&f>g&&(y=(g+f)/2);const m=g+d,_=i.lineHeight*(p+1);let v=m;p+1<e.length&&_<m&&(v=(m+_)/2);const x=(v-y)/h;for(let b=0;b<u.length;b++){let R=0;typeof c[b]=="number"?R=c[b]:R=b/u.length;let w=Math.min(1,Math.max(0,y/h+R*x));w=Number(w.toFixed(5)),n.addColorStop(w,u[b])}}}else{n=this.context.createLinearGradient(o,h/2,l+o,h/2);const d=u.length+1;let p=1;for(let f=0;f<u.length;f++){let g;typeof c[f]=="number"?g=c[f]:g=p/d,n.addColorStop(g,u[f]),p++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Q0,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const e=_r(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const e=_r(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof Ir?this._style=t:this._style=new Ir(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};Tf.defaultAutoResolution=!0;let Sl=Tf;Sl.prototype._renderCanvas=function(r){this._autoResolution&&this._resolution!==r.resolution&&(this._resolution=r.resolution,this.dirty=!0),this.updateText(!0),nr.prototype._renderCanvas.call(this,r)};const Ef=new Ct;Ot.prototype._cacheAsBitmap=!1,Ot.prototype._cacheData=null,Ot.prototype._cacheAsBitmapResolution=null,Ot.prototype._cacheAsBitmapMultisample=null;class tx{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(Ot.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(r){r!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(r){r!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(r){if(this._cacheAsBitmap===r)return;this._cacheAsBitmap=r;let t;r?(this._cacheData||(this._cacheData=new tx),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}}),Ot.prototype._renderCached=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(r),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(r))},Ot.prototype._initCachedDisplayObject=function(r){var d,p;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new pt,!0);if((p=this.filters)!=null&&p.length){const f=this.filters[0].padding;e.pad(f)}const i=this.cacheAsBitmapResolution||r.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const s=r.renderTexture.current,n=r.renderTexture.sourceFrame.clone(),a=r.renderTexture.destinationFrame.clone(),o=r.projection.transform,l=sr.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${Ar()}`;this._cacheData.textureCacheId=h,dt.addToCache(l.baseTexture,h),it.addToCache(l,h);const u=this.transform.localTransform.copyTo(Ef).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:u,skipUpdateTransform:!1}),r.framebuffer.blit(),r.projection.transform=o,r.renderTexture.bind(s,n,a),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const c=new nr(l);c.transform.worldTransform=this.transform.worldTransform,c.anchor.x=-(e.x/e.width),c.anchor.y=-(e.y/e.height),c.alpha=t,c._bounds=this._bounds,this._cacheData.sprite=c,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=c.containsPoint.bind(c)},Ot.prototype._renderCachedCanvas=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(r),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(r))},Ot.prototype._initCachedDisplayObjectCanvas=function(r){var u;if((u=this._cacheData)!=null&&u.sprite)return;const t=this.getLocalBounds(new pt,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,s=r._projTransform,n=this.cacheAsBitmapResolution||r.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const a=sr.create({width:t.width,height:t.height,resolution:n}),o=`cacheAsBitmap_${Ar()}`;this._cacheData.textureCacheId=o,dt.addToCache(a.baseTexture,o),it.addToCache(a,o);const l=Ef;this.transform.localTransform.copyTo(l),l.invert(),l.tx-=t.x,l.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:a,clear:!0,transform:l,skipUpdateTransform:!1}),r.canvasContext.activeContext=i,r._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const h=new nr(a);h.transform.worldTransform=this.transform.worldTransform,h.anchor.x=-(t.x/t.width),h.anchor.y=-(t.y/t.height),h.alpha=e,h._bounds=this._bounds,this._cacheData.sprite=h,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=r._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=h.containsPoint.bind(h)},Ot.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Ot.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Ot.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,dt.removeFromCache(this._cacheData.textureCacheId),it.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Ot.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Ot.prototype.name=null,de.prototype.getChildByName=function(r,t){for(let e=0,i=this.children.length;e<i;e++)if(this.children[e].name===r)return this.children[e];if(t)for(let e=0,i=this.children.length;e<i;e++){const s=this.children[e];if(!s.getChildByName)continue;const n=s.getChildByName(r,!0);if(n)return n}return null},Ot.prototype.getGlobalPosition=function(r=new vt,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var ex=`varying vec2 vTextureCoord;
675
675
 
676
676
  uniform sampler2D uSampler;
677
677
  uniform float uAlpha;
@@ -680,9 +680,9 @@ void main(void)
680
680
  {
681
681
  gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
682
682
  }
683
- `;class z1 extends ne{constructor(t=1){super(T1,W1,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const j1={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},Y1=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
684
- `);function q1(r){const t=j1[r],e=t.length;let i=Y1,s="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=n.replace("%index%",a.toString());o=a,a>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),s+=l,s+=`
685
- `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const K1=`
683
+ `;class rx extends he{constructor(t=1){super(B0,ex,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const ix={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},sx=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
684
+ `);function nx(r){const t=ix[r],e=t.length;let i=sx,s="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let a;for(let o=0;o<r;o++){let l=n.replace("%index%",o.toString());a=o,o>=e&&(a=r-o-1),l=l.replace("%value%",t[a].toString()),s+=l,s+=`
685
+ `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const ax=`
686
686
  attribute vec2 aVertexPosition;
687
687
 
688
688
  uniform mat3 projectionMatrix;
@@ -712,8 +712,8 @@ void main(void)
712
712
 
713
713
  vec2 textureCoord = filterTextureCoord();
714
714
  %blur%
715
- }`;function Z1(r,t){const e=Math.ceil(r/2);let i=K1,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),s+=a,s+=`
716
- `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}class zl extends ne{constructor(t,e=8,i=4,s=ne.defaultResolution,n=5){const o=Z1(n,t),a=q1(n);super(o,a),this.horizontal=t,this.resolution=s,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,s){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/e.width):this.uniforms.strength=1/i.height*(i.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,i,s);else{const n=t.getFilterTexture(),o=t.renderer;let a=e,l=n;this.state.blend=!1,t.applyFilter(this,a,l,Xe.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(a,Xe.BLIT),this.uniforms.uSampler=l;const u=l;l=a,a=u,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,l,i,s),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class J1 extends ne{constructor(t=8,e=4,i=ne.defaultResolution,s=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new zl(!0,t,e,i,s),this.blurYFilter=new zl(!1,t,e,i,s),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,s){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=t.getFilterTexture();this.blurXFilter.apply(t,e,a,Xe.CLEAR),this.blurYFilter.apply(t,a,i,s),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,i,s):this.blurXFilter.apply(t,e,i,s)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var Q1=`varying vec2 vTextureCoord;
715
+ }`;function ox(r,t){const e=Math.ceil(r/2);let i=ax,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let a=0;a<r;a++){let o=n.replace("%index%",a.toString());o=o.replace("%sampleIndex%",`${a-(e-1)}.0`),s+=o,s+=`
716
+ `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}class Cl extends he{constructor(t,e=8,i=4,s=he.defaultResolution,n=5){const a=ox(n,t),o=nx(n);super(a,o),this.horizontal=t,this.resolution=s,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,s){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/e.width):this.uniforms.strength=1/i.height*(i.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,i,s);else{const n=t.getFilterTexture(),a=t.renderer;let o=e,l=n;this.state.blend=!1,t.applyFilter(this,o,l,Ze.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(o,Ze.BLIT),this.uniforms.uSampler=l;const u=l;l=o,o=u,a.shader.bind(this),a.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,l,i,s),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class lx extends he{constructor(t=8,e=4,i=he.defaultResolution,s=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new Cl(!0,t,e,i,s),this.blurYFilter=new Cl(!1,t,e,i,s),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,s){const n=Math.abs(this.blurXFilter.strength),a=Math.abs(this.blurYFilter.strength);if(n&&a){const o=t.getFilterTexture();this.blurXFilter.apply(t,e,o,Ze.CLEAR),this.blurYFilter.apply(t,o,i,s),t.returnFilterTexture(o)}else a?this.blurYFilter.apply(t,e,i,s):this.blurXFilter.apply(t,e,i,s)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var hx=`varying vec2 vTextureCoord;
717
717
  uniform sampler2D uSampler;
718
718
  uniform float m[20];
719
719
  uniform float uAlpha;
@@ -765,7 +765,7 @@ void main(void)
765
765
 
766
766
  gl_FragColor = vec4(rgb, result.a);
767
767
  }
768
- `;class jl extends ne{constructor(){const t={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super(vf,Q1,t),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,s,n]=ut.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),s=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=i+(1-i)*o,h=o*(1-i)-a*s,u=o*(1-i)+a*s,c=o*(1-i)+a*s,d=i+o*(1-i),p=o*(1-i)-a*s,f=o*(1-i)-a*s,m=o*(1-i)+a*s,_=i+o*(1-i),g=[l,h,u,0,0,c,d,p,0,0,f,m,_,0,0,0,0,0,1,0];this._loadMatrix(g,e)}contrast(t,e){const i=(t||0)+1,s=-.5*(i-1),n=[i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,s=(i-1)*-.5,n=[i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,s,n){t=t||.2,e=e||.15,i=i||16770432,s=s||3375104;const o=ut.shared,[a,l,h]=o.setValue(i).toArray(),[u,c,d]=o.setValue(s).toArray(),p=[.3,.59,.11,0,0,a,l,h,t,0,u,c,d,e,0,a-u,l-c,h-d,0,0];this._loadMatrix(p,n)}night(t,e){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}jl.prototype.grayscale=jl.prototype.greyscale;var tw=`varying vec2 vFilterCoord;
768
+ `;class Il extends he{constructor(){const t={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super(sf,hx,t),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,s,n]=_t.shared.setValue(t).toArray(),a=[i,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(a,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),s=Math.sin(t),n=Math.sqrt,a=1/3,o=n(a),l=i+(1-i)*a,h=a*(1-i)-o*s,u=a*(1-i)+o*s,c=a*(1-i)+o*s,d=i+a*(1-i),p=a*(1-i)-o*s,f=a*(1-i)-o*s,g=a*(1-i)+o*s,y=i+a*(1-i),m=[l,h,u,0,0,c,d,p,0,0,f,g,y,0,0,0,0,0,1,0];this._loadMatrix(m,e)}contrast(t,e){const i=(t||0)+1,s=-.5*(i-1),n=[i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,s=(i-1)*-.5,n=[i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,s,n){t=t||.2,e=e||.15,i=i||16770432,s=s||3375104;const a=_t.shared,[o,l,h]=a.setValue(i).toArray(),[u,c,d]=a.setValue(s).toArray(),p=[.3,.59,.11,0,0,o,l,h,t,0,u,c,d,e,0,o-u,l-c,h-d,0,0];this._loadMatrix(p,n)}night(t,e){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}Il.prototype.grayscale=Il.prototype.greyscale;var ux=`varying vec2 vFilterCoord;
769
769
  varying vec2 vTextureCoord;
770
770
 
771
771
  uniform vec2 scale;
@@ -785,7 +785,7 @@ void main(void)
785
785
 
786
786
  gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));
787
787
  }
788
- `,ew=`attribute vec2 aVertexPosition;
788
+ `,cx=`attribute vec2 aVertexPosition;
789
789
 
790
790
  uniform mat3 projectionMatrix;
791
791
  uniform mat3 filterMatrix;
@@ -814,7 +814,7 @@ void main(void)
814
814
  vTextureCoord = filterTextureCoord();
815
815
  vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;
816
816
  }
817
- `;class rw extends ne{constructor(t,e){const i=new wt;t.renderable=!1,super(ew,tw,{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,e==null&&(e=20),this.scale=new dt(e,e)}apply(t,e,i,s){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,o=Math.sqrt(n.a*n.a+n.b*n.b),a=Math.sqrt(n.c*n.c+n.d*n.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=n.a/o,this.uniforms.rotation[1]=n.b/o,this.uniforms.rotation[2]=n.c/a,this.uniforms.rotation[3]=n.d/a),t.applyFilter(this,e,i,s)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var iw=`varying vec2 v_rgbNW;
817
+ `;class dx extends he{constructor(t,e){const i=new Ct;t.renderable=!1,super(cx,ux,{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,e==null&&(e=20),this.scale=new vt(e,e)}apply(t,e,i,s){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,a=Math.sqrt(n.a*n.a+n.b*n.b),o=Math.sqrt(n.c*n.c+n.d*n.d);a!==0&&o!==0&&(this.uniforms.rotation[0]=n.a/a,this.uniforms.rotation[1]=n.b/a,this.uniforms.rotation[2]=n.c/o,this.uniforms.rotation[3]=n.d/o),t.applyFilter(this,e,i,s)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var fx=`varying vec2 v_rgbNW;
818
818
  varying vec2 v_rgbNE;
819
819
  varying vec2 v_rgbSW;
820
820
  varying vec2 v_rgbSE;
@@ -935,7 +935,7 @@ void main() {
935
935
 
936
936
  gl_FragColor = color;
937
937
  }
938
- `,sw=`
938
+ `,px=`
939
939
  attribute vec2 aVertexPosition;
940
940
 
941
941
  uniform mat3 projectionMatrix;
@@ -977,7 +977,7 @@ void main(void) {
977
977
 
978
978
  texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
979
979
  }
980
- `;class nw extends ne{constructor(){super(sw,iw)}}var ow=`precision highp float;
980
+ `;class mx extends he{constructor(){super(px,fx)}}var gx=`precision highp float;
981
981
 
982
982
  varying vec2 vTextureCoord;
983
983
  varying vec4 vColor;
@@ -1011,8 +1011,8 @@ void main()
1011
1011
 
1012
1012
  gl_FragColor = color;
1013
1013
  }
1014
- `;class aw extends ne{constructor(t=.5,e=Math.random()){super(vf,ow,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}const Gf={AlphaFilter:z1,BlurFilter:J1,BlurFilterPass:zl,ColorMatrixFilter:jl,DisplacementFilter:rw,FXAAFilter:nw,NoiseFilter:aw};Object.entries(Gf).forEach(([r,t])=>{Object.defineProperty(Gf,r,{get(){return et("7.1.0",`filters.${r} has moved to ${r}`),t}})});class lw{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||(pe.system.add(this.tickerUpdate,this,ii.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(pe.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const Mr=new lw;class Rs{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Rs.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new dt,this.page=new dt,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class eo extends Rs{constructor(){super(...arguments),this.client=new dt,this.movement=new dt,this.offset=new dt,this.global=new dt,this.screen=new dt}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,s,n,o,a,l,h,u,c,d,p,f,m){throw new Error("Method not implemented.")}}class Be extends eo{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Fi extends eo{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Fi.DOM_DELTA_PIXEL=0,Fi.DOM_DELTA_LINE=1,Fi.DOM_DELTA_PAGE=2;const hw=2048,uw=new dt,Yl=new dt;class cw{constructor(t){this.dispatch=new wi,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,s)=>i.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){Mr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,uw.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let s=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<hw&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Mr.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children;for(let c=u.length-1;c>=0;c--){const d=u[c],p=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,s,n,o||n(t,i));if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();(p.length>0||f)&&(f&&this._allInteractiveElements.push(t),p.push(t)),this._hitElements.length===0&&(this._hitElements=p),a=!0}}}const l=this._isInteractive(e),h=t.isInteractive();return l&&h&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,i)&&s(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Mr.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let h=l.length-1;h>=0;h--){const u=l[h],c=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,i,s,n);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=t.isInteractive();return(c.length>0||d)&&c.push(t),c}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&s(t,i)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){var i;if(t.hitArea&&(t.worldTransform.applyInverse(e,Yl),!t.hitArea.contains(Yl.x,Yl.y)))return!0;if(t._mask){const s=t._mask.isMaskData?t._mask.maskObject:t._mask;if(s&&!((i=s.containsPoint)!=null&&i.call(s,e)))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){var n,o;e=e??t.type;const i=`on${e}`;(o=(n=t.currentTarget)[i])==null||o.call(n,t);const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const s=e.button===2;this.dispatchEvent(e,s?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var l,h;if(!(t instanceof Be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=e.pointerType==="mouse"||e.pointerType==="pen",s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.overTargets);if(((l=s.overTargets)==null?void 0:l.length)>0&&n!==e.target){const u=t.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(t,u,n);if(this.dispatchEvent(c,"pointerout"),i&&this.dispatchEvent(c,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(c)}if(n!==e.target){const u=t.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(e,u);this.dispatchEvent(c,"pointerover"),i&&this.dispatchEvent(c,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const p=this.clonePointerEvent(e,"pointerenter");for(p.eventPhase=p.AT_TARGET;p.target&&p.target!==n&&p.target!==this.rootTarget.parent;)p.currentTarget=p.target,this.notifyTarget(p),i&&this.notifyTarget(p,"mouseenter"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(c)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&o.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&o.push("globaltouchmove")),i&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&o.push("globalmousemove"),this.cursor=(h=e.target)==null?void 0:h.cursor),o.length>0&&this.all(e,o),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var o;if(!(t instanceof Be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(o=i.target)==null?void 0:o.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof Be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",s);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let o=n;if(n&&!i.composedPath().includes(n)){let a=n;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=s.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,a.detail=l.clickCount,a.pointerType==="mouse"){const h=a.button===2;this.dispatchEvent(a,h?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof Be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof Fi)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const s=this.allocateEvent(Be);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=i??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(Fi);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(Be);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Be&&e instanceof Be&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof eo&&e instanceof eo&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}const dw=1,fw={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},ql=class Ch{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new cw(null),Mr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new Be(null),this.rootWheelEvent=new Fi(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Ch.defaultEventFeatures},{set:(e,i,s)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=s,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,Ch._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,s=e.length;i<s;i++){const n=e[i],o=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Mr.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this.normalizeToPointerData(t);for(let n=0,o=s.length;n<o;n++){const a=this.bootstrapEvent(this.rootPointerEvent,s[n]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,Mr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Mr.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;Mr.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,e,i){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=dw),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this.rootWheelEvent;return this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=fw[t.type]||t.type),t}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};ql.extension={name:"events",type:[X.RendererSystem,X.CanvasRendererSystem]},ql.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Kl=ql;j.add(Kl);function Hf(r){return r==="dynamic"||r==="static"}const pw={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??Hf(Kl.defaultEventMode)},set interactive(r){et("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=r,this.eventMode=r?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Kl.defaultEventMode},set eventMode(r){this._internalInteractive=Hf(r),this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;r=i?`${r}capture`:r;const a=typeof t=="function"?t:t.handleEvent,l=this;s&&s.addEventListener("abort",()=>{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,s)},dispatchEvent(r){if(!(r instanceof Rs))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};Ct.mixin(pw);const mw={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Ct.mixin(mw);const gw=9,ro=100,yw=0,_w=0,$f=2,Vf=1,vw=-1e3,xw=-1e3,bw=2;class Xf{constructor(t){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(ze.tablet||ze.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${ro}px`,e.style.height=`${ro}px`,e.style.position="absolute",e.style.top=`${yw}px`,e.style.left=`${_w}px`,e.style.zIndex=$f.toString(),this.div=e,this.renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const t=document.createElement("button");t.style.width=`${Vf}px`,t.style.height=`${Vf}px`,t.style.position="absolute",t.style.top=`${vw}px`,t.style.left=`${xw}px`,t.style.zIndex=bw.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(t=this.renderer.view.parentNode)==null||t.appendChild(this.div))}deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this.updateAccessibleObjects(e[i])}update(){const t=performance.now();if(ze.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:i,width:s,height:n}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=s/o*l,u=n/a*l;let c=this.div;c.style.left=`${e}px`,c.style.top=`${i}px`,c.style.width=`${o}px`,c.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const p=this.children[d];if(p.renderId!==this.renderId)p._accessibleActive=!1,Yr(this.children,d,1),this.div.removeChild(p._accessibleDiv),this.pool.push(p._accessibleDiv),p._accessibleDiv=null,d--;else{c=p._accessibleDiv;let f=p.hitArea;const m=p.worldTransform;p.hitArea?(c.style.left=`${(m.tx+f.x*m.a)*h}px`,c.style.top=`${(m.ty+f.y*m.d)*u}px`,c.style.width=`${f.width*m.a*h}px`,c.style.height=`${f.height*m.d*u}px`):(f=p.getBounds(),this.capHitArea(f),c.style.left=`${f.x*h}px`,c.style.top=`${f.y*u}px`,c.style.width=`${f.width*h}px`,c.style.height=`${f.height*u}px`,c.title!==p.accessibleTitle&&p.accessibleTitle!==null&&(c.title=p.accessibleTitle),c.getAttribute("aria-label")!==p.accessibleHint&&p.accessibleHint!==null&&c.setAttribute("aria-label",p.accessibleHint)),(p.accessibleTitle!==c.title||p.tabIndex!==c.tabIndex)&&(c.title=p.accessibleTitle,c.tabIndex=p.tabIndex,this.debug&&this.updateDebugHTML(c))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${ro}px`,e.style.height=`${ro}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=$f.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:i}=t.target,s=this.renderer.events.rootBoundary,n=Object.assign(new Rs(s),{target:i});s.rootTarget=this.renderer.lastObjectRendered,e.forEach(o=>s.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===gw&&this.activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}Xf.extension={name:"accessibility",type:[X.RendererPlugin,X.CanvasRendererPlugin]},j.add(Xf);const Wf=class Ih{constructor(t){this.stage=new le,t=Object.assign({forceCanvas:!1},t),this.renderer=_f(t),Ih._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){var t;return(t=this.renderer)==null?void 0:t.view}get screen(){var t;return(t=this.renderer)==null?void 0:t.screen}destroy(t,e){const i=Ih._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Wf._plugins=[];let ww=Wf;j.handleByList(X.Application,ww._plugins);class zf{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),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}}zf.extension=X.Application,j.add(zf);const jf={loader:X.LoadParser,resolver:X.ResolveParser,cache:X.CacheParser,detection:X.DetectionParser};j.handle(X.Asset,r=>{const t=r.ref;Object.entries(jf).filter(([e])=>!!t[e]).forEach(([e,i])=>j.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(jf).filter(e=>!!t[e]).forEach(e=>j.remove(t[e]))});class Tw{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function Ni(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function Dr(r,t){const e=r.split("?")[0],i=Ut.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const Oe=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),Zl=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Yf(r,t,e,i,s){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?Yf(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function Ew(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),Yf(r,s,0,e,i)}else i.push(r);return i}const io=r=>!Array.isArray(r);class Aw{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){const e=this._cache.get(t);return e||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=Oe(t);let s;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(e)){s=l.getCacheableAssets(i,e);break}}s||(s={},i.forEach(a=>{s[a]=e}));const n=Object.keys(s),o={cacheKeys:n,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),n.forEach(a=>{this._cache.has(a)&&this._cache.get(a)!==e&&console.warn("[Cache] already has key:",a),this._cache.set(a,s[a])}),e instanceof Y){const a=e;i.forEach(l=>{a.baseTexture!==Y.EMPTY.baseTexture&&st.addToCache(a.baseTexture,l),Y.addToCache(a,l)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const si=new Aw;class Sw{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var o,a;let s=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.load&&((o=h.test)!=null&&o.call(h,t,e,this))){n=h;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(t,e,this),i.parser=n;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];h.parse&&h.parse&&await((a=h.testParse)==null?void 0:a.call(h,s,e,this))&&(s=await h.parse(s,e,this)||s,i.parser=h)}return s})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const s={},n=io(t),o=Oe(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const u=Ut.toAbsolute(h.src);if(!s[h.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,h)),s[h.src]=await this.promiseCache[u].promise,e&&e(++i/a)}catch(c){throw delete this.promiseCache[u],delete s[h.src],new Error(`[Loader.load] Failed to load ${u}.
1015
- ${c}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=Oe(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const s=Ut.toAbsolute(i.src),n=this.promiseCache[s];if(n){const l=await n.promise;delete this.promiseCache[s],(a=(o=n.parser)==null?void 0:o.unload)==null||a.call(o,l,i,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name]&&console.warn(`[Assets] loadParser name conflict "${e.name}"`),{...t,[e.name]:e}),{})}}var Le=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Le||{});const Cw=".json",Iw="application/json",Rw={extension:{type:X.LoadParser,priority:Le.Low},name:"loadJson",test(r){return Ni(r,Iw)||Dr(r,Cw)},async load(r){return await(await z.ADAPTER.fetch(r)).json()}};j.add(Rw);const Pw=".txt",Mw="text/plain",Dw={name:"loadTxt",extension:{type:X.LoadParser,priority:Le.Low},test(r){return Ni(r,Mw)||Dr(r,Pw)},async load(r){return await(await z.ADAPTER.fetch(r)).text()}};j.add(Dw);const Bw=["normal","bold","100","200","300","400","500","600","700","800","900"],Ow=[".ttf",".otf",".woff",".woff2"],Lw=["font/ttf","font/otf","font/woff","font/woff2"],Fw=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Nw(r){const t=Ut.extname(r),e=Ut.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match(Fw)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const Uw=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function kw(r){return Uw.test(r)?r:encodeURI(r)}const Gw={extension:{type:X.LoadParser,priority:Le.Low},name:"loadWebFont",test(r){return Ni(r,Lw)||Dr(r,Ow)},async load(r,t){var i,s,n;const e=z.ADAPTER.getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??Nw(r),l=((n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(u=>Bw.includes(u)))??["normal"],h=t.data??{};for(let u=0;u<l.length;u++){const c=l[u],d=new FontFace(a,`url(${kw(r)})`,{...h,weight:c});await d.load(),e.add(d),o.push(d)}return o.length===1?o[0]:o}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(r){(Array.isArray(r)?r:[r]).forEach(t=>z.ADAPTER.getFontFaceSet().delete(t))}};j.add(Gw);const Hw=`(function() {
1014
+ `;class yx extends he{constructor(t=.5,e=Math.random()){super(sf,gx,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}const Af={AlphaFilter:rx,BlurFilter:lx,BlurFilterPass:Cl,ColorMatrixFilter:Il,DisplacementFilter:dx,FXAAFilter:mx,NoiseFilter:yx};Object.entries(Af).forEach(([r,t])=>{Object.defineProperty(Af,r,{get(){return ct("7.1.0",`filters.${r} has moved to ${r}`),t}})});class _x{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||(_e.system.add(this.tickerUpdate,this,Jr.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(_e.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const Rr=new _x;class ps{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=ps.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new vt,this.page=new vt,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class An extends ps{constructor(){super(...arguments),this.client=new vt,this.movement=new vt,this.offset=new vt,this.global=new vt,this.screen=new vt}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,s,n,a,o,l,h,u,c,d,p,f,g){throw new Error("Method not implemented.")}}class Ue extends An{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Ci extends An{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Ci.DOM_DELTA_PIXEL=0,Ci.DOM_DELTA_LINE=1,Ci.DOM_DELTA_PAGE=2;const vx=2048,xx=new vt,Rl=new vt;class bx{constructor(t){this.dispatch=new bi,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,s)=>i.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){Rr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,xx.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let s=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(a=>{t.currentTarget=i[n],this.notifyTarget(t,a)})}propagationPath(t){const e=[t];for(let i=0;i<vx&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,s,n,a=!1){let o=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Rr.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children;for(let c=u.length-1;c>=0;c--){const d=u[c],p=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,s,n,a||n(t,i));if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();(p.length>0||f)&&(f&&this._allInteractiveElements.push(t),p.push(t)),this._hitElements.length===0&&(this._hitElements=p),o=!0}}}const l=this._isInteractive(e),h=t.isInteractive();return l&&h&&this._allInteractiveElements.push(t),a||this._hitElements.length>0?null:o?this._hitElements:l&&!n(t,i)&&s(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Rr.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let h=l.length-1;h>=0;h--){const u=l[h],c=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,i,s,n);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=t.isInteractive();return(c.length>0||d)&&c.push(t),c}}}const a=this._isInteractive(e),o=t.isInteractive();return a&&s(t,i)?o?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){var i;if(t.hitArea&&(t.worldTransform.applyInverse(e,Rl),!t.hitArea.contains(Rl.x,Rl.y)))return!0;if(t._mask){const s=t._mask.isMaskData?t._mask.maskObject:t._mask;if(s&&!((i=s.containsPoint)!=null&&i.call(s,e)))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){var n,a;e=e??t.type;const i=`on${e}`;(a=(n=t.currentTarget)[i])==null||a.call(n,t);const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Ue)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const s=e.button===2;this.dispatchEvent(e,s?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var l,h;if(!(t instanceof Ue)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=e.pointerType==="mouse"||e.pointerType==="pen",s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.overTargets);if(((l=s.overTargets)==null?void 0:l.length)>0&&n!==e.target){const u=t.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(t,u,n);if(this.dispatchEvent(c,"pointerout"),i&&this.dispatchEvent(c,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(c)}if(n!==e.target){const u=t.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(e,u);this.dispatchEvent(c,"pointerover"),i&&this.dispatchEvent(c,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const p=this.clonePointerEvent(e,"pointerenter");for(p.eventPhase=p.AT_TARGET;p.target&&p.target!==n&&p.target!==this.rootTarget.parent;)p.currentTarget=p.target,this.notifyTarget(p),i&&this.notifyTarget(p,"mouseenter"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(c)}const a=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?a.push("pointermove"):this.dispatchEvent(e,"pointermove"),o&&a.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?a.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),o&&a.push("globaltouchmove")),i&&(this.moveOnAll?a.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),o&&a.push("globalmousemove"),this.cursor=(h=e.target)==null?void 0:h.cursor),a.length>0&&this.all(e,a),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var a;if(!(t instanceof Ue)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(a=i.target)==null?void 0:a.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof Ue)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const a=this.createPointerEvent(t,"pointerleave",s);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),i&&this.notifyTarget(a,"mouseleave"),a.target=a.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(a)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Ue)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const o=i.button===2;this.dispatchEvent(i,o?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let a=n;if(n&&!i.composedPath().includes(n)){let o=n;for(;o&&!i.composedPath().includes(o);){if(i.currentTarget=o,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}o=o.parent}delete s.pressTargetsByButton[t.button],a=o}if(a){const o=this.clonePointerEvent(i,"click");o.target=a,o.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:o.target,timeStamp:e});const l=s.clicksByButton[t.button];if(l.target===o.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=o.target,l.timeStamp=e,o.detail=l.clickCount,o.pointerType==="mouse"){const h=o.button===2;this.dispatchEvent(o,h?"rightclick":"click")}else o.pointerType==="touch"&&this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof Ue)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof Ci)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const s=this.allocateEvent(Ue);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=i??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(Ci);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(Ue);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof Ue&&e instanceof Ue&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof An&&e instanceof An&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}const wx=1,Tx={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Pl=class mh{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new bx(null),Rr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new Ue(null),this.rootWheelEvent=new Ci(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...mh.defaultEventFeatures},{set:(e,i,s)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=s,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,mh._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,s=e.length;i<s;i++){const n=e[i],a=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Rr.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this.normalizeToPointerData(t);for(let n=0,a=s.length;n<a;n++){const o=this.bootstrapEvent(this.rootPointerEvent,s[n]);o.type+=i,this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,Rr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Rr.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;Rr.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,e,i){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=wx),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this.rootWheelEvent;return this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=Tx[t.type]||t.type),t}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};Pl.extension={name:"events",type:[J.RendererSystem,J.CanvasRendererSystem]},Pl.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Ml=Pl;rt.add(Ml);function Sf(r){return r==="dynamic"||r==="static"}const Ex={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??Sf(Ml.defaultEventMode)},set interactive(r){ct("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=r,this.eventMode=r?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Ml.defaultEventMode},set eventMode(r){this._internalInteractive=Sf(r),this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,a=typeof t=="function"?void 0:t;r=i?`${r}capture`:r;const o=typeof t=="function"?t:t.handleEvent,l=this;s&&s.addEventListener("abort",()=>{l.off(r,o,a)}),n?l.once(r,o,a):l.on(r,o,a)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,s)},dispatchEvent(r){if(!(r instanceof ps))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};Ot.mixin(Ex);const Ax={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Ot.mixin(Ax);const Sx=9,Sn=100,Cx=0,Ix=0,Cf=2,If=1,Rx=-1e3,Px=-1e3,Mx=2;class Rf{constructor(t){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(Qe.tablet||Qe.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${Sn}px`,e.style.height=`${Sn}px`,e.style.position="absolute",e.style.top=`${Cx}px`,e.style.left=`${Ix}px`,e.style.zIndex=Cf.toString(),this.div=e,this.renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const t=document.createElement("button");t.style.width=`${If}px`,t.style.height=`${If}px`,t.style.position="absolute",t.style.top=`${Rx}px`,t.style.left=`${Px}px`,t.style.zIndex=Mx.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(t=this.renderer.view.parentNode)==null||t.appendChild(this.div))}deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this.updateAccessibleObjects(e[i])}update(){const t=performance.now();if(Qe.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:i,width:s,height:n}=this.renderer.view.getBoundingClientRect(),{width:a,height:o,resolution:l}=this.renderer,h=s/a*l,u=n/o*l;let c=this.div;c.style.left=`${e}px`,c.style.top=`${i}px`,c.style.width=`${a}px`,c.style.height=`${o}px`;for(let d=0;d<this.children.length;d++){const p=this.children[d];if(p.renderId!==this.renderId)p._accessibleActive=!1,Vr(this.children,d,1),this.div.removeChild(p._accessibleDiv),this.pool.push(p._accessibleDiv),p._accessibleDiv=null,d--;else{c=p._accessibleDiv;let f=p.hitArea;const g=p.worldTransform;p.hitArea?(c.style.left=`${(g.tx+f.x*g.a)*h}px`,c.style.top=`${(g.ty+f.y*g.d)*u}px`,c.style.width=`${f.width*g.a*h}px`,c.style.height=`${f.height*g.d*u}px`):(f=p.getBounds(),this.capHitArea(f),c.style.left=`${f.x*h}px`,c.style.top=`${f.y*u}px`,c.style.width=`${f.width*h}px`,c.style.height=`${f.height*u}px`,c.title!==p.accessibleTitle&&p.accessibleTitle!==null&&(c.title=p.accessibleTitle),c.getAttribute("aria-label")!==p.accessibleHint&&p.accessibleHint!==null&&c.setAttribute("aria-label",p.accessibleHint)),(p.accessibleTitle!==c.title||p.tabIndex!==c.tabIndex)&&(c.title=p.accessibleTitle,c.tabIndex=p.tabIndex,this.debug&&this.updateDebugHTML(c))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${Sn}px`,e.style.height=`${Sn}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Cf.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:i}=t.target,s=this.renderer.events.rootBoundary,n=Object.assign(new ps(s),{target:i});s.rootTarget=this.renderer.lastObjectRendered,e.forEach(a=>s.dispatchEvent(n,a))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===Sx&&this.activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}Rf.extension={name:"accessibility",type:[J.RendererPlugin,J.CanvasRendererPlugin]},rt.add(Rf);const Pf=class gh{constructor(t){this.stage=new de,t=Object.assign({forceCanvas:!1},t),this.renderer=P0(t),gh._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){var t;return(t=this.renderer)==null?void 0:t.view}get screen(){var t;return(t=this.renderer)==null?void 0:t.screen}destroy(t,e){const i=gh._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Pf._plugins=[];let Dx=Pf;rt.handleByList(J.Application,Dx._plugins);class Mf{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),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}}Mf.extension=J.Application,rt.add(Mf);const Df={loader:J.LoadParser,resolver:J.ResolveParser,cache:J.CacheParser,detection:J.DetectionParser};rt.handle(J.Asset,r=>{const t=r.ref;Object.entries(Df).filter(([e])=>!!t[e]).forEach(([e,i])=>rt.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(Df).filter(e=>!!t[e]).forEach(e=>rt.remove(t[e]))});class Bx{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function Ii(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function Pr(r,t){const e=r.split("?")[0],i=Xt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const ke=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),Dl=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Bf(r,t,e,i,s){const n=t[e];for(let a=0;a<n.length;a++){const o=n[a];e<t.length-1?Bf(r.replace(i[e],o),t,e+1,i,s):s.push(r.replace(i[e],o))}}function Ox(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const a=n.substring(1,n.length-1).split(",");s.push(a)}),Bf(r,s,0,e,i)}else i.push(r);return i}const Cn=r=>!Array.isArray(r);class Lx{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){const e=this._cache.get(t);return e||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=ke(t);let s;for(let o=0;o<this.parsers.length;o++){const l=this.parsers[o];if(l.test(e)){s=l.getCacheableAssets(i,e);break}}s||(s={},i.forEach(o=>{s[o]=e}));const n=Object.keys(s),a={cacheKeys:n,keys:i};if(i.forEach(o=>{this._cacheMap.set(o,a)}),n.forEach(o=>{this._cache.has(o)&&this._cache.get(o)!==e&&console.warn("[Cache] already has key:",o),this._cache.set(o,s[o])}),e instanceof it){const o=e;i.forEach(l=>{o.baseTexture!==it.EMPTY.baseTexture&&dt.addToCache(o.baseTexture,l),it.addToCache(o,l)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const Qr=new Lx;class Fx{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var a,o;let s=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.load&&((a=h.test)!=null&&a.call(h,t,e,this))){n=h;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(t,e,this),i.parser=n;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];h.parse&&h.parse&&await((o=h.testParse)==null?void 0:o.call(h,s,e,this))&&(s=await h.parse(s,e,this)||s,i.parser=h)}return s})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const s={},n=Cn(t),a=ke(t,h=>({alias:[h],src:h})),o=a.length,l=a.map(async h=>{const u=Xt.toAbsolute(h.src);if(!s[h.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,h)),s[h.src]=await this.promiseCache[u].promise,e&&e(++i/o)}catch(c){throw delete this.promiseCache[u],delete s[h.src],new Error(`[Loader.load] Failed to load ${u}.
1015
+ ${c}`)}});return await Promise.all(l),n?s[a[0].src]:s}async unload(t){const e=ke(t,i=>({alias:[i],src:i})).map(async i=>{var a,o;const s=Xt.toAbsolute(i.src),n=this.promiseCache[s];if(n){const l=await n.promise;delete this.promiseCache[s],(o=(a=n.parser)==null?void 0:a.unload)==null||o.call(a,l,i,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name]&&console.warn(`[Assets] loadParser name conflict "${e.name}"`),{...t,[e.name]:e}),{})}}var Ge=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Ge||{});const Nx=".json",Ux="application/json",kx={extension:{type:J.LoadParser,priority:Ge.Low},name:"loadJson",test(r){return Ii(r,Ux)||Pr(r,Nx)},async load(r){return await(await et.ADAPTER.fetch(r)).json()}};rt.add(kx);const Gx=".txt",Hx="text/plain",$x={name:"loadTxt",extension:{type:J.LoadParser,priority:Ge.Low},test(r){return Ii(r,Hx)||Pr(r,Gx)},async load(r){return await(await et.ADAPTER.fetch(r)).text()}};rt.add($x);const Vx=["normal","bold","100","200","300","400","500","600","700","800","900"],Xx=[".ttf",".otf",".woff",".woff2"],Wx=["font/ttf","font/otf","font/woff","font/woff2"],zx=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function jx(r){const t=Xt.extname(r),e=Xt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match(zx)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const Yx=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function qx(r){return Yx.test(r)?r:encodeURI(r)}const Kx={extension:{type:J.LoadParser,priority:Ge.Low},name:"loadWebFont",test(r){return Ii(r,Wx)||Pr(r,Xx)},async load(r,t){var i,s,n;const e=et.ADAPTER.getFontFaceSet();if(e){const a=[],o=((i=t.data)==null?void 0:i.family)??jx(r),l=((n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(u=>Vx.includes(u)))??["normal"],h=t.data??{};for(let u=0;u<l.length;u++){const c=l[u],d=new FontFace(o,`url(${qx(r)})`,{...h,weight:c});await d.load(),e.add(d),a.push(d)}return a.length===1?a[0]:a}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(r){(Array.isArray(r)?r:[r]).forEach(t=>et.ADAPTER.getFontFaceSet().delete(t))}};rt.add(Kx);const Zx=`(function() {
1016
1016
  "use strict";
1017
1017
  const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
1018
1018
  async function checkImageBitmap() {
@@ -1029,7 +1029,7 @@ ${c}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=Oe
1029
1029
  self.postMessage(result);
1030
1030
  });
1031
1031
  })();
1032
- `;let Ui=null,Jl=class{constructor(){Ui||(Ui=URL.createObjectURL(new Blob([Hw],{type:"application/javascript"}))),this.worker=new Worker(Ui)}};Jl.revokeObjectURL=function(){Ui&&(URL.revokeObjectURL(Ui),Ui=null)};const $w=`(function() {
1032
+ `;let Ri=null,Bl=class{constructor(){Ri||(Ri=URL.createObjectURL(new Blob([Zx],{type:"application/javascript"}))),this.worker=new Worker(Ri)}};Bl.revokeObjectURL=function(){Ri&&(URL.revokeObjectURL(Ri),Ri=null)};const Jx=`(function() {
1033
1033
  "use strict";
1034
1034
  async function loadImageBitmap(url) {
1035
1035
  const response = await fetch(url);
@@ -1055,8 +1055,8 @@ ${c}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=Oe
1055
1055
  }
1056
1056
  };
1057
1057
  })();
1058
- `;let ki=null;class qf{constructor(){ki||(ki=URL.createObjectURL(new Blob([$w],{type:"application/javascript"}))),this.worker=new Worker(ki)}}qf.revokeObjectURL=function(){ki&&(URL.revokeObjectURL(ki),ki=null)};let Kf=0,Ql;class Vw{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new Jl;e.addEventListener("message",i=>{e.terminate(),Jl.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Ql===void 0&&(Ql=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Ql&&(this._createdWorkers++,t=new qf().worker,t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((s,n)=>{this.queue.push({id:t,arguments:e,resolve:s,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),i=e.id;this.resolveHash[Kf]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Kf++,id:i})}}const Zf=new Vw;function Ps(r,t,e){r.resource.internal=!0;const i=new Y(r),s=()=>{delete t.promiseCache[e],si.has(e)&&si.remove(e)};return i.baseTexture.once("destroyed",()=>{e in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),s())}),i.once("destroyed",()=>{r.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),s())}),i}const Xw=[".jpeg",".jpg",".png",".webp",".avif"],Ww=["image/jpeg","image/png","image/webp","image/avif"];async function zw(r){const t=await z.ADAPTER.fetch(r);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const so={name:"loadTextures",extension:{type:X.LoadParser,priority:Le.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Ni(r,Ww)||Dr(r,Xw)},async load(r,t,e){var a;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await Zf.isImageBitmapSupported()?s=await Zf.loadImageBitmap(r):s=await zw(r):s=await new Promise((l,h)=>{const u=new Image;u.crossOrigin=this.config.crossOrigin,u.src=r,u.complete?l(u):(u.onload=()=>l(u),u.onerror=c=>h(c))});const n={...t.data};n.resolution??(n.resolution=Ze(r)),i&&((a=n.resourceOptions)==null?void 0:a.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new st(s,n);return o.resource.src=r,Ps(o,e,r)},unload(r){r.destroy(!0)}};j.add(so);const jw=".svg",Yw="image/svg+xml",qw={extension:{type:X.LoadParser,priority:Le.High},name:"loadSVG",test(r){return Ni(r,Yw)||Dr(r,jw)},async testParse(r){return Gl.test(r)},async parse(r,t,e){var n;const i=new Gl(r,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const s=new st(i,{resolution:Ze(r),...t==null?void 0:t.data});return s.resource.src=t.src,Ps(s,e,t.src)},async load(r,t){return(await z.ADAPTER.fetch(r)).text()},unload:so.unload};j.add(qw);const Kw=[".mp4",".m4v",".webm",".ogv"],Zw=["video/mp4","video/webm","video/ogg"],Jw={name:"loadVideo",extension:{type:X.LoadParser,priority:Le.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(r){return Ni(r,Zw)||Dr(r,Kw)},async load(r,t,e){var o;let i;const s=await(await z.ADAPTER.fetch(r)).blob(),n=URL.createObjectURL(s);try{const a={autoPlay:this.config.defaultAutoPlay,updateFPS:this.config.defaultUpdateFPS,loop:this.config.defaultLoop,muted:this.config.defaultMuted,playsinline:this.config.defaultPlaysinline,...(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions,autoLoad:!0},l=new Sf(n,a);await l.load();const h=new st(l,{alphaMode:await ad(),resolution:Ze(r),...t==null?void 0:t.data});h.resource.src=r,i=Ps(h,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(a){throw URL.revokeObjectURL(n),a}return i},unload(r){r.destroy(!0)}};j.add(Jw);class Qw{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{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,name:i,src:s,srcs:n}=t;return Oe(e||i||s||n,o=>typeof o=="string"?o:Array.isArray(o)?o.map(a=>(a==null?void 0:a.src)??(a==null?void 0:a.srcs)??a):o!=null&&o.src||o!=null&&o.srcs?o.src??o.srcs:o,!0)}addManifest(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];Array.isArray(e)?e.forEach(s=>{const n=s.src??s.srcs,o=s.alias??s.name;let a;if(typeof o=="string"){const l=this._createBundleAssetId(t,o);i.push(l),a=[o,l]}else{const l=o.map(h=>this._createBundleAssetId(t,h));i.push(...l),a=[...o,...l]}this.add({...s,alias:a,src:n})}):Object.keys(e).forEach(s=>{const n=[s,this._createBundleAssetId(t,s)];if(typeof e[s]=="string")this.add({alias:n,src:e[s]});else if(Array.isArray(e[s]))this.add({alias:n,src:e[s]});else{const o=e[s],a=o.src??o.srcs;this.add({...o,alias:n,src:Array.isArray(a)?a:[a]})}i.push(...n)}),this._bundles[t]=i}add(t,e,i,s,n){const o=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(et("7.2.0",`Assets.add now uses an object instead of individual parameters.
1059
- Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:t,src:e,data:i,format:s,loadParser:n})):Array.isArray(t)?o.push(...t):o.push(t);let a;a=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},Oe(o).forEach(l=>{const{src:h,srcs:u}=l;let{data:c,format:d,loadParser:p}=l;const f=Oe(h||u).map(g=>typeof g=="string"?Ew(g):Array.isArray(g)?g:[g]),m=this.getAlias(l);Array.isArray(m)?m.forEach(a):a(m);const _=[];f.forEach(g=>{g.forEach(v=>{let y={};if(typeof v!="object"){y.src=v;for(let x=0;x<this._parsers.length;x++){const b=this._parsers[x];if(b.test(v)){y=b.parse(v);break}}}else c=v.data??c,d=v.format??d,p=v.loadParser??p,y={...y,...v};if(!m)throw new Error(`[Resolver] alias is undefined for this asset: ${y.src}`);y=this.buildResolvedAsset(y,{aliases:m,data:c,format:d,loadParser:p}),_.push(y)})}),m.forEach(g=>{this._assetMap[g]=_})})}resolveBundle(t){const e=io(t);t=Oe(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(s,l)]=h}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=io(t);t=Oe(t);const i={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=n[0],a=this._getPreferredOrder(n);a==null||a.priority.forEach(l=>{a.params[l].forEach(h=>{const u=n.filter(c=>c[l]?c[l]===h:!1);u.length&&(n=u)})}),this._resolverHash[s]=n[0]??o}else this._resolverHash[s]=this.buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}buildResolvedAsset(t,e){const{aliases:i,data:s,loadParser:n,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=Ut.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.format=o??t.format??Ut.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class tT{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Qw,this.loader=new Sw,this.cache=si,this._backgroundLoader=new Tw(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,o;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let a=t.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,s=await this._detectFormats({preferredFormats:(o=t.texturePreference)==null?void 0:o.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,s,n){this.resolver.add(t,e,i,s,n)}async load(t,e){this._initialized||await this.init();const i=io(t),s=Oe(t).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(h=>!this.resolver.hasKey(h))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,e);return i?o[s[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},o=Object.keys(s);let a=0,l=0;const h=()=>{e==null||e(++a/l)},u=o.map(c=>{const d=s[c];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(p=>{n[c]=p})});return await Promise.all(u),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return si.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=si.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),s=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=n[a.src],u=[a.src];a.alias&&u.push(...a.alias),o[s[l]]=h,si.set(u,h)}),o}async unload(t){this._initialized||await this.init();const e=Oe(t).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=Oe(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{si.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,s)=>e.indexOf(i)===s),e}get detections(){return this._detections}get preferWorkers(){return so.config.preferWorkers}set preferWorkers(t){et("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const no=new tT;j.handleByList(X.LoadParser,no.loader.parsers).handleByList(X.ResolveParser,no.resolver.parsers).handleByList(X.CacheParser,no.cache.parsers).handleByList(X.DetectionParser,no.detections);const eT={extension:X.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof Y),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};j.add(eT);async function Jf(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const rT={extension:{type:X.DetectionParser,priority:1},test:async()=>Jf("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};j.add(rT);const iT={extension:{type:X.DetectionParser,priority:0},test:async()=>Jf("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};j.add(iT);const Qf=["png","jpg","jpeg"],sT={extension:{type:X.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Qf],remove:async r=>r.filter(t=>!Qf.includes(t))};j.add(sT);const nT="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function th(r){return nT?!1:document.createElement("video").canPlayType(r)!==""}const oT={extension:{type:X.DetectionParser,priority:0},test:async()=>th("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};j.add(oT);const aT={extension:{type:X.DetectionParser,priority:0},test:async()=>th("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};j.add(aT);const lT={extension:{type:X.DetectionParser,priority:0},test:async()=>th("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};j.add(lT);const hT={extension:X.ResolveParser,test:so.test,parse:r=>{var t;return{resolution:parseFloat(((t=z.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:Ut.extname(r).slice(1),src:r}}};j.add(hT);var Yt=(r=>(r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",r[r.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",r[r.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r[r.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",r[r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",r[r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",r[r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",r))(Yt||{});const oo={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let sr,Gi;function tp(){Gi={bptc:sr.getExtension("EXT_texture_compression_bptc"),astc:sr.getExtension("WEBGL_compressed_texture_astc"),etc:sr.getExtension("WEBGL_compressed_texture_etc"),s3tc:sr.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:sr.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:sr.getExtension("WEBGL_compressed_texture_pvrtc")||sr.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:sr.getExtension("WEBGL_compressed_texture_etc1"),atc:sr.getExtension("WEBGL_compressed_texture_atc")}}const uT={extension:{type:X.DetectionParser,priority:2},test:async()=>{const r=z.ADAPTER.createCanvas().getContext("webgl");return r?(sr=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{Gi||tp();const t=[];for(const e in Gi)Gi[e]&&t.push(e);return[...t,...r]},remove:async r=>(Gi||tp(),r.filter(t=>!(t in Gi)))};j.add(uT);class cT extends Cn{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,s;typeof t=="string"?(i=t,s=new Uint8Array):(i=null,s=t),super(s,e),this.origin=i,this.buffer=s?new pl(s):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new pl(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class ni extends cT{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=ni._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||ni._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const s=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,o=this.levels;n<o;n++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:u}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,a,this.format,l,h,0,u)}return!0}onBlobLoaded(){this._levelBuffers=ni._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,e,i,s,n,o,a){const l=new Array(i);let h=t.byteOffset,u=o,c=a,d=u+s-1&~(s-1),p=c+n-1&~(n-1),f=d*p*oo[e];for(let m=0;m<i;m++)l[m]={levelID:m,levelWidth:i>1?u:d,levelHeight:i>1?c:p,levelBuffer:new Uint8Array(t.buffer,h,f)},h+=f,u=u>>1||1,c=c>>1||1,d=u+s-1&~(s-1),p=c+n-1&~(n-1),f=d*p*oo[e];return l}}const eh=4,ao=124,dT=32,ep=20,fT=542327876,lo={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},pT={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},ho={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},mT=1,gT=2,yT=4,_T=64,vT=512,xT=131072,bT=827611204,wT=861165636,TT=894720068,ET=808540228,AT=4,ST={[bT]:Yt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[wT]:Yt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[TT]:Yt.COMPRESSED_RGBA_S3TC_DXT5_EXT},CT={70:Yt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Yt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Yt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Yt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Yt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Yt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Yt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Yt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Yt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:Yt.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:Yt.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:Yt.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:Yt.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function IT(r){const t=new Uint32Array(r);if(t[0]!==fT)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,ao/Uint32Array.BYTES_PER_ELEMENT),i=e[lo.HEIGHT],s=e[lo.WIDTH],n=e[lo.MIPMAP_COUNT],o=new Uint32Array(r,lo.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,dT/Uint32Array.BYTES_PER_ELEMENT),a=o[mT];if(a&yT){const l=o[pT.FOURCC];if(l!==ET){const v=ST[l],y=eh+ao,x=new Uint8Array(r,y);return[new ni(x,{format:v,width:s,height:i,levels:n})]}const h=eh+ao,u=new Uint32Array(t.buffer,h,ep/Uint32Array.BYTES_PER_ELEMENT),c=u[ho.DXGI_FORMAT],d=u[ho.RESOURCE_DIMENSION],p=u[ho.MISC_FLAG],f=u[ho.ARRAY_SIZE],m=CT[c];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(p===AT)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const _=new Array,g=eh+ao+ep;if(f===1)_.push(new Uint8Array(r,g));else{const v=oo[m];let y=0,x=s,b=i;for(let T=0;T<n;T++){const A=Math.max(1,x+3&-4),M=Math.max(1,b+3&-4),S=A*M*v;y+=S,x=x>>>1,b=b>>>1}let E=g;for(let T=0;T<f;T++)_.push(new Uint8Array(r,E,y)),E+=y}return _.map(v=>new ni(v,{format:m,width:s,height:i,levels:n}))}throw a&_T?new Error("DDSParser does not support uncompressed texture data."):a&vT?new Error("DDSParser does not supported YUV uncompressed texture data."):a&xT?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&gT?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const rp=[171,75,84,88,32,49,49,187,13,10,26,10],RT=67305985,Fe={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},rh=64,ip={[J.UNSIGNED_BYTE]:1,[J.UNSIGNED_SHORT]:2,[J.INT]:4,[J.UNSIGNED_INT]:4,[J.FLOAT]:4,[J.HALF_FLOAT]:8},PT={[$.RGBA]:4,[$.RGB]:3,[$.RG]:2,[$.RED]:1,[$.LUMINANCE]:1,[$.LUMINANCE_ALPHA]:2,[$.ALPHA]:1},MT={[J.UNSIGNED_SHORT_4_4_4_4]:2,[J.UNSIGNED_SHORT_5_5_5_1]:2,[J.UNSIGNED_SHORT_5_6_5]:2};function DT(r,t,e=!1){const i=new DataView(t);if(!BT(r,i))return null;const s=i.getUint32(Fe.ENDIANNESS,!0)===RT,n=i.getUint32(Fe.GL_TYPE,s),o=i.getUint32(Fe.GL_FORMAT,s),a=i.getUint32(Fe.GL_INTERNAL_FORMAT,s),l=i.getUint32(Fe.PIXEL_WIDTH,s),h=i.getUint32(Fe.PIXEL_HEIGHT,s)||1,u=i.getUint32(Fe.PIXEL_DEPTH,s)||1,c=i.getUint32(Fe.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(Fe.NUMBER_OF_FACES,s),p=i.getUint32(Fe.NUMBER_OF_MIPMAP_LEVELS,s),f=i.getUint32(Fe.BYTES_OF_KEY_VALUE_DATA,s);if(h===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");const m=4,_=4,g=l+3&-4,v=h+3&-4,y=new Array(c);let x=l*h;n===0&&(x=g*v);let b;if(n!==0?ip[n]?b=ip[n]*PT[o]:b=MT[n]:b=oo[a],b===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const E=e?LT(i,f,s):null;let T=x*b,A=l,M=h,S=g,P=v,C=rh+f;for(let w=0;w<p;w++){const D=i.getUint32(C,s);let N=C+4;for(let V=0;V<c;V++){let H=y[V];H||(H=y[V]=new Array(p)),H[w]={levelID:w,levelWidth:p>1||n!==0?A:S,levelHeight:p>1||n!==0?M:P,levelBuffer:new Uint8Array(t,N,T)},N+=T}C+=D+4,C=C%4!==0?C+4-C%4:C,A=A>>1||1,M=M>>1||1,S=A+m-1&-4,P=M+_-1&-4,T=S*P*b}return n!==0?{uncompressed:y.map(w=>{let D=w[0].levelBuffer,N=!1;return n===J.FLOAT?D=new Float32Array(w[0].levelBuffer.buffer,w[0].levelBuffer.byteOffset,w[0].levelBuffer.byteLength/4):n===J.UNSIGNED_INT?(N=!0,D=new Uint32Array(w[0].levelBuffer.buffer,w[0].levelBuffer.byteOffset,w[0].levelBuffer.byteLength/4)):n===J.INT&&(N=!0,D=new Int32Array(w[0].levelBuffer.buffer,w[0].levelBuffer.byteOffset,w[0].levelBuffer.byteLength/4)),{resource:new Cn(D,{width:w[0].levelWidth,height:w[0].levelHeight}),type:n,format:N?OT(o):o}}),kvData:E}:{compressed:y.map(w=>new ni(null,{format:a,width:l,height:h,levels:p,levelBuffers:w})),kvData:E}}function BT(r,t){for(let e=0;e<rp.length;e++)if(t.getUint8(e)!==rp[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function OT(r){switch(r){case $.RGBA:return $.RGBA_INTEGER;case $.RGB:return $.RGB_INTEGER;case $.RG:return $.RG_INTEGER;case $.RED:return $.RED_INTEGER;default:return r}}function LT(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(rh+s,e),o=rh+s+4,a=3-(n+3)%4;if(n===0||n>t-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<n&&r.getUint8(o+l)!==0;l++);if(l===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const h=new TextDecoder().decode(new Uint8Array(r.buffer,o,l)),u=new DataView(r.buffer,o+l+1,n-l-1);i.set(h,u),s+=4+n+a}return i}const FT={extension:{type:X.LoadParser,priority:Le.High},name:"loadDDS",test(r){return Dr(r,".dds")},async load(r,t,e){const i=await(await z.ADAPTER.fetch(r)).arrayBuffer(),s=IT(i).map(n=>{const o=new st(n,{mipmap:Ve.OFF,alphaMode:ae.NO_PREMULTIPLIED_ALPHA,resolution:Ze(r),...t.data});return Ps(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};j.add(FT);const NT={extension:{type:X.LoadParser,priority:Le.High},name:"loadKTX",test(r){return Dr(r,".ktx")},async load(r,t,e){const i=await(await z.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=DT(r,i),a=s??n,l={mipmap:Ve.OFF,alphaMode:ae.NO_PREMULTIPLIED_ALPHA,resolution:Ze(r),...t.data},h=a.map(u=>{a===n&&Object.assign(l,{type:u.type,format:u.format});const c=u.resource??u,d=new st(c,l);return d.ktxKeyValueData=o,Ps(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};j.add(NT);const UT=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],kT={extension:X.ResolveParser,test:r=>{const t=Ut.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{var i,s;const t=r.split("."),e=t.pop();if(["ktx","dds"].includes(e)){const n=t.pop();if(UT.includes(n))return{resolution:parseFloat(((i=z.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:n,src:r}}return{resolution:parseFloat(((s=z.RETINA_PREFIX.exec(r))==null?void 0:s[1])??"1"),format:e,src:r}}};j.add(kT);const uo=new at,GT=4,sp=class ks{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,e,i,s){const n=new Image;return n.src=await this.base64(t,e,i,s),n}async base64(t,e,i,s){const n=this.canvas(t,s);if(n.toBlob!==void 0)return new Promise((o,a)=>{n.toBlob(l=>{if(!l){a(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>o(h.result),h.onerror=a,h.readAsDataURL(l)},e,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const o=await n.convertToBlob({type:e,quality:i});return new Promise((a,l)=>{const h=new FileReader;h.onload=()=>a(h.result),h.onerror=l,h.readAsDataURL(o)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);o&&ks._flipY(i,s,n),a&&ks._unpremultiplyAlpha(i);const l=new vs(s,n,1),h=new ImageData(new Uint8ClampedArray(i.buffer),s,n);return l.context.putImageData(h,0,0),l.canvas}pixels(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&ks._flipY(i,s,n),a&&ks._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let s,n=!1,o=!1,a,l=!1;t&&(t instanceof tr?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(uo.width=e.width,uo.height=e.height,e=uo)));const h=i.gl;if(a){if(s=a.baseTexture.resolution,e=e??a.frame,n=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===$.RGBA,!l){i.renderTexture.bind(a);const p=a.framebuffer.glFramebuffers[i.CONTEXT_UID];p.blitFramebuffer&&i.framebuffer.bind(p.blitFramebuffer)}}else s=i.resolution,e||(e=uo,e.width=i.width/s,e.height=i.height/s),n=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(e.width*s),1),c=Math.max(Math.round(e.height*s),1),d=new Uint8Array(GT*u*c);return h.readPixels(Math.round(e.x*s),Math.round(e.y*s),u,c,h.RGBA,h.UNSIGNED_BYTE,d),l&&(a==null||a.destroy(!0)),{pixels:d,width:u,height:c,flipY:n,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(t,e,i){const s=e<<2,n=i>>1,o=new Uint8Array(s);for(let a=0;a<n;a++){const l=a*s,h=(i-a-1)*s;o.set(t.subarray(l,l+s)),t.copyWithin(l,h,h+s),t.set(o,h)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let i=0;i<e;i+=4){const s=t[i+3];if(s!==0){const n=255.001/s;t[i]=t[i]*n+.5,t[i+1]=t[i+1]*n+.5,t[i+2]=t[i+2]*n+.5}}}};sp.extension={name:"extract",type:X.RendererSystem};let HT=sp;j.add(HT);const co={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===Tt.CIRC){const f=r.shape;e=f.x,i=f.y,o=a=f.radius,s=n=0}else if(r.type===Tt.ELIP){const f=r.shape;e=f.x,i=f.y,o=f.width,a=f.height,s=n=0}else{const f=r.shape,m=f.width/2,_=f.height/2;e=f.x+m,i=f.y+_,o=a=Math.max(0,Math.min(f.radius,Math.min(m,_))),s=m-o,n=_-a}if(!(o>=0&&a>=0&&s>=0&&n>=0)){t.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(s?4:0)+(n?4:0);if(t.length=h,h===0)return;if(l===0){t.length=8,t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n;return}let u=0,c=l*4+(s?2:0)+2,d=c,p=h;{const f=s+o,m=n,_=e+f,g=e-f,v=i+m;if(t[u++]=_,t[u++]=v,t[--c]=v,t[--c]=g,n){const y=i-m;t[d++]=g,t[d++]=y,t[--p]=y,t[--p]=_}}for(let f=1;f<l;f++){const m=Math.PI/2*(f/l),_=s+Math.cos(m)*o,g=n+Math.sin(m)*a,v=e+_,y=e-_,x=i+g,b=i-g;t[u++]=v,t[u++]=x,t[--c]=x,t[--c]=y,t[d++]=y,t[d++]=b,t[--p]=b,t[--p]=v}{const f=s,m=n+a,_=e+f,g=e-f,v=i+m,y=i-m;t[u++]=_,t[u++]=v,t[--p]=y,t[--p]=_,s&&(t[u++]=g,t[u++]=v,t[--p]=y,t[--p]=g)}},triangulate(r,t){const e=r.points,i=t.points,s=t.indices;if(e.length===0)return;let n=i.length/2;const o=n;let a,l;if(r.type!==Tt.RREC){const u=r.shape;a=u.x,l=u.y}else{const u=r.shape;a=u.x+u.width/2,l=u.y+u.height/2}const h=r.matrix;i.push(r.matrix?h.a*a+h.c*l+h.tx:a,r.matrix?h.b*a+h.d*l+h.ty:l),n++,i.push(e[0],e[1]);for(let u=2;u<e.length;u+=2)i.push(e[u],e[u+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function np(r,t=!1){const e=r.length;if(e<6)return;let i=0;for(let s=0,n=r[e-2],o=r[e-1];s<e;s+=2){const a=r[s],l=r[s+1];i+=(a-n)*(l+o),n=a,o=l}if(!t&&i>0||t&&i<=0){const s=e/2;for(let n=s+s%2;n<e;n+=2){const o=e-n-2,a=e-n-1,l=n,h=n+1;[r[o],r[l]]=[r[l],r[o]],[r[a],r[h]]=[r[h],r[a]]}}}const op={build(r){r.points=r.shape.points.slice()},triangulate(r,t){let e=r.points;const i=r.holes,s=t.points,n=t.indices;if(e.length>=6){np(e,!1);const o=[];for(let h=0;h<i.length;h++){const u=i[h];np(u.points,!0),o.push(e.length/2),e=e.concat(u.points)}const a=ic(e,o,2);if(!a)return;const l=s.length/2;for(let h=0;h<a.length;h+=3)n.push(a[h]+l),n.push(a[h+1]+l),n.push(a[h+2]+l);for(let h=0;h<e.length;h++)s.push(e[h])}}},$T={build(r){const t=r.shape,e=t.x,i=t.y,s=t.width,n=t.height,o=r.points;o.length=0,s>=0&&n>=0&&o.push(e,i,e+s,i,e+s,i+n,e,i+n)},triangulate(r,t){const e=r.points,i=t.points;if(e.length===0)return;const s=i.length/2;i.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},VT={build(r){co.build(r)},triangulate(r,t){co.triangulate(r,t)}};var be=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(be||{}),Br=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(Br||{});const Hi={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,t=20){if(!this.adaptive||!r||isNaN(r))return t;let e=Math.ceil(r/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class ap{static curveTo(t,e,i,s,n,o){const a=o[o.length-2],l=o[o.length-1]-e,h=a-t,u=s-e,c=i-t,d=Math.abs(l*c-h*u);if(d<1e-8||n===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const p=l*l+h*h,f=u*u+c*c,m=l*u+h*c,_=n*Math.sqrt(p)/d,g=n*Math.sqrt(f)/d,v=_*m/p,y=g*m/f,x=_*c+g*h,b=_*u+g*l,E=h*(g+v),T=l*(g+v),A=c*(_+y),M=u*(_+y),S=Math.atan2(T-b,E-x),P=Math.atan2(M-b,A-x);return{cx:x+t,cy:b+e,radius:n,startAngle:S,endAngle:P,anticlockwise:h*u>c*l}}static arc(t,e,i,s,n,o,a,l,h){const u=a-o,c=Hi._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/Rn)*40),d=u/(c*2),p=d*2,f=Math.cos(d),m=Math.sin(d),_=c-1,g=_%1/_;for(let v=0;v<=_;++v){const y=v+g*v,x=d+o+p*y,b=Math.cos(x),E=-Math.sin(x);h.push((f*b+m*E)*n+i,(f*-E+m*b)*n+s)}}}class XT{constructor(){this.reset()}begin(t,e,i){this.reset(),this.style=t,this.start=e,this.attribStart=i}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class ih{static curveLength(t,e,i,s,n,o,a,l){let h=0,u=0,c=0,d=0,p=0,f=0,m=0,_=0,g=0,v=0,y=0,x=t,b=e;for(let E=1;E<=10;++E)u=E/10,c=u*u,d=c*u,p=1-u,f=p*p,m=f*p,_=m*t+3*f*u*i+3*p*c*n+d*a,g=m*e+3*f*u*s+3*p*c*o+d*l,v=x-_,y=b-g,x=_,b=g,h+=Math.sqrt(v*v+y*y);return h}static curveTo(t,e,i,s,n,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const u=Hi._segmentsCount(ih.curveLength(l,h,t,e,i,s,n,o));let c=0,d=0,p=0,f=0,m=0;a.push(l,h);for(let _=1,g=0;_<=u;++_)g=_/u,c=1-g,d=c*c,p=d*c,f=g*g,m=f*g,a.push(p*l+3*d*g*t+3*c*f*i+m*n,p*h+3*d*g*e+3*c*f*s+m*o)}}function lp(r,t,e,i,s,n,o,a){const l=r-e*s,h=t-i*s,u=r+e*n,c=t+i*n;let d,p;o?(d=i,p=-e):(d=-i,p=e);const f=l+d,m=h+p,_=u+d,g=c+p;return a.push(f,m,_,g),2}function oi(r,t,e,i,s,n,o,a){const l=e-r,h=i-t;let u=Math.atan2(l,h),c=Math.atan2(s-r,n-t);a&&u<c?u+=Math.PI*2:!a&&u>c&&(c+=Math.PI*2);let d=u;const p=c-u,f=Math.abs(p),m=Math.sqrt(l*l+h*h),_=(15*f*Math.sqrt(m)/Math.PI>>0)+1,g=p/_;if(d+=g,a){o.push(r,t,e,i);for(let v=1,y=d;v<_;v++,y+=g)o.push(r,t,r+Math.sin(y)*m,t+Math.cos(y)*m);o.push(r,t,s,n)}else{o.push(e,i,r,t);for(let v=1,y=d;v<_;v++,y+=g)o.push(r+Math.sin(y)*m,t+Math.cos(y)*m,r,t);o.push(s,n,r,t)}return _*2}function WT(r,t){const e=r.shape;let i=r.points||e.points.slice();const s=t.closePointEps;if(i.length===0)return;const n=r.lineStyle,o=new dt(i[0],i[1]),a=new dt(i[i.length-2],i[i.length-1]),l=e.type!==Tt.POLY||e.closeStroke,h=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const H=(o.x+a.x)*.5,W=(a.y+o.y)*.5;i.unshift(H,W),i.push(H,W)}const u=t.points,c=i.length/2;let d=i.length;const p=u.length/2,f=n.width/2,m=f*f,_=n.miterLimit*n.miterLimit;let g=i[0],v=i[1],y=i[2],x=i[3],b=0,E=0,T=-(v-x),A=g-y,M=0,S=0,P=Math.sqrt(T*T+A*A);T/=P,A/=P,T*=f,A*=f;const C=n.alignment,w=(1-C)*2,D=C*2;l||(n.cap===Br.ROUND?d+=oi(g-T*(w-D)*.5,v-A*(w-D)*.5,g-T*w,v-A*w,g+T*D,v+A*D,u,!0)+2:n.cap===Br.SQUARE&&(d+=lp(g,v,T,A,w,D,!0,u))),u.push(g-T*w,v-A*w,g+T*D,v+A*D);for(let H=1;H<c-1;++H){g=i[(H-1)*2],v=i[(H-1)*2+1],y=i[H*2],x=i[H*2+1],b=i[(H+1)*2],E=i[(H+1)*2+1],T=-(v-x),A=g-y,P=Math.sqrt(T*T+A*A),T/=P,A/=P,T*=f,A*=f,M=-(x-E),S=y-b,P=Math.sqrt(M*M+S*S),M/=P,S/=P,M*=f,S*=f;const W=y-g,rt=v-x,I=y-b,F=E-x,G=W*I+rt*F,Q=rt*I-F*W,K=Q<0;if(Math.abs(Q)<.001*Math.abs(G)){u.push(y-T*w,x-A*w,y+T*D,x+A*D),G>=0&&(n.join===be.ROUND?d+=oi(y,x,y-T*w,x-A*w,y-M*w,x-S*w,u,!1)+4:d+=2,u.push(y-M*D,x-S*D,y+M*w,x+S*w));continue}const k=(-T+g)*(-A+x)-(-T+y)*(-A+v),it=(-M+b)*(-S+x)-(-M+y)*(-S+E),gt=(W*it-I*k)/Q,B=(F*k-rt*it)/Q,O=(gt-y)*(gt-y)+(B-x)*(B-x),tt=y+(gt-y)*w,nt=x+(B-x)*w,vt=y-(gt-y)*D,xt=x-(B-x)*D,nr=Math.min(W*W+rt*rt,I*I+F*F),or=K?w:D,Ls=nr+or*or*m,NA=O<=Ls;let Eo=n.join;if(Eo===be.MITER&&O/m>_&&(Eo=be.BEVEL),NA)switch(Eo){case be.MITER:{u.push(tt,nt,vt,xt);break}case be.BEVEL:{K?u.push(tt,nt,y+T*D,x+A*D,tt,nt,y+M*D,x+S*D):u.push(y-T*w,x-A*w,vt,xt,y-M*w,x-S*w,vt,xt),d+=2;break}case be.ROUND:{K?(u.push(tt,nt,y+T*D,x+A*D),d+=oi(y,x,y+T*D,x+A*D,y+M*D,x+S*D,u,!0)+4,u.push(tt,nt,y+M*D,x+S*D)):(u.push(y-T*w,x-A*w,vt,xt),d+=oi(y,x,y-T*w,x-A*w,y-M*w,x-S*w,u,!1)+4,u.push(y-M*w,x-S*w,vt,xt));break}}else{switch(u.push(y-T*w,x-A*w,y+T*D,x+A*D),Eo){case be.MITER:{K?u.push(vt,xt,vt,xt):u.push(tt,nt,tt,nt),d+=2;break}case be.ROUND:{K?d+=oi(y,x,y+T*D,x+A*D,y+M*D,x+S*D,u,!0)+2:d+=oi(y,x,y-T*w,x-A*w,y-M*w,x-S*w,u,!1)+2;break}}u.push(y-M*w,x-S*w,y+M*D,x+S*D),d+=2}}g=i[(c-2)*2],v=i[(c-2)*2+1],y=i[(c-1)*2],x=i[(c-1)*2+1],T=-(v-x),A=g-y,P=Math.sqrt(T*T+A*A),T/=P,A/=P,T*=f,A*=f,u.push(y-T*w,x-A*w,y+T*D,x+A*D),l||(n.cap===Br.ROUND?d+=oi(y-T*(w-D)*.5,x-A*(w-D)*.5,y-T*w,x-A*w,y+T*D,x+A*D,u,!1)+2:n.cap===Br.SQUARE&&(d+=lp(y,x,T,A,w,D,!1,u)));const N=t.indices,V=Hi.epsilon*Hi.epsilon;for(let H=p;H<d+p-2;++H)g=u[H*2],v=u[H*2+1],y=u[(H+1)*2],x=u[(H+1)*2+1],b=u[(H+2)*2],E=u[(H+2)*2+1],!(Math.abs(g*(x-E)+y*(E-v)+b*(v-x))<V)&&N.push(H,H+1,H+2)}function zT(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==Tt.POLY||i.closeStroke;if(s.length===0)return;const o=t.points,a=t.indices,l=s.length/2,h=o.length/2;let u=h;for(o.push(s[0],s[1]),e=1;e<l;e++)o.push(s[e*2],s[e*2+1]),a.push(u,u+1),u++;n&&a.push(u,h)}function hp(r,t){r.lineStyle.native?zT(r,t):WT(r,t)}class sh{static curveLength(t,e,i,s,n,o){const a=t-2*i+n,l=e-2*s+o,h=2*i-2*t,u=2*s-2*e,c=4*(a*a+l*l),d=4*(a*h+l*u),p=h*h+u*u,f=2*Math.sqrt(c+d+p),m=Math.sqrt(c),_=2*c*m,g=2*Math.sqrt(p),v=d/m;return(_*f+m*d*(f-g)+(4*p*c-d*d)*Math.log((2*m+v+f)/(v+g)))/(4*_)}static curveTo(t,e,i,s,n){const o=n[n.length-2],a=n[n.length-1],l=Hi._segmentsCount(sh.curveLength(o,a,t,e,i,s));let h=0,u=0;for(let c=1;c<=l;++c){const d=c/l;h=o+(t-o)*d,u=a+(e-a)*d,n.push(h+(t+(i-t)*d-h)*d,u+(e+(s-e)*d-u)*d)}}}const nh={[Tt.POLY]:op,[Tt.CIRC]:co,[Tt.ELIP]:co,[Tt.RECT]:$T,[Tt.RREC]:VT},up=[],fo=[];class po{constructor(t,e=null,i=null,s=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=s,this.type=t.type}clone(){return new po(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const $i=new dt,cp=class rm extends Md{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new Kn,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),fo.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),up.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,s=null){const n=new po(t,e,i,s);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new po(t,null,null,e),s=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=s.lineStyle,s.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const s=e[i];if(s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(t,$i):$i.copyFrom(t),s.shape.contains($i.x,$i.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains($i.x,$i.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,s=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],s=i.style);for(let l=this.shapeIndex;l<e.length;l++){this.shapeIndex++;const h=e[l],u=h.fillStyle,c=h.lineStyle;nh[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(u.visible||c.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const p=d===0?u:c;if(!p.visible)continue;const f=p.texture.baseTexture,m=this.indices.length,_=this.points.length/2;f.wrapMode=pr.REPEAT,d===0?this.processFill(h):this.processLine(h);const g=this.points.length/2-_;g!==0&&(i&&!this._compareStyles(s,p)&&(i.end(m,_),i=null),i||(i=up.pop()||new XT,i.begin(p,m,_),this.batches.push(i),s=p),this.addUvs(this.points,t,p.texture,_,g,p.matrix))}}const n=this.indices.length,o=this.points.length/2;if(i&&i.end(n,o),this.batches.length===0){this.batchable=!0;return}const a=o>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&a===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=a?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const i=this.graphicsData[t],s=i.fillStyle,n=i.lineStyle;if(s&&!s.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const s=t[e];for(let n=0;n<s.size;n++){const o=s.start+n;this.indicesUint16[o]=this.indicesUint16[o]-s.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<rm.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++st._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),fo.push(this.drawCalls[c]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=fo.pop();s||(s=new Tl,s.texArray=new Il),s.texArray.count=0,s.start=0,s.size=0,s.type=Ce.TRIANGLES;let n=0,o=null,a=0,l=!1,h=Ce.TRIANGLES,u=0;this.drawCalls.push(s);for(let c=0;c<this.batches.length;c++){const d=this.batches[c],p=8,f=d.style,m=f.texture.baseTexture;l!==!!f.native&&(l=!!f.native,h=l?Ce.LINES:Ce.TRIANGLES,o=null,n=p,t++),o!==m&&(o=m,m._batchEnabled!==t&&(n===p&&(t++,n=0,s.size>0&&(s=fo.pop(),s||(s=new Tl,s.texArray=new Il),this.drawCalls.push(s)),s.start=u,s.size=0,s.texArray.count=0,s.type=h),m.touched=1,m._batchEnabled=t,m._batchLocation=n,m.wrapMode=pr.REPEAT,s.texArray.elements[s.texArray.count++]=m,n++)),s.size+=d.size,u+=d.size,a=m._batchLocation,this.addColors(e,f.color,f.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}st._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,s=this.textureIds,n=new ArrayBuffer(t.length*3*4),o=new Float32Array(n),a=new Uint32Array(n);let l=0;for(let h=0;h<t.length/2;h++)o[l++]=t[h*2],o[l++]=t[h*2+1],o[l++]=e[h*2],o[l++]=e[h*2+1],a[l++]=i[h],o[l++]=s[h];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?op.triangulate(t,this):nh[t.type].triangulate(t,this)}processLine(t){hp(t,this);for(let e=0;e<t.holes.length;e++)hp(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];nh[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const s=t[i*2],n=t[i*2+1];t[i*2]=e.a*s+e.c*n+e.tx,t[i*2+1]=e.b*s+e.d*n+e.ty}}addColors(t,e,i,s,n=0){const o=ut.shared.setValue(e).toLittleEndianNumber(),a=ut.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,n+s);for(let l=0;l<s;l++)t[n+l]=a}addTextureIds(t,e,i,s=0){t.length=Math.max(t.length,s+i);for(let n=0;n<i;n++)t[s+n]=e}addUvs(t,e,i,s,n,o=null){let a=0;const l=e.length,h=i.frame;for(;a<n;){let c=t[(s+a)*2],d=t[(s+a)*2+1];if(o){const p=o.a*c+o.c*d+o.tx;d=o.b*c+o.d*d+o.ty,c=p}a++,e.push(c/h.width,d/h.height)}const u=i.baseTexture;(h.width<u.width||h.height<u.height)&&this.adjustUvs(e,i,l,n)}adjustUvs(t,e,i,s){const n=e.baseTexture,o=1e-6,a=i+s*2,l=e.frame,h=l.width/n.width,u=l.height/n.height;let c=l.x/l.width,d=l.y/l.height,p=Math.floor(t[i]+o),f=Math.floor(t[i+1]+o);for(let m=i+2;m<a;m+=2)p=Math.min(p,Math.floor(t[m]+o)),f=Math.min(f,Math.floor(t[m+1]+o));c-=p,d-=f;for(let m=i;m<a;m+=2)t[m]=(t[m]+c)*h,t[m+1]=(t[m+1]+d)*u}};cp.BATCHABLE_SIZE=100;let jT=cp;class mo{constructor(){this.color=16777215,this.alpha=1,this.texture=Y.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new mo;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=Y.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class oh extends mo{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Br.BUTT,this.join=be.MITER,this.miterLimit=10}clone(){const t=new oh;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=Br.BUTT,this.join=be.MITER,this.miterLimit=10}}const ah={},lh=class Ro extends le{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new mo,this._lineStyle=new oh,this._matrix=null,this._holeMode=!1,this.state=Je.for2d(),this._geometry=t||new jT,this._geometry.refCount++,this._transformID=-1,this._tintColor=new ut(16777215),this.blendMode=U.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new Ro(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,s=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:s,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:Y.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:Br.BUTT,join:be.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new qr,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new qr,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,s=i[i.length-2],n=i[i.length-1];return(s!==t||n!==e)&&i.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,i,s){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),sh.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),ih.curveTo(t,e,i,s,n,o,this.currentPath.points),this}arcTo(t,e,i,s,n){this._initCurve(t,e);const o=this.currentPath.points,a=ap.curveTo(t,e,i,s,n,o);if(a){const{cx:l,cy:h,radius:u,startAngle:c,endAngle:d,anticlockwise:p}=a;this.arc(l,h,u,c,d,p)}return this}arc(t,e,i,s,n,o=!1){if(s===n)return this;if(!o&&n<=s?n+=Rn:o&&s<=n&&(s+=Rn),n-s===0)return this;const a=t+Math.cos(s)*i,l=e+Math.sin(s)*i,h=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const c=Math.abs(u[u.length-2]-a),d=Math.abs(u[u.length-1]-l);c<h&&d<h||u.push(a,l)}else this.moveTo(a,l),u=this.currentPath.points;return ap.arc(a,l,t,e,i,s,n,o,u),this}beginFill(t=0,e){return this.beginTextureFill({texture:Y.WHITE,color:t,alpha:e})}normalizeColor(t){const e=ut.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:Y.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,s){return this.drawShape(new at(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new Bn(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new Mn(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new Dn(t,e,i,s))}drawPolygon(...t){let e,i=!0;const s=t[0];s.points?(i=s.closeStroke,e=s.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new qr(e);return n.closeStroke=i,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Tt.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let s=0;s<i;s++){const n=t.batches[s],o=n.style.color,a=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),l=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),h=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),u={vertexData:a,blendMode:e,indices:h,uvs:l,_batchRGB:ut.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=u}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const s=this.batches[e];s.worldAlpha=this.worldAlpha*s.alpha,t.plugins[this.pluginName].render(s)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,s=this.worldAlpha,n=e.uniforms,o=i.drawCalls;n.translationMatrix=this.transform.worldTransform,ut.shared.setValue(this._tintColor).premultiply(s).toArray(n.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let a=0,l=o.length;a<l;a++)this._renderDrawCallDirect(t,i.drawCalls[a])}_renderDrawCallDirect(t,e){const{texArray:i,type:s,size:n,start:o}=e,a=i.count;for(let l=0;l<a;l++)t.texture.bind(i.elements[l],l);t.geometry.draw(s,n,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!ah[i]){const{maxTextures:s}=t.plugins[i],n=new Int32Array(s);for(let l=0;l<s;l++)n[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new wt,default:De.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;ah[i]=new Qe(a,o)}e=ah[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:s,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,i,s,n)}containsPoint(t){return this.worldTransform.applyInverse(t,Ro._TEMP_POINT),this._geometry.containsPoint(Ro._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=ut.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this._geometry.points,u=this.vertexData;let c=0;for(let d=0;d<h.length;d+=2){const p=h[d],f=h[d+1];u[c++]=i*p+n*f+a,u[c++]=o*f+s*p+l}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};lh.curves=Hi,lh._TEMP_POINT=new dt;let Or=lh;class YT{constructor(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}}const hh=new dt,dp=new qr,fp=class im extends le{constructor(t,e,i,s=Ce.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||Je.for2d(),this.drawMode=s,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=z.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===Ce.TRIANGLES&&e.length<im.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const s=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[s]),t.plugins[s].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const s=this.transform.worldTransform,n=s.a,o=s.b,a=s.c,l=s.d,h=s.tx,u=s.ty,c=this.vertexData;for(let d=0;d<c.length/2;d++){const p=e[d*2],f=e[d*2+1];c[d*2]=n*p+a*f+h,c[d*2+1]=o*p+l*f+u}if(this._roundPixels){const d=z.RESOLUTION;for(let p=0;p<c.length;++p)c[p]=Math.round(c[p]*d)/d}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new YT(t,e.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,hh);const e=this.geometry.getBuffer("aVertexPosition").data,i=dp.points,s=this.geometry.getIndex().data,n=s.length,o=this.drawMode===4?3:1;for(let a=0;a+2<n;a+=o){const l=s[a]*2,h=s[a+1]*2,u=s[a+2]*2;if(i[0]=e[l],i[1]=e[l+1],i[2]=e[h],i[3]=e[h+1],i[4]=e[u],i[5]=e[u+1],dp.contains(hh.x,hh.y))return!0}return!1}destroy(t){super.destroy(t),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};fp.BATCHABLE_SIZE=100;let oe=fp;class go extends Ir{constructor(t,e,i){super();const s=new Bt(t),n=new Bt(e,!0),o=new Bt(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,J.FLOAT).addAttribute("aTextureCoord",n,2,!1,J.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var qT=`varying vec2 vTextureCoord;
1058
+ `;let Pi=null;class Of{constructor(){Pi||(Pi=URL.createObjectURL(new Blob([Jx],{type:"application/javascript"}))),this.worker=new Worker(Pi)}}Of.revokeObjectURL=function(){Pi&&(URL.revokeObjectURL(Pi),Pi=null)};let Lf=0,Ol;class Qx{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new Bl;e.addEventListener("message",i=>{e.terminate(),Bl.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Ol===void 0&&(Ol=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Ol&&(this._createdWorkers++,t=new Of().worker,t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((s,n)=>{this.queue.push({id:t,arguments:e,resolve:s,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),i=e.id;this.resolveHash[Lf]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Lf++,id:i})}}const Ff=new Qx;function ms(r,t,e){r.resource.internal=!0;const i=new it(r),s=()=>{delete t.promiseCache[e],Qr.has(e)&&Qr.remove(e)};return i.baseTexture.once("destroyed",()=>{e in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),s())}),i.once("destroyed",()=>{r.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),s())}),i}const tb=[".jpeg",".jpg",".png",".webp",".avif"],eb=["image/jpeg","image/png","image/webp","image/avif"];async function rb(r){const t=await et.ADAPTER.fetch(r);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const In={name:"loadTextures",extension:{type:J.LoadParser,priority:Ge.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Ii(r,eb)||Pr(r,tb)},async load(r,t,e){var o;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await Ff.isImageBitmapSupported()?s=await Ff.loadImageBitmap(r):s=await rb(r):s=await new Promise((l,h)=>{const u=new Image;u.crossOrigin=this.config.crossOrigin,u.src=r,u.complete?l(u):(u.onload=()=>l(u),u.onerror=c=>h(c))});const n={...t.data};n.resolution??(n.resolution=er(r)),i&&((o=n.resourceOptions)==null?void 0:o.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const a=new dt(s,n);return a.resource.src=r,ms(a,e,r)},unload(r){r.destroy(!0)}};rt.add(In);const ib=".svg",sb="image/svg+xml",nb={extension:{type:J.LoadParser,priority:Ge.High},name:"loadSVG",test(r){return Ii(r,sb)||Pr(r,ib)},async testParse(r){return bl.test(r)},async parse(r,t,e){var n;const i=new bl(r,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const s=new dt(i,{resolution:er(r),...t==null?void 0:t.data});return s.resource.src=t.src,ms(s,e,t.src)},async load(r,t){return(await et.ADAPTER.fetch(r)).text()},unload:In.unload};rt.add(nb);const ab=[".mp4",".m4v",".webm",".ogv"],ob=["video/mp4","video/webm","video/ogg"],lb={name:"loadVideo",extension:{type:J.LoadParser,priority:Ge.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(r){return Ii(r,ob)||Pr(r,ab)},async load(r,t,e){var a;let i;const s=await(await et.ADAPTER.fetch(r)).blob(),n=URL.createObjectURL(s);try{const o={autoPlay:this.config.defaultAutoPlay,updateFPS:this.config.defaultUpdateFPS,loop:this.config.defaultLoop,muted:this.config.defaultMuted,playsinline:this.config.defaultPlaysinline,...(a=t==null?void 0:t.data)==null?void 0:a.resourceOptions,autoLoad:!0},l=new cf(n,o);await l.load();const h=new dt(l,{alphaMode:await jc(),resolution:er(r),...t==null?void 0:t.data});h.resource.src=r,i=ms(h,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(o){throw URL.revokeObjectURL(n),o}return i},unload(r){r.destroy(!0)}};rt.add(lb);class hb{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{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,name:i,src:s,srcs:n}=t;return ke(e||i||s||n,a=>typeof a=="string"?a:Array.isArray(a)?a.map(o=>(o==null?void 0:o.src)??(o==null?void 0:o.srcs)??o):a!=null&&a.src||a!=null&&a.srcs?a.src??a.srcs:a,!0)}addManifest(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];Array.isArray(e)?e.forEach(s=>{const n=s.src??s.srcs,a=s.alias??s.name;let o;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);i.push(l),o=[a,l]}else{const l=a.map(h=>this._createBundleAssetId(t,h));i.push(...l),o=[...a,...l]}this.add({...s,alias:o,src:n})}):Object.keys(e).forEach(s=>{const n=[s,this._createBundleAssetId(t,s)];if(typeof e[s]=="string")this.add({alias:n,src:e[s]});else if(Array.isArray(e[s]))this.add({alias:n,src:e[s]});else{const a=e[s],o=a.src??a.srcs;this.add({...a,alias:n,src:Array.isArray(o)?o:[o]})}i.push(...n)}),this._bundles[t]=i}add(t,e,i,s,n){const a=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(ct("7.2.0",`Assets.add now uses an object instead of individual parameters.
1059
+ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),a.push({alias:t,src:e,data:i,format:s,loadParser:n})):Array.isArray(t)?a.push(...t):a.push(t);let o;o=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},ke(a).forEach(l=>{const{src:h,srcs:u}=l;let{data:c,format:d,loadParser:p}=l;const f=ke(h||u).map(m=>typeof m=="string"?Ox(m):Array.isArray(m)?m:[m]),g=this.getAlias(l);Array.isArray(g)?g.forEach(o):o(g);const y=[];f.forEach(m=>{m.forEach(_=>{let v={};if(typeof _!="object"){v.src=_;for(let x=0;x<this._parsers.length;x++){const b=this._parsers[x];if(b.test(_)){v=b.parse(_);break}}}else c=_.data??c,d=_.format??d,p=_.loadParser??p,v={...v,..._};if(!g)throw new Error(`[Resolver] alias is undefined for this asset: ${v.src}`);v=this.buildResolvedAsset(v,{aliases:g,data:c,format:d,loadParser:p}),y.push(v)})}),g.forEach(m=>{this._assetMap[m]=y})})}resolveBundle(t){const e=Cn(t);t=ke(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const a=this.resolve(n),o={};for(const l in a){const h=a[l];o[this._extractAssetIdFromBundle(s,l)]=h}i[s]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=Cn(t);t=ke(t);const i={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const a=n[0],o=this._getPreferredOrder(n);o==null||o.priority.forEach(l=>{o.params[l].forEach(h=>{const u=n.filter(c=>c[l]?c[l]===h:!1);u.length&&(n=u)})}),this._resolverHash[s]=n[0]??a}else this._resolverHash[s]=this.buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}buildResolvedAsset(t,e){const{aliases:i,data:s,loadParser:n,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=Xt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.format=a??t.format??Xt.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class ub{constructor(){this._detections=[],this._initialized=!1,this.resolver=new hb,this.loader=new Fx,this.cache=Qr,this._backgroundLoader=new Bx(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,a;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let o=t.manifest;typeof o=="string"&&(o=await this.load(o)),this.resolver.addManifest(o)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,s=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,s,n){this.resolver.add(t,e,i,s,n)}async load(t,e){this._initialized||await this.init();const i=Cn(t),s=ke(t).map(o=>{if(typeof o!="string"){const l=this.resolver.getAlias(o);return l.some(h=>!this.resolver.hasKey(h))&&this.add(o),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),n=this.resolver.resolve(s),a=await this._mapLoadToResolve(n,e);return i?a[s[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},a=Object.keys(s);let o=0,l=0;const h=()=>{e==null||e(++o/l)},u=a.map(c=>{const d=s[c];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(p=>{n[c]=p})});return await Promise.all(u),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Qr.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Qr.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),s=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const a={};return i.forEach((o,l)=>{const h=n[o.src],u=[o.src];o.alias&&u.push(...o.alias),a[s[l]]=h,Qr.set(u,h)}),a}async unload(t){this._initialized||await this.init();const e=ke(t).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=ke(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{Qr.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,s)=>e.indexOf(i)===s),e}get detections(){return this._detections}get preferWorkers(){return In.config.preferWorkers}set preferWorkers(t){ct("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const Rn=new ub;rt.handleByList(J.LoadParser,Rn.loader.parsers).handleByList(J.ResolveParser,Rn.resolver.parsers).handleByList(J.CacheParser,Rn.cache.parsers).handleByList(J.DetectionParser,Rn.detections);const cb={extension:J.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof it),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};rt.add(cb);async function Nf(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const db={extension:{type:J.DetectionParser,priority:1},test:async()=>Nf("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};rt.add(db);const fb={extension:{type:J.DetectionParser,priority:0},test:async()=>Nf("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};rt.add(fb);const Uf=["png","jpg","jpeg"],pb={extension:{type:J.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Uf],remove:async r=>r.filter(t=>!Uf.includes(t))};rt.add(pb);const mb="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Ll(r){return mb?!1:document.createElement("video").canPlayType(r)!==""}const gb={extension:{type:J.DetectionParser,priority:0},test:async()=>Ll("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};rt.add(gb);const yb={extension:{type:J.DetectionParser,priority:0},test:async()=>Ll("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};rt.add(yb);const _b={extension:{type:J.DetectionParser,priority:0},test:async()=>Ll("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};rt.add(_b);const vb={extension:J.ResolveParser,test:In.test,parse:r=>{var t;return{resolution:parseFloat(((t=et.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:Xt.extname(r).slice(1),src:r}}};rt.add(vb);var Jt=(r=>(r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",r[r.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",r[r.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r[r.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",r[r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",r[r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",r[r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",r))(Jt||{});const Pn={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let lr,Mi;function kf(){Mi={bptc:lr.getExtension("EXT_texture_compression_bptc"),astc:lr.getExtension("WEBGL_compressed_texture_astc"),etc:lr.getExtension("WEBGL_compressed_texture_etc"),s3tc:lr.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:lr.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:lr.getExtension("WEBGL_compressed_texture_pvrtc")||lr.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:lr.getExtension("WEBGL_compressed_texture_etc1"),atc:lr.getExtension("WEBGL_compressed_texture_atc")}}const xb={extension:{type:J.DetectionParser,priority:2},test:async()=>{const r=et.ADAPTER.createCanvas().getContext("webgl");return r?(lr=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{Mi||kf();const t=[];for(const e in Mi)Mi[e]&&t.push(e);return[...t,...r]},remove:async r=>(Mi||kf(),r.filter(t=>!(t in Mi)))};rt.add(xb);class bb extends Ks{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,s;typeof t=="string"?(i=t,s=new Uint8Array):(i=null,s=t),super(s,e),this.origin=i,this.buffer=s?new qo(s):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new qo(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class ti extends bb{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=ti._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||ti._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const s=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,a=this.levels;n<a;n++){const{levelID:o,levelWidth:l,levelHeight:h,levelBuffer:u}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,o,this.format,l,h,0,u)}return!0}onBlobLoaded(){this._levelBuffers=ti._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,e,i,s,n,a,o){const l=new Array(i);let h=t.byteOffset,u=a,c=o,d=u+s-1&~(s-1),p=c+n-1&~(n-1),f=d*p*Pn[e];for(let g=0;g<i;g++)l[g]={levelID:g,levelWidth:i>1?u:d,levelHeight:i>1?c:p,levelBuffer:new Uint8Array(t.buffer,h,f)},h+=f,u=u>>1||1,c=c>>1||1,d=u+s-1&~(s-1),p=c+n-1&~(n-1),f=d*p*Pn[e];return l}}const Fl=4,Mn=124,wb=32,Gf=20,Tb=542327876,Dn={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},Eb={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},Bn={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},Ab=1,Sb=2,Cb=4,Ib=64,Rb=512,Pb=131072,Mb=827611204,Db=861165636,Bb=894720068,Ob=808540228,Lb=4,Fb={[Mb]:Jt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[Db]:Jt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[Bb]:Jt.COMPRESSED_RGBA_S3TC_DXT5_EXT},Nb={70:Jt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Jt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Jt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Jt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Jt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Jt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Jt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Jt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Jt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:Jt.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:Jt.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:Jt.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:Jt.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function Ub(r){const t=new Uint32Array(r);if(t[0]!==Tb)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,Mn/Uint32Array.BYTES_PER_ELEMENT),i=e[Dn.HEIGHT],s=e[Dn.WIDTH],n=e[Dn.MIPMAP_COUNT],a=new Uint32Array(r,Dn.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,wb/Uint32Array.BYTES_PER_ELEMENT),o=a[Ab];if(o&Cb){const l=a[Eb.FOURCC];if(l!==Ob){const _=Fb[l],v=Fl+Mn,x=new Uint8Array(r,v);return[new ti(x,{format:_,width:s,height:i,levels:n})]}const h=Fl+Mn,u=new Uint32Array(t.buffer,h,Gf/Uint32Array.BYTES_PER_ELEMENT),c=u[Bn.DXGI_FORMAT],d=u[Bn.RESOURCE_DIMENSION],p=u[Bn.MISC_FLAG],f=u[Bn.ARRAY_SIZE],g=Nb[c];if(g===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(p===Lb)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const y=new Array,m=Fl+Mn+Gf;if(f===1)y.push(new Uint8Array(r,m));else{const _=Pn[g];let v=0,x=s,b=i;for(let w=0;w<n;w++){const D=Math.max(1,x+3&-4),U=Math.max(1,b+3&-4),M=D*U*_;v+=M,x=x>>>1,b=b>>>1}let R=m;for(let w=0;w<f;w++)y.push(new Uint8Array(r,R,v)),R+=v}return y.map(_=>new ti(_,{format:g,width:s,height:i,levels:n}))}throw o&Ib?new Error("DDSParser does not support uncompressed texture data."):o&Rb?new Error("DDSParser does not supported YUV uncompressed texture data."):o&Pb?new Error("DDSParser does not support single-channel (lumninance) texture data!"):o&Sb?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const Hf=[171,75,84,88,32,49,49,187,13,10,26,10],kb=67305985,He={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},Nl=64,$f={[ut.UNSIGNED_BYTE]:1,[ut.UNSIGNED_SHORT]:2,[ut.INT]:4,[ut.UNSIGNED_INT]:4,[ut.FLOAT]:4,[ut.HALF_FLOAT]:8},Gb={[Z.RGBA]:4,[Z.RGB]:3,[Z.RG]:2,[Z.RED]:1,[Z.LUMINANCE]:1,[Z.LUMINANCE_ALPHA]:2,[Z.ALPHA]:1},Hb={[ut.UNSIGNED_SHORT_4_4_4_4]:2,[ut.UNSIGNED_SHORT_5_5_5_1]:2,[ut.UNSIGNED_SHORT_5_6_5]:2};function $b(r,t,e=!1){const i=new DataView(t);if(!Vb(r,i))return null;const s=i.getUint32(He.ENDIANNESS,!0)===kb,n=i.getUint32(He.GL_TYPE,s),a=i.getUint32(He.GL_FORMAT,s),o=i.getUint32(He.GL_INTERNAL_FORMAT,s),l=i.getUint32(He.PIXEL_WIDTH,s),h=i.getUint32(He.PIXEL_HEIGHT,s)||1,u=i.getUint32(He.PIXEL_DEPTH,s)||1,c=i.getUint32(He.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(He.NUMBER_OF_FACES,s),p=i.getUint32(He.NUMBER_OF_MIPMAP_LEVELS,s),f=i.getUint32(He.BYTES_OF_KEY_VALUE_DATA,s);if(h===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");const g=4,y=4,m=l+3&-4,_=h+3&-4,v=new Array(c);let x=l*h;n===0&&(x=m*_);let b;if(n!==0?$f[n]?b=$f[n]*Gb[a]:b=Hb[n]:b=Pn[o],b===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const R=e?Wb(i,f,s):null;let w=x*b,D=l,U=h,M=m,F=_,S=Nl+f;for(let I=0;I<p;I++){const H=i.getUint32(S,s);let j=S+4;for(let A=0;A<c;A++){let C=v[A];C||(C=v[A]=new Array(p)),C[I]={levelID:I,levelWidth:p>1||n!==0?D:M,levelHeight:p>1||n!==0?U:F,levelBuffer:new Uint8Array(t,j,w)},j+=w}S+=H+4,S=S%4!==0?S+4-S%4:S,D=D>>1||1,U=U>>1||1,M=D+g-1&-4,F=U+y-1&-4,w=M*F*b}return n!==0?{uncompressed:v.map(I=>{let H=I[0].levelBuffer,j=!1;return n===ut.FLOAT?H=new Float32Array(I[0].levelBuffer.buffer,I[0].levelBuffer.byteOffset,I[0].levelBuffer.byteLength/4):n===ut.UNSIGNED_INT?(j=!0,H=new Uint32Array(I[0].levelBuffer.buffer,I[0].levelBuffer.byteOffset,I[0].levelBuffer.byteLength/4)):n===ut.INT&&(j=!0,H=new Int32Array(I[0].levelBuffer.buffer,I[0].levelBuffer.byteOffset,I[0].levelBuffer.byteLength/4)),{resource:new Ks(H,{width:I[0].levelWidth,height:I[0].levelHeight}),type:n,format:j?Xb(a):a}}),kvData:R}:{compressed:v.map(I=>new ti(null,{format:o,width:l,height:h,levels:p,levelBuffers:I})),kvData:R}}function Vb(r,t){for(let e=0;e<Hf.length;e++)if(t.getUint8(e)!==Hf[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function Xb(r){switch(r){case Z.RGBA:return Z.RGBA_INTEGER;case Z.RGB:return Z.RGB_INTEGER;case Z.RG:return Z.RG_INTEGER;case Z.RED:return Z.RED_INTEGER;default:return r}}function Wb(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(Nl+s,e),a=Nl+s+4,o=3-(n+3)%4;if(n===0||n>t-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<n&&r.getUint8(a+l)!==0;l++);if(l===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const h=new TextDecoder().decode(new Uint8Array(r.buffer,a,l)),u=new DataView(r.buffer,a+l+1,n-l-1);i.set(h,u),s+=4+n+o}return i}const zb={extension:{type:J.LoadParser,priority:Ge.High},name:"loadDDS",test(r){return Pr(r,".dds")},async load(r,t,e){const i=await(await et.ADAPTER.fetch(r)).arrayBuffer(),s=Ub(i).map(n=>{const a=new dt(n,{mipmap:Ke.OFF,alphaMode:ce.NO_PREMULTIPLIED_ALPHA,resolution:er(r),...t.data});return ms(a,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};rt.add(zb);const jb={extension:{type:J.LoadParser,priority:Ge.High},name:"loadKTX",test(r){return Pr(r,".ktx")},async load(r,t,e){const i=await(await et.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:a}=$b(r,i),o=s??n,l={mipmap:Ke.OFF,alphaMode:ce.NO_PREMULTIPLIED_ALPHA,resolution:er(r),...t.data},h=o.map(u=>{o===n&&Object.assign(l,{type:u.type,format:u.format});const c=u.resource??u,d=new dt(c,l);return d.ktxKeyValueData=a,ms(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};rt.add(jb);const Yb=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],qb={extension:J.ResolveParser,test:r=>{const t=Xt.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{var i,s;const t=r.split("."),e=t.pop();if(["ktx","dds"].includes(e)){const n=t.pop();if(Yb.includes(n))return{resolution:parseFloat(((i=et.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:n,src:r}}return{resolution:parseFloat(((s=et.RETINA_PREFIX.exec(r))==null?void 0:s[1])??"1"),format:e,src:r}}};rt.add(qb);const On=new pt,Kb=4,Vf=class As{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,e,i,s){const n=new Image;return n.src=await this.base64(t,e,i,s),n}async base64(t,e,i,s){const n=this.canvas(t,s);if(n.toBlob!==void 0)return new Promise((a,o)=>{n.toBlob(l=>{if(!l){o(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>a(h.result),h.onerror=o,h.readAsDataURL(l)},e,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const a=await n.convertToBlob({type:e,quality:i});return new Promise((o,l)=>{const h=new FileReader;h.onload=()=>o(h.result),h.onerror=l,h.readAsDataURL(a)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const{pixels:i,width:s,height:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(t,e);a&&As._flipY(i,s,n),o&&As._unpremultiplyAlpha(i);const l=new ss(s,n,1),h=new ImageData(new Uint8ClampedArray(i.buffer),s,n);return l.context.putImageData(h,0,0),l.canvas}pixels(t,e){const{pixels:i,width:s,height:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(t,e);return a&&As._flipY(i,s,n),o&&As._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let s,n=!1,a=!1,o,l=!1;t&&(t instanceof sr?o=t:(o=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(On.width=e.width,On.height=e.height,e=On)));const h=i.gl;if(o){if(s=o.baseTexture.resolution,e=e??o.frame,n=!1,a=o.baseTexture.alphaMode>0&&o.baseTexture.format===Z.RGBA,!l){i.renderTexture.bind(o);const p=o.framebuffer.glFramebuffers[i.CONTEXT_UID];p.blitFramebuffer&&i.framebuffer.bind(p.blitFramebuffer)}}else s=i.resolution,e||(e=On,e.width=i.width/s,e.height=i.height/s),n=!0,a=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(e.width*s),1),c=Math.max(Math.round(e.height*s),1),d=new Uint8Array(Kb*u*c);return h.readPixels(Math.round(e.x*s),Math.round(e.y*s),u,c,h.RGBA,h.UNSIGNED_BYTE,d),l&&(o==null||o.destroy(!0)),{pixels:d,width:u,height:c,flipY:n,premultipliedAlpha:a}}destroy(){this.renderer=null}static _flipY(t,e,i){const s=e<<2,n=i>>1,a=new Uint8Array(s);for(let o=0;o<n;o++){const l=o*s,h=(i-o-1)*s;a.set(t.subarray(l,l+s)),t.copyWithin(l,h,h+s),t.set(a,h)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let i=0;i<e;i+=4){const s=t[i+3];if(s!==0){const n=255.001/s;t[i]=t[i]*n+.5,t[i+1]=t[i+1]*n+.5,t[i+2]=t[i+2]*n+.5}}}};Vf.extension={name:"extract",type:J.RendererSystem};let Zb=Vf;rt.add(Zb);const Ln={build(r){const t=r.points;let e,i,s,n,a,o;if(r.type===Rt.CIRC){const f=r.shape;e=f.x,i=f.y,a=o=f.radius,s=n=0}else if(r.type===Rt.ELIP){const f=r.shape;e=f.x,i=f.y,a=f.width,o=f.height,s=n=0}else{const f=r.shape,g=f.width/2,y=f.height/2;e=f.x+g,i=f.y+y,a=o=Math.max(0,Math.min(f.radius,Math.min(g,y))),s=g-a,n=y-o}if(!(a>=0&&o>=0&&s>=0&&n>=0)){t.length=0;return}const l=Math.ceil(2.3*Math.sqrt(a+o)),h=l*8+(s?4:0)+(n?4:0);if(t.length=h,h===0)return;if(l===0){t.length=8,t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n;return}let u=0,c=l*4+(s?2:0)+2,d=c,p=h;{const f=s+a,g=n,y=e+f,m=e-f,_=i+g;if(t[u++]=y,t[u++]=_,t[--c]=_,t[--c]=m,n){const v=i-g;t[d++]=m,t[d++]=v,t[--p]=v,t[--p]=y}}for(let f=1;f<l;f++){const g=Math.PI/2*(f/l),y=s+Math.cos(g)*a,m=n+Math.sin(g)*o,_=e+y,v=e-y,x=i+m,b=i-m;t[u++]=_,t[u++]=x,t[--c]=x,t[--c]=v,t[d++]=v,t[d++]=b,t[--p]=b,t[--p]=_}{const f=s,g=n+o,y=e+f,m=e-f,_=i+g,v=i-g;t[u++]=y,t[u++]=_,t[--p]=v,t[--p]=y,s&&(t[u++]=m,t[u++]=_,t[--p]=v,t[--p]=m)}},triangulate(r,t){const e=r.points,i=t.points,s=t.indices;if(e.length===0)return;let n=i.length/2;const a=n;let o,l;if(r.type!==Rt.RREC){const u=r.shape;o=u.x,l=u.y}else{const u=r.shape;o=u.x+u.width/2,l=u.y+u.height/2}const h=r.matrix;i.push(r.matrix?h.a*o+h.c*l+h.tx:o,r.matrix?h.b*o+h.d*l+h.ty:l),n++,i.push(e[0],e[1]);for(let u=2;u<e.length;u+=2)i.push(e[u],e[u+1]),s.push(n++,a,n);s.push(a+1,a,n)}};function Xf(r,t=!1){const e=r.length;if(e<6)return;let i=0;for(let s=0,n=r[e-2],a=r[e-1];s<e;s+=2){const o=r[s],l=r[s+1];i+=(o-n)*(l+a),n=o,a=l}if(!t&&i>0||t&&i<=0){const s=e/2;for(let n=s+s%2;n<e;n+=2){const a=e-n-2,o=e-n-1,l=n,h=n+1;[r[a],r[l]]=[r[l],r[a]],[r[o],r[h]]=[r[h],r[o]]}}}const Wf={build(r){r.points=r.shape.points.slice()},triangulate(r,t){let e=r.points;const i=r.holes,s=t.points,n=t.indices;if(e.length>=6){Xf(e,!1);const a=[];for(let h=0;h<i.length;h++){const u=i[h];Xf(u.points,!0),a.push(e.length/2),e=e.concat(u.points)}const o=Vu(e,a,2);if(!o)return;const l=s.length/2;for(let h=0;h<o.length;h+=3)n.push(o[h]+l),n.push(o[h+1]+l),n.push(o[h+2]+l);for(let h=0;h<e.length;h++)s.push(e[h])}}},Jb={build(r){const t=r.shape,e=t.x,i=t.y,s=t.width,n=t.height,a=r.points;a.length=0,s>=0&&n>=0&&a.push(e,i,e+s,i,e+s,i+n,e,i+n)},triangulate(r,t){const e=r.points,i=t.points;if(e.length===0)return;const s=i.length/2;i.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},Qb={build(r){Ln.build(r)},triangulate(r,t){Ln.triangulate(r,t)}};var Se=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(Se||{}),Mr=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(Mr||{});const Di={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,t=20){if(!this.adaptive||!r||isNaN(r))return t;let e=Math.ceil(r/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class zf{static curveTo(t,e,i,s,n,a){const o=a[a.length-2],l=a[a.length-1]-e,h=o-t,u=s-e,c=i-t,d=Math.abs(l*c-h*u);if(d<1e-8||n===0)return(a[a.length-2]!==t||a[a.length-1]!==e)&&a.push(t,e),null;const p=l*l+h*h,f=u*u+c*c,g=l*u+h*c,y=n*Math.sqrt(p)/d,m=n*Math.sqrt(f)/d,_=y*g/p,v=m*g/f,x=y*c+m*h,b=y*u+m*l,R=h*(m+_),w=l*(m+_),D=c*(y+v),U=u*(y+v),M=Math.atan2(w-b,R-x),F=Math.atan2(U-b,D-x);return{cx:x+t,cy:b+e,radius:n,startAngle:M,endAngle:F,anticlockwise:h*u>c*l}}static arc(t,e,i,s,n,a,o,l,h){const u=o-a,c=Di._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/Js)*40),d=u/(c*2),p=d*2,f=Math.cos(d),g=Math.sin(d),y=c-1,m=y%1/y;for(let _=0;_<=y;++_){const v=_+m*_,x=d+a+p*v,b=Math.cos(x),R=-Math.sin(x);h.push((f*b+g*R)*n+i,(f*-R+g*b)*n+s)}}}class t1{constructor(){this.reset()}begin(t,e,i){this.reset(),this.style=t,this.start=e,this.attribStart=i}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class Ul{static curveLength(t,e,i,s,n,a,o,l){let h=0,u=0,c=0,d=0,p=0,f=0,g=0,y=0,m=0,_=0,v=0,x=t,b=e;for(let R=1;R<=10;++R)u=R/10,c=u*u,d=c*u,p=1-u,f=p*p,g=f*p,y=g*t+3*f*u*i+3*p*c*n+d*o,m=g*e+3*f*u*s+3*p*c*a+d*l,_=x-y,v=b-m,x=y,b=m,h+=Math.sqrt(_*_+v*v);return h}static curveTo(t,e,i,s,n,a,o){const l=o[o.length-2],h=o[o.length-1];o.length-=2;const u=Di._segmentsCount(Ul.curveLength(l,h,t,e,i,s,n,a));let c=0,d=0,p=0,f=0,g=0;o.push(l,h);for(let y=1,m=0;y<=u;++y)m=y/u,c=1-m,d=c*c,p=d*c,f=m*m,g=f*m,o.push(p*l+3*d*m*t+3*c*f*i+g*n,p*h+3*d*m*e+3*c*f*s+g*a)}}function jf(r,t,e,i,s,n,a,o){const l=r-e*s,h=t-i*s,u=r+e*n,c=t+i*n;let d,p;a?(d=i,p=-e):(d=-i,p=e);const f=l+d,g=h+p,y=u+d,m=c+p;return o.push(f,g,y,m),2}function ei(r,t,e,i,s,n,a,o){const l=e-r,h=i-t;let u=Math.atan2(l,h),c=Math.atan2(s-r,n-t);o&&u<c?u+=Math.PI*2:!o&&u>c&&(c+=Math.PI*2);let d=u;const p=c-u,f=Math.abs(p),g=Math.sqrt(l*l+h*h),y=(15*f*Math.sqrt(g)/Math.PI>>0)+1,m=p/y;if(d+=m,o){a.push(r,t,e,i);for(let _=1,v=d;_<y;_++,v+=m)a.push(r,t,r+Math.sin(v)*g,t+Math.cos(v)*g);a.push(r,t,s,n)}else{a.push(e,i,r,t);for(let _=1,v=d;_<y;_++,v+=m)a.push(r+Math.sin(v)*g,t+Math.cos(v)*g,r,t);a.push(s,n,r,t)}return y*2}function e1(r,t){const e=r.shape;let i=r.points||e.points.slice();const s=t.closePointEps;if(i.length===0)return;const n=r.lineStyle,a=new vt(i[0],i[1]),o=new vt(i[i.length-2],i[i.length-1]),l=e.type!==Rt.POLY||e.closeStroke,h=Math.abs(a.x-o.x)<s&&Math.abs(a.y-o.y)<s;if(l){i=i.slice(),h&&(i.pop(),i.pop(),o.set(i[i.length-2],i[i.length-1]));const C=(a.x+o.x)*.5,T=(o.y+a.y)*.5;i.unshift(C,T),i.push(C,T)}const u=t.points,c=i.length/2;let d=i.length;const p=u.length/2,f=n.width/2,g=f*f,y=n.miterLimit*n.miterLimit;let m=i[0],_=i[1],v=i[2],x=i[3],b=0,R=0,w=-(_-x),D=m-v,U=0,M=0,F=Math.sqrt(w*w+D*D);w/=F,D/=F,w*=f,D*=f;const S=n.alignment,I=(1-S)*2,H=S*2;l||(n.cap===Mr.ROUND?d+=ei(m-w*(I-H)*.5,_-D*(I-H)*.5,m-w*I,_-D*I,m+w*H,_+D*H,u,!0)+2:n.cap===Mr.SQUARE&&(d+=jf(m,_,w,D,I,H,!0,u))),u.push(m-w*I,_-D*I,m+w*H,_+D*H);for(let C=1;C<c-1;++C){m=i[(C-1)*2],_=i[(C-1)*2+1],v=i[C*2],x=i[C*2+1],b=i[(C+1)*2],R=i[(C+1)*2+1],w=-(_-x),D=m-v,F=Math.sqrt(w*w+D*D),w/=F,D/=F,w*=f,D*=f,U=-(x-R),M=v-b,F=Math.sqrt(U*U+M*M),U/=F,M/=F,U*=f,M*=f;const T=v-m,k=_-x,E=v-b,P=R-x,B=T*E+k*P,G=k*E-P*T,z=G<0;if(Math.abs(G)<.001*Math.abs(B)){u.push(v-w*I,x-D*I,v+w*H,x+D*H),B>=0&&(n.join===Se.ROUND?d+=ei(v,x,v-w*I,x-D*I,v-U*I,x-M*I,u,!1)+4:d+=2,u.push(v-U*H,x-M*H,v+U*I,x+M*I));continue}const $=(-w+m)*(-D+x)-(-w+v)*(-D+_),K=(-U+b)*(-M+x)-(-U+v)*(-M+R),Q=(T*K-E*$)/G,O=(P*$-k*K)/G,L=(Q-v)*(Q-v)+(O-x)*(O-x),Y=v+(Q-v)*I,tt=x+(O-x)*I,st=v-(Q-v)*H,lt=x-(O-x)*H,At=Math.min(T*T+k*k,E*E+P*P),ht=z?I:H,at=At+ht*ht*g,$t=L<=at;let Ce=n.join;if(Ce===Se.MITER&&L/g>y&&(Ce=Se.BEVEL),$t)switch(Ce){case Se.MITER:{u.push(Y,tt,st,lt);break}case Se.BEVEL:{z?u.push(Y,tt,v+w*H,x+D*H,Y,tt,v+U*H,x+M*H):u.push(v-w*I,x-D*I,st,lt,v-U*I,x-M*I,st,lt),d+=2;break}case Se.ROUND:{z?(u.push(Y,tt,v+w*H,x+D*H),d+=ei(v,x,v+w*H,x+D*H,v+U*H,x+M*H,u,!0)+4,u.push(Y,tt,v+U*H,x+M*H)):(u.push(v-w*I,x-D*I,st,lt),d+=ei(v,x,v-w*I,x-D*I,v-U*I,x-M*I,u,!1)+4,u.push(v-U*I,x-M*I,st,lt));break}}else{switch(u.push(v-w*I,x-D*I,v+w*H,x+D*H),Ce){case Se.MITER:{z?u.push(st,lt,st,lt):u.push(Y,tt,Y,tt),d+=2;break}case Se.ROUND:{z?d+=ei(v,x,v+w*H,x+D*H,v+U*H,x+M*H,u,!0)+2:d+=ei(v,x,v-w*I,x-D*I,v-U*I,x-M*I,u,!1)+2;break}}u.push(v-U*I,x-M*I,v+U*H,x+M*H),d+=2}}m=i[(c-2)*2],_=i[(c-2)*2+1],v=i[(c-1)*2],x=i[(c-1)*2+1],w=-(_-x),D=m-v,F=Math.sqrt(w*w+D*D),w/=F,D/=F,w*=f,D*=f,u.push(v-w*I,x-D*I,v+w*H,x+D*H),l||(n.cap===Mr.ROUND?d+=ei(v-w*(I-H)*.5,x-D*(I-H)*.5,v-w*I,x-D*I,v+w*H,x+D*H,u,!1)+2:n.cap===Mr.SQUARE&&(d+=jf(v,x,w,D,I,H,!1,u)));const j=t.indices,A=Di.epsilon*Di.epsilon;for(let C=p;C<d+p-2;++C)m=u[C*2],_=u[C*2+1],v=u[(C+1)*2],x=u[(C+1)*2+1],b=u[(C+2)*2],R=u[(C+2)*2+1],!(Math.abs(m*(x-R)+v*(R-_)+b*(_-x))<A)&&j.push(C,C+1,C+2)}function r1(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==Rt.POLY||i.closeStroke;if(s.length===0)return;const a=t.points,o=t.indices,l=s.length/2,h=a.length/2;let u=h;for(a.push(s[0],s[1]),e=1;e<l;e++)a.push(s[e*2],s[e*2+1]),o.push(u,u+1),u++;n&&o.push(u,h)}function Yf(r,t){r.lineStyle.native?r1(r,t):e1(r,t)}class kl{static curveLength(t,e,i,s,n,a){const o=t-2*i+n,l=e-2*s+a,h=2*i-2*t,u=2*s-2*e,c=4*(o*o+l*l),d=4*(o*h+l*u),p=h*h+u*u,f=2*Math.sqrt(c+d+p),g=Math.sqrt(c),y=2*c*g,m=2*Math.sqrt(p),_=d/g;return(y*f+g*d*(f-m)+(4*p*c-d*d)*Math.log((2*g+_+f)/(_+m)))/(4*y)}static curveTo(t,e,i,s,n){const a=n[n.length-2],o=n[n.length-1],l=Di._segmentsCount(kl.curveLength(a,o,t,e,i,s));let h=0,u=0;for(let c=1;c<=l;++c){const d=c/l;h=a+(t-a)*d,u=o+(e-o)*d,n.push(h+(t+(i-t)*d-h)*d,u+(e+(s-e)*d-u)*d)}}}const Gl={[Rt.POLY]:Wf,[Rt.CIRC]:Ln,[Rt.ELIP]:Ln,[Rt.RECT]:Jb,[Rt.RREC]:Qb},qf=[],Fn=[];class Nn{constructor(t,e=null,i=null,s=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=s,this.type=t.type}clone(){return new Nn(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const Bi=new vt,Kf=class qp extends yd{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new xn,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),Fn.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),qf.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,s=null){const n=new Nn(t,e,i,s);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new Nn(t,null,null,e),s=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=s.lineStyle,s.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const s=e[i];if(s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(t,Bi):Bi.copyFrom(t),s.shape.contains(Bi.x,Bi.y))){let n=!1;if(s.holes){for(let a=0;a<s.holes.length;a++)if(s.holes[a].shape.contains(Bi.x,Bi.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,s=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],s=i.style);for(let l=this.shapeIndex;l<e.length;l++){this.shapeIndex++;const h=e[l],u=h.fillStyle,c=h.lineStyle;Gl[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(u.visible||c.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const p=d===0?u:c;if(!p.visible)continue;const f=p.texture.baseTexture,g=this.indices.length,y=this.points.length/2;f.wrapMode=mr.REPEAT,d===0?this.processFill(h):this.processLine(h);const m=this.points.length/2-y;m!==0&&(i&&!this._compareStyles(s,p)&&(i.end(g,y),i=null),i||(i=qf.pop()||new t1,i.begin(p,g,y),this.batches.push(i),s=p),this.addUvs(this.points,t,p.texture,y,m,p.matrix))}}const n=this.indices.length,a=this.points.length/2;if(i&&i.end(n,a),this.batches.length===0){this.batchable=!0;return}const o=a>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&o===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=o?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const i=this.graphicsData[t],s=i.fillStyle,n=i.lineStyle;if(s&&!s.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const s=t[e];for(let n=0;n<s.size;n++){const a=s.start+n;this.indicesUint16[a]=this.indicesUint16[a]-s.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<qp.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++dt._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),Fn.push(this.drawCalls[c]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=Fn.pop();s||(s=new sl,s.texArray=new hl),s.texArray.count=0,s.start=0,s.size=0,s.type=Be.TRIANGLES;let n=0,a=null,o=0,l=!1,h=Be.TRIANGLES,u=0;this.drawCalls.push(s);for(let c=0;c<this.batches.length;c++){const d=this.batches[c],p=8,f=d.style,g=f.texture.baseTexture;l!==!!f.native&&(l=!!f.native,h=l?Be.LINES:Be.TRIANGLES,a=null,n=p,t++),a!==g&&(a=g,g._batchEnabled!==t&&(n===p&&(t++,n=0,s.size>0&&(s=Fn.pop(),s||(s=new sl,s.texArray=new hl),this.drawCalls.push(s)),s.start=u,s.size=0,s.texArray.count=0,s.type=h),g.touched=1,g._batchEnabled=t,g._batchLocation=n,g.wrapMode=mr.REPEAT,s.texArray.elements[s.texArray.count++]=g,n++)),s.size+=d.size,u+=d.size,o=g._batchLocation,this.addColors(e,f.color,f.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,o,d.attribSize,d.attribStart)}dt._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,s=this.textureIds,n=new ArrayBuffer(t.length*3*4),a=new Float32Array(n),o=new Uint32Array(n);let l=0;for(let h=0;h<t.length/2;h++)a[l++]=t[h*2],a[l++]=t[h*2+1],a[l++]=e[h*2],a[l++]=e[h*2+1],o[l++]=i[h],a[l++]=s[h];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Wf.triangulate(t,this):Gl[t.type].triangulate(t,this)}processLine(t){Yf(t,this);for(let e=0;e<t.holes.length;e++)Yf(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];Gl[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const s=t[i*2],n=t[i*2+1];t[i*2]=e.a*s+e.c*n+e.tx,t[i*2+1]=e.b*s+e.d*n+e.ty}}addColors(t,e,i,s,n=0){const a=_t.shared.setValue(e).toLittleEndianNumber(),o=_t.shared.setValue(a).toPremultiplied(i);t.length=Math.max(t.length,n+s);for(let l=0;l<s;l++)t[n+l]=o}addTextureIds(t,e,i,s=0){t.length=Math.max(t.length,s+i);for(let n=0;n<i;n++)t[s+n]=e}addUvs(t,e,i,s,n,a=null){let o=0;const l=e.length,h=i.frame;for(;o<n;){let c=t[(s+o)*2],d=t[(s+o)*2+1];if(a){const p=a.a*c+a.c*d+a.tx;d=a.b*c+a.d*d+a.ty,c=p}o++,e.push(c/h.width,d/h.height)}const u=i.baseTexture;(h.width<u.width||h.height<u.height)&&this.adjustUvs(e,i,l,n)}adjustUvs(t,e,i,s){const n=e.baseTexture,a=1e-6,o=i+s*2,l=e.frame,h=l.width/n.width,u=l.height/n.height;let c=l.x/l.width,d=l.y/l.height,p=Math.floor(t[i]+a),f=Math.floor(t[i+1]+a);for(let g=i+2;g<o;g+=2)p=Math.min(p,Math.floor(t[g]+a)),f=Math.min(f,Math.floor(t[g+1]+a));c-=p,d-=f;for(let g=i;g<o;g+=2)t[g]=(t[g]+c)*h,t[g+1]=(t[g+1]+d)*u}};Kf.BATCHABLE_SIZE=100;let i1=Kf;class Un{constructor(){this.color=16777215,this.alpha=1,this.texture=it.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Un;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=it.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class Hl extends Un{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Mr.BUTT,this.join=Se.MITER,this.miterLimit=10}clone(){const t=new Hl;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=Mr.BUTT,this.join=Se.MITER,this.miterLimit=10}}const $l={},Vl=class ta extends de{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new Un,this._lineStyle=new Hl,this._matrix=null,this._holeMode=!1,this.state=rr.for2d(),this._geometry=t||new i1,this._geometry.refCount++,this._transformID=-1,this._tintColor=new _t(16777215),this.blendMode=q.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new ta(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,s=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:s,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:it.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:Mr.BUTT,join:Se.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new Xr,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Xr,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,s=i[i.length-2],n=i[i.length-1];return(s!==t||n!==e)&&i.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,i,s){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),kl.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,a){return this._initCurve(),Ul.curveTo(t,e,i,s,n,a,this.currentPath.points),this}arcTo(t,e,i,s,n){this._initCurve(t,e);const a=this.currentPath.points,o=zf.curveTo(t,e,i,s,n,a);if(o){const{cx:l,cy:h,radius:u,startAngle:c,endAngle:d,anticlockwise:p}=o;this.arc(l,h,u,c,d,p)}return this}arc(t,e,i,s,n,a=!1){if(s===n)return this;if(!a&&n<=s?n+=Js:a&&s<=n&&(s+=Js),n-s===0)return this;const o=t+Math.cos(s)*i,l=e+Math.sin(s)*i,h=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const c=Math.abs(u[u.length-2]-o),d=Math.abs(u[u.length-1]-l);c<h&&d<h||u.push(o,l)}else this.moveTo(o,l),u=this.currentPath.points;return zf.arc(o,l,t,e,i,s,n,a,u),this}beginFill(t=0,e){return this.beginTextureFill({texture:it.WHITE,color:t,alpha:e})}normalizeColor(t){const e=_t.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:it.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,s){return this.drawShape(new pt(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new rn(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new tn(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new en(t,e,i,s))}drawPolygon(...t){let e,i=!0;const s=t[0];s.points?(i=s.closeStroke,e=s.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new Xr(e);return n.closeStroke=i,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Rt.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let s=0;s<i;s++){const n=t.batches[s],a=n.style.color,o=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),l=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),h=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),u={vertexData:o,blendMode:e,indices:h,uvs:l,_batchRGB:_t.shared.setValue(a).toRgbArray(),_tintRGB:a,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=u}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const s=this.batches[e];s.worldAlpha=this.worldAlpha*s.alpha,t.plugins[this.pluginName].render(s)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,s=this.worldAlpha,n=e.uniforms,a=i.drawCalls;n.translationMatrix=this.transform.worldTransform,_t.shared.setValue(this._tintColor).premultiply(s).toArray(n.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let o=0,l=a.length;o<l;o++)this._renderDrawCallDirect(t,i.drawCalls[o])}_renderDrawCallDirect(t,e){const{texArray:i,type:s,size:n,start:a}=e,o=i.count;for(let l=0;l<o;l++)t.texture.bind(i.elements[l],l);t.geometry.draw(s,n,a)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!$l[i]){const{maxTextures:s}=t.plugins[i],n=new Int32Array(s);for(let l=0;l<s;l++)n[l]=l;const a={tint:new Float32Array([1,1,1,1]),translationMatrix:new Ct,default:Ne.from({uSamplers:n},!0)},o=t.plugins[i]._shader.program;$l[i]=new ir(o,a)}e=$l[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:s,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,i,s,n)}containsPoint(t){return this.worldTransform.applyInverse(t,ta._TEMP_POINT),this._geometry.containsPoint(ta._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=_t.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,a=e.d,o=e.tx,l=e.ty,h=this._geometry.points,u=this.vertexData;let c=0;for(let d=0;d<h.length;d+=2){const p=h[d],f=h[d+1];u[c++]=i*p+n*f+o,u[c++]=a*f+s*p+l}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};Vl.curves=Di,Vl._TEMP_POINT=new vt;let gs=Vl;class s1{constructor(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}}const Xl=new vt,Zf=new Xr,Jf=class Kp extends de{constructor(t,e,i,s=Be.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||rr.for2d(),this.drawMode=s,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=et.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===Be.TRIANGLES&&e.length<Kp.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const s=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[s]),t.plugins[s].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const s=this.transform.worldTransform,n=s.a,a=s.b,o=s.c,l=s.d,h=s.tx,u=s.ty,c=this.vertexData;for(let d=0;d<c.length/2;d++){const p=e[d*2],f=e[d*2+1];c[d*2]=n*p+o*f+h,c[d*2+1]=a*p+l*f+u}if(this._roundPixels){const d=et.RESOLUTION;for(let p=0;p<c.length;++p)c[p]=Math.round(c[p]*d)/d}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new s1(t,e.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,Xl);const e=this.geometry.getBuffer("aVertexPosition").data,i=Zf.points,s=this.geometry.getIndex().data,n=s.length,a=this.drawMode===4?3:1;for(let o=0;o+2<n;o+=a){const l=s[o]*2,h=s[o+1]*2,u=s[o+2]*2;if(i[0]=e[l],i[1]=e[l+1],i[2]=e[h],i[3]=e[h+1],i[4]=e[u],i[5]=e[u+1],Zf.contains(Xl.x,Xl.y))return!0}return!1}destroy(t){super.destroy(t),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};Jf.BATCHABLE_SIZE=100;let ue=Jf;class kn extends Sr{constructor(t,e,i){super();const s=new kt(t),n=new kt(e,!0),a=new kt(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,ut.FLOAT).addAttribute("aTextureCoord",n,2,!1,ut.FLOAT).addIndex(a),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var n1=`varying vec2 vTextureCoord;
1060
1060
  uniform vec4 uColor;
1061
1061
 
1062
1062
  uniform sampler2D uSampler;
@@ -1065,7 +1065,7 @@ void main(void)
1065
1065
  {
1066
1066
  gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
1067
1067
  }
1068
- `,KT=`attribute vec2 aVertexPosition;
1068
+ `,a1=`attribute vec2 aVertexPosition;
1069
1069
  attribute vec2 aTextureCoord;
1070
1070
 
1071
1071
  uniform mat3 projectionMatrix;
@@ -1080,7 +1080,7 @@ void main(void)
1080
1080
 
1081
1081
  vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
1082
1082
  }
1083
- `;class Vi extends Qe{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:wt.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(i,e.uniforms),super(e.program||xr.from(KT,qT),i),this._colorDirty=!1,this.uvMatrix=new Ll(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new ut(e.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=e.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture.alphaMode;ut.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class ZT extends go{constructor(t=100,e=100,i=10,s=10){super(),this.segWidth=i,this.segHeight=s,this.width=t,this.height=e,this.build()}build(){const t=this.segWidth*this.segHeight,e=[],i=[],s=[],n=this.segWidth-1,o=this.segHeight-1,a=this.width/n,l=this.height/o;for(let u=0;u<t;u++){const c=u%this.segWidth,d=u/this.segWidth|0;e.push(c*a,d*l),i.push(c/n,d/o)}const h=n*o;for(let u=0;u<h;u++){const c=u%n,d=u/n|0,p=d*this.segWidth+c,f=d*this.segWidth+c+1,m=(d+1)*this.segWidth+c,_=(d+1)*this.segWidth+c+1;s.push(p,f,m,f,_,m)}this.buffers[0].data=new Float32Array(e),this.buffers[1].data=new Float32Array(i),this.indexBuffer.data=new Uint16Array(s),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}}class JT extends go{constructor(t=200,e,i=0){super(new Float32Array(e.length*4),new Float32Array(e.length*4),new Uint16Array((e.length-1)*6)),this.points=e,this._width=t,this.textureScale=i,this.build()}get width(){return this._width}build(){const t=this.points;if(!t)return;const e=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),s=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),s.data=new Uint16Array((t.length-1)*6));const n=i.data,o=s.data;n[0]=0,n[1]=0,n[2]=0,n[3]=1;let a=0,l=t[0];const h=this._width*this.textureScale,u=t.length;for(let d=0;d<u;d++){const p=d*4;if(this.textureScale>0){const f=l.x-t[d].x,m=l.y-t[d].y,_=Math.sqrt(f*f+m*m);l=t[d],a+=_/h}else a=d/(u-1);n[p]=a,n[p+1]=0,n[p+2]=a,n[p+3]=1}let c=0;for(let d=0;d<u-1;d++){const p=d*2;o[c++]=p,o[c++]=p+1,o[c++]=p+2,o[c++]=p+2,o[c++]=p+1,o[c++]=p+3}i.update(),s.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let e=t[0],i,s=0,n=0;const o=this.buffers[0].data,a=t.length,l=this.textureScale>0?this.textureScale*this._width/2:this._width/2;for(let h=0;h<a;h++){const u=t[h],c=h*4;h<t.length-1?i=t[h+1]:i=u,n=-(i.x-e.x),s=i.y-e.y;const d=Math.sqrt(s*s+n*n);d<1e-6?(s=0,n=0):(s/=d,n/=d,s*=l,n*=l),o[c]=u.x+s,o[c+1]=u.y+n,o[c+2]=u.x-s,o[c+3]=u.y-n,e=u}this.buffers[0].update()}update(){this.textureScale>0?this.build():this.updateVertices()}}class QT extends oe{constructor(t,e,i){const s=new ZT(t.width,t.height,e,i),n=new Vi(Y.WHITE);super(s,n),this.texture=t,this.autoResize=!0}textureUpdated(){this._textureID=this.shader.texture._updateID;const t=this.geometry,{width:e,height:i}=this.shader.texture;this.autoResize&&(t.width!==e||t.height!==i)&&(t.width=this.shader.texture.width,t.height=this.shader.texture.height,t.build())}set texture(t){this.shader.texture!==t&&(this.shader.texture=t,this._textureID=-1,t.baseTexture.valid?this.textureUpdated():t.once("update",this.textureUpdated,this))}get texture(){return this.shader.texture}_render(t){this._textureID!==this.shader.texture._updateID&&this.textureUpdated(),super._render(t)}destroy(t){this.shader.texture.off("update",this.textureUpdated,this),super.destroy(t)}}const yo=10;class _o extends QT{constructor(t,e,i,s,n){var o,a,l,h;super(Y.WHITE,4,4),this._origWidth=t.orig.width,this._origHeight=t.orig.height,this._width=this._origWidth,this._height=this._origHeight,this._leftWidth=e??((o=t.defaultBorders)==null?void 0:o.left)??yo,this._rightWidth=s??((a=t.defaultBorders)==null?void 0:a.right)??yo,this._topHeight=i??((l=t.defaultBorders)==null?void 0:l.top)??yo,this._bottomHeight=n??((h=t.defaultBorders)==null?void 0:h.bottom)??yo,this.texture=t}textureUpdated(){this._textureID=this.shader.texture._updateID,this._refresh()}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}updateHorizontalVertices(){const t=this.vertices,e=this._getMinScale();t[9]=t[11]=t[13]=t[15]=this._topHeight*e,t[17]=t[19]=t[21]=t[23]=this._height-this._bottomHeight*e,t[25]=t[27]=t[29]=t[31]=this._height}updateVerticalVertices(){const t=this.vertices,e=this._getMinScale();t[2]=t[10]=t[18]=t[26]=this._leftWidth*e,t[4]=t[12]=t[20]=t[28]=this._width-this._rightWidth*e,t[6]=t[14]=t[22]=t[30]=this._width}_getMinScale(){const t=this._leftWidth+this._rightWidth,e=this._width>t?1:this._width/t,i=this._topHeight+this._bottomHeight,s=this._height>i?1:this._height/i;return Math.min(e,s)}get width(){return this._width}set width(t){this._width=t,this._refresh()}get height(){return this._height}set height(t){this._height=t,this._refresh()}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this._refresh()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this._refresh()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this._refresh()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this._refresh()}_refresh(){const t=this.texture,e=this.geometry.buffers[1].data;this._origWidth=t.orig.width,this._origHeight=t.orig.height;const i=1/this._origWidth,s=1/this._origHeight;e[0]=e[8]=e[16]=e[24]=0,e[1]=e[3]=e[5]=e[7]=0,e[6]=e[14]=e[22]=e[30]=1,e[25]=e[27]=e[29]=e[31]=1,e[2]=e[10]=e[18]=e[26]=i*this._leftWidth,e[4]=e[12]=e[20]=e[28]=1-i*this._rightWidth,e[9]=e[11]=e[13]=e[15]=s*this._topHeight,e[17]=e[19]=e[21]=e[23]=1-s*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()}}class tE extends oe{constructor(t=Y.EMPTY,e,i,s,n){const o=new go(e,i,s);o.getBuffer("aVertexPosition").static=!1;const a=new Vi(t);super(o,a,null,n),this.autoUpdate=!0}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}_render(t){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),super._render(t)}}class eE extends oe{constructor(t,e,i=0){const s=new JT(t.height,e,i),n=new Vi(t);i>0&&(t.baseTexture.wrapMode=pr.REPEAT),super(s,n),this.autoUpdate=!0}_render(t){const e=this.geometry;(this.autoUpdate||e._width!==this.shader.texture.height)&&(e._width=this.shader.texture.height,e.update()),super._render(t)}}class rE{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function iE(r,t){var i;let e=!1;if((i=r==null?void 0:r._textures)!=null&&i.length){for(let s=0;s<r._textures.length;s++)if(r._textures[s]instanceof Y){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function sE(r,t){if(r.baseTexture instanceof st){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function nE(r,t){if(r._texture&&r._texture instanceof Y){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function oE(r,t){return t instanceof Wl?(t.updateText(!0),!0):!1}function aE(r,t){if(t instanceof Pr){const e=t.toFontString();return Rr.measureFont(e),!0}return!1}function lE(r,t){if(r instanceof Wl){t.includes(r.style)||t.push(r.style),t.includes(r)||t.push(r);const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function hE(r,t){return r instanceof Pr?(t.includes(r)||t.push(r),!0):!1}const pp=class sm{constructor(t){this.limiter=new rE(sm.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(lE),this.registerFindHook(hE),this.registerFindHook(iE),this.registerFindHook(sE),this.registerFindHook(nE),this.registerUploadHook(oE),this.registerUploadHook(aE)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,pe.system.addOnce(this.tick,this,ii.UTILITY))):e()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed){for(let i=0,s=this.uploadHooks.length;i<s;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)pe.system.addOnce(this.tick,this,ii.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,i=t.length;e<i;e++)t[e]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof le)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&pe.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};pp.uploadsPerFrame=4;let vo=pp;Object.defineProperties(z,{UPLOADS_PER_FRAME:{get(){return vo.uploadsPerFrame},set(r){et("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),vo.uploadsPerFrame=r}}});function mp(r,t){return t instanceof st?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function uE(r,t){if(!(t instanceof Or))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let s=0;s<i.length;s++){const{texture:n}=i[s].style;n&&mp(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function cE(r,t){return r instanceof Or?(t.push(r),!0):!1}class gp extends vo{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(cE),this.registerUploadHook(mp),this.registerUploadHook(uE)}}gp.extension={name:"prepare",type:X.RendererSystem},j.add(gp);const yp=class Gs{constructor(t,e,i){this.linkedSheets=[],(t instanceof st||t instanceof Y)&&(t={texture:t,data:e,resolutionFilename:i});const{texture:s,data:n,resolutionFilename:o=null,cachePrefix:a=""}=t;this.cachePrefix=a,this._texture=s instanceof Y?s:null,this.baseTexture=s instanceof st?s:this._texture.baseTexture,this.textures={},this.animations={},this.data=n;const l=this.baseTexture.resource;this.resolution=this._updateResolution(o||(l?l.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:e}=this.data.meta;let i=Ze(t,null);return i===null&&(i=typeof e=="number"?e:parseFloat(e??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Gs.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Gs.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],o=n.frame;if(o){let a=null,l=null;const h=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,u=new at(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new at(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 at(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(l=new at(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new Y(this.baseTexture,a,u,l,n.rotated?2:0,n.anchor,n.borders),Y.addToCache(this.textures[s],this.cachePrefix+s.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Gs.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Gs.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};yp.BATCH_SIZE=1e3;let _p=yp;const dE=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function vp(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){const s=Ut.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{Object.assign(i,vp([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0))})}return i}const fE={extension:X.Asset,cache:{test:r=>r instanceof _p,getCacheableAssets:(r,t)=>vp(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&dE.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=z.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:X.LoadParser,priority:Le.Normal},async testParse(r,t){return Ut.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var u,c;const{texture:i,imageFilename:s,cachePrefix:n}=(t==null?void 0:t.data)??{};let o=Ut.dirname(t.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i&&i.baseTexture)a=i;else{const d=Zl(o+(s??r.meta.image),t.src);a=(await e.load([d]))[d]}const l=new _p({texture:a.baseTexture,data:r,resolutionFilename:t.src,cachePrefix:n});await l.parse();const h=(u=r==null?void 0:r.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(h)){const d=[];for(const f of h){if(typeof f!="string")continue;let m=o+f;(c=t.data)!=null&&c.ignoreMultiPack||(m=Zl(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const p=await Promise.all(d);l.linkedSheets=p,p.forEach(f=>{f.linkedSheets=[l].concat(l.linkedSheets.filter(m=>m!==f))})}return l},unload(r){r.destroy(!0)}}};j.add(fE);class xo{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class bo{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const o=e[n].match(/^[a-z]+/gm)[0],a=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const h in a){const u=a[h].split("="),c=u[0],d=u[1].replace(/"/gm,""),p=parseFloat(d),f=isNaN(p)?d:p;l[c]=f}i[o].push(l)}const s=new xo;return i.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),i.char.forEach(n=>s.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),i.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class uh{static test(t){const e=t;return typeof t!="string"&&"getElementsByTagName"in t&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new xo,i=t.getElementsByTagName("info"),s=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),l=t.getElementsByTagName("distanceField");for(let h=0;h<i.length;h++)e.info.push({face:i[h].getAttribute("face"),size:parseInt(i[h].getAttribute("size"),10)});for(let h=0;h<s.length;h++)e.common.push({lineHeight:parseInt(s[h].getAttribute("lineHeight"),10)});for(let h=0;h<n.length;h++)e.page.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});for(let h=0;h<o.length;h++){const u=o[h];e.char.push({id:parseInt(u.getAttribute("id"),10),page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xoffset:parseInt(u.getAttribute("xoffset"),10),yoffset:parseInt(u.getAttribute("yoffset"),10),xadvance:parseInt(u.getAttribute("xadvance"),10)})}for(let h=0;h<a.length;h++)e.kerning.push({first:parseInt(a[h].getAttribute("first"),10),second:parseInt(a[h].getAttribute("second"),10),amount:parseInt(a[h].getAttribute("amount"),10)});for(let h=0;h<l.length;h++)e.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return e}}class ch{static test(t){return typeof t=="string"&&t.includes("<font>")?uh.test(z.ADAPTER.parseXML(t)):!1}static parse(t){return uh.parse(z.ADAPTER.parseXML(t))}}const dh=[bo,uh,ch];function pE(r){for(let t=0;t<dh.length;t++)if(dh[t].test(r))return dh[t];return null}function mE(r,t,e,i,s,n){const o=e.fill;if(Array.isArray(o)){if(o.length===1)return o[0]}else return o;let a;const l=e.dropShadow?e.dropShadowDistance:0,h=e.padding||0,u=r.width/i-l-h*2,c=r.height/i-l-h*2,d=o.slice(),p=e.fillGradientStops.slice();if(!p.length){const f=d.length+1;for(let m=1;m<f;++m)p.push(m/f)}if(d.unshift(o[0]),p.unshift(0),d.push(o[o.length-1]),p.push(1),e.fillGradientType===Qn.LINEAR_VERTICAL){a=t.createLinearGradient(u/2,h,u/2,c+h);let f=0;const m=(n.fontProperties.fontSize+e.strokeThickness)/c;for(let _=0;_<s.length;_++){const g=n.lineHeight*_;for(let v=0;v<d.length;v++){let y=0;typeof p[v]=="number"?y=p[v]:y=v/d.length;const x=g/c+y*m;let b=Math.max(f,x);b=Math.min(b,1),a.addColorStop(b,d[v]),f=b}}}else{a=t.createLinearGradient(h,c/2,u+h,c/2);const f=d.length+1;let m=1;for(let _=0;_<d.length;_++){let g;typeof p[_]=="number"?g=p[_]:g=m/f,a.addColorStop(g,d[_]),m++}}return a}function gE(r,t,e,i,s,n,o){const a=e.text,l=e.fontProperties;t.translate(i,s),t.scale(n,n);const h=o.strokeThickness/2,u=-(o.strokeThickness/2);if(t.font=o.toFontString(),t.lineWidth=o.strokeThickness,t.textBaseline=o.textBaseline,t.lineJoin=o.lineJoin,t.miterLimit=o.miterLimit,t.fillStyle=mE(r,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const c=o.dropShadowColor,d=o.dropShadowBlur*n,p=o.dropShadowDistance*n;t.shadowColor=ut.shared.setValue(c).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*p,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*p}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,h,u+e.lineHeight-l.descent),o.fill&&t.fillText(a,h,u+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function wo(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function xp(r){return Array.from?Array.from(r):r.split("")}function yE(r){typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const s=r[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);const n=s[0].charCodeAt(0),o=s[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...xp(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Lr=class ar{constructor(t,e,i){var u;const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=Ze(o.file),h={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=n.lineHeight/l,this.chars={},this.pageTextures=h;for(let c=0;c<t.page.length;c++){const{id:d,file:p}=t.page[c];h[d]=e instanceof Array?e[c]:e[p],a!=null&&a.fieldType&&a.fieldType!=="none"&&(h[d].baseTexture.alphaMode=ae.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=Ve.OFF)}for(let c=0;c<t.char.length;c++){const{id:d,page:p}=t.char[c];let{x:f,y:m,width:_,height:g,xoffset:v,yoffset:y,xadvance:x}=t.char[c];f/=l,m/=l,_/=l,g/=l,v/=l,y/=l,x/=l;const b=new at(f+h[p].frame.x/l,m+h[p].frame.y/l,_,g);this.chars[d]={xOffset:v,yOffset:y,xAdvance:x,kerning:{},texture:new Y(h[p].baseTexture,b),page:p}}for(let c=0;c<t.kerning.length;c++){let{first:d,second:p,amount:f}=t.kerning[c];d/=l,p/=l,f/=l,this.chars[p]&&(this.chars[p].kerning[d]=f)}this.distanceFieldRange=a==null?void 0:a.distanceRange,this.distanceFieldType=((u=a==null?void 0:a.fieldType)==null?void 0:u.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let s;if(t instanceof xo)s=t;else{const o=pE(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof Y&&(e=[e]);const n=new ar(s,e,i);return ar.available[n.font]=n,n}static uninstall(t){const e=ar.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete ar.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:s,padding:n,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},ar.defaultOptions,i),u=yE(s),c=e instanceof Pr?e:new Pr(e),d=a,p=new xo;p.info[0]={face:c.fontFamily,size:c.fontSize},p.common[0]={lineHeight:c.fontSize};let f=0,m=0,_,g,v,y=0;const x=[];for(let E=0;E<u.length;E++){_||(_=z.ADAPTER.createCanvas(),_.width=a,_.height=l,g=_.getContext("2d"),v=new st(_,{resolution:o,...h}),x.push(new Y(v)),p.page.push({id:x.length-1,file:""}));const T=u[E],A=Rr.measureText(T,c,!1,_),M=A.width,S=Math.ceil(A.height),P=Math.ceil((c.fontStyle==="italic"?2:1)*M);if(m>=l-S*o){if(m===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${T}')`);--E,_=null,g=null,v=null,m=0,f=0,y=0;continue}if(y=Math.max(S+A.fontProperties.descent,y),P*o+f>=d){if(f===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${T}')`);--E,m+=y*o,m=Math.ceil(m),f=0,y=0;continue}gE(_,g,A,f,m,o,c);const C=wo(A.text);p.char.push({id:C,page:x.length-1,x:f/o,y:m/o,width:P,height:S,xoffset:0,yoffset:0,xadvance:M-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),f+=(P+2*n)*o,f=Math.ceil(f)}if(!(i!=null&&i.skipKerning))for(let E=0,T=u.length;E<T;E++){const A=u[E];for(let M=0;M<T;M++){const S=u[M],P=g.measureText(A).width,C=g.measureText(S).width,w=g.measureText(A+S).width-(P+C);w&&p.kerning.push({first:wo(A),second:wo(S),amount:w})}}const b=new ar(p,x,!0);return ar.available[t]!==void 0&&ar.uninstall(t),ar.available[t]=b,b}};Lr.ALPHA=[["a","z"],["A","Z"]," "],Lr.NUMERIC=[["0","9"]],Lr.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Lr.ASCII=[[" ","~"]],Lr.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Lr.ALPHANUMERIC},Lr.available={};let Fr=Lr;var _E=`// Pixi texture info\r
1083
+ `;class Oi extends ir{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:Ct.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(i,e.uniforms),super(e.program||xr.from(a1,n1),i),this._colorDirty=!1,this.uvMatrix=new gl(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new _t(e.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=e.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture.alphaMode;_t.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class o1 extends kn{constructor(t=100,e=100,i=10,s=10){super(),this.segWidth=i,this.segHeight=s,this.width=t,this.height=e,this.build()}build(){const t=this.segWidth*this.segHeight,e=[],i=[],s=[],n=this.segWidth-1,a=this.segHeight-1,o=this.width/n,l=this.height/a;for(let u=0;u<t;u++){const c=u%this.segWidth,d=u/this.segWidth|0;e.push(c*o,d*l),i.push(c/n,d/a)}const h=n*a;for(let u=0;u<h;u++){const c=u%n,d=u/n|0,p=d*this.segWidth+c,f=d*this.segWidth+c+1,g=(d+1)*this.segWidth+c,y=(d+1)*this.segWidth+c+1;s.push(p,f,g,f,y,g)}this.buffers[0].data=new Float32Array(e),this.buffers[1].data=new Float32Array(i),this.indexBuffer.data=new Uint16Array(s),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}}class l1 extends kn{constructor(t=200,e,i=0){super(new Float32Array(e.length*4),new Float32Array(e.length*4),new Uint16Array((e.length-1)*6)),this.points=e,this._width=t,this.textureScale=i,this.build()}get width(){return this._width}build(){const t=this.points;if(!t)return;const e=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),s=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),s.data=new Uint16Array((t.length-1)*6));const n=i.data,a=s.data;n[0]=0,n[1]=0,n[2]=0,n[3]=1;let o=0,l=t[0];const h=this._width*this.textureScale,u=t.length;for(let d=0;d<u;d++){const p=d*4;if(this.textureScale>0){const f=l.x-t[d].x,g=l.y-t[d].y,y=Math.sqrt(f*f+g*g);l=t[d],o+=y/h}else o=d/(u-1);n[p]=o,n[p+1]=0,n[p+2]=o,n[p+3]=1}let c=0;for(let d=0;d<u-1;d++){const p=d*2;a[c++]=p,a[c++]=p+1,a[c++]=p+2,a[c++]=p+2,a[c++]=p+1,a[c++]=p+3}i.update(),s.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let e=t[0],i,s=0,n=0;const a=this.buffers[0].data,o=t.length,l=this.textureScale>0?this.textureScale*this._width/2:this._width/2;for(let h=0;h<o;h++){const u=t[h],c=h*4;h<t.length-1?i=t[h+1]:i=u,n=-(i.x-e.x),s=i.y-e.y;const d=Math.sqrt(s*s+n*n);d<1e-6?(s=0,n=0):(s/=d,n/=d,s*=l,n*=l),a[c]=u.x+s,a[c+1]=u.y+n,a[c+2]=u.x-s,a[c+3]=u.y-n,e=u}this.buffers[0].update()}update(){this.textureScale>0?this.build():this.updateVertices()}}class h1 extends ue{constructor(t,e,i){const s=new o1(t.width,t.height,e,i),n=new Oi(it.WHITE);super(s,n),this.texture=t,this.autoResize=!0}textureUpdated(){this._textureID=this.shader.texture._updateID;const t=this.geometry,{width:e,height:i}=this.shader.texture;this.autoResize&&(t.width!==e||t.height!==i)&&(t.width=this.shader.texture.width,t.height=this.shader.texture.height,t.build())}set texture(t){this.shader.texture!==t&&(this.shader.texture=t,this._textureID=-1,t.baseTexture.valid?this.textureUpdated():t.once("update",this.textureUpdated,this))}get texture(){return this.shader.texture}_render(t){this._textureID!==this.shader.texture._updateID&&this.textureUpdated(),super._render(t)}destroy(t){this.shader.texture.off("update",this.textureUpdated,this),super.destroy(t)}}const Gn=10;class Hn extends h1{constructor(t,e,i,s,n){var a,o,l,h;super(it.WHITE,4,4),this._origWidth=t.orig.width,this._origHeight=t.orig.height,this._width=this._origWidth,this._height=this._origHeight,this._leftWidth=e??((a=t.defaultBorders)==null?void 0:a.left)??Gn,this._rightWidth=s??((o=t.defaultBorders)==null?void 0:o.right)??Gn,this._topHeight=i??((l=t.defaultBorders)==null?void 0:l.top)??Gn,this._bottomHeight=n??((h=t.defaultBorders)==null?void 0:h.bottom)??Gn,this.texture=t}textureUpdated(){this._textureID=this.shader.texture._updateID,this._refresh()}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}updateHorizontalVertices(){const t=this.vertices,e=this._getMinScale();t[9]=t[11]=t[13]=t[15]=this._topHeight*e,t[17]=t[19]=t[21]=t[23]=this._height-this._bottomHeight*e,t[25]=t[27]=t[29]=t[31]=this._height}updateVerticalVertices(){const t=this.vertices,e=this._getMinScale();t[2]=t[10]=t[18]=t[26]=this._leftWidth*e,t[4]=t[12]=t[20]=t[28]=this._width-this._rightWidth*e,t[6]=t[14]=t[22]=t[30]=this._width}_getMinScale(){const t=this._leftWidth+this._rightWidth,e=this._width>t?1:this._width/t,i=this._topHeight+this._bottomHeight,s=this._height>i?1:this._height/i;return Math.min(e,s)}get width(){return this._width}set width(t){this._width=t,this._refresh()}get height(){return this._height}set height(t){this._height=t,this._refresh()}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this._refresh()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this._refresh()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this._refresh()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this._refresh()}_refresh(){const t=this.texture,e=this.geometry.buffers[1].data;this._origWidth=t.orig.width,this._origHeight=t.orig.height;const i=1/this._origWidth,s=1/this._origHeight;e[0]=e[8]=e[16]=e[24]=0,e[1]=e[3]=e[5]=e[7]=0,e[6]=e[14]=e[22]=e[30]=1,e[25]=e[27]=e[29]=e[31]=1,e[2]=e[10]=e[18]=e[26]=i*this._leftWidth,e[4]=e[12]=e[20]=e[28]=1-i*this._rightWidth,e[9]=e[11]=e[13]=e[15]=s*this._topHeight,e[17]=e[19]=e[21]=e[23]=1-s*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()}}class u1 extends ue{constructor(t=it.EMPTY,e,i,s,n){const a=new kn(e,i,s);a.getBuffer("aVertexPosition").static=!1;const o=new Oi(t);super(a,o,null,n),this.autoUpdate=!0}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}_render(t){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),super._render(t)}}class c1 extends ue{constructor(t,e,i=0){const s=new l1(t.height,e,i),n=new Oi(t);i>0&&(t.baseTexture.wrapMode=mr.REPEAT),super(s,n),this.autoUpdate=!0}_render(t){const e=this.geometry;(this.autoUpdate||e._width!==this.shader.texture.height)&&(e._width=this.shader.texture.height,e.update()),super._render(t)}}class d1{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function f1(r,t){var i;let e=!1;if((i=r==null?void 0:r._textures)!=null&&i.length){for(let s=0;s<r._textures.length;s++)if(r._textures[s]instanceof it){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function p1(r,t){if(r.baseTexture instanceof dt){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function m1(r,t){if(r._texture&&r._texture instanceof it){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function g1(r,t){return t instanceof Sl?(t.updateText(!0),!0):!1}function y1(r,t){if(t instanceof Ir){const e=t.toFontString();return Cr.measureFont(e),!0}return!1}function _1(r,t){if(r instanceof Sl){t.includes(r.style)||t.push(r.style),t.includes(r)||t.push(r);const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function v1(r,t){return r instanceof Ir?(t.includes(r)||t.push(r),!0):!1}const Qf=class Zp{constructor(t){this.limiter=new d1(Zp.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(_1),this.registerFindHook(v1),this.registerFindHook(f1),this.registerFindHook(p1),this.registerFindHook(m1),this.registerUploadHook(g1),this.registerUploadHook(y1)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,_e.system.addOnce(this.tick,this,Jr.UTILITY))):e()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed){for(let i=0,s=this.uploadHooks.length;i<s;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)_e.system.addOnce(this.tick,this,Jr.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,i=t.length;e<i;e++)t[e]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof de)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&_e.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};Qf.uploadsPerFrame=4;let $n=Qf;Object.defineProperties(et,{UPLOADS_PER_FRAME:{get(){return $n.uploadsPerFrame},set(r){ct("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),$n.uploadsPerFrame=r}}});function tp(r,t){return t instanceof dt?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function x1(r,t){if(!(t instanceof gs))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let s=0;s<i.length;s++){const{texture:n}=i[s].style;n&&tp(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function b1(r,t){return r instanceof gs?(t.push(r),!0):!1}class ep extends $n{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(b1),this.registerUploadHook(tp),this.registerUploadHook(x1)}}ep.extension={name:"prepare",type:J.RendererSystem},rt.add(ep);const rp=class Ss{constructor(t,e,i){this.linkedSheets=[],(t instanceof dt||t instanceof it)&&(t={texture:t,data:e,resolutionFilename:i});const{texture:s,data:n,resolutionFilename:a=null,cachePrefix:o=""}=t;this.cachePrefix=o,this._texture=s instanceof it?s:null,this.baseTexture=s instanceof dt?s:this._texture.baseTexture,this.textures={},this.animations={},this.data=n;const l=this.baseTexture.resource;this.resolution=this._updateResolution(a||(l?l.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:e}=this.data.meta;let i=er(t,null);return i===null&&(i=typeof e=="number"?e:parseFloat(e??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Ss.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Ss.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],a=n.frame;if(a){let o=null,l=null;const h=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,u=new pt(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?o=new pt(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):o=new pt(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(l=new pt(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[s]=new it(this.baseTexture,o,u,l,n.rotated?2:0,n.anchor,n.borders),it.addToCache(this.textures[s],this.cachePrefix+s.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Ss.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Ss.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};rp.BATCH_SIZE=1e3;let ip=rp;const w1=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function sp(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){const s=Xt.dirname(r[0]);t.linkedSheets.forEach((n,a)=>{Object.assign(i,sp([`${s}/${t.data.meta.related_multi_packs[a]}`],n,!0))})}return i}const T1={extension:J.Asset,cache:{test:r=>r instanceof ip,getCacheableAssets:(r,t)=>sp(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&w1.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=et.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:J.LoadParser,priority:Ge.Normal},async testParse(r,t){return Xt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var u,c;const{texture:i,imageFilename:s,cachePrefix:n}=(t==null?void 0:t.data)??{};let a=Xt.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let o;if(i&&i.baseTexture)o=i;else{const d=Dl(a+(s??r.meta.image),t.src);o=(await e.load([d]))[d]}const l=new ip({texture:o.baseTexture,data:r,resolutionFilename:t.src,cachePrefix:n});await l.parse();const h=(u=r==null?void 0:r.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(h)){const d=[];for(const f of h){if(typeof f!="string")continue;let g=a+f;(c=t.data)!=null&&c.ignoreMultiPack||(g=Dl(g,t.src),d.push(e.load({src:g,data:{ignoreMultiPack:!0}})))}const p=await Promise.all(d);l.linkedSheets=p,p.forEach(f=>{f.linkedSheets=[l].concat(l.linkedSheets.filter(g=>g!==f))})}return l},unload(r){r.destroy(!0)}}};rt.add(T1);class Vn{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Xn{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const a=e[n].match(/^[a-z]+/gm)[0],o=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const h in o){const u=o[h].split("="),c=u[0],d=u[1].replace(/"/gm,""),p=parseFloat(d),f=isNaN(p)?d:p;l[c]=f}i[a].push(l)}const s=new Vn;return i.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),i.char.forEach(n=>s.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),i.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class Wl{static test(t){const e=t;return typeof t!="string"&&"getElementsByTagName"in t&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new Vn,i=t.getElementsByTagName("info"),s=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),a=t.getElementsByTagName("char"),o=t.getElementsByTagName("kerning"),l=t.getElementsByTagName("distanceField");for(let h=0;h<i.length;h++)e.info.push({face:i[h].getAttribute("face"),size:parseInt(i[h].getAttribute("size"),10)});for(let h=0;h<s.length;h++)e.common.push({lineHeight:parseInt(s[h].getAttribute("lineHeight"),10)});for(let h=0;h<n.length;h++)e.page.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});for(let h=0;h<a.length;h++){const u=a[h];e.char.push({id:parseInt(u.getAttribute("id"),10),page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xoffset:parseInt(u.getAttribute("xoffset"),10),yoffset:parseInt(u.getAttribute("yoffset"),10),xadvance:parseInt(u.getAttribute("xadvance"),10)})}for(let h=0;h<o.length;h++)e.kerning.push({first:parseInt(o[h].getAttribute("first"),10),second:parseInt(o[h].getAttribute("second"),10),amount:parseInt(o[h].getAttribute("amount"),10)});for(let h=0;h<l.length;h++)e.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return e}}class zl{static test(t){return typeof t=="string"&&t.includes("<font>")?Wl.test(et.ADAPTER.parseXML(t)):!1}static parse(t){return Wl.parse(et.ADAPTER.parseXML(t))}}const jl=[Xn,Wl,zl];function E1(r){for(let t=0;t<jl.length;t++)if(jl[t].test(r))return jl[t];return null}function A1(r,t,e,i,s,n){const a=e.fill;if(Array.isArray(a)){if(a.length===1)return a[0]}else return a;let o;const l=e.dropShadow?e.dropShadowDistance:0,h=e.padding||0,u=r.width/i-l-h*2,c=r.height/i-l-h*2,d=a.slice(),p=e.fillGradientStops.slice();if(!p.length){const f=d.length+1;for(let g=1;g<f;++g)p.push(g/f)}if(d.unshift(a[0]),p.unshift(0),d.push(a[a.length-1]),p.push(1),e.fillGradientType===Tn.LINEAR_VERTICAL){o=t.createLinearGradient(u/2,h,u/2,c+h);let f=0;const g=(n.fontProperties.fontSize+e.strokeThickness)/c;for(let y=0;y<s.length;y++){const m=n.lineHeight*y;for(let _=0;_<d.length;_++){let v=0;typeof p[_]=="number"?v=p[_]:v=_/d.length;const x=m/c+v*g;let b=Math.max(f,x);b=Math.min(b,1),o.addColorStop(b,d[_]),f=b}}}else{o=t.createLinearGradient(h,c/2,u+h,c/2);const f=d.length+1;let g=1;for(let y=0;y<d.length;y++){let m;typeof p[y]=="number"?m=p[y]:m=g/f,o.addColorStop(m,d[y]),g++}}return o}function S1(r,t,e,i,s,n,a){const o=e.text,l=e.fontProperties;t.translate(i,s),t.scale(n,n);const h=a.strokeThickness/2,u=-(a.strokeThickness/2);if(t.font=a.toFontString(),t.lineWidth=a.strokeThickness,t.textBaseline=a.textBaseline,t.lineJoin=a.lineJoin,t.miterLimit=a.miterLimit,t.fillStyle=A1(r,t,a,n,[o],e),t.strokeStyle=a.stroke,a.dropShadow){const c=a.dropShadowColor,d=a.dropShadowBlur*n,p=a.dropShadowDistance*n;t.shadowColor=_t.shared.setValue(c).setAlpha(a.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(a.dropShadowAngle)*p,t.shadowOffsetY=Math.sin(a.dropShadowAngle)*p}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;a.stroke&&a.strokeThickness&&t.strokeText(o,h,u+e.lineHeight-l.descent),a.fill&&t.fillText(o,h,u+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Wn(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function np(r){return Array.from?Array.from(r):r.split("")}function C1(r){typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const s=r[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);const n=s[0].charCodeAt(0),a=s[1].charCodeAt(0);if(a<n)throw new Error("[BitmapFont]: Invalid character range.");for(let o=n,l=a;o<=l;o++)t.push(String.fromCharCode(o))}else t.push(...np(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Dr=class hr{constructor(t,e,i){var u;const[s]=t.info,[n]=t.common,[a]=t.page,[o]=t.distanceField,l=er(a.file),h={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=n.lineHeight/l,this.chars={},this.pageTextures=h;for(let c=0;c<t.page.length;c++){const{id:d,file:p}=t.page[c];h[d]=e instanceof Array?e[c]:e[p],o!=null&&o.fieldType&&o.fieldType!=="none"&&(h[d].baseTexture.alphaMode=ce.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=Ke.OFF)}for(let c=0;c<t.char.length;c++){const{id:d,page:p}=t.char[c];let{x:f,y:g,width:y,height:m,xoffset:_,yoffset:v,xadvance:x}=t.char[c];f/=l,g/=l,y/=l,m/=l,_/=l,v/=l,x/=l;const b=new pt(f+h[p].frame.x/l,g+h[p].frame.y/l,y,m);this.chars[d]={xOffset:_,yOffset:v,xAdvance:x,kerning:{},texture:new it(h[p].baseTexture,b),page:p}}for(let c=0;c<t.kerning.length;c++){let{first:d,second:p,amount:f}=t.kerning[c];d/=l,p/=l,f/=l,this.chars[p]&&(this.chars[p].kerning[d]=f)}this.distanceFieldRange=o==null?void 0:o.distanceRange,this.distanceFieldType=((u=o==null?void 0:o.fieldType)==null?void 0:u.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let s;if(t instanceof Vn)s=t;else{const a=E1(t);if(!a)throw new Error("Unrecognized data format for font.");s=a.parse(t)}e instanceof it&&(e=[e]);const n=new hr(s,e,i);return hr.available[n.font]=n,n}static uninstall(t){const e=hr.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete hr.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:s,padding:n,resolution:a,textureWidth:o,textureHeight:l,...h}=Object.assign({},hr.defaultOptions,i),u=C1(s),c=e instanceof Ir?e:new Ir(e),d=o,p=new Vn;p.info[0]={face:c.fontFamily,size:c.fontSize},p.common[0]={lineHeight:c.fontSize};let f=0,g=0,y,m,_,v=0;const x=[];for(let R=0;R<u.length;R++){y||(y=et.ADAPTER.createCanvas(),y.width=o,y.height=l,m=y.getContext("2d"),_=new dt(y,{resolution:a,...h}),x.push(new it(_)),p.page.push({id:x.length-1,file:""}));const w=u[R],D=Cr.measureText(w,c,!1,y),U=D.width,M=Math.ceil(D.height),F=Math.ceil((c.fontStyle==="italic"?2:1)*U);if(g>=l-M*a){if(g===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${w}')`);--R,y=null,m=null,_=null,g=0,f=0,v=0;continue}if(v=Math.max(M+D.fontProperties.descent,v),F*a+f>=d){if(f===0)throw new Error(`[BitmapFont] textureWidth ${o}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${w}')`);--R,g+=v*a,g=Math.ceil(g),f=0,v=0;continue}S1(y,m,D,f,g,a,c);const S=Wn(D.text);p.char.push({id:S,page:x.length-1,x:f/a,y:g/a,width:F,height:M,xoffset:0,yoffset:0,xadvance:U-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),f+=(F+2*n)*a,f=Math.ceil(f)}if(!(i!=null&&i.skipKerning))for(let R=0,w=u.length;R<w;R++){const D=u[R];for(let U=0;U<w;U++){const M=u[U],F=m.measureText(D).width,S=m.measureText(M).width,I=m.measureText(D+M).width-(F+S);I&&p.kerning.push({first:Wn(D),second:Wn(M),amount:I})}}const b=new hr(p,x,!0);return hr.available[t]!==void 0&&hr.uninstall(t),hr.available[t]=b,b}};Dr.ALPHA=[["a","z"],["A","Z"]," "],Dr.NUMERIC=[["0","9"]],Dr.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Dr.ASCII=[[" ","~"]],Dr.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Dr.ALPHANUMERIC},Dr.available={};let Br=Dr;var I1=`// Pixi texture info\r
1084
1084
  varying vec2 vTextureCoord;\r
1085
1085
  uniform sampler2D uSampler;\r
1086
1086
  \r
@@ -1118,7 +1118,7 @@ void main(void) {\r
1118
1118
  // NPM Textures, NPM outputs\r
1119
1119
  gl_FragColor = vec4(uColor.rgb, coverage);\r
1120
1120
  }\r
1121
- `,vE=`// Mesh material default fragment\r
1121
+ `,R1=`// Mesh material default fragment\r
1122
1122
  attribute vec2 aVertexPosition;\r
1123
1123
  attribute vec2 aTextureCoord;\r
1124
1124
  \r
@@ -1134,15 +1134,15 @@ void main(void)\r
1134
1134
  \r
1135
1135
  vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
1136
1136
  }\r
1137
- `;const bp=[],wp=[],Tp=[],xE=class nm extends le{constructor(t,e={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},nm.styleDefaults,e);if(!Fr.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new ut(s),this._font=void 0,this._fontName=a,this._fontSize=l,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new vr(()=>{this.dirty=!0},this,0,0),this._roundPixels=z.ROUND_PIXELS,this.dirty=!0,this._resolution=z.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var P;const t=Fr.available[this._fontName],e=this.fontSize,i=e/t.size,s=new dt,n=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,`
1138
- `)||" ",h=xp(l),u=this._maxWidth*t.size/e,c=t.distanceFieldType==="none"?bp:wp;let d=null,p=0,f=0,m=0,_=-1,g=0,v=0,y=0,x=0;for(let C=0;C<h.length;C++){const w=h[C],D=wo(w);if(/(?:\s)/.test(w)&&(_=C,g=p,x++),w==="\r"||w===`
1139
- `){o.push(p),a.push(-1),f=Math.max(f,p),++m,++v,s.x=0,s.y+=t.lineHeight,d=null,x=0;continue}const N=t.chars[D];if(!N)continue;d&&N.kerning[d]&&(s.x+=N.kerning[d]);const V=Tp.pop()||{texture:Y.EMPTY,line:0,charCode:0,prevSpaces:0,position:new dt};V.texture=N.texture,V.line=m,V.charCode=D,V.position.x=Math.round(s.x+N.xOffset+this._letterSpacing/2),V.position.y=Math.round(s.y+N.yOffset),V.prevSpaces=x,n.push(V),p=V.position.x+Math.max(N.xAdvance-N.xOffset,N.texture.orig.width),s.x+=N.xAdvance+this._letterSpacing,y=Math.max(y,N.yOffset+N.texture.height),d=D,_!==-1&&u>0&&s.x>u&&(++v,Yr(n,1+_-v,1+C-_),C=_,_=-1,o.push(g),a.push(n.length>0?n[n.length-1].prevSpaces:0),f=Math.max(f,g),m++,s.x=0,s.y+=t.lineHeight,d=null,x=0)}const b=h[h.length-1];b!=="\r"&&b!==`
1140
- `&&(/(?:\s)/.test(b)&&(p=g),o.push(p),f=Math.max(f,p),a.push(-1));const E=[];for(let C=0;C<=m;C++){let w=0;this._align==="right"?w=f-o[C]:this._align==="center"?w=(f-o[C])/2:this._align==="justify"&&(w=a[C]<0?0:(f-o[C])/a[C]),E.push(w)}const T=n.length,A={},M=[],S=this._activePagesMeshData;c.push(...S);for(let C=0;C<T;C++){const w=n[C].texture,D=w.baseTexture.uid;if(!A[D]){let N=c.pop();if(!N){const H=new go;let W,rt;t.distanceFieldType==="none"?(W=new Vi(Y.EMPTY),rt=U.NORMAL):(W=new Vi(Y.EMPTY,{program:xr.from(vE,_E),uniforms:{uFWidth:0}}),rt=U.NORMAL_NPM);const I=new oe(H,W);I.blendMode=rt,N={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:I,vertices:null,uvs:null,indices:null}}N.index=0,N.indexCount=0,N.vertexCount=0,N.uvsCount=0,N.total=0;const{_textureCache:V}=this;V[D]=V[D]||new Y(w.baseTexture),N.mesh.texture=V[D],N.mesh.tint=this._tintColor.value,M.push(N),A[D]=N}A[D].total++}for(let C=0;C<S.length;C++)M.includes(S[C])||this.removeChild(S[C].mesh);for(let C=0;C<M.length;C++)M[C].mesh.parent!==this&&this.addChild(M[C].mesh);this._activePagesMeshData=M;for(const C in A){const w=A[C],D=w.total;if(!(((P=w.indices)==null?void 0:P.length)>6*D)||w.vertices.length<oe.BATCHABLE_SIZE*2)w.vertices=new Float32Array(4*2*D),w.uvs=new Float32Array(4*2*D),w.indices=new Uint16Array(6*D);else{const N=w.total,V=w.vertices;for(let H=N*4*2;H<V.length;H++)V[H]=0}w.mesh.size=6*D}for(let C=0;C<T;C++){const w=n[C];let D=w.position.x+E[w.line]*(this._align==="justify"?w.prevSpaces:1);this._roundPixels&&(D=Math.round(D));const N=D*i,V=w.position.y*i,H=w.texture,W=A[H.baseTexture.uid],rt=H.frame,I=H._uvs,F=W.index++;W.indices[F*6+0]=0+F*4,W.indices[F*6+1]=1+F*4,W.indices[F*6+2]=2+F*4,W.indices[F*6+3]=0+F*4,W.indices[F*6+4]=2+F*4,W.indices[F*6+5]=3+F*4,W.vertices[F*8+0]=N,W.vertices[F*8+1]=V,W.vertices[F*8+2]=N+rt.width*i,W.vertices[F*8+3]=V,W.vertices[F*8+4]=N+rt.width*i,W.vertices[F*8+5]=V+rt.height*i,W.vertices[F*8+6]=N,W.vertices[F*8+7]=V+rt.height*i,W.uvs[F*8+0]=I.x0,W.uvs[F*8+1]=I.y0,W.uvs[F*8+2]=I.x1,W.uvs[F*8+3]=I.y1,W.uvs[F*8+4]=I.x2,W.uvs[F*8+5]=I.y2,W.uvs[F*8+6]=I.x3,W.uvs[F*8+7]=I.y3}this._textWidth=f*i,this._textHeight=(s.y+t.lineHeight)*i;for(const C in A){const w=A[C];if(this.anchor.x!==0||this.anchor.y!==0){let H=0;const W=this._textWidth*this.anchor.x,rt=this._textHeight*this.anchor.y;for(let I=0;I<w.total;I++)w.vertices[H++]-=W,w.vertices[H++]-=rt,w.vertices[H++]-=W,w.vertices[H++]-=rt,w.vertices[H++]-=W,w.vertices[H++]-=rt,w.vertices[H++]-=W,w.vertices[H++]-=rt}this._maxLineHeight=y*i;const D=w.mesh.geometry.getBuffer("aVertexPosition"),N=w.mesh.geometry.getBuffer("aTextureCoord"),V=w.mesh.geometry.getIndex();D.data=w.vertices,N.data=w.uvs,V.data=w.indices,D.update(),N.update(),V.update()}for(let C=0;C<n.length;C++)Tp.push(n[C]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:i,size:s}=Fr.available[this._fontName];if(i!=="none"){const{a:n,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(n*n+o*o),u=Math.sqrt(a*a+l*l),c=(Math.abs(h)+Math.abs(u))/2,d=this.fontSize/s,p=t._view.resolution;for(const f of this._activePagesMeshData)f.mesh.shader.uniforms.uFWidth=c*e*d*p}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=Fr.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let e=0;e<this._activePagesMeshData.length;e++)this._activePagesMeshData[e].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!Fr.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??Fr.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:e}=this,i=Fr.available[this._fontName].distanceFieldType==="none"?bp:wp;i.push(...this._activePagesMeshData);for(const s of this._activePagesMeshData)this.removeChild(s.mesh);this._activePagesMeshData=[],i.filter(s=>e[s.mesh.texture.baseTexture.uid]).forEach(s=>{s.mesh.texture=Y.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};xE.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const bE=[".xml",".fnt"],wE={extension:{type:X.LoadParser,priority:Le.Normal},name:"loadBitmapFont",test(r){return bE.includes(Ut.extname(r).toLowerCase())},async testParse(r){return bo.test(r)||ch.test(r)},async parse(r,t,e){const i=bo.test(r)?bo.parse(r):ch.parse(r),{src:s}=t,{page:n}=i,o=[];for(let h=0;h<n.length;++h){const u=n[h].file;let c=Ut.join(Ut.dirname(s),u);c=Zl(c,s),o.push(c)}const a=await e.load(o),l=o.map(h=>a[h]);return Fr.install(i,l,!0)},async load(r,t){return(await z.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};j.add(wE);const fh=class ji extends Pr{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new ji(Object.keys(ji.defaultOptions).reduce((e,i)=>({...e,[i]:t[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete ji.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=ji;if(i[t]){const s=i[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return z.ADAPTER.fetch(t).then(s=>s.blob()).then(async s=>new Promise((n,o)=>{const a=URL.createObjectURL(s),l=new FileReader;l.onload=()=>n([a,l.result]),l.onerror=o,l.readAsDataURL(s)})).then(async([s,n])=>{const o=Object.assign({family:Ut.basename(t,Ut.extname(t)),weight:"normal",style:"normal",display:"auto",src:s,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);i[t]=o,this._fonts.push(o),this.styleID++;const a=new FontFace(o.family,`url(${o.src})`,{weight:o.weight,style:o.style,display:o.display});o.fontFace=a,await a.load(),document.fonts.add(a),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const e=t.filter(i=>!this._overrides.includes(i));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(i=>this._overrides.includes(i));e.length>0&&(this._overrides=this._overrides.filter(i=>!e.includes(i)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((t,e)=>`${t}
1137
+ `;const ap=[],op=[],lp=[],P1=class Jp extends de{constructor(t,e={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:a,fontName:o,fontSize:l}=Object.assign({},Jp.styleDefaults,e);if(!Br.available[o])throw new Error(`Missing BitmapFont "${o}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new _t(s),this._font=void 0,this._fontName=o,this._fontSize=l,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=a,this._anchor=new vr(()=>{this.dirty=!0},this,0,0),this._roundPixels=et.ROUND_PIXELS,this.dirty=!0,this._resolution=et.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var F;const t=Br.available[this._fontName],e=this.fontSize,i=e/t.size,s=new vt,n=[],a=[],o=[],l=this._text.replace(/(?:\r\n|\r)/g,`
1138
+ `)||" ",h=np(l),u=this._maxWidth*t.size/e,c=t.distanceFieldType==="none"?ap:op;let d=null,p=0,f=0,g=0,y=-1,m=0,_=0,v=0,x=0;for(let S=0;S<h.length;S++){const I=h[S],H=Wn(I);if(/(?:\s)/.test(I)&&(y=S,m=p,x++),I==="\r"||I===`
1139
+ `){a.push(p),o.push(-1),f=Math.max(f,p),++g,++_,s.x=0,s.y+=t.lineHeight,d=null,x=0;continue}const j=t.chars[H];if(!j)continue;d&&j.kerning[d]&&(s.x+=j.kerning[d]);const A=lp.pop()||{texture:it.EMPTY,line:0,charCode:0,prevSpaces:0,position:new vt};A.texture=j.texture,A.line=g,A.charCode=H,A.position.x=Math.round(s.x+j.xOffset+this._letterSpacing/2),A.position.y=Math.round(s.y+j.yOffset),A.prevSpaces=x,n.push(A),p=A.position.x+Math.max(j.xAdvance-j.xOffset,j.texture.orig.width),s.x+=j.xAdvance+this._letterSpacing,v=Math.max(v,j.yOffset+j.texture.height),d=H,y!==-1&&u>0&&s.x>u&&(++_,Vr(n,1+y-_,1+S-y),S=y,y=-1,a.push(m),o.push(n.length>0?n[n.length-1].prevSpaces:0),f=Math.max(f,m),g++,s.x=0,s.y+=t.lineHeight,d=null,x=0)}const b=h[h.length-1];b!=="\r"&&b!==`
1140
+ `&&(/(?:\s)/.test(b)&&(p=m),a.push(p),f=Math.max(f,p),o.push(-1));const R=[];for(let S=0;S<=g;S++){let I=0;this._align==="right"?I=f-a[S]:this._align==="center"?I=(f-a[S])/2:this._align==="justify"&&(I=o[S]<0?0:(f-a[S])/o[S]),R.push(I)}const w=n.length,D={},U=[],M=this._activePagesMeshData;c.push(...M);for(let S=0;S<w;S++){const I=n[S].texture,H=I.baseTexture.uid;if(!D[H]){let j=c.pop();if(!j){const C=new kn;let T,k;t.distanceFieldType==="none"?(T=new Oi(it.EMPTY),k=q.NORMAL):(T=new Oi(it.EMPTY,{program:xr.from(R1,I1),uniforms:{uFWidth:0}}),k=q.NORMAL_NPM);const E=new ue(C,T);E.blendMode=k,j={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:E,vertices:null,uvs:null,indices:null}}j.index=0,j.indexCount=0,j.vertexCount=0,j.uvsCount=0,j.total=0;const{_textureCache:A}=this;A[H]=A[H]||new it(I.baseTexture),j.mesh.texture=A[H],j.mesh.tint=this._tintColor.value,U.push(j),D[H]=j}D[H].total++}for(let S=0;S<M.length;S++)U.includes(M[S])||this.removeChild(M[S].mesh);for(let S=0;S<U.length;S++)U[S].mesh.parent!==this&&this.addChild(U[S].mesh);this._activePagesMeshData=U;for(const S in D){const I=D[S],H=I.total;if(!(((F=I.indices)==null?void 0:F.length)>6*H)||I.vertices.length<ue.BATCHABLE_SIZE*2)I.vertices=new Float32Array(4*2*H),I.uvs=new Float32Array(4*2*H),I.indices=new Uint16Array(6*H);else{const j=I.total,A=I.vertices;for(let C=j*4*2;C<A.length;C++)A[C]=0}I.mesh.size=6*H}for(let S=0;S<w;S++){const I=n[S];let H=I.position.x+R[I.line]*(this._align==="justify"?I.prevSpaces:1);this._roundPixels&&(H=Math.round(H));const j=H*i,A=I.position.y*i,C=I.texture,T=D[C.baseTexture.uid],k=C.frame,E=C._uvs,P=T.index++;T.indices[P*6+0]=0+P*4,T.indices[P*6+1]=1+P*4,T.indices[P*6+2]=2+P*4,T.indices[P*6+3]=0+P*4,T.indices[P*6+4]=2+P*4,T.indices[P*6+5]=3+P*4,T.vertices[P*8+0]=j,T.vertices[P*8+1]=A,T.vertices[P*8+2]=j+k.width*i,T.vertices[P*8+3]=A,T.vertices[P*8+4]=j+k.width*i,T.vertices[P*8+5]=A+k.height*i,T.vertices[P*8+6]=j,T.vertices[P*8+7]=A+k.height*i,T.uvs[P*8+0]=E.x0,T.uvs[P*8+1]=E.y0,T.uvs[P*8+2]=E.x1,T.uvs[P*8+3]=E.y1,T.uvs[P*8+4]=E.x2,T.uvs[P*8+5]=E.y2,T.uvs[P*8+6]=E.x3,T.uvs[P*8+7]=E.y3}this._textWidth=f*i,this._textHeight=(s.y+t.lineHeight)*i;for(const S in D){const I=D[S];if(this.anchor.x!==0||this.anchor.y!==0){let C=0;const T=this._textWidth*this.anchor.x,k=this._textHeight*this.anchor.y;for(let E=0;E<I.total;E++)I.vertices[C++]-=T,I.vertices[C++]-=k,I.vertices[C++]-=T,I.vertices[C++]-=k,I.vertices[C++]-=T,I.vertices[C++]-=k,I.vertices[C++]-=T,I.vertices[C++]-=k}this._maxLineHeight=v*i;const H=I.mesh.geometry.getBuffer("aVertexPosition"),j=I.mesh.geometry.getBuffer("aTextureCoord"),A=I.mesh.geometry.getIndex();H.data=I.vertices,j.data=I.uvs,A.data=I.indices,H.update(),j.update(),A.update()}for(let S=0;S<n.length;S++)lp.push(n[S]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:i,size:s}=Br.available[this._fontName];if(i!=="none"){const{a:n,b:a,c:o,d:l}=this.worldTransform,h=Math.sqrt(n*n+a*a),u=Math.sqrt(o*o+l*l),c=(Math.abs(h)+Math.abs(u))/2,d=this.fontSize/s,p=t._view.resolution;for(const f of this._activePagesMeshData)f.mesh.shader.uniforms.uFWidth=c*e*d*p}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=Br.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let e=0;e<this._activePagesMeshData.length;e++)this._activePagesMeshData[e].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!Br.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??Br.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:e}=this,i=Br.available[this._fontName].distanceFieldType==="none"?ap:op;i.push(...this._activePagesMeshData);for(const s of this._activePagesMeshData)this.removeChild(s.mesh);this._activePagesMeshData=[],i.filter(s=>e[s.mesh.texture.baseTexture.uid]).forEach(s=>{s.mesh.texture=it.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};P1.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const M1=[".xml",".fnt"],D1={extension:{type:J.LoadParser,priority:Ge.Normal},name:"loadBitmapFont",test(r){return M1.includes(Xt.extname(r).toLowerCase())},async testParse(r){return Xn.test(r)||zl.test(r)},async parse(r,t,e){const i=Xn.test(r)?Xn.parse(r):zl.parse(r),{src:s}=t,{page:n}=i,a=[];for(let h=0;h<n.length;++h){const u=n[h].file;let c=Xt.join(Xt.dirname(s),u);c=Dl(c,s),a.push(c)}const o=await e.load(a),l=a.map(h=>o[h]);return Br.install(i,l,!0)},async load(r,t){return(await et.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};rt.add(D1);const Yl=class Vi extends Ir{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new Vi(Object.keys(Vi.defaultOptions).reduce((e,i)=>({...e,[i]:t[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete Vi.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=Vi;if(i[t]){const s=i[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return et.ADAPTER.fetch(t).then(s=>s.blob()).then(async s=>new Promise((n,a)=>{const o=URL.createObjectURL(s),l=new FileReader;l.onload=()=>n([o,l.result]),l.onerror=a,l.readAsDataURL(s)})).then(async([s,n])=>{const a=Object.assign({family:Xt.basename(t,Xt.extname(t)),weight:"normal",style:"normal",display:"auto",src:s,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);i[t]=a,this._fonts.push(a),this.styleID++;const o=new FontFace(a.family,`url(${a.src})`,{weight:a.weight,style:a.style,display:a.display});a.fontFace=o,await o.load(),document.fonts.add(o),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const e=t.filter(i=>!this._overrides.includes(i));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(i=>this._overrides.includes(i));e.length>0&&(this._overrides=this._overrides.filter(i=>!e.includes(i)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((t,e)=>`${t}
1141
1141
  @font-face {
1142
1142
  font-family: "${e.family}";
1143
1143
  src: url('${e.dataSrc}');
1144
1144
  font-weight: ${e.weight};
1145
1145
  font-style: ${e.style};
1146
1146
  font-display: ${e.display};
1147
- }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=xd(t)),typeof t=="number"?vd(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,ji.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=z.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};fh.availableFonts={},fh.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let ph=fh;const To=class Yi extends er{constructor(t="",e={}){super(Y.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,s=Y.from(i,{scaleMode:z.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new at,s.trim=new at,this.texture=s;const n="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(n,"svg"),l=document.createElementNS(n,"foreignObject"),h=document.createElementNS(o,"div"),u=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=Yi.defaultMaxWidth,this.maxHeight=Yi.defaultMaxHeight,this._domElement=h,this._styleElement=u,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(u),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Yi.defaultAutoResolution,this._resolution=Yi.defaultResolution??z.RESOLUTION,this.text=t,this.style=e}measureText(t){var u,c;const{text:e,style:i,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(s)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=n;(o>this.maxWidth||a>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const l=Math.min(this.maxWidth,Math.ceil(o)),h=Math.min(this.maxHeight,Math.ceil(a));return this._svgRoot.setAttribute("width",l.toString()),this._svgRoot.setAttribute("height",h.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(u=this._style)==null?void 0:u.toCSS(s)}),this._styleElement.textContent=(c=this._style)==null?void 0:c.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:s}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:o}=this.measureText();i.width=s.width=Math.ceil(Math.max(1,n)),i.height=s.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{s.onload=async()=>{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.src=s.src,s.onload=null,s.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:s}=this,{padding:n}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/s,e.trim.height=e._frame.height=i.height/s,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,s),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){var i,s,n,o,a;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Yi.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(s=this._svgRoot)==null||s.remove(),this._svgRoot=e,(n=this._domElement)==null||n.remove(),this._domElement=e,(o=this._foreignObject)==null||o.remove(),this._foreignObject=e,(a=this._styleElement)==null||a.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=_r(this.scale.x)||1;this.scale.x=e*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const e=_r(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof ph?(this.ownsStyle=!1,this._style=t):t instanceof Pr?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=ph.from(t)):(this.ownsStyle=!0,this._style=new ph(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")}};To.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},To.defaultMaxWidth=2024,To.defaultMaxHeight=2024,To.defaultAutoResolution=!0;const Nr=new at;class Ep{constructor(t){this.renderer=t}async image(t,e,i,s){const n=new Image;return n.src=await this.base64(t,e,i,s),n}async base64(t,e,i,s){const n=this.canvas(t,s);if(n.toBlob!==void 0)return new Promise((o,a)=>{n.toBlob(l=>{if(!l){a(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>o(h.result),h.onerror=a,h.readAsDataURL(l)},e,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const o=await n.convertToBlob({type:e,quality:i});return new Promise((a,l)=>{const h=new FileReader;h.onload=()=>a(h.result),h.onerror=l,h.readAsDataURL(o)})}throw new Error("CanvasExtract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const i=this.renderer;if(!i)throw new Error("The CanvasExtract has already been destroyed");let s,n,o;t&&(t instanceof tr?o=t:(o=i.generateTexture(t,{region:e,resolution:i.resolution}),e&&(Nr.width=e.width,Nr.height=e.height,e=Nr))),o?(s=o.baseTexture._canvasRenderTarget.context,n=o.baseTexture._canvasRenderTarget.resolution,e=e??o.frame):(s=i.canvasContext.rootContext,n=i._view.resolution,e||(e=Nr,e.width=i.width/n,e.height=i.height/n));const a=Math.round(e.x*n),l=Math.round(e.y*n),h=Math.max(Math.round(e.width*n),1),u=Math.max(Math.round(e.height*n),1),c=new vs(h,u,1),d=s.getImageData(a,l,h,u);return c.context.putImageData(d,0,0),c.canvas}pixels(t,e){const i=this.renderer;if(!i)throw new Error("The CanvasExtract has already been destroyed");let s,n,o;t&&(t instanceof tr?o=t:(o=i.generateTexture(t,{region:e,resolution:i.resolution}),e&&(Nr.width=e.width,Nr.height=e.height,e=Nr))),o?(s=o.baseTexture._canvasRenderTarget.context,n=o.baseTexture._canvasRenderTarget.resolution,e=e??o.frame):(s=i.canvasContext.rootContext,n=i.resolution,e||(e=Nr,e.width=i.width/n,e.height=i.height/n));const a=Math.round(e.x*n),l=Math.round(e.y*n),h=Math.max(Math.round(e.width*n),1),u=Math.max(Math.round(e.height*n),1);return s.getImageData(a,l,h,u).data}destroy(){this.renderer=null}}Ep.extension={name:"extract",type:X.CanvasRendererSystem},j.add(Ep);let mh;const Ms=new wt;Or.prototype.generateCanvasTexture=function(r,t=1){const e=this.getLocalBounds(new at);e.width=Math.max(e.width,1/t),e.height=Math.max(e.height,1/t);const i=tr.create({width:e.width,height:e.height,scaleMode:r,resolution:t});mh||(mh=new qn),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(Ms),Ms.invert(),Ms.tx-=e.x,Ms.ty-=e.y,mh.render(this,{renderTexture:i,clear:!0,transform:Ms});const s=Y.from(i.baseTexture._canvasRenderTarget.canvas,{scaleMode:r});return s.baseTexture.setResolution(t),s},Or.prototype.cachedGraphicsData=[],Or.prototype._renderCanvas=function(r){this.isMask!==!0&&(this.finishPoly(),r.plugins.graphics.render(this))};class Ds{static offsetPolygon(t,e){const i=[],s=t.length;e=Ds.isPolygonClockwise(t)?e:-1*e;for(let n=0;n<s;n+=2){let o=n-2;o<0&&(o+=s);const a=(n+2)%s;let l=t[n]-t[o],h=t[n+1]-t[o+1],u=Math.sqrt(l*l+h*h);l/=u,h/=u,l*=e,h*=e;const c=-h,d=l,p=[t[o]+c,t[o+1]+d],f=[t[n]+c,t[n+1]+d];let m=t[a]-t[n],_=t[a+1]-t[n+1];u=Math.sqrt(m*m+_*_),m/=u,_/=u,m*=e,_*=e;const g=-_,v=m,y=[t[n]+g,t[n+1]+v],x=[t[a]+g,t[a+1]+v],b=Ds.findIntersection(p[0],p[1],f[0],f[1],y[0],y[1],x[0],x[1]);b&&i.push(...b)}return i}static findIntersection(t,e,i,s,n,o,a,l){const h=(l-o)*(i-t)-(a-n)*(s-e),u=(a-n)*(e-o)-(l-o)*(t-n),c=(i-t)*(e-o)-(s-e)*(t-n);if(h===0)return u===0&&c===0?[(t+i)/2,(e+s)/2]:null;const d=u/h;return[t+d*(i-t),e+d*(s-e)]}static isPolygonClockwise(t){let e=0;for(let i=0,s=t.length-2;i<t.length;s=i,i+=2)e+=(t[i]-t[s])*(t[i+1]+t[s+1]);return e>0}}class Ap{constructor(t){this._svgMatrix=null,this._tempMatrix=new wt,this.renderer=t}_calcCanvasStyle(t,e){let i;return t.texture&&t.texture.baseTexture!==Y.WHITE.baseTexture?t.texture.valid?(i=Vt.getTintedPattern(t.texture,e),this.setPatternTransform(i,t.matrix||wt.IDENTITY)):i="#808080":i=`#${`00000${(e|0).toString(16)}`.slice(-6)}`,i}render(t){const e=this.renderer,i=e.canvasContext.activeContext,s=t.worldAlpha,n=t.transform.worldTransform;e.canvasContext.setContextTransform(n),e.canvasContext.setBlendMode(t.blendMode);const o=t.geometry.graphicsData;let a,l;const h=ut.shared.setValue(t.tint).toArray();for(let u=0;u<o.length;u++){const c=o[u],d=c.shape,p=c.fillStyle,f=c.lineStyle,m=c.fillStyle.color|0,_=c.lineStyle.color|0;if(c.matrix&&e.canvasContext.setContextTransform(n.copyTo(this._tempMatrix).append(c.matrix)),p.visible&&(a=this._calcCanvasStyle(p,ut.shared.setValue(m).multiply(h).toNumber())),f.visible&&(l=this._calcCanvasStyle(f,ut.shared.setValue(_).multiply(h).toNumber())),i.lineWidth=f.width,i.lineCap=f.cap,i.lineJoin=f.join,i.miterLimit=f.miterLimit,c.type===Tt.POLY){i.beginPath();const g=d;let v=g.points;const y=c.holes;let x,b,E,T,A;i.moveTo(v[0],v[1]);for(let M=2;M<v.length;M+=2)i.lineTo(v[M],v[M+1]);if(g.closeStroke&&i.closePath(),y.length>0){A=[],x=0,E=v[0],T=v[1];for(let M=2;M+2<v.length;M+=2)x+=(v[M]-E)*(v[M+3]-T)-(v[M+2]-E)*(v[M+1]-T);for(let M=0;M<y.length;M++)if(v=y[M].shape.points,!!v){b=0,E=v[0],T=v[1];for(let S=2;S+2<v.length;S+=2)b+=(v[S]-E)*(v[S+3]-T)-(v[S+2]-E)*(v[S+1]-T);if(b*x<0){i.moveTo(v[0],v[1]);for(let S=2;S<v.length;S+=2)i.lineTo(v[S],v[S+1])}else{i.moveTo(v[v.length-2],v[v.length-1]);for(let S=v.length-4;S>=0;S-=2)i.lineTo(v[S],v[S+1])}y[M].shape.closeStroke&&i.closePath(),A[M]=b*x<0}}p.visible&&(i.globalAlpha=p.alpha*s,i.fillStyle=a,i.fill()),f.visible&&this.paintPolygonStroke(g,f,l,y,A,s,i)}else if(c.type===Tt.RECT){const g=d;if(p.visible&&(i.globalAlpha=p.alpha*s,i.fillStyle=a,i.fillRect(g.x,g.y,g.width,g.height)),f.visible){const v=f.width*(.5-(1-f.alignment)),y=g.width+2*v,x=g.height+2*v;i.globalAlpha=f.alpha*s,i.strokeStyle=l,i.strokeRect(g.x-v,g.y-v,y,x)}}else if(c.type===Tt.CIRC){const g=d;if(i.beginPath(),i.arc(g.x,g.y,g.radius,0,2*Math.PI),i.closePath(),p.visible&&(i.globalAlpha=p.alpha*s,i.fillStyle=a,i.fill()),f.visible){if(f.alignment!==.5){const v=f.width*(.5-(1-f.alignment));i.beginPath(),i.arc(g.x,g.y,g.radius+v,0,2*Math.PI),i.closePath()}i.globalAlpha=f.alpha*s,i.strokeStyle=l,i.stroke()}}else if(c.type===Tt.ELIP){const g=d,v=f.alignment===1;if(v||this.paintEllipse(g,p,f,a,s,i),f.visible){if(f.alignment!==.5){const y=.5522848,x=f.width*(.5-(1-f.alignment)),b=(g.width+x)*2,E=(g.height+x)*2,T=g.x-b/2,A=g.y-E/2,M=b/2*y,S=E/2*y,P=T+b,C=A+E,w=T+b/2,D=A+E/2;i.beginPath(),i.moveTo(T,D),i.bezierCurveTo(T,D-S,w-M,A,w,A),i.bezierCurveTo(w+M,A,P,D-S,P,D),i.bezierCurveTo(P,D+S,w+M,C,w,C),i.bezierCurveTo(w-M,C,T,D+S,T,D),i.closePath()}i.globalAlpha=f.alpha*s,i.strokeStyle=l,i.stroke()}v&&this.paintEllipse(g,p,f,a,s,i)}else if(c.type===Tt.RREC){const g=d,v=f.alignment===1;if(v||this.paintRoundedRectangle(g,p,f,a,s,i),f.visible){if(f.alignment!==.5){const y=g.width,x=g.height,b=f.width*(.5-(1-f.alignment)),E=g.x-b,T=g.y-b,A=g.width+2*b,M=g.height+2*b,S=b*(f.alignment>=1?Math.min(A/y,M/x):Math.min(y/A,x/M));let P=g.radius+S;const C=Math.min(A,M)/2;P=P>C?C:P,i.beginPath(),i.moveTo(E,T+P),i.lineTo(E,T+M-P),i.quadraticCurveTo(E,T+M,E+P,T+M),i.lineTo(E+A-P,T+M),i.quadraticCurveTo(E+A,T+M,E+A,T+M-P),i.lineTo(E+A,T+P),i.quadraticCurveTo(E+A,T,E+A-P,T),i.lineTo(E+P,T),i.quadraticCurveTo(E,T,E,T+P),i.closePath()}i.globalAlpha=f.alpha*s,i.strokeStyle=l,i.stroke()}v&&this.paintRoundedRectangle(g,p,f,a,s,i)}}}paintPolygonStroke(t,e,i,s,n,o,a){if(e.alignment!==.5){const l=e.width*(.5-(1-e.alignment));let h=Ds.offsetPolygon(t.points,l),u;a.beginPath(),a.moveTo(h[0],h[1]);for(let c=2;c<h.length;c+=2)a.lineTo(h[c],h[c+1]);t.closeStroke&&a.closePath();for(let c=0;c<s.length;c++){if(u=s[c].shape.points,h=Ds.offsetPolygon(u,l),n[c]){a.moveTo(h[0],h[1]);for(let d=2;d<h.length;d+=2)a.lineTo(h[d],h[d+1])}else{a.moveTo(h[h.length-2],h[h.length-1]);for(let d=h.length-4;d>=0;d-=2)a.lineTo(h[d],h[d+1])}s[c].shape.closeStroke&&a.closePath()}}a.globalAlpha=e.alpha*o,a.strokeStyle=i,a.stroke()}paintEllipse(t,e,i,s,n,o){const a=t.width*2,l=t.height*2,h=t.x-a/2,u=t.y-l/2,c=.5522848,d=a/2*c,p=l/2*c,f=h+a,m=u+l,_=h+a/2,g=u+l/2;i.alignment===0&&o.save(),o.beginPath(),o.moveTo(h,g),o.bezierCurveTo(h,g-p,_-d,u,_,u),o.bezierCurveTo(_+d,u,f,g-p,f,g),o.bezierCurveTo(f,g+p,_+d,m,_,m),o.bezierCurveTo(_-d,m,h,g+p,h,g),o.closePath(),i.alignment===0&&o.clip(),e.visible&&(o.globalAlpha=e.alpha*n,o.fillStyle=s,o.fill()),i.alignment===0&&o.restore()}paintRoundedRectangle(t,e,i,s,n,o){const a=t.x,l=t.y,h=t.width,u=t.height;let c=t.radius;const d=Math.min(h,u)/2;c=c>d?d:c,i.alignment===0&&o.save(),o.beginPath(),o.moveTo(a,l+c),o.lineTo(a,l+u-c),o.quadraticCurveTo(a,l+u,a+c,l+u),o.lineTo(a+h-c,l+u),o.quadraticCurveTo(a+h,l+u,a+h,l+u-c),o.lineTo(a+h,l+c),o.quadraticCurveTo(a+h,l,a+h-c,l),o.lineTo(a+c,l),o.quadraticCurveTo(a,l,a,l+c),o.closePath(),i.alignment===0&&o.clip(),e.visible&&(o.globalAlpha=e.alpha*n,o.fillStyle=s,o.fill()),i.alignment===0&&o.restore()}setPatternTransform(t,e){if(this._svgMatrix!==!1){if(!this._svgMatrix){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");if(i!=null&&i.createSVGMatrix&&(this._svgMatrix=i.createSVGMatrix()),!this._svgMatrix||!t.setTransform){this._svgMatrix=!1;return}}this._svgMatrix.a=e.a,this._svgMatrix.b=e.b,this._svgMatrix.c=e.c,this._svgMatrix.d=e.d,this._svgMatrix.e=e.tx,this._svgMatrix.f=e.ty,t.setTransform(this._svgMatrix.inverse())}}destroy(){this.renderer=null,this._svgMatrix=null,this._tempMatrix=null}}Ap.extension={name:"graphics",type:X.CanvasRendererPlugin},j.add(Ap),Object.defineProperties(z,{MESH_CANVAS_PADDING:{get(){return oe.defaultCanvasPadding},set(r){et("7.1.0","settings.MESH_CANVAS_PADDING is deprecated, use Mesh.defaultCanvasPadding"),oe.defaultCanvasPadding=r}}}),Vi.prototype._renderCanvas=function(r,t){r.plugins.mesh.render(t)},_o.prototype._cachedTint=16777215,_o.prototype._tintedCanvas=null,_o.prototype._canvasUvs=null,_o.prototype._renderCanvas=function(r){const t=r.canvasContext.activeContext,e=this.worldTransform,i=this.tintValue!==16777215,s=this.texture;if(!s.valid)return;i&&this._cachedTint!==this.tintValue&&(this._cachedTint=this.tintValue,this._tintedCanvas=Vt.getTintedCanvas(this,this.tintValue));const n=i?this._tintedCanvas:s.baseTexture.getDrawableSource();this._canvasUvs||(this._canvasUvs=[0,0,0,0,0,0,0,0]);const o=this.vertices,a=this._canvasUvs,l=i?0:s.frame.x,h=i?0:s.frame.y,u=l+s.frame.width,c=h+s.frame.height;a[0]=l,a[1]=l+this._leftWidth,a[2]=u-this._rightWidth,a[3]=u,a[4]=h,a[5]=h+this._topHeight,a[6]=c-this._bottomHeight,a[7]=c;for(let d=0;d<8;d++)a[d]*=s.baseTexture.resolution;t.globalAlpha=this.worldAlpha,r.canvasContext.setBlendMode(this.blendMode),r.canvasContext.setContextTransform(e,this.roundPixels);for(let d=0;d<3;d++)for(let p=0;p<3;p++){const f=p*2+d*8,m=Math.max(1,a[p+1]-a[p]),_=Math.max(1,a[d+5]-a[d+4]),g=Math.max(1,o[f+10]-o[f]),v=Math.max(1,o[f+11]-o[f+1]);t.drawImage(n,a[p],a[d+4],m,_,o[f],o[f+1],g,v)}};let Sp=!1;oe.prototype._cachedTint=16777215,oe.prototype._tintedCanvas=null,oe.prototype._cachedTexture=null,oe.prototype._renderCanvas=function(r){this.shader.uvMatrix&&(this.shader.uvMatrix.update(),this.calculateUvs()),this.material._renderCanvas?this.material._renderCanvas(r,this):Sp||(Sp=!0,globalThis.console.warn("Mesh with custom shaders are not supported in CanvasRenderer."))},oe.prototype._canvasPadding=null,oe.defaultCanvasPadding=0,Object.defineProperty(oe.prototype,"canvasPadding",{get(){return this._canvasPadding??oe.defaultCanvasPadding},set(r){this._canvasPadding=r}}),tE.prototype._renderCanvas=function(r){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),this.shader.update&&this.shader.update(),this.calculateUvs(),this.material._renderCanvas(r,this)},eE.prototype._renderCanvas=function(r){(this.autoUpdate||this.geometry._width!==this.shader.texture.height)&&(this.geometry._width=this.shader.texture.height,this.geometry.update()),this.shader.update&&this.shader.update(),this.calculateUvs(),this.material._renderCanvas(r,this)};class Cp{constructor(t){this.renderer=t}render(t){const e=this.renderer,i=t.worldTransform;e.canvasContext.activeContext.globalAlpha=t.worldAlpha,e.canvasContext.setBlendMode(t.blendMode),e.canvasContext.setContextTransform(i,t.roundPixels),t.drawMode!==Ce.TRIANGLES?this._renderTriangleMesh(t):this._renderTriangles(t)}_renderTriangleMesh(t){const e=t.geometry.buffers[0].data.length;for(let i=0;i<e-2;i++){const s=i*2;this._renderDrawTriangle(t,s,s+2,s+4)}}_renderTriangles(t){const e=t.geometry.getIndex().data,i=e.length;for(let s=0;s<i;s+=3){const n=e[s]*2,o=e[s+1]*2,a=e[s+2]*2;this._renderDrawTriangle(t,n,o,a)}}_renderDrawTriangle(t,e,i,s){var W;const n=this.renderer.canvasContext.activeContext,o=t.geometry.buffers[0].data,{uvs:a,texture:l}=t;if(!l.valid)return;const h=t.tintValue!==16777215,u=l.baseTexture,c=u.width,d=u.height;t._cachedTexture&&t._cachedTexture.baseTexture!==u&&(t._cachedTint=16777215,(W=t._cachedTexture)==null||W.destroy(),t._cachedTexture=null,t._tintedCanvas=null),h&&t._cachedTint!==t.tintValue&&(t._cachedTint=t.tintValue,t._cachedTexture=t._cachedTexture||new Y(u),t._tintedCanvas=Vt.getTintedCanvas({texture:t._cachedTexture},t.tintValue));const p=h?t._tintedCanvas:u.getDrawableSource(),f=a[e]*u.width,m=a[i]*u.width,_=a[s]*u.width,g=a[e+1]*u.height,v=a[i+1]*u.height,y=a[s+1]*u.height;let x=o[e],b=o[i],E=o[s],T=o[e+1],A=o[i+1],M=o[s+1];const S=t.canvasPadding/this.renderer.canvasContext.activeResolution;if(S>0){const{a:rt,b:I,c:F,d:G}=t.worldTransform,Q=(x+b+E)/3,K=(T+A+M)/3;let k=x-Q,it=T-K,gt=rt*k+F*it,B=I*k+G*it,O=Math.sqrt(gt*gt+B*B),tt=1+S/O;x=Q+k*tt,T=K+it*tt,k=b-Q,it=A-K,gt=rt*k+F*it,B=I*k+G*it,O=Math.sqrt(gt*gt+B*B),tt=1+S/O,b=Q+k*tt,A=K+it*tt,k=E-Q,it=M-K,gt=rt*k+F*it,B=I*k+G*it,O=Math.sqrt(gt*gt+B*B),tt=1+S/O,E=Q+k*tt,M=K+it*tt}n.save(),n.beginPath(),n.moveTo(x,T),n.lineTo(b,A),n.lineTo(E,M),n.closePath(),n.clip();const P=f*v+g*_+m*y-v*_-g*m-f*y,C=x*v+g*E+b*y-v*E-g*b-x*y,w=f*b+x*_+m*E-b*_-x*m-f*E,D=f*v*E+g*b*_+x*m*y-x*v*_-g*m*E-f*b*y,N=T*v+g*M+A*y-v*M-g*A-T*y,V=f*A+T*_+m*M-A*_-T*m-f*M,H=f*v*M+g*A*_+T*m*y-T*v*_-g*m*M-f*A*y;n.transform(C/P,N/P,w/P,V/P,D/P,H/P),n.drawImage(p,0,0,c*u.resolution,d*u.resolution,0,0,c,d),n.restore(),this.renderer.canvasContext.invalidateBlendMode()}renderMeshFlat(t){const e=this.renderer.canvasContext.activeContext,i=t.geometry.getBuffer("aVertexPosition").data,s=i.length/2;e.beginPath();for(let n=1;n<s-2;++n){const o=n*2,a=i[o],l=i[o+1],h=i[o+2],u=i[o+3],c=i[o+4],d=i[o+5];e.moveTo(a,l),e.lineTo(h,u),e.lineTo(c,d)}e.fillStyle="#FF0000",e.fill(),e.closePath()}destroy(){this.renderer=null}}Cp.extension={name:"mesh",type:X.CanvasRendererPlugin},j.add(Cp);const Ip=16;function TE(r,t){const e=r;if(t instanceof st){const i=t.source,s=i.width===0?e.canvas.width:Math.min(e.canvas.width,i.width),n=i.height===0?e.canvas.height:Math.min(e.canvas.height,i.height);return e.ctx.drawImage(i,0,0,s,n,0,0,e.canvas.width,e.canvas.height),!0}return!1}class Rp extends vo{constructor(t){super(t),this.uploadHookHelper=this,this.canvas=z.ADAPTER.createCanvas(Ip,Ip),this.ctx=this.canvas.getContext("2d"),this.registerUploadHook(TE)}destroy(){super.destroy(),this.ctx=null,this.canvas=null}}Rp.extension={name:"prepare",type:X.CanvasRendererSystem},j.add(Rp),er.prototype._tintedCanvas=null,er.prototype._renderCanvas=function(r){r.plugins.sprite.render(this)};const Pp=new wt;class Mp{constructor(t){this.renderer=t}render(t){const e=t._texture,i=this.renderer,s=i.canvasContext.activeContext,n=i.canvasContext.activeResolution;if(!e.valid)return;const o=e._frame.width,a=e._frame.height;let l=e._frame.width,h=e._frame.height;e.trim&&(l=e.trim.width,h=e.trim.height);let u=t.transform.worldTransform,c=0,d=0;const p=e.baseTexture.getDrawableSource();if(e.orig.width<=0||e.orig.height<=0||!e.valid||!p)return;i.canvasContext.setBlendMode(t.blendMode,!0),s.globalAlpha=t.worldAlpha;const f=e.baseTexture.scaleMode===Ie.LINEAR,m=i.canvasContext.smoothProperty;m&&s[m]!==f&&(s[m]=f),e.trim?(c=e.trim.width/2+e.trim.x-t.anchor.x*e.orig.width,d=e.trim.height/2+e.trim.y-t.anchor.y*e.orig.height):(c=(.5-t.anchor.x)*e.orig.width,d=(.5-t.anchor.y)*e.orig.height),e.rotate&&(u.copyTo(Pp),u=Pp,St.matrixAppendRotationInv(u,e.rotate,c,d),c=0,d=0),c-=l/2,d-=h/2,i.canvasContext.setContextTransform(u,t.roundPixels,1),t.roundPixels&&(c=c|0,d=d|0);const _=e.baseTexture.resolution,g=i.canvasContext._outerBlend;g&&(s.save(),s.beginPath(),s.rect(c*n,d*n,l*n,h*n),s.clip()),t.tint!==16777215?((t._cachedTint!==t.tintValue||t._tintedCanvas.tintId!==t._texture._updateID)&&(t._cachedTint=t.tintValue,t._tintedCanvas=Vt.getTintedCanvas(t,t.tintValue)),s.drawImage(t._tintedCanvas,0,0,Math.floor(o*_),Math.floor(a*_),Math.floor(c*n),Math.floor(d*n),Math.floor(l*n),Math.floor(h*n))):s.drawImage(p,e._frame.x*_,e._frame.y*_,Math.floor(o*_),Math.floor(a*_),Math.floor(c*n),Math.floor(d*n),Math.floor(l*n),Math.floor(h*n)),g&&s.restore(),i.canvasContext.setBlendMode(U.NORMAL)}destroy(){this.renderer=null}}Mp.extension={name:"sprite",type:X.CanvasRendererPlugin},j.add(Mp);const EE=16777215,AE=.25,SE=16777215,CE=1,IE=1.5;let Ur=!1,Bs;const gh=r=>{const t={tint:r!=null&&r.fill?new ut(r.fill).toNumber():EE,alpha:(r==null?void 0:r.fillOpacity)!==void 0?Math.min(r.fillOpacity,1):String(r==null?void 0:r.fill).toLowerCase().startsWith("rgba(")?new ut(r==null?void 0:r.fill).alpha:AE},e={tint:r!=null&&r.stroke?new ut(r.stroke).toNumber():SE,alpha:(r==null?void 0:r.strokeOpacity)!==void 0?Math.min(r.strokeOpacity,1):String(r==null?void 0:r.stroke).toLowerCase().startsWith("rgba(")?new ut(r==null?void 0:r.stroke).alpha:CE,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?IE:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},yh=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=gh(i),o=new Or;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new Or,l=n.lineWidth===1?1:n.lineWidth/Bs;return a.lineStyle(l,16777215,1,.5,n.lineWidth===1),r(e,a),a.tint=n.tint||16777215,a.alpha=n.alpha,t.addChild(a),{fill:o,stroke:a,strokeWidth:n.lineWidth}},RE=yh((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),PE=yh((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),ME=yh((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),Dp=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},Bp=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=Dp(r);(n!==Bs||!Ur)&&(Ur=!0,e.forEach(({stroke:d,strokeWidth:p})=>{const{lineStyle:f}=d.geometry.graphicsData[0];p>1?(Ur=n===Bs,f.width=p/n,f.native=!1,d.geometry.invalidate()):p===1&&!f.native&&(f.width=1,f.native=!0,d.geometry.invalidate())})),Bs=n;const o=r.viewport.getFlip();let a=Math.PI*r.viewport.getRotation(!0)/180;a<0&&(a+=2*Math.PI),a>2*Math.PI&&(a-=2*Math.PI);const l=o?r.viewport._containerInnerSize.x+s.x*n:-s.x*n,h=-s.y*n;let u,c;a>0&&a<=Math.PI/2?(u=s.height*n,c=0):a>Math.PI/2&&a<=Math.PI?(u=s.width*n,c=s.height*n):a>Math.PI&&a<=Math.PI*1.5?(u=0,c=s.width*n):(u=0,c=0),t.position.x=u+l*Math.cos(a)-h*Math.sin(a),t.position.y=c+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-n:n,n),t.rotation=a,i.render(t)},DE=(r,t)=>{const e=new Or,i=_f({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o,a;Bs=Dp(r);const l=(y,x)=>{Ur=!1;const{selector:b}=y.target,E=typeof a=="function"?a(y,x):a;let T;b.type===Et.RECTANGLE?T=ME(e,b,E):b.type===Et.POLYGON?T=PE(e,b,E):b.type===Et.ELLIPSE?T=RE(e,b,E):console.warn(`Unsupported shape type: ${b.type}`),T&&s.set(y.id,{annotation:y,...T})},h=y=>{const x=s.get(y.id);x&&(s.delete(y.id),x.fill.destroy(),x.stroke.destroy())},u=(y,x,b)=>{Ur=!1;const E=s.get(y.id);E&&(s.delete(y.id),E.fill.destroy(),E.stroke.destroy(),l(x,b))},c=(y,x)=>{const b=s.get(y);b&&(s.delete(y),b.fill.destroy(),b.stroke.destroy(),l(b.annotation,x))},d=(y,x)=>{i.resize(y,x),i.render(e)},p=y=>{Ur=!1;const{children:x}=e;s.forEach(({fill:b,stroke:E,annotation:T})=>{const A=y?n.has(T.id)||y(T):!0;A&&!x.includes(b)?(e.addChild(b),e.addChild(E)):!A&&x.includes(b)&&(e.removeChild(b),e.removeChild(E))}),i.render(e)},f=y=>{o!==y&&(o&&c(o,{selected:n.has(o)}),y&&c(y,{selected:n.has(y),hovered:!0}),o=y,i.render(e))},m=y=>{const x=y.selected.map(T=>T.id),b=x.filter(T=>!n.has(T)),E=[...n].filter(T=>!x.includes(T));[...b,...E].forEach(T=>c(T,{selected:x.includes(T),hovered:T===o})),n=new Set(x),i.render(e)},_=y=>{if(typeof y=="function")s.forEach(({annotation:x,fill:b,stroke:E,strokeWidth:T},A)=>{T>1&&(Ur=!1);const M={selected:n.has(x.id),hovered:o===x.id},{fillStyle:S,strokeStyle:P}=gh(y(x,M));b.tint=S.tint,b.alpha=S.alpha,E.tint=P.tint||16777215,E.alpha=P.alpha,s.set(x.id,{annotation:x,fill:b,stroke:E,strokeWidth:P.lineWidth})});else{const{fillStyle:x,strokeStyle:b}=gh(y);b.lineWidth>1&&(Ur=!1),s.forEach(({annotation:E,fill:T,stroke:A,strokeWidth:M},S)=>{T.tint=x.tint,T.alpha=x.alpha,A.tint=b.tint||16777215,A.alpha=b.alpha,s.set(E.id,{annotation:E,fill:T,stroke:A,strokeWidth:b.lineWidth})})}a=y,i.render(e),Bp(r,e,s,i)()},g=y=>{y?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),redraw:Bp(r,e,s,i),removeAnnotation:h,resize:d,setFilter:p,setHovered:f,setSelected:m,setStyle:_,setVisible:g,updateAnnotation:u}};function BE(r,t,e){let i,s,{filter:n}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:u,hover:c,selection:d,viewport:p}=o;ea(r,c,E=>e(11,i=E)),ea(r,d,E=>e(8,s=E));const f=en();let m,_;const g=E=>{const T=new kt.Point(E.x,E.y),{x:A,y:M}=l.viewport.pointFromPixel(T);return l.viewport.viewportToImageCoordinates(A,M)},v=E=>{const{x:T,y:A}=E.position;_={x:T,y:A}},y=E=>T=>{const{x:A,y:M}=g(new kt.Point(T.offsetX,T.offsetY)),S=u.getAt(A,M);S&&(!n||n(S))?(E.classList.add("hover"),i!==S.id&&(c.set(S.id),m.setHovered(S.id))):(E.classList.remove("hover"),i&&(c.set(void 0),m.setHovered(void 0)))},x=E=>{if(!_)return;const T=E.originalEvent,{x:A,y:M}=E.position,S=A-_.x,P=M-_.y;if(Math.sqrt(S*S+P*P)<5){const{x:w,y:D}=g(E.position),N=u.getAt(w,D);N?f("click",{originalEvent:T,annotation:N}):f("click",{originalEvent:T})}_=void 0};let b;return tn(()=>{var N;const{offsetWidth:E,offsetHeight:T}=l.canvas,A=document.createElement("canvas");A.width=E,A.height=T,A.className="a9s-gl-canvas",(N=l.element.querySelector(".openseadragon-canvas"))==null||N.appendChild(A),e(7,m=DE(l,A));const M=y(A);A.addEventListener("pointermove",M);const S=new ResizeObserver(V=>{try{const{width:H,height:W}=V[0].contentRect;A.width=H,A.height=W,m.resize(H,W)}catch{console.warn("WebGL canvas already disposed")}});S.observe(A);const P=()=>{const V=l.viewport.getBounds();b=l.viewport.viewportToImageRectangle(V);const{x:H,y:W,width:rt,height:I}=b,F=u.getIntersecting(H,W,rt,I);p.set(F.map(G=>G.id))};l.addHandler("canvas-press",v),l.addHandler("canvas-release",x),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",P);const C=V=>V.filter(H=>hr(H)),w=V=>hr(V.oldValue)&&hr(V.newValue),D=V=>{const{created:H,updated:W,deleted:rt}=V.changes;if(C(H||[]).forEach(I=>m.addAnnotation(I)),C(rt||[]).forEach(I=>m.removeAnnotation(I)),(W||[]).filter(I=>w(I)).forEach(({oldValue:I,newValue:F})=>m.updateAnnotation(I,F)),b){const{x:I,y:F,width:G,height:Q}=b,K=u.getIntersecting(I,F,G,Q);p.set(K.map(k=>k.id))}else p.set(u.all().map(I=>I.id));m.redraw()};return u.observe(D),()=>{var V;A.removeEventListener("pointermove",M),S.disconnect(),l.removeHandler("canvas-press",v),l.removeHandler("canvas-release",x),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",P),u.unobserve(D),m.destroy(),(V=A.parentNode)==null||V.removeChild(A)}}),r.$$set=E=>{"filter"in E&&e(2,n=E.filter),"state"in E&&e(3,o=E.state),"style"in E&&e(4,a=E.style),"viewer"in E&&e(5,l=E.viewer),"visible"in E&&e(6,h=E.visible)},r.$$.update=()=>{r.$$.dirty&132&&(m==null||m.setFilter(n)),r.$$.dirty&384&&(m==null||m.setSelected(s)),r.$$.dirty&144&&(m==null||m.setStyle(a)),r.$$.dirty&192&&(m==null||m.setVisible(h))},[c,d,n,o,a,l,h,m,s]}class OE extends de{constructor(t){super(),ce(this,t,BE,null,re,{filter:2,state:3,style:4,viewer:5,visible:6})}}const qt=[];for(let r=0;r<256;++r)qt.push((r+256).toString(16).slice(1));function LE(r,t=0){return(qt[r[t+0]]+qt[r[t+1]]+qt[r[t+2]]+qt[r[t+3]]+"-"+qt[r[t+4]]+qt[r[t+5]]+"-"+qt[r[t+6]]+qt[r[t+7]]+"-"+qt[r[t+8]]+qt[r[t+9]]+"-"+qt[r[t+10]]+qt[r[t+11]]+qt[r[t+12]]+qt[r[t+13]]+qt[r[t+14]]+qt[r[t+15]]).toLowerCase()}let _h;const FE=new Uint8Array(16);function NE(){if(!_h){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");_h=crypto.getRandomValues.bind(crypto)}return _h(FE)}const Op={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function UE(r,t,e){var s;if(Op.randomUUID&&!r)return Op.randomUUID();r=r||{};const i=r.random??((s=r.rng)==null?void 0:s.call(r))??NE();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,LE(i)}var Xi=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(Xi||{});const vh=(r,t)=>t,kE=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},GE={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=t-i,c=e-s,d=l*u+h*c,p=h*u-l*c;return d*d/(n*n)+p*p/(o*o)<=1}};vh(Xi.ELLIPSE,GE);const HE={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],u=i[o][1];l>e!=u>e&&t<(h-a)*(e-l)/(u-l)+a&&(s=!s)}return s}};vh(Xi.POLYGON,HE);const $E={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};vh(Xi.RECTANGLE,$E);function Lp(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function Fp(r){let t,e;return t=new Os({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Zt(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){ie(t.$$.fragment)},m(i,s){Jt(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(ht(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){Qt(t,i)}}}function VE(r){let t,e,i,s,n,o,a,l,h,u,c,d=vi(r[4].points),p=[];for(let m=0;m<d.length;m+=1)p[m]=Fp(Lp(r,d,m));const f=m=>pt(p[m],1,1,()=>{p[m]=null});return{c(){t=At("polygon"),s=Se(),n=At("polygon"),a=Se();for(let m=0;m<p.length;m+=1)p[m].c();l=dr(),L(t,"class","a9s-outer"),L(t,"style",e=r[1]?"display:none;":void 0),L(t,"points",i=r[4].points.map(Np).join(" ")),L(n,"class","a9s-inner a9s-shape-handle"),L(n,"style",r[1]),L(n,"points",o=r[4].points.map(Up).join(" "))},m(m,_){mt(m,t,_),mt(m,s,_),mt(m,n,_),mt(m,a,_);for(let g=0;g<p.length;g+=1)p[g]&&p[g].m(m,_);mt(m,l,_),h=!0,u||(c=[jt(t,"pointerdown",function(){Zt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),jt(n,"pointerdown",function(){Zt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],u=!0)},p(m,_){if(r=m,(!h||_&2&&e!==(e=r[1]?"display:none;":void 0))&&L(t,"style",e),(!h||_&16&&i!==(i=r[4].points.map(Np).join(" ")))&&L(t,"points",i),(!h||_&2)&&L(n,"style",r[1]),(!h||_&16&&o!==(o=r[4].points.map(Up).join(" ")))&&L(n,"points",o),_&536){d=vi(r[4].points);let g;for(g=0;g<d.length;g+=1){const v=Lp(r,d,g);p[g]?(p[g].p(v,_),ht(p[g],1)):(p[g]=Fp(v),p[g].c(),ht(p[g],1),p[g].m(l.parentNode,l))}for(He(),g=d.length;g<p.length;g+=1)f(g);$e()}},i(m){if(!h){for(let _=0;_<d.length;_+=1)ht(p[_]);h=!0}},o(m){p=p.filter(Boolean);for(let _=0;_<p.length;_+=1)pt(p[_]);h=!1},d(m){m&&(ft(t),ft(s),ft(n),ft(a),ft(l)),ra(p,m),u=!1,ur(c)}}}function XE(r){let t,e;return t=new Gp({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[VE,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){ie(t.$$.fragment)},m(i,s){Jt(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ht(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){Qt(t,i)}}}const Np=r=>r.join(","),Up=r=>r.join(",");function WE(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{let m;const _=d.geometry;p==="SHAPE"?m=_.points.map(([v,y])=>[v+f[0],y+f[1]]):m=_.points.map(([v,y],x)=>p===`HANDLE-${x}`?[v+f[0],y+f[1]]:[v,y]);const g=kE(m);return{...d,geometry:{points:m,bounds:g}}};function h(d){fr.call(this,r,d)}function u(d){fr.call(this,r,d)}function c(d){fr.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class zE extends de{constructor(t){super(),ce(this,t,WE,XE,re,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const jE=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function YE(r){let t,e,i,s,n,o;return{c(){t=At("rect"),L(t,"class",e=Js(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),L(t,"x",i=r[0]-r[5]/2),L(t,"y",s=r[1]-r[5]/2),L(t,"width",r[5]),L(t,"height",r[5])},m(a,l){mt(a,t,l),n||(o=jt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=Js(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&L(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&L(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&L(t,"y",s),l&32&&L(t,"width",a[5]),l&32&&L(t,"height",a[5])},d(a){a&&ft(t),n=!1,o()}}}function qE(r){let t,e,i,s,n,o,a,l,h;return{c(){t=At("g"),e=At("circle"),s=At("rect"),L(e,"cx",r[0]),L(e,"cy",r[1]),L(e,"r",i=r[3]/r[2]),L(e,"class","a9s-touch-halo svelte-1sgkh33"),Qs(e,"touched",r[4]),L(s,"class",n=Js(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),L(s,"x",o=r[0]-r[5]/2),L(s,"y",a=r[1]-r[5]/2),L(s,"width",r[5]),L(s,"height",r[5]),L(t,"class","a9s-touch-handle")},m(u,c){mt(u,t,c),cr(t,e),cr(t,s),l||(h=[jt(e,"pointerdown",r[10]),jt(e,"pointerdown",r[6]),jt(e,"pointerup",r[7]),jt(s,"pointerdown",r[9]),jt(s,"pointerdown",r[6]),jt(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&L(e,"cx",u[0]),c&2&&L(e,"cy",u[1]),c&12&&i!==(i=u[3]/u[2])&&L(e,"r",i),c&16&&Qs(e,"touched",u[4]),c&256&&n!==(n=Js(`a9s-handle ${u[8].class||""}`.trim())+" svelte-1sgkh33")&&L(s,"class",n),c&33&&o!==(o=u[0]-u[5]/2)&&L(s,"x",o),c&34&&a!==(a=u[1]-u[5]/2)&&L(s,"y",a),c&32&&L(s,"width",u[5]),c&32&&L(s,"height",u[5])},d(u){u&&ft(t),l=!1,ur(h)}}}function KE(r){let t;function e(n,o){return jE?qE:YE}let s=e()(r);return{c(){s.c(),t=dr()},m(n,o){s.m(n,o),mt(n,t,o)},p(n,[o]){s.p(n,o)},i:Ge,o:Ge,d(n){n&&ft(t),s.d(n)}}}function ZE(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=f=>{f.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(f){fr.call(this,r,f)}function d(f){fr.call(this,r,f)}function p(f){fr.call(this,r,f)}return r.$$set=f=>{e(8,t=ta(ta({},t),Fu(f))),"x"in f&&e(0,s=f.x),"y"in f&&e(1,n=f.y),"scale"in f&&e(2,o=f.scale),"radius"in f&&e(3,a=f.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=Fu(t),[s,n,o,a,l,i,h,u,t,c,d,p]}class Os extends de{constructor(t){super(),ce(this,t,ZE,KE,re,{x:0,y:1,scale:2,radius:3})}}function JE(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,_,g,v,y,x,b,E,T,A,M,S,P,C,w,D,N,V,H,W,rt,I,F,G,Q,K,k,it,gt;return W=new Os({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),W.$on("pointerdown",function(){Zt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),I=new Os({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),I.$on("pointerdown",function(){Zt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),G=new Os({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),G.$on("pointerdown",function(){Zt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),K=new Os({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),K.$on("pointerdown",function(){Zt(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=At("rect"),a=Se(),l=At("rect"),p=Se(),f=At("rect"),v=Se(),y=At("rect"),T=Se(),A=At("rect"),C=Se(),w=At("rect"),H=Se(),ie(W.$$.fragment),rt=Se(),ie(I.$$.fragment),F=Se(),ie(G.$$.fragment),Q=Se(),ie(K.$$.fragment),L(t,"class","a9s-outer"),L(t,"style",e=r[1]?"display:none;":void 0),L(t,"x",i=r[4].x),L(t,"y",s=r[4].y),L(t,"width",n=r[4].w),L(t,"height",o=r[4].h),L(l,"class","a9s-inner a9s-shape-handle"),L(l,"style",r[1]),L(l,"x",h=r[4].x),L(l,"y",u=r[4].y),L(l,"width",c=r[4].w),L(l,"height",d=r[4].h),L(f,"class","a9s-edge-handle a9s-edge-handle-top"),L(f,"x",m=r[4].x),L(f,"y",_=r[4].y),L(f,"height",1),L(f,"width",g=r[4].w),L(y,"class","a9s-edge-handle a9s-edge-handle-right"),L(y,"x",x=r[4].x+r[4].w),L(y,"y",b=r[4].y),L(y,"height",E=r[4].h),L(y,"width",1),L(A,"class","a9s-edge-handle a9s-edge-handle-bottom"),L(A,"x",M=r[4].x),L(A,"y",S=r[4].y+r[4].h),L(A,"height",1),L(A,"width",P=r[4].w),L(w,"class","a9s-edge-handle a9s-edge-handle-left"),L(w,"x",D=r[4].x),L(w,"y",N=r[4].y),L(w,"height",V=r[4].h),L(w,"width",1)},m(B,O){mt(B,t,O),mt(B,a,O),mt(B,l,O),mt(B,p,O),mt(B,f,O),mt(B,v,O),mt(B,y,O),mt(B,T,O),mt(B,A,O),mt(B,C,O),mt(B,w,O),mt(B,H,O),Jt(W,B,O),mt(B,rt,O),Jt(I,B,O),mt(B,F,O),Jt(G,B,O),mt(B,Q,O),Jt(K,B,O),k=!0,it||(gt=[jt(t,"pointerdown",function(){Zt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),jt(l,"pointerdown",function(){Zt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),jt(f,"pointerdown",function(){Zt(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),jt(y,"pointerdown",function(){Zt(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),jt(A,"pointerdown",function(){Zt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),jt(w,"pointerdown",function(){Zt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],it=!0)},p(B,O){r=B,(!k||O&2&&e!==(e=r[1]?"display:none;":void 0))&&L(t,"style",e),(!k||O&16&&i!==(i=r[4].x))&&L(t,"x",i),(!k||O&16&&s!==(s=r[4].y))&&L(t,"y",s),(!k||O&16&&n!==(n=r[4].w))&&L(t,"width",n),(!k||O&16&&o!==(o=r[4].h))&&L(t,"height",o),(!k||O&2)&&L(l,"style",r[1]),(!k||O&16&&h!==(h=r[4].x))&&L(l,"x",h),(!k||O&16&&u!==(u=r[4].y))&&L(l,"y",u),(!k||O&16&&c!==(c=r[4].w))&&L(l,"width",c),(!k||O&16&&d!==(d=r[4].h))&&L(l,"height",d),(!k||O&16&&m!==(m=r[4].x))&&L(f,"x",m),(!k||O&16&&_!==(_=r[4].y))&&L(f,"y",_),(!k||O&16&&g!==(g=r[4].w))&&L(f,"width",g),(!k||O&16&&x!==(x=r[4].x+r[4].w))&&L(y,"x",x),(!k||O&16&&b!==(b=r[4].y))&&L(y,"y",b),(!k||O&16&&E!==(E=r[4].h))&&L(y,"height",E),(!k||O&16&&M!==(M=r[4].x))&&L(A,"x",M),(!k||O&16&&S!==(S=r[4].y+r[4].h))&&L(A,"y",S),(!k||O&16&&P!==(P=r[4].w))&&L(A,"width",P),(!k||O&16&&D!==(D=r[4].x))&&L(w,"x",D),(!k||O&16&&N!==(N=r[4].y))&&L(w,"y",N),(!k||O&16&&V!==(V=r[4].h))&&L(w,"height",V);const tt={};O&16&&(tt.x=r[4].x),O&16&&(tt.y=r[4].y),O&8&&(tt.scale=r[3]),W.$set(tt);const nt={};O&16&&(nt.x=r[4].x+r[4].w),O&16&&(nt.y=r[4].y),O&8&&(nt.scale=r[3]),I.$set(nt);const vt={};O&16&&(vt.x=r[4].x+r[4].w),O&16&&(vt.y=r[4].y+r[4].h),O&8&&(vt.scale=r[3]),G.$set(vt);const xt={};O&16&&(xt.x=r[4].x),O&16&&(xt.y=r[4].y+r[4].h),O&8&&(xt.scale=r[3]),K.$set(xt)},i(B){k||(ht(W.$$.fragment,B),ht(I.$$.fragment,B),ht(G.$$.fragment,B),ht(K.$$.fragment,B),k=!0)},o(B){pt(W.$$.fragment,B),pt(I.$$.fragment,B),pt(G.$$.fragment,B),pt(K.$$.fragment,B),k=!1},d(B){B&&(ft(t),ft(a),ft(l),ft(p),ft(f),ft(v),ft(y),ft(T),ft(A),ft(C),ft(w),ft(H),ft(rt),ft(F),ft(Q)),Qt(W,B),Qt(I,B),Qt(G,B),Qt(K,B),it=!1,ur(gt)}}}function QE(r){let t,e;return t=new Gp({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[JE,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){ie(t.$$.fragment)},m(i,s){Jt(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ht(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){Qt(t,i)}}}function tA(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{const m=d.geometry.bounds;let[_,g]=[m.minX,m.minY],[v,y]=[m.maxX,m.maxY];const[x,b]=f;if(p==="SHAPE")_+=x,v+=x,g+=b,y+=b;else{switch(p){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{g+=b;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{y+=b;break}}switch(p){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{_+=x;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{v+=x;break}}}const E=Math.min(_,v),T=Math.min(g,y),A=Math.abs(v-_),M=Math.abs(y-g);return{...d,geometry:{x:E,y:T,w:A,h:M,bounds:{minX:E,minY:T,maxX:E+A,maxY:T+M}}}};function h(d){fr.call(this,r,d)}function u(d){fr.call(this,r,d)}function c(d){fr.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class eA extends de{constructor(t){super(),ce(this,t,tA,QE,re,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}Xi.RECTANGLE,Xi.POLYGON;const rA=r=>({}),kp=r=>({grab:r[0]});function iA(r){let t,e,i,s;const n=r[7].default,o=Mu(n,r,r[6],kp);return{c(){t=At("g"),o&&o.c(),L(t,"class","a9s-annotation selected")},m(a,l){mt(a,t,l),o&&o.m(t,null),e=!0,i||(s=[jt(t,"pointerup",r[2]),jt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&Ou(o,n,a,a[6],e?Bu(n,a[6],l,rA):Lu(a[6]),kp)},i(a){e||(ht(o,a),e=!0)},o(a){pt(o,a),e=!1},d(a){a&&ft(t),o&&o.d(a),i=!1,ur(s)}}}function sA(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=en();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,u,c;const d=m=>_=>{h=m,u=l.elementToImage(_.offsetX,_.offsetY),c=o,_.target.setPointerCapture(_.pointerId),n("grab",_)},p=m=>{if(h){const[_,g]=l.elementToImage(m.offsetX,m.offsetY),v=[_-u[0],g-u[1]];e(3,o=a(c,h,v)),n("change",o)}},f=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,c=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,p,f,o,a,l,s,i]}class Gp extends de{constructor(t){super(),ce(this,t,sA,iA,re,{shape:3,editor:4,transform:5})}}const nA=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}};function oA(r,t,e){let i;const s=en();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return tn(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=nA(n,a)),r.$$.dirty&65&&n&&(c==null||c.$set({shape:n.target.selector})),r.$$.dirty&80&&c&&c.$set({transform:h}),r.$$.dirty&96&&c&&c.$set({viewportScale:u}),r.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[n,o,a,l,h,u,c,i]}class aA extends de{constructor(t){super(),ce(this,t,oA,null,re,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;const lA=r=>({transform:r&2,scale:r&1}),Hp=r=>({transform:r[1],scale:r[0]});function hA(r){let t;const e=r[4].default,i=Mu(e,r,r[3],Hp);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&Ou(i,e,s,s[3],t?Bu(e,s[3],n,lA):Lu(s[3]),Hp)},i(s){t||(ht(i,s),t=!0)},o(s){pt(i,s),t=!1},d(s){i&&i.d(s)}}}function uA(r,t,e){let{$$slots:i={},$$scope:s}=t,{viewer:n}=t,o=1,a;const l=()=>{const h=n.viewport.getContainerSize().x,u=n.viewport.getZoom(!0),c=n.viewport.getFlip(),d=n.viewport.pixelFromPoint(new kt.Point(0,0),!0);c&&(d.x=h-d.x);const p=u*h/n.world.getContentFactor(),f=c?-p:p,m=n.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${f}, ${p}) rotate(${m})`),e(0,o=u*h/n.world.getContentFactor())};return tn(()=>(n.addHandler("update-viewport",l),()=>{n.removeHandler("update-viewport",l)})),r.$$set=h=>{"viewer"in h&&e(2,n=h.viewer),"$$scope"in h&&e(3,s=h.$$scope)},[o,a,n,s,i]}class $p extends de{constructor(t){super(),ce(this,t,uA,hA,re,{viewer:2})}}function cA(r,t,e){const i=en();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewer:l}=t,{viewportScale:h}=t,u;return tn(()=>{const c=n.closest("svg"),d=[],p=(f,m,_)=>{if(c==null||c.addEventListener(f,m,_),d.push(()=>c==null?void 0:c.removeEventListener(f,m,_)),f==="pointerup"||f==="dblclick"){const g=y=>{const{originalEvent:x}=y;m(x)},v=f==="pointerup"?"canvas-click":"canvas-double-click";l.addHandler(v,g),d.push(()=>l.removeHandler(v,g))}else if(f==="pointermove"){const g=v=>{const{originalEvent:y}=v;m(y)};l.addHandler("canvas-drag",g),d.push(()=>l.removeHandler("canvas-drag",g))}};return e(6,u=new o({target:n,props:{addEventListener:p,drawingMode:s,transform:a,viewportScale:h}})),u.$on("create",f=>i("create",f.detail)),()=>{d.forEach(f=>f()),u.$destroy()}}),r.$$set=c=>{"drawingMode"in c&&e(0,s=c.drawingMode),"target"in c&&e(1,n=c.target),"tool"in c&&e(2,o=c.tool),"transform"in c&&e(3,a=c.transform),"viewer"in c&&e(4,l=c.viewer),"viewportScale"in c&&e(5,h=c.viewportScale)},r.$$.update=()=>{r.$$.dirty&72&&u&&u.$set({transform:a}),r.$$.dirty&96&&u&&u.$set({viewportScale:h})},[s,n,o,a,l,h,u]}class dA extends de{constructor(t){super(),ce(this,t,cA,null,re,{drawingMode:0,target:1,tool:2,transform:3,viewer:4,viewportScale:5})}}function Vp(r,t,e){const i=r.slice();i[35]=t[e];const s=i[15](i[35].target.selector);return i[36]=s,i}function fA(r){let t=`${r[2]}-${r[5]}`,e,i,s=Xp(r);return{c(){s.c(),e=dr()},m(n,o){s.m(n,o),mt(n,e,o),i=!0},p(n,o){o[0]&36&&re(t,t=`${n[2]}-${n[5]}`)?(He(),pt(s,1,1,Ge),$e(),s=Xp(n),s.c(),ht(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ht(s),i=!0)},o(n){pt(s),i=!1},d(n){n&&ft(e),s.d(n)}}}function pA(r){let t,e,i=vi(r[7].filter(r[25])),s=[];for(let o=0;o<i.length;o+=1)s[o]=jp(Vp(r,i,o));const n=o=>pt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=dr()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);mt(o,t,a),e=!0},p(o,a){if(a[0]&48322|a[1]&8){i=vi(o[7].filter(o[25]));let l;for(l=0;l<i.length;l+=1){const h=Vp(o,i,l);s[l]?(s[l].p(h,a),ht(s[l],1)):(s[l]=jp(h),s[l].c(),ht(s[l],1),s[l].m(t.parentNode,t))}for(He(),l=i.length;l<s.length;l+=1)n(l);$e()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ht(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)pt(s[a]);e=!1},d(o){o&&ft(t),ra(s,o)}}}function Xp(r){let t,e;return t=new dA({props:{target:r[6],tool:r[8],drawingMode:r[4],transform:{elementToImage:r[10]},viewer:r[3],viewportScale:r[34]}}),t.$on("create",r[14]),{c(){ie(t.$$.fragment)},m(i,s){Jt(t,i,s),e=!0},p(i,s){const n={};s[0]&64&&(n.target=i[6]),s[0]&256&&(n.tool=i[8]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[1]&8&&(n.viewportScale=i[34]),t.$set(n)},i(i){e||(ht(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){Qt(t,i)}}}function Wp(r){let t=r[35].id,e,i,s=zp(r);return{c(){s.c(),e=dr()},m(n,o){s.m(n,o),mt(n,e,o),i=!0},p(n,o){o[0]&128&&re(t,t=n[35].id)?(He(),pt(s,1,1,Ge),$e(),s=zp(n),s.c(),ht(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ht(s),i=!0)},o(n){pt(s),i=!1},d(n){n&&ft(e),s.d(n)}}}function zp(r){let t,e;return t=new aA({props:{target:r[6],editor:r[15](r[35].target.selector),annotation:r[35],style:r[1],transform:{elementToImage:r[10]},viewportScale:r[34]}}),t.$on("grab",r[11]),t.$on("change",function(){Zt(r[13](r[35]))&&r[13](r[35]).apply(this,arguments)}),t.$on("release",r[12]),{c(){ie(t.$$.fragment)},m(i,s){Jt(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&64&&(n.target=r[6]),s[0]&128&&(n.editor=r[15](r[35].target.selector)),s[0]&128&&(n.annotation=r[35]),s[0]&2&&(n.style=r[1]),s[1]&8&&(n.viewportScale=r[34]),t.$set(n)},i(i){e||(ht(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){Qt(t,i)}}}function jp(r){let t,e,i=r[36]&&Wp(r);return{c(){i&&i.c(),t=dr()},m(s,n){i&&i.m(s,n),mt(s,t,n),e=!0},p(s,n){s[36]?i?(i.p(s,n),n[0]&128&&ht(i,1)):(i=Wp(s),i.c(),ht(i,1),i.m(t.parentNode,t)):i&&(He(),pt(i,1,1,()=>{i=null}),$e())},i(s){e||(ht(i),e=!0)},o(s){pt(i),e=!1},d(s){s&&ft(t),i&&i.d(s)}}}function mA(r){let t,e,i,s,n,o;const a=[pA,fA],l=[];function h(u,c){return u[6]&&u[7]?0:u[6]&&u[8]&&u[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=At("svg"),e=At("g"),s&&s.c(),L(e,"transform",n=r[33]),L(e,"class","svelte-190cqdf"),L(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-190cqdf"),Qs(t,"drawing",r[0])},m(u,c){mt(u,t,c),cr(t,e),~i&&l[i].m(e,null),r[26](e),o=!0},p(u,c){let d=i;i=h(u),i===d?~i&&l[i].p(u,c):(s&&(He(),pt(l[d],1,1,()=>{l[d]=null}),$e()),~i?(s=l[i],s?s.p(u,c):(s=l[i]=a[i](u),s.c()),ht(s,1),s.m(e,null)):s=null),(!o||c[1]&4&&n!==(n=u[33]))&&L(e,"transform",n),(!o||c[0]&1)&&Qs(t,"drawing",u[0])},i(u){o||(ht(s),o=!0)},o(u){pt(s),o=!1},d(u){u&&ft(t),~i&&l[i].d(),r[26](null)}}}function gA(r){let t,e;return t=new $p({props:{viewer:r[3],$$slots:{default:[mA,({transform:i,scale:s})=>({33:i,34:s}),({transform:i,scale:s})=>[0,(i?4:0)|(s?8:0)]]},$$scope:{ctx:r}}}),{c(){ie(t.$$.fragment)},m(i,s){Jt(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.viewer=i[3]),s[0]&511|s[1]&268&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ht(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){Qt(t,i)}}}function yA(r,t,e){let i,s,n,o,{drawingEnabled:a}=t,{filter:l}=t,{preferredDrawingMode:h}=t,{state:u}=t,{style:c=void 0}=t,{toolName:d=Ys()[0]}=t,{user:p}=t,{viewer:f}=t,m=0;const _=()=>e(5,m+=1),g=()=>d,v=()=>a,y=navigator.userAgent.match(/firefox|fxios/i);let x;const{store:b,selection:E,hover:T}=u;ea(r,E,I=>e(24,o=I));let A,M,S;const P=I=>{b.unobserve(A);const F=I.filter(({editable:G})=>G).map(({id:G})=>G);if(F.length>0){if(e(7,M=F.map(G=>b.getAnnotation(G))),A=G=>{const{updated:Q}=G.changes;e(7,M=(Q||[]).map(K=>K.newValue))},b.observe(A,{annotations:F}),y){const{width:G}=f.viewport.viewerElementToViewportRectangle(new kt.Rect(0,0,1,1));f.viewport.panBy(new kt.Point(Math.abs(G/10),0))}}else e(7,M=void 0)},C=(I,F)=>{const{x:G,y:Q}=f.viewport.viewerElementToImageCoordinates(new kt.Point(I,F));return[G,Q]},w=I=>{f.setMouseNavEnabled(!1),S=I.timeStamp},D=I=>{if(f.setMouseNavEnabled(!0),performance.now()-(S||0)<300){const{offsetX:G,offsetY:Q}=I.detail,[K,k]=C(G,Q),it=b.getAt(K,k);it&&(!l||l(it))&&!M.find(B=>B.id===it.id)&&(T.set(it.id),E.setSelected(it.id))}},N=I=>F=>{var k;const{target:G}=I,Q=10*60*1e3,K=((k=G.creator)==null?void 0:k.id)!==p.id||!G.created||new Date().getTime()-G.created.getTime()>Q;b.updateTarget({...G,selector:F.detail,created:K?G.created:new Date,updated:K?new Date:void 0,updatedBy:K?p:void 0})},V=I=>{const F=UE(),G={id:F,bodies:[],target:{annotation:F,selector:I.detail,creator:p,created:new Date}};b.addAnnotation(G),E.setSelected(G.id),f.setMouseNavEnabled(!0)},H=I=>ru(I),W=I=>hr(I);function rt(I){rn[I?"unshift":"push"](()=>{x=I,e(6,x)})}return r.$$set=I=>{"drawingEnabled"in I&&e(0,a=I.drawingEnabled),"filter"in I&&e(16,l=I.filter),"preferredDrawingMode"in I&&e(17,h=I.preferredDrawingMode),"state"in I&&e(18,u=I.state),"style"in I&&e(1,c=I.style),"toolName"in I&&e(2,d=I.toolName),"user"in I&&e(19,p=I.user),"viewer"in I&&e(3,f=I.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(8,{tool:i,opts:s}=qs(d)||{tool:void 0,opts:void 0},i,(e(23,s),e(2,d))),r.$$.dirty[0]&8519680&&e(4,n=(s==null?void 0:s.drawingMode)||h),r.$$.dirty[0]&25&&(a&&n==="drag"?f.setMouseNavEnabled(!1):f.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&E.clear(),r.$$.dirty[0]&16777241&&o.selected.length===0&&n==="drag"&&a&&f.setMouseNavEnabled(!1),r.$$.dirty[0]&16777216&&P(o.selected)},[a,c,d,f,n,m,x,M,i,E,C,w,D,N,V,H,l,h,u,p,_,g,v,s,o,W,rt]}class _A extends de{constructor(t){super(),ce(this,t,yA,gA,re,{drawingEnabled:0,filter:16,preferredDrawingMode:17,state:18,style:1,toolName:2,user:19,viewer:3,cancelDrawing:20,getDrawingTool:21,isDrawingEnabled:22},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[20]}get getDrawingTool(){return this.$$.ctx[21]}get isDrawingEnabled(){return this.$$.ctx[22]}}function vA(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,u,c,d;return{c(){t=At("g"),e=At("rect"),a=At("text"),h=ia(l),L(e,"class","a9s-presence-label-bg svelte-1rehw2p"),L(e,"x",r[0]),L(e,"y",i=r[1]-18/r[3]),L(e,"height",s=18/r[3]),L(e,"fill",n=r[2].appearance.color),L(e,"stroke",o=r[2].appearance.color),L(a,"font-size",u=12/r[3]),L(a,"x",c=r[0]+Math.round(5/r[3])),L(a,"y",d=r[1]-5/r[3]),L(a,"class","svelte-1rehw2p"),L(t,"class","a9s-presence-label")},m(p,f){mt(p,t,f),cr(t,e),cr(t,a),cr(a,h),r[6](t)},p(p,[f]){f&1&&L(e,"x",p[0]),f&10&&i!==(i=p[1]-18/p[3])&&L(e,"y",i),f&8&&s!==(s=18/p[3])&&L(e,"height",s),f&4&&n!==(n=p[2].appearance.color)&&L(e,"fill",n),f&4&&o!==(o=p[2].appearance.color)&&L(e,"stroke",o),f&4&&l!==(l=p[2].appearance.label+"")&&o_(h,l),f&8&&u!==(u=12/p[3])&&L(a,"font-size",u),f&9&&c!==(c=p[0]+Math.round(5/p[3]))&&L(a,"x",c),f&10&&d!==(d=p[1]-5/p[3])&&L(a,"y",d)},i:Ge,o:Ge,d(p){p&&ft(t),r[6](null)}}}function xA(r,t,e){let{x:i}=t,{y:s}=t,{user:n}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=c=>{const d=l.querySelector("text"),p=l.querySelector("rect"),f=d.getBBox().width+10/c;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${f/2}px)`),p.setAttribute("width",`${f}`)};function u(c){rn[c?"unshift":"push"](()=>{l=c,e(4,l)})}return r.$$set=c=>{"x"in c&&e(0,i=c.x),"y"in c&&e(1,s=c.y),"user"in c&&e(2,n=c.user),"scale"in c&&e(3,o=c.scale),"hAlign"in c&&e(5,a=c.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,s,n,o,l,a,u]}class Yp extends de{constructor(t){super(),ce(this,t,xA,vA,re,{x:0,y:1,user:2,scale:3,hAlign:5})}}function bA(r){let t,e,i,s,n,o;return e=new Yp({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=At("g"),ie(e.$$.fragment),i=At("polygon"),L(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),L(i,"stroke",s=r[0].appearance.color),L(i,"fill","transparent"),L(i,"points",n=r[2].points.map(qp).join(" ")),L(t,"class","a9s-presence-overlay")},m(a,l){mt(a,t,l),Jt(e,t,null),cr(t,i),o=!0},p(a,[l]){const h={};l&2&&(h.scale=a[1]),l&1&&(h.user=a[0]),l&8&&(h.x=a[3][0]),l&8&&(h.y=a[3][1]),e.$set(h),(!o||l&1&&s!==(s=a[0].appearance.color))&&L(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map(qp).join(" ")))&&L(i,"points",n)},i(a){o||(ht(e.$$.fragment,a),o=!0)},o(a){pt(e.$$.fragment,a),o=!1},d(a){a&&ft(t),Qt(e)}}}const qp=r=>r.join(",");function wA(r,t,e){let i,s,{annotation:n}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[u,...c]=h.points;return c.forEach(([d,p])=>{p<u[1]&&(u=[d,p])}),u};return r.$$set=h=>{"annotation"in h&&e(4,n=h.annotation),"user"in h&&e(0,o=h.user),"scale"in h&&e(1,a=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=n.target.selector.geometry),r.$$.dirty&4&&e(3,s=l(i))},[o,a,i,s,n]}class TA extends de{constructor(t){super(),ce(this,t,wA,bA,re,{annotation:4,user:0,scale:1})}}function EA(r){let t,e,i,s,n,o,a,l,h;return e=new Yp({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=At("g"),ie(e.$$.fragment),i=At("rect"),L(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),L(i,"stroke",s=r[0].appearance.color),L(i,"fill","transparent"),L(i,"x",n=r[2].x),L(i,"y",o=r[2].y),L(i,"width",a=r[2].w),L(i,"height",l=r[2].h),L(t,"class","a9s-presence-overlay")},m(u,c){mt(u,t,c),Jt(e,t,null),cr(t,i),h=!0},p(u,[c]){const d={};c&2&&(d.scale=u[1]),c&1&&(d.user=u[0]),c&4&&(d.x=u[2].x),c&4&&(d.y=u[2].y),e.$set(d),(!h||c&1&&s!==(s=u[0].appearance.color))&&L(i,"stroke",s),(!h||c&4&&n!==(n=u[2].x))&&L(i,"x",n),(!h||c&4&&o!==(o=u[2].y))&&L(i,"y",o),(!h||c&4&&a!==(a=u[2].w))&&L(i,"width",a),(!h||c&4&&l!==(l=u[2].h))&&L(i,"height",l)},i(u){h||(ht(e.$$.fragment,u),h=!0)},o(u){pt(e.$$.fragment,u),h=!1},d(u){u&&ft(t),Qt(e)}}}function AA(r,t,e){let i,{annotation:s}=t,{user:n}=t,{scale:o}=t;return r.$$set=a=>{"annotation"in a&&e(3,s=a.annotation),"user"in a&&e(0,n=a.user),"scale"in a&&e(1,o=a.scale)},r.$$.update=()=>{r.$$.dirty&8&&e(2,i=s.target.selector.geometry)},[n,o,i,s]}class SA extends de{constructor(t){super(),ce(this,t,AA,EA,re,{annotation:3,user:0,scale:1})}}const{Boolean:CA}=s_;function Kp(r,t,e){const i=r.slice();return i[8]=t[e],i}function Zp(r){let t,e;return t=new $p({props:{viewer:r[0],$$slots:{default:[PA,({transform:i,scale:s})=>({6:i,7:s}),({transform:i,scale:s})=>(i?64:0)|(s?128:0)]},$$scope:{ctx:r}}}),{c(){ie(t.$$.fragment)},m(i,s){Jt(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&2244&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ht(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){Qt(t,i)}}}function Jp(r){let t,e,i=vi(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Qp(Kp(r,i,o));const n=o=>pt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=dr()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);mt(o,t,a),e=!0},p(o,a){if(a&132){i=vi(o[2]);let l;for(l=0;l<i.length;l+=1){const h=Kp(o,i,l);s[l]?(s[l].p(h,a),ht(s[l],1)):(s[l]=Qp(h),s[l].c(),ht(s[l],1),s[l].m(t.parentNode,t))}for(He(),l=i.length;l<s.length;l+=1)n(l);$e()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ht(s[a]);e=!0}},o(o){s=s.filter(CA);for(let a=0;a<s.length;a+=1)pt(s[a]);e=!1},d(o){o&&ft(t),ra(s,o)}}}function IA(r){let t,e;return t=new TA({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){ie(t.$$.fragment)},m(i,s){Jt(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(ht(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){Qt(t,i)}}}function RA(r){let t,e;return t=new SA({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){ie(t.$$.fragment)},m(i,s){Jt(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(ht(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){Qt(t,i)}}}function Qp(r){let t,e,i,s;const n=[RA,IA],o=[];function a(l,h){return l[8].annotation.target.selector.type===Et.RECTANGLE?0:l[8].annotation.target.selector.type===Et.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=dr()},m(l,h){~t&&o[t].m(l,h),mt(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(He(),pt(o[u],1,1,()=>{o[u]=null}),$e()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ht(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ht(e),s=!0)},o(l){pt(e),s=!1},d(l){l&&ft(i),~t&&o[t].d(l)}}}function PA(r){let t,e,i,s,n=r[2].length>0&&Jp(r);return{c(){t=At("svg"),e=At("g"),n&&n.c(),L(e,"transform",i=r[6]),L(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){mt(o,t,a),cr(t,e),n&&n.m(e,null),s=!0},p(o,a){o[2].length>0?n?(n.p(o,a),a&4&&ht(n,1)):(n=Jp(o),n.c(),ht(n,1),n.m(e,null)):n&&(He(),pt(n,1,1,()=>{n=null}),$e()),(!s||a&64&&i!==(i=o[6]))&&L(e,"transform",i)},i(o){s||(ht(n),s=!0)},o(o){pt(n),s=!1},d(o){o&&ft(t),n&&n.d()}}}function MA(r){let t=!!r[1],e,i,s=t&&Zp(r);return{c(){s&&s.c(),e=dr()},m(n,o){s&&s.m(n,o),mt(n,e,o),i=!0},p(n,[o]){o&2&&(t=!!n[1]),t?s?(s.p(n,o),o&2&&ht(s,1)):(s=Zp(n),s.c(),ht(s,1),s.m(e.parentNode,e)):s&&(He(),pt(s,1,1,()=>{s=null}),$e())},i(n){i||(ht(s),i=!0)},o(n){pt(s),i=!1},d(n){n&&ft(e),s&&s.d(n)}}}function DA(r,t,e){let{store:i}=t,{viewer:s}=t,{provider:n}=t,o=[],a;const l=(h,u)=>{e(2,o=[...o.filter(({selectedBy:c})=>c.presenceKey!==h.presenceKey),...(u||[]).map(c=>({annotation:i.getAnnotation(c),selectedBy:h}))].filter(({annotation:c})=>(c||console.warn("Selection event on unknown annotation"),!!c))),a&&i.unobserve(a),a=c=>{const{deleted:d,updated:p}=c.changes,f=new Set((d||[]).map(_=>_.id)),m=o.filter(({annotation:_})=>!f.has(_.id)).map(_=>{const g=(p||[]).find(v=>v.oldValue.id===_.annotation.id);return g?{selectedBy:_.selectedBy,annotation:g.newValue}:_});e(2,o=m)},i.observe(a,{annotations:o.map(c=>c.annotation.id)})};return l_(()=>{a&&i.unobserve(a)}),r.$$set=h=>{"store"in h&&e(3,i=h.store),"viewer"in h&&e(0,s=h.viewer),"provider"in h&&e(1,n=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&n&&n.on("selectionChange",l)},[s,n,o,i]}class BA extends de{constructor(t){super(),ce(this,t,DA,MA,re,{store:3,viewer:0,provider:1})}}const tm=(r,t)=>{t==="auto"?r.addHandler("open",e=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",n=>{const{fullyLoaded:o}=n;if(o){const a=r.canvas.querySelector("canvas"),l=Eu(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},em=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o||!hr(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=s;let[h,u,c,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,u=u/a.width,c=c/a.height,d=d/a.width;const{minX:p,minY:f,maxX:m,maxY:_}=o.target.selector.geometry.bounds,g=m-p,v=_-f,y=p-d*g,x=f-h*v,b=g+(u+d)*g,E=v+(h+c)*v,T=r.viewport.imageToViewportRectangle(y,x,b,E);r.viewport[e](T,s.immediately)},OA=(r,t)=>em(r,t,"fitBounds"),LA=(r,t)=>em(r,t,"fitBoundsWithConstraints"),FA=(r,t={})=>{const e=Su(t,{drawingEnabled:!1,drawingMode:tu?"drag":"click",userSelectAction:Po.EDIT,theme:"light"}),i=Tu(e),{hover:s,selection:n,store:o}=i,a=xm(o,e.initialHistory),l=bm(i,a,e.adapter,e.autoSave);let h=Rm(),u=e.drawingEnabled,c=e.drawingMode,d=e.modalSelect;const p=Iu(a,r.element),f=new OE({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),m=new BA({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),_=new _A({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!u,filter:void 0,preferredDrawingMode:c,state:i,style:e.style,user:h,viewer:r}});f.$on("click",I=>{const{originalEvent:F,annotation:G}=I.detail;d?n.isEmpty()&&G&&n.userSelect(G.id,F):G&&!(c==="click"&&u)?n.userSelect(G.id,F):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",I=>{if(s.current){const F=o.getAnnotation(s.current);l.emit("clickAnnotation",F,I)}}),tm(r,e.theme);const g=Tm(i,a,e.adapter),v=()=>_.cancelDrawing(),y=()=>{f.$destroy(),m.$destroy(),_.$destroy(),p.destroy(),a.destroy()},x=OA(r,o),b=LA(r,o),E=()=>_.getDrawingTool(),T=()=>h,A=()=>_.isDrawingEnabled(),M=(I,F,G)=>hu(I,F,G),S=(I,F)=>iu(I,F),P=I=>{if(!qs(I))throw`No drawing tool named ${I}`;_.$set({toolName:I})},C=I=>{u=I,_.$set({drawingEnabled:I})},w=I=>{f.$set({filter:I}),_.$set({filter:I})},D=I=>d=I,N=I=>{f.$set({style:I}),_.$set({style:I})},V=I=>m.$set({provider:I}),H=I=>tm(r,I),W=I=>{h=I,_.$set({user:I})},rt=I=>f.$set({visible:I});return{...g,cancelDrawing:v,destroy:y,fitBounds:x,fitBoundsWithConstraints:b,getDrawingTool:E,getUser:T,isDrawingEnabled:A,listDrawingTools:Ys,on:l.on,off:l.off,registerDrawingTool:M,registerShapeEditor:S,setDrawingEnabled:C,setDrawingTool:P,setFilter:w,setModalSelect:D,setPresenceProvider:V,setStyle:N,setTheme:H,setUser:W,setVisible:rt,state:i,viewer:r}};Dt.ShapeType=Et,Dt.UserSelectAction=Po,Dt.W3CImageFormat=Xg,Dt.chainStyles=Og,Dt.computeStyle=Bg,Dt.createBody=cm,Dt.createImageAnnotator=e_,Dt.createOSDAnnotator=FA,Dt.defaultColorProvider=Mm,Object.defineProperty(Dt,Symbol.toStringTag,{value:"Module"})});
1147
+ }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=ad(t)),typeof t=="number"?nd(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,Vi.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=et.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};Yl.availableFonts={},Yl.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let ql=Yl;const zn=class Xi extends nr{constructor(t="",e={}){super(it.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,s=it.from(i,{scaleMode:et.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new pt,s.trim=new pt,this.texture=s;const n="http://www.w3.org/2000/svg",a="http://www.w3.org/1999/xhtml",o=document.createElementNS(n,"svg"),l=document.createElementNS(n,"foreignObject"),h=document.createElementNS(a,"div"),u=document.createElementNS(a,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",o.appendChild(l),this.maxWidth=Xi.defaultMaxWidth,this.maxHeight=Xi.defaultMaxHeight,this._domElement=h,this._styleElement=u,this._svgRoot=o,this._foreignObject=l,this._foreignObject.appendChild(u),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Xi.defaultAutoResolution,this._resolution=Xi.defaultResolution??et.RESOLUTION,this.text=t,this.style=e}measureText(t){var u,c;const{text:e,style:i,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(s)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:a,height:o}=n;(a>this.maxWidth||o>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const l=Math.min(this.maxWidth,Math.ceil(a)),h=Math.min(this.maxHeight,Math.ceil(o));return this._svgRoot.setAttribute("width",l.toString()),this._svgRoot.setAttribute("height",h.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(u=this._style)==null?void 0:u.toCSS(s)}),this._styleElement.textContent=(c=this._style)==null?void 0:c.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:s}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:a}=this.measureText();i.width=s.width=Math.ceil(Math.max(1,n)),i.height=s.height=Math.ceil(Math.max(1,a)),this._updateID++;const o=this._updateID;await new Promise(l=>{s.onload=async()=>{if(o<this._updateID){l();return}await e.onBeforeDraw(),i.src=s.src,s.onload=null,s.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:s}=this,{padding:n}=t,{baseTexture:a}=e;e.trim.width=e._frame.width=i.width/s,e.trim.height=e._frame.height=i.height/s,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),a.setRealSize(i.width,i.height,s),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){var i,s,n,a,o;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Xi.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(s=this._svgRoot)==null||s.remove(),this._svgRoot=e,(n=this._domElement)==null||n.remove(),this._domElement=e,(a=this._foreignObject)==null||a.remove(),this._foreignObject=e,(o=this._styleElement)==null||o.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=_r(this.scale.x)||1;this.scale.x=e*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const e=_r(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof ql?(this.ownsStyle=!1,this._style=t):t instanceof Ir?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=ql.from(t)):(this.ownsStyle=!0,this._style=new ql(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")}};zn.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},zn.defaultMaxWidth=2024,zn.defaultMaxHeight=2024,zn.defaultAutoResolution=!0;const Or=new pt;class hp{constructor(t){this.renderer=t}async image(t,e,i,s){const n=new Image;return n.src=await this.base64(t,e,i,s),n}async base64(t,e,i,s){const n=this.canvas(t,s);if(n.toBlob!==void 0)return new Promise((a,o)=>{n.toBlob(l=>{if(!l){o(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>a(h.result),h.onerror=o,h.readAsDataURL(l)},e,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const a=await n.convertToBlob({type:e,quality:i});return new Promise((o,l)=>{const h=new FileReader;h.onload=()=>o(h.result),h.onerror=l,h.readAsDataURL(a)})}throw new Error("CanvasExtract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const i=this.renderer;if(!i)throw new Error("The CanvasExtract has already been destroyed");let s,n,a;t&&(t instanceof sr?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution}),e&&(Or.width=e.width,Or.height=e.height,e=Or))),a?(s=a.baseTexture._canvasRenderTarget.context,n=a.baseTexture._canvasRenderTarget.resolution,e=e??a.frame):(s=i.canvasContext.rootContext,n=i._view.resolution,e||(e=Or,e.width=i.width/n,e.height=i.height/n));const o=Math.round(e.x*n),l=Math.round(e.y*n),h=Math.max(Math.round(e.width*n),1),u=Math.max(Math.round(e.height*n),1),c=new ss(h,u,1),d=s.getImageData(o,l,h,u);return c.context.putImageData(d,0,0),c.canvas}pixels(t,e){const i=this.renderer;if(!i)throw new Error("The CanvasExtract has already been destroyed");let s,n,a;t&&(t instanceof sr?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution}),e&&(Or.width=e.width,Or.height=e.height,e=Or))),a?(s=a.baseTexture._canvasRenderTarget.context,n=a.baseTexture._canvasRenderTarget.resolution,e=e??a.frame):(s=i.canvasContext.rootContext,n=i.resolution,e||(e=Or,e.width=i.width/n,e.height=i.height/n));const o=Math.round(e.x*n),l=Math.round(e.y*n),h=Math.max(Math.round(e.width*n),1),u=Math.max(Math.round(e.height*n),1);return s.getImageData(o,l,h,u).data}destroy(){this.renderer=null}}hp.extension={name:"extract",type:J.CanvasRendererSystem},rt.add(hp);let Kl;const ys=new Ct;gs.prototype.generateCanvasTexture=function(r,t=1){const e=this.getLocalBounds(new pt);e.width=Math.max(e.width,1/t),e.height=Math.max(e.height,1/t);const i=sr.create({width:e.width,height:e.height,scaleMode:r,resolution:t});Kl||(Kl=new vn),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(ys),ys.invert(),ys.tx-=e.x,ys.ty-=e.y,Kl.render(this,{renderTexture:i,clear:!0,transform:ys});const s=it.from(i.baseTexture._canvasRenderTarget.canvas,{scaleMode:r});return s.baseTexture.setResolution(t),s},gs.prototype.cachedGraphicsData=[],gs.prototype._renderCanvas=function(r){this.isMask!==!0&&(this.finishPoly(),r.plugins.graphics.render(this))};class _s{static offsetPolygon(t,e){const i=[],s=t.length;e=_s.isPolygonClockwise(t)?e:-1*e;for(let n=0;n<s;n+=2){let a=n-2;a<0&&(a+=s);const o=(n+2)%s;let l=t[n]-t[a],h=t[n+1]-t[a+1],u=Math.sqrt(l*l+h*h);l/=u,h/=u,l*=e,h*=e;const c=-h,d=l,p=[t[a]+c,t[a+1]+d],f=[t[n]+c,t[n+1]+d];let g=t[o]-t[n],y=t[o+1]-t[n+1];u=Math.sqrt(g*g+y*y),g/=u,y/=u,g*=e,y*=e;const m=-y,_=g,v=[t[n]+m,t[n+1]+_],x=[t[o]+m,t[o+1]+_],b=_s.findIntersection(p[0],p[1],f[0],f[1],v[0],v[1],x[0],x[1]);b&&i.push(...b)}return i}static findIntersection(t,e,i,s,n,a,o,l){const h=(l-a)*(i-t)-(o-n)*(s-e),u=(o-n)*(e-a)-(l-a)*(t-n),c=(i-t)*(e-a)-(s-e)*(t-n);if(h===0)return u===0&&c===0?[(t+i)/2,(e+s)/2]:null;const d=u/h;return[t+d*(i-t),e+d*(s-e)]}static isPolygonClockwise(t){let e=0;for(let i=0,s=t.length-2;i<t.length;s=i,i+=2)e+=(t[i]-t[s])*(t[i+1]+t[s+1]);return e>0}}class up{constructor(t){this._svgMatrix=null,this._tempMatrix=new Ct,this.renderer=t}_calcCanvasStyle(t,e){let i;return t.texture&&t.texture.baseTexture!==it.WHITE.baseTexture?t.texture.valid?(i=jt.getTintedPattern(t.texture,e),this.setPatternTransform(i,t.matrix||Ct.IDENTITY)):i="#808080":i=`#${`00000${(e|0).toString(16)}`.slice(-6)}`,i}render(t){const e=this.renderer,i=e.canvasContext.activeContext,s=t.worldAlpha,n=t.transform.worldTransform;e.canvasContext.setContextTransform(n),e.canvasContext.setBlendMode(t.blendMode);const a=t.geometry.graphicsData;let o,l;const h=_t.shared.setValue(t.tint).toArray();for(let u=0;u<a.length;u++){const c=a[u],d=c.shape,p=c.fillStyle,f=c.lineStyle,g=c.fillStyle.color|0,y=c.lineStyle.color|0;if(c.matrix&&e.canvasContext.setContextTransform(n.copyTo(this._tempMatrix).append(c.matrix)),p.visible&&(o=this._calcCanvasStyle(p,_t.shared.setValue(g).multiply(h).toNumber())),f.visible&&(l=this._calcCanvasStyle(f,_t.shared.setValue(y).multiply(h).toNumber())),i.lineWidth=f.width,i.lineCap=f.cap,i.lineJoin=f.join,i.miterLimit=f.miterLimit,c.type===Rt.POLY){i.beginPath();const m=d;let _=m.points;const v=c.holes;let x,b,R,w,D;i.moveTo(_[0],_[1]);for(let U=2;U<_.length;U+=2)i.lineTo(_[U],_[U+1]);if(m.closeStroke&&i.closePath(),v.length>0){D=[],x=0,R=_[0],w=_[1];for(let U=2;U+2<_.length;U+=2)x+=(_[U]-R)*(_[U+3]-w)-(_[U+2]-R)*(_[U+1]-w);for(let U=0;U<v.length;U++)if(_=v[U].shape.points,!!_){b=0,R=_[0],w=_[1];for(let M=2;M+2<_.length;M+=2)b+=(_[M]-R)*(_[M+3]-w)-(_[M+2]-R)*(_[M+1]-w);if(b*x<0){i.moveTo(_[0],_[1]);for(let M=2;M<_.length;M+=2)i.lineTo(_[M],_[M+1])}else{i.moveTo(_[_.length-2],_[_.length-1]);for(let M=_.length-4;M>=0;M-=2)i.lineTo(_[M],_[M+1])}v[U].shape.closeStroke&&i.closePath(),D[U]=b*x<0}}p.visible&&(i.globalAlpha=p.alpha*s,i.fillStyle=o,i.fill()),f.visible&&this.paintPolygonStroke(m,f,l,v,D,s,i)}else if(c.type===Rt.RECT){const m=d;if(p.visible&&(i.globalAlpha=p.alpha*s,i.fillStyle=o,i.fillRect(m.x,m.y,m.width,m.height)),f.visible){const _=f.width*(.5-(1-f.alignment)),v=m.width+2*_,x=m.height+2*_;i.globalAlpha=f.alpha*s,i.strokeStyle=l,i.strokeRect(m.x-_,m.y-_,v,x)}}else if(c.type===Rt.CIRC){const m=d;if(i.beginPath(),i.arc(m.x,m.y,m.radius,0,2*Math.PI),i.closePath(),p.visible&&(i.globalAlpha=p.alpha*s,i.fillStyle=o,i.fill()),f.visible){if(f.alignment!==.5){const _=f.width*(.5-(1-f.alignment));i.beginPath(),i.arc(m.x,m.y,m.radius+_,0,2*Math.PI),i.closePath()}i.globalAlpha=f.alpha*s,i.strokeStyle=l,i.stroke()}}else if(c.type===Rt.ELIP){const m=d,_=f.alignment===1;if(_||this.paintEllipse(m,p,f,o,s,i),f.visible){if(f.alignment!==.5){const v=.5522848,x=f.width*(.5-(1-f.alignment)),b=(m.width+x)*2,R=(m.height+x)*2,w=m.x-b/2,D=m.y-R/2,U=b/2*v,M=R/2*v,F=w+b,S=D+R,I=w+b/2,H=D+R/2;i.beginPath(),i.moveTo(w,H),i.bezierCurveTo(w,H-M,I-U,D,I,D),i.bezierCurveTo(I+U,D,F,H-M,F,H),i.bezierCurveTo(F,H+M,I+U,S,I,S),i.bezierCurveTo(I-U,S,w,H+M,w,H),i.closePath()}i.globalAlpha=f.alpha*s,i.strokeStyle=l,i.stroke()}_&&this.paintEllipse(m,p,f,o,s,i)}else if(c.type===Rt.RREC){const m=d,_=f.alignment===1;if(_||this.paintRoundedRectangle(m,p,f,o,s,i),f.visible){if(f.alignment!==.5){const v=m.width,x=m.height,b=f.width*(.5-(1-f.alignment)),R=m.x-b,w=m.y-b,D=m.width+2*b,U=m.height+2*b,M=b*(f.alignment>=1?Math.min(D/v,U/x):Math.min(v/D,x/U));let F=m.radius+M;const S=Math.min(D,U)/2;F=F>S?S:F,i.beginPath(),i.moveTo(R,w+F),i.lineTo(R,w+U-F),i.quadraticCurveTo(R,w+U,R+F,w+U),i.lineTo(R+D-F,w+U),i.quadraticCurveTo(R+D,w+U,R+D,w+U-F),i.lineTo(R+D,w+F),i.quadraticCurveTo(R+D,w,R+D-F,w),i.lineTo(R+F,w),i.quadraticCurveTo(R,w,R,w+F),i.closePath()}i.globalAlpha=f.alpha*s,i.strokeStyle=l,i.stroke()}_&&this.paintRoundedRectangle(m,p,f,o,s,i)}}}paintPolygonStroke(t,e,i,s,n,a,o){if(e.alignment!==.5){const l=e.width*(.5-(1-e.alignment));let h=_s.offsetPolygon(t.points,l),u;o.beginPath(),o.moveTo(h[0],h[1]);for(let c=2;c<h.length;c+=2)o.lineTo(h[c],h[c+1]);t.closeStroke&&o.closePath();for(let c=0;c<s.length;c++){if(u=s[c].shape.points,h=_s.offsetPolygon(u,l),n[c]){o.moveTo(h[0],h[1]);for(let d=2;d<h.length;d+=2)o.lineTo(h[d],h[d+1])}else{o.moveTo(h[h.length-2],h[h.length-1]);for(let d=h.length-4;d>=0;d-=2)o.lineTo(h[d],h[d+1])}s[c].shape.closeStroke&&o.closePath()}}o.globalAlpha=e.alpha*a,o.strokeStyle=i,o.stroke()}paintEllipse(t,e,i,s,n,a){const o=t.width*2,l=t.height*2,h=t.x-o/2,u=t.y-l/2,c=.5522848,d=o/2*c,p=l/2*c,f=h+o,g=u+l,y=h+o/2,m=u+l/2;i.alignment===0&&a.save(),a.beginPath(),a.moveTo(h,m),a.bezierCurveTo(h,m-p,y-d,u,y,u),a.bezierCurveTo(y+d,u,f,m-p,f,m),a.bezierCurveTo(f,m+p,y+d,g,y,g),a.bezierCurveTo(y-d,g,h,m+p,h,m),a.closePath(),i.alignment===0&&a.clip(),e.visible&&(a.globalAlpha=e.alpha*n,a.fillStyle=s,a.fill()),i.alignment===0&&a.restore()}paintRoundedRectangle(t,e,i,s,n,a){const o=t.x,l=t.y,h=t.width,u=t.height;let c=t.radius;const d=Math.min(h,u)/2;c=c>d?d:c,i.alignment===0&&a.save(),a.beginPath(),a.moveTo(o,l+c),a.lineTo(o,l+u-c),a.quadraticCurveTo(o,l+u,o+c,l+u),a.lineTo(o+h-c,l+u),a.quadraticCurveTo(o+h,l+u,o+h,l+u-c),a.lineTo(o+h,l+c),a.quadraticCurveTo(o+h,l,o+h-c,l),a.lineTo(o+c,l),a.quadraticCurveTo(o,l,o,l+c),a.closePath(),i.alignment===0&&a.clip(),e.visible&&(a.globalAlpha=e.alpha*n,a.fillStyle=s,a.fill()),i.alignment===0&&a.restore()}setPatternTransform(t,e){if(this._svgMatrix!==!1){if(!this._svgMatrix){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");if(i!=null&&i.createSVGMatrix&&(this._svgMatrix=i.createSVGMatrix()),!this._svgMatrix||!t.setTransform){this._svgMatrix=!1;return}}this._svgMatrix.a=e.a,this._svgMatrix.b=e.b,this._svgMatrix.c=e.c,this._svgMatrix.d=e.d,this._svgMatrix.e=e.tx,this._svgMatrix.f=e.ty,t.setTransform(this._svgMatrix.inverse())}}destroy(){this.renderer=null,this._svgMatrix=null,this._tempMatrix=null}}up.extension={name:"graphics",type:J.CanvasRendererPlugin},rt.add(up),Object.defineProperties(et,{MESH_CANVAS_PADDING:{get(){return ue.defaultCanvasPadding},set(r){ct("7.1.0","settings.MESH_CANVAS_PADDING is deprecated, use Mesh.defaultCanvasPadding"),ue.defaultCanvasPadding=r}}}),Oi.prototype._renderCanvas=function(r,t){r.plugins.mesh.render(t)},Hn.prototype._cachedTint=16777215,Hn.prototype._tintedCanvas=null,Hn.prototype._canvasUvs=null,Hn.prototype._renderCanvas=function(r){const t=r.canvasContext.activeContext,e=this.worldTransform,i=this.tintValue!==16777215,s=this.texture;if(!s.valid)return;i&&this._cachedTint!==this.tintValue&&(this._cachedTint=this.tintValue,this._tintedCanvas=jt.getTintedCanvas(this,this.tintValue));const n=i?this._tintedCanvas:s.baseTexture.getDrawableSource();this._canvasUvs||(this._canvasUvs=[0,0,0,0,0,0,0,0]);const a=this.vertices,o=this._canvasUvs,l=i?0:s.frame.x,h=i?0:s.frame.y,u=l+s.frame.width,c=h+s.frame.height;o[0]=l,o[1]=l+this._leftWidth,o[2]=u-this._rightWidth,o[3]=u,o[4]=h,o[5]=h+this._topHeight,o[6]=c-this._bottomHeight,o[7]=c;for(let d=0;d<8;d++)o[d]*=s.baseTexture.resolution;t.globalAlpha=this.worldAlpha,r.canvasContext.setBlendMode(this.blendMode),r.canvasContext.setContextTransform(e,this.roundPixels);for(let d=0;d<3;d++)for(let p=0;p<3;p++){const f=p*2+d*8,g=Math.max(1,o[p+1]-o[p]),y=Math.max(1,o[d+5]-o[d+4]),m=Math.max(1,a[f+10]-a[f]),_=Math.max(1,a[f+11]-a[f+1]);t.drawImage(n,o[p],o[d+4],g,y,a[f],a[f+1],m,_)}};let cp=!1;ue.prototype._cachedTint=16777215,ue.prototype._tintedCanvas=null,ue.prototype._cachedTexture=null,ue.prototype._renderCanvas=function(r){this.shader.uvMatrix&&(this.shader.uvMatrix.update(),this.calculateUvs()),this.material._renderCanvas?this.material._renderCanvas(r,this):cp||(cp=!0,globalThis.console.warn("Mesh with custom shaders are not supported in CanvasRenderer."))},ue.prototype._canvasPadding=null,ue.defaultCanvasPadding=0,Object.defineProperty(ue.prototype,"canvasPadding",{get(){return this._canvasPadding??ue.defaultCanvasPadding},set(r){this._canvasPadding=r}}),u1.prototype._renderCanvas=function(r){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),this.shader.update&&this.shader.update(),this.calculateUvs(),this.material._renderCanvas(r,this)},c1.prototype._renderCanvas=function(r){(this.autoUpdate||this.geometry._width!==this.shader.texture.height)&&(this.geometry._width=this.shader.texture.height,this.geometry.update()),this.shader.update&&this.shader.update(),this.calculateUvs(),this.material._renderCanvas(r,this)};class dp{constructor(t){this.renderer=t}render(t){const e=this.renderer,i=t.worldTransform;e.canvasContext.activeContext.globalAlpha=t.worldAlpha,e.canvasContext.setBlendMode(t.blendMode),e.canvasContext.setContextTransform(i,t.roundPixels),t.drawMode!==Be.TRIANGLES?this._renderTriangleMesh(t):this._renderTriangles(t)}_renderTriangleMesh(t){const e=t.geometry.buffers[0].data.length;for(let i=0;i<e-2;i++){const s=i*2;this._renderDrawTriangle(t,s,s+2,s+4)}}_renderTriangles(t){const e=t.geometry.getIndex().data,i=e.length;for(let s=0;s<i;s+=3){const n=e[s]*2,a=e[s+1]*2,o=e[s+2]*2;this._renderDrawTriangle(t,n,a,o)}}_renderDrawTriangle(t,e,i,s){var T;const n=this.renderer.canvasContext.activeContext,a=t.geometry.buffers[0].data,{uvs:o,texture:l}=t;if(!l.valid)return;const h=t.tintValue!==16777215,u=l.baseTexture,c=u.width,d=u.height;t._cachedTexture&&t._cachedTexture.baseTexture!==u&&(t._cachedTint=16777215,(T=t._cachedTexture)==null||T.destroy(),t._cachedTexture=null,t._tintedCanvas=null),h&&t._cachedTint!==t.tintValue&&(t._cachedTint=t.tintValue,t._cachedTexture=t._cachedTexture||new it(u),t._tintedCanvas=jt.getTintedCanvas({texture:t._cachedTexture},t.tintValue));const p=h?t._tintedCanvas:u.getDrawableSource(),f=o[e]*u.width,g=o[i]*u.width,y=o[s]*u.width,m=o[e+1]*u.height,_=o[i+1]*u.height,v=o[s+1]*u.height;let x=a[e],b=a[i],R=a[s],w=a[e+1],D=a[i+1],U=a[s+1];const M=t.canvasPadding/this.renderer.canvasContext.activeResolution;if(M>0){const{a:k,b:E,c:P,d:B}=t.worldTransform,G=(x+b+R)/3,z=(w+D+U)/3;let $=x-G,K=w-z,Q=k*$+P*K,O=E*$+B*K,L=Math.sqrt(Q*Q+O*O),Y=1+M/L;x=G+$*Y,w=z+K*Y,$=b-G,K=D-z,Q=k*$+P*K,O=E*$+B*K,L=Math.sqrt(Q*Q+O*O),Y=1+M/L,b=G+$*Y,D=z+K*Y,$=R-G,K=U-z,Q=k*$+P*K,O=E*$+B*K,L=Math.sqrt(Q*Q+O*O),Y=1+M/L,R=G+$*Y,U=z+K*Y}n.save(),n.beginPath(),n.moveTo(x,w),n.lineTo(b,D),n.lineTo(R,U),n.closePath(),n.clip();const F=f*_+m*y+g*v-_*y-m*g-f*v,S=x*_+m*R+b*v-_*R-m*b-x*v,I=f*b+x*y+g*R-b*y-x*g-f*R,H=f*_*R+m*b*y+x*g*v-x*_*y-m*g*R-f*b*v,j=w*_+m*U+D*v-_*U-m*D-w*v,A=f*D+w*y+g*U-D*y-w*g-f*U,C=f*_*U+m*D*y+w*g*v-w*_*y-m*g*U-f*D*v;n.transform(S/F,j/F,I/F,A/F,H/F,C/F),n.drawImage(p,0,0,c*u.resolution,d*u.resolution,0,0,c,d),n.restore(),this.renderer.canvasContext.invalidateBlendMode()}renderMeshFlat(t){const e=this.renderer.canvasContext.activeContext,i=t.geometry.getBuffer("aVertexPosition").data,s=i.length/2;e.beginPath();for(let n=1;n<s-2;++n){const a=n*2,o=i[a],l=i[a+1],h=i[a+2],u=i[a+3],c=i[a+4],d=i[a+5];e.moveTo(o,l),e.lineTo(h,u),e.lineTo(c,d)}e.fillStyle="#FF0000",e.fill(),e.closePath()}destroy(){this.renderer=null}}dp.extension={name:"mesh",type:J.CanvasRendererPlugin},rt.add(dp);const fp=16;function B1(r,t){const e=r;if(t instanceof dt){const i=t.source,s=i.width===0?e.canvas.width:Math.min(e.canvas.width,i.width),n=i.height===0?e.canvas.height:Math.min(e.canvas.height,i.height);return e.ctx.drawImage(i,0,0,s,n,0,0,e.canvas.width,e.canvas.height),!0}return!1}class pp extends $n{constructor(t){super(t),this.uploadHookHelper=this,this.canvas=et.ADAPTER.createCanvas(fp,fp),this.ctx=this.canvas.getContext("2d"),this.registerUploadHook(B1)}destroy(){super.destroy(),this.ctx=null,this.canvas=null}}pp.extension={name:"prepare",type:J.CanvasRendererSystem},rt.add(pp),nr.prototype._tintedCanvas=null,nr.prototype._renderCanvas=function(r){r.plugins.sprite.render(this)};const mp=new Ct;class gp{constructor(t){this.renderer=t}render(t){const e=t._texture,i=this.renderer,s=i.canvasContext.activeContext,n=i.canvasContext.activeResolution;if(!e.valid)return;const a=e._frame.width,o=e._frame.height;let l=e._frame.width,h=e._frame.height;e.trim&&(l=e.trim.width,h=e.trim.height);let u=t.transform.worldTransform,c=0,d=0;const p=e.baseTexture.getDrawableSource();if(e.orig.width<=0||e.orig.height<=0||!e.valid||!p)return;i.canvasContext.setBlendMode(t.blendMode,!0),s.globalAlpha=t.worldAlpha;const f=e.baseTexture.scaleMode===Oe.LINEAR,g=i.canvasContext.smoothProperty;g&&s[g]!==f&&(s[g]=f),e.trim?(c=e.trim.width/2+e.trim.x-t.anchor.x*e.orig.width,d=e.trim.height/2+e.trim.y-t.anchor.y*e.orig.height):(c=(.5-t.anchor.x)*e.orig.width,d=(.5-t.anchor.y)*e.orig.height),e.rotate&&(u.copyTo(mp),u=mp,Bt.matrixAppendRotationInv(u,e.rotate,c,d),c=0,d=0),c-=l/2,d-=h/2,i.canvasContext.setContextTransform(u,t.roundPixels,1),t.roundPixels&&(c=c|0,d=d|0);const y=e.baseTexture.resolution,m=i.canvasContext._outerBlend;m&&(s.save(),s.beginPath(),s.rect(c*n,d*n,l*n,h*n),s.clip()),t.tint!==16777215?((t._cachedTint!==t.tintValue||t._tintedCanvas.tintId!==t._texture._updateID)&&(t._cachedTint=t.tintValue,t._tintedCanvas=jt.getTintedCanvas(t,t.tintValue)),s.drawImage(t._tintedCanvas,0,0,Math.floor(a*y),Math.floor(o*y),Math.floor(c*n),Math.floor(d*n),Math.floor(l*n),Math.floor(h*n))):s.drawImage(p,e._frame.x*y,e._frame.y*y,Math.floor(a*y),Math.floor(o*y),Math.floor(c*n),Math.floor(d*n),Math.floor(l*n),Math.floor(h*n)),m&&s.restore(),i.canvasContext.setBlendMode(q.NORMAL)}destroy(){this.renderer=null}}gp.extension={name:"sprite",type:J.CanvasRendererPlugin},rt.add(gp);function O1(r,t,e){let i,{filter:s}=t,{state:n}=t,{style:a}=t,{viewer:o}=t,{visible:l=!0}=t;const{store:h,hover:u,selection:c,viewport:d}=n;Sa(r,u,f=>e(11,f)),Sa(r,c,f=>e(8,i=f)),Gs();let p;return r.$$set=f=>{"filter"in f&&e(2,s=f.filter),"state"in f&&e(3,n=f.state),"style"in f&&e(4,a=f.style),"viewer"in f&&e(5,o=f.viewer),"visible"in f&&e(6,l=f.visible)},r.$$.update=()=>{r.$$.dirty&132,r.$$.dirty&384,r.$$.dirty&144,r.$$.dirty&192},[u,c,s,n,a,o,l,p,i]}class L1 extends ge{constructor(t){super(),me(this,t,O1,null,ae,{filter:2,state:3,style:4,viewer:5,visible:6})}}const Qt=[];for(let r=0;r<256;++r)Qt.push((r+256).toString(16).slice(1));function F1(r,t=0){return(Qt[r[t+0]]+Qt[r[t+1]]+Qt[r[t+2]]+Qt[r[t+3]]+"-"+Qt[r[t+4]]+Qt[r[t+5]]+"-"+Qt[r[t+6]]+Qt[r[t+7]]+"-"+Qt[r[t+8]]+Qt[r[t+9]]+"-"+Qt[r[t+10]]+Qt[r[t+11]]+Qt[r[t+12]]+Qt[r[t+13]]+Qt[r[t+14]]+Qt[r[t+15]]).toLowerCase()}let Zl;const N1=new Uint8Array(16);function U1(){if(!Zl){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Zl=crypto.getRandomValues.bind(crypto)}return Zl(N1)}const yp={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function k1(r,t,e){var s;if(yp.randomUUID&&!r)return yp.randomUUID();r=r||{};const i=r.random??((s=r.rng)==null?void 0:s.call(r))??U1();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,F1(i)}var Li=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(Li||{});const Jl=(r,t)=>t,G1=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,a])=>{t=Math.min(t,n),e=Math.min(e,a),i=Math.max(i,n),s=Math.max(s,a)}),{minX:t,minY:e,maxX:i,maxY:s}},H1={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:a}=r.geometry,o=0,l=Math.cos(o),h=Math.sin(o),u=t-i,c=e-s,d=l*u+h*c,p=h*u-l*c;return d*d/(n*n)+p*p/(a*a)<=1}};Jl(Li.ELLIPSE,H1);const $1={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,a=i.length-1;n<i.length;a=n++){const o=i[n][0],l=i[n][1],h=i[a][0],u=i[a][1];l>e!=u>e&&t<(h-o)*(e-l)/(u-l)+o&&(s=!s)}return s}};Jl(Li.POLYGON,$1);const V1={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};Jl(Li.RECTANGLE,V1);function _p(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function vp(r){let t,e;return t=new vs({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){ee(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){oe(t.$$.fragment)},m(i,s){re(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(gt(t.$$.fragment,i),e=!0)},o(i){wt(t.$$.fragment,i),e=!1},d(i){ie(t,i)}}}function X1(r){let t,e,i,s,n,a,o,l,h,u,c,d=_i(r[4].points),p=[];for(let g=0;g<d.length;g+=1)p[g]=vp(_p(r,d,g));const f=g=>wt(p[g],1,1,()=>{p[g]=null});return{c(){t=Dt("polygon"),s=De(),n=Dt("polygon"),o=De();for(let g=0;g<p.length;g+=1)p[g].c();l=fr(),W(t,"class","a9s-outer"),W(t,"style",e=r[1]?"display:none;":void 0),W(t,"points",i=r[4].points.map(xp).join(" ")),W(n,"class","a9s-inner a9s-shape-handle"),W(n,"style",r[1]),W(n,"points",a=r[4].points.map(bp).join(" "))},m(g,y){Tt(g,t,y),Tt(g,s,y),Tt(g,n,y),Tt(g,o,y);for(let m=0;m<p.length;m+=1)p[m]&&p[m].m(g,y);Tt(g,l,y),h=!0,u||(c=[Zt(t,"pointerdown",function(){ee(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(n,"pointerdown",function(){ee(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],u=!0)},p(g,y){if(r=g,(!h||y&2&&e!==(e=r[1]?"display:none;":void 0))&&W(t,"style",e),(!h||y&16&&i!==(i=r[4].points.map(xp).join(" ")))&&W(t,"points",i),(!h||y&2)&&W(n,"style",r[1]),(!h||y&16&&a!==(a=r[4].points.map(bp).join(" ")))&&W(n,"points",a),y&536){d=_i(r[4].points);let m;for(m=0;m<d.length;m+=1){const _=_p(r,d,m);p[m]?(p[m].p(_,y),gt(p[m],1)):(p[m]=vp(_),p[m].c(),gt(p[m],1),p[m].m(l.parentNode,l))}for(Ye(),m=d.length;m<p.length;m+=1)f(m);qe()}},i(g){if(!h){for(let y=0;y<d.length;y+=1)gt(p[y]);h=!0}},o(g){p=p.filter(Boolean);for(let y=0;y<p.length;y+=1)wt(p[y]);h=!1},d(g){g&&(bt(t),bt(s),bt(n),bt(o),bt(l)),Ca(p,g),u=!1,cr(c)}}}function W1(r){let t,e;return t=new Tp({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[X1,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){oe(t.$$.fragment)},m(i,s){re(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(gt(t.$$.fragment,i),e=!0)},o(i){wt(t.$$.fragment,i),e=!1},d(i){ie(t,i)}}}const xp=r=>r.join(","),bp=r=>r.join(",");function z1(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:a}=t,{viewportScale:o=1}=t;const l=(d,p,f)=>{let g;const y=d.geometry;p==="SHAPE"?g=y.points.map(([_,v])=>[_+f[0],v+f[1]]):g=y.points.map(([_,v],x)=>p===`HANDLE-${x}`?[_+f[0],v+f[1]]:[_,v]);const m=G1(g);return{...d,geometry:{points:g,bounds:m}}};function h(d){pr.call(this,r,d)}function u(d){pr.call(this,r,d)}function c(d){pr.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,a=d.transform),"viewportScale"in d&&e(3,o=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,a,o,i,l,h,u,c]}class j1 extends ge{constructor(t){super(),me(this,t,z1,W1,ae,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const Y1=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function q1(r){let t,e,i,s,n,a;return{c(){t=Dt("rect"),W(t,"class",e=Us(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),W(t,"x",i=r[0]-r[5]/2),W(t,"y",s=r[1]-r[5]/2),W(t,"width",r[5]),W(t,"height",r[5])},m(o,l){Tt(o,t,l),n||(a=Zt(t,"pointerdown",r[11]),n=!0)},p(o,l){l&256&&e!==(e=Us(`a9s-handle ${o[8].class||""}`.trim())+" svelte-1sgkh33")&&W(t,"class",e),l&33&&i!==(i=o[0]-o[5]/2)&&W(t,"x",i),l&34&&s!==(s=o[1]-o[5]/2)&&W(t,"y",s),l&32&&W(t,"width",o[5]),l&32&&W(t,"height",o[5])},d(o){o&&bt(t),n=!1,a()}}}function K1(r){let t,e,i,s,n,a,o,l,h;return{c(){t=Dt("g"),e=Dt("circle"),s=Dt("rect"),W(e,"cx",r[0]),W(e,"cy",r[1]),W(e,"r",i=r[3]/r[2]),W(e,"class","a9s-touch-halo svelte-1sgkh33"),ks(e,"touched",r[4]),W(s,"class",n=Us(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),W(s,"x",a=r[0]-r[5]/2),W(s,"y",o=r[1]-r[5]/2),W(s,"width",r[5]),W(s,"height",r[5]),W(t,"class","a9s-touch-handle")},m(u,c){Tt(u,t,c),dr(t,e),dr(t,s),l||(h=[Zt(e,"pointerdown",r[10]),Zt(e,"pointerdown",r[6]),Zt(e,"pointerup",r[7]),Zt(s,"pointerdown",r[9]),Zt(s,"pointerdown",r[6]),Zt(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&W(e,"cx",u[0]),c&2&&W(e,"cy",u[1]),c&12&&i!==(i=u[3]/u[2])&&W(e,"r",i),c&16&&ks(e,"touched",u[4]),c&256&&n!==(n=Us(`a9s-handle ${u[8].class||""}`.trim())+" svelte-1sgkh33")&&W(s,"class",n),c&33&&a!==(a=u[0]-u[5]/2)&&W(s,"x",a),c&34&&o!==(o=u[1]-u[5]/2)&&W(s,"y",o),c&32&&W(s,"width",u[5]),c&32&&W(s,"height",u[5])},d(u){u&&bt(t),l=!1,cr(h)}}}function Z1(r){let t;function e(n,a){return Y1?K1:q1}let s=e()(r);return{c(){s.c(),t=fr()},m(n,a){s.m(n,a),Tt(n,t,a)},p(n,[a]){s.p(n,a)},i:je,o:je,d(n){n&&bt(t),s.d(n)}}}function J1(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:a}=t,{radius:o=30}=t,l=!1;const h=f=>{f.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(f){pr.call(this,r,f)}function d(f){pr.call(this,r,f)}function p(f){pr.call(this,r,f)}return r.$$set=f=>{e(8,t=Aa(Aa({},t),Eu(f))),"x"in f&&e(0,s=f.x),"y"in f&&e(1,n=f.y),"scale"in f&&e(2,a=f.scale),"radius"in f&&e(3,o=f.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/a)},t=Eu(t),[s,n,a,o,l,i,h,u,t,c,d,p]}class vs extends ge{constructor(t){super(),me(this,t,J1,Z1,ae,{x:0,y:1,scale:2,radius:3})}}function Q1(r){let t,e,i,s,n,a,o,l,h,u,c,d,p,f,g,y,m,_,v,x,b,R,w,D,U,M,F,S,I,H,j,A,C,T,k,E,P,B,G,z,$,K,Q;return T=new vs({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),T.$on("pointerdown",function(){ee(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),E=new vs({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),E.$on("pointerdown",function(){ee(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),B=new vs({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),B.$on("pointerdown",function(){ee(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),z=new vs({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),z.$on("pointerdown",function(){ee(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=Dt("rect"),o=De(),l=Dt("rect"),p=De(),f=Dt("rect"),_=De(),v=Dt("rect"),w=De(),D=Dt("rect"),S=De(),I=Dt("rect"),C=De(),oe(T.$$.fragment),k=De(),oe(E.$$.fragment),P=De(),oe(B.$$.fragment),G=De(),oe(z.$$.fragment),W(t,"class","a9s-outer"),W(t,"style",e=r[1]?"display:none;":void 0),W(t,"x",i=r[4].x),W(t,"y",s=r[4].y),W(t,"width",n=r[4].w),W(t,"height",a=r[4].h),W(l,"class","a9s-inner a9s-shape-handle"),W(l,"style",r[1]),W(l,"x",h=r[4].x),W(l,"y",u=r[4].y),W(l,"width",c=r[4].w),W(l,"height",d=r[4].h),W(f,"class","a9s-edge-handle a9s-edge-handle-top"),W(f,"x",g=r[4].x),W(f,"y",y=r[4].y),W(f,"height",1),W(f,"width",m=r[4].w),W(v,"class","a9s-edge-handle a9s-edge-handle-right"),W(v,"x",x=r[4].x+r[4].w),W(v,"y",b=r[4].y),W(v,"height",R=r[4].h),W(v,"width",1),W(D,"class","a9s-edge-handle a9s-edge-handle-bottom"),W(D,"x",U=r[4].x),W(D,"y",M=r[4].y+r[4].h),W(D,"height",1),W(D,"width",F=r[4].w),W(I,"class","a9s-edge-handle a9s-edge-handle-left"),W(I,"x",H=r[4].x),W(I,"y",j=r[4].y),W(I,"height",A=r[4].h),W(I,"width",1)},m(O,L){Tt(O,t,L),Tt(O,o,L),Tt(O,l,L),Tt(O,p,L),Tt(O,f,L),Tt(O,_,L),Tt(O,v,L),Tt(O,w,L),Tt(O,D,L),Tt(O,S,L),Tt(O,I,L),Tt(O,C,L),re(T,O,L),Tt(O,k,L),re(E,O,L),Tt(O,P,L),re(B,O,L),Tt(O,G,L),re(z,O,L),$=!0,K||(Q=[Zt(t,"pointerdown",function(){ee(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(l,"pointerdown",function(){ee(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(f,"pointerdown",function(){ee(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Zt(v,"pointerdown",function(){ee(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Zt(D,"pointerdown",function(){ee(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Zt(I,"pointerdown",function(){ee(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],K=!0)},p(O,L){r=O,(!$||L&2&&e!==(e=r[1]?"display:none;":void 0))&&W(t,"style",e),(!$||L&16&&i!==(i=r[4].x))&&W(t,"x",i),(!$||L&16&&s!==(s=r[4].y))&&W(t,"y",s),(!$||L&16&&n!==(n=r[4].w))&&W(t,"width",n),(!$||L&16&&a!==(a=r[4].h))&&W(t,"height",a),(!$||L&2)&&W(l,"style",r[1]),(!$||L&16&&h!==(h=r[4].x))&&W(l,"x",h),(!$||L&16&&u!==(u=r[4].y))&&W(l,"y",u),(!$||L&16&&c!==(c=r[4].w))&&W(l,"width",c),(!$||L&16&&d!==(d=r[4].h))&&W(l,"height",d),(!$||L&16&&g!==(g=r[4].x))&&W(f,"x",g),(!$||L&16&&y!==(y=r[4].y))&&W(f,"y",y),(!$||L&16&&m!==(m=r[4].w))&&W(f,"width",m),(!$||L&16&&x!==(x=r[4].x+r[4].w))&&W(v,"x",x),(!$||L&16&&b!==(b=r[4].y))&&W(v,"y",b),(!$||L&16&&R!==(R=r[4].h))&&W(v,"height",R),(!$||L&16&&U!==(U=r[4].x))&&W(D,"x",U),(!$||L&16&&M!==(M=r[4].y+r[4].h))&&W(D,"y",M),(!$||L&16&&F!==(F=r[4].w))&&W(D,"width",F),(!$||L&16&&H!==(H=r[4].x))&&W(I,"x",H),(!$||L&16&&j!==(j=r[4].y))&&W(I,"y",j),(!$||L&16&&A!==(A=r[4].h))&&W(I,"height",A);const Y={};L&16&&(Y.x=r[4].x),L&16&&(Y.y=r[4].y),L&8&&(Y.scale=r[3]),T.$set(Y);const tt={};L&16&&(tt.x=r[4].x+r[4].w),L&16&&(tt.y=r[4].y),L&8&&(tt.scale=r[3]),E.$set(tt);const st={};L&16&&(st.x=r[4].x+r[4].w),L&16&&(st.y=r[4].y+r[4].h),L&8&&(st.scale=r[3]),B.$set(st);const lt={};L&16&&(lt.x=r[4].x),L&16&&(lt.y=r[4].y+r[4].h),L&8&&(lt.scale=r[3]),z.$set(lt)},i(O){$||(gt(T.$$.fragment,O),gt(E.$$.fragment,O),gt(B.$$.fragment,O),gt(z.$$.fragment,O),$=!0)},o(O){wt(T.$$.fragment,O),wt(E.$$.fragment,O),wt(B.$$.fragment,O),wt(z.$$.fragment,O),$=!1},d(O){O&&(bt(t),bt(o),bt(l),bt(p),bt(f),bt(_),bt(v),bt(w),bt(D),bt(S),bt(I),bt(C),bt(k),bt(P),bt(G)),ie(T,O),ie(E,O),ie(B,O),ie(z,O),K=!1,cr(Q)}}}function tw(r){let t,e;return t=new Tp({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Q1,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){oe(t.$$.fragment)},m(i,s){re(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(gt(t.$$.fragment,i),e=!0)},o(i){wt(t.$$.fragment,i),e=!1},d(i){ie(t,i)}}}function ew(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:a}=t,{viewportScale:o=1}=t;const l=(d,p,f)=>{const g=d.geometry.bounds;let[y,m]=[g.minX,g.minY],[_,v]=[g.maxX,g.maxY];const[x,b]=f;if(p==="SHAPE")y+=x,_+=x,m+=b,v+=b;else{switch(p){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{m+=b;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{v+=b;break}}switch(p){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{y+=x;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{_+=x;break}}}const R=Math.min(y,_),w=Math.min(m,v),D=Math.abs(_-y),U=Math.abs(v-m);return{...d,geometry:{x:R,y:w,w:D,h:U,bounds:{minX:R,minY:w,maxX:R+D,maxY:w+U}}}};function h(d){pr.call(this,r,d)}function u(d){pr.call(this,r,d)}function c(d){pr.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,a=d.transform),"viewportScale"in d&&e(3,o=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,a,o,i,l,h,u,c]}class rw extends ge{constructor(t){super(),me(this,t,ew,tw,ae,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}Li.RECTANGLE,Li.POLYGON;const iw=r=>({}),wp=r=>({grab:r[0]});function sw(r){let t,e,i,s;const n=r[7].default,a=vu(n,r,r[6],wp);return{c(){t=Dt("g"),a&&a.c(),W(t,"class","a9s-annotation selected")},m(o,l){Tt(o,t,l),a&&a.m(t,null),e=!0,i||(s=[Zt(t,"pointerup",r[2]),Zt(t,"pointermove",r[1])],i=!0)},p(o,[l]){a&&a.p&&(!e||l&64)&&wu(a,n,o,o[6],e?bu(n,o[6],l,iw):Tu(o[6]),wp)},i(o){e||(gt(a,o),e=!0)},o(o){wt(a,o),e=!1},d(o){o&&bt(t),a&&a.d(o),i=!1,cr(s)}}}function nw(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Gs();let{shape:a}=t,{editor:o}=t,{transform:l}=t,h,u,c;const d=g=>y=>{h=g,u=l.elementToImage(y.offsetX,y.offsetY),c=a,y.target.setPointerCapture(y.pointerId),n("grab",y)},p=g=>{if(h){const[y,m]=l.elementToImage(g.offsetX,g.offsetY),_=[y-u[0],m-u[1]];e(3,a=o(c,h,_)),n("change",a)}},f=g=>{g.target.releasePointerCapture(g.pointerId),h=void 0,c=a,n("release",g)};return r.$$set=g=>{"shape"in g&&e(3,a=g.shape),"editor"in g&&e(4,o=g.editor),"transform"in g&&e(5,l=g.transform),"$$scope"in g&&e(6,s=g.$$scope)},[d,p,f,a,o,l,s,i]}class Tp extends ge{constructor(t){super(),me(this,t,nw,sw,ae,{shape:3,editor:4,transform:5})}}const aw=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:a,strokeOpacity:o}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${a||"1"};`,l+=`stroke-opacity:${o||"1"};`),l}};function ow(r,t,e){let i;Gs();let{annotation:s}=t,{editor:n}=t,{style:a}=t,{target:o}=t,{transform:l}=t,{viewportScale:h}=t,u;return r.$$set=c=>{"annotation"in c&&e(0,s=c.annotation),"editor"in c&&e(1,n=c.editor),"style"in c&&e(2,a=c.style),"target"in c&&e(3,o=c.target),"transform"in c&&e(4,l=c.transform),"viewportScale"in c&&e(5,h=c.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=aw(s,a)),r.$$.dirty&65,r.$$.dirty&80,r.$$.dirty&96,r.$$.dirty&192},[s,n,a,o,l,h,u,i]}class lw extends ge{constructor(t){super(),me(this,t,ow,null,ae,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;const hw=r=>({transform:r&2,scale:r&1}),Ep=r=>({transform:r[1],scale:r[0]});function uw(r){let t;const e=r[4].default,i=vu(e,r,r[3],Ep);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&wu(i,e,s,s[3],t?bu(e,s[3],n,hw):Tu(s[3]),Ep)},i(s){t||(gt(i,s),t=!0)},o(s){wt(i,s),t=!1},d(s){i&&i.d(s)}}}function cw(r,t,e){let{$$slots:i={},$$scope:s}=t,{viewer:n}=t,a=1,o;return r.$$set=l=>{"viewer"in l&&e(2,n=l.viewer),"$$scope"in l&&e(3,s=l.$$scope)},[a,o,n,s,i]}class Ap extends ge{constructor(t){super(),me(this,t,cw,uw,ae,{viewer:2})}}function dw(r,t,e){Gs();let{drawingMode:i}=t,{target:s}=t,{tool:n}=t,{transform:a}=t,{viewer:o}=t,{viewportScale:l}=t,h;return r.$$set=u=>{"drawingMode"in u&&e(0,i=u.drawingMode),"target"in u&&e(1,s=u.target),"tool"in u&&e(2,n=u.tool),"transform"in u&&e(3,a=u.transform),"viewer"in u&&e(4,o=u.viewer),"viewportScale"in u&&e(5,l=u.viewportScale)},r.$$.update=()=>{r.$$.dirty&72,r.$$.dirty&96},[i,s,n,a,o,l,h]}class fw extends ge{constructor(t){super(),me(this,t,dw,null,ae,{drawingMode:0,target:1,tool:2,transform:3,viewer:4,viewportScale:5})}}function Sp(r,t,e){const i=r.slice();i[35]=t[e];const s=i[15](i[35].target.selector);return i[36]=s,i}function pw(r){let t=`${r[2]}-${r[5]}`,e,i,s=Cp(r);return{c(){s.c(),e=fr()},m(n,a){s.m(n,a),Tt(n,e,a),i=!0},p(n,a){a[0]&36&&ae(t,t=`${n[2]}-${n[5]}`)?(Ye(),wt(s,1,1,je),qe(),s=Cp(n),s.c(),gt(s,1),s.m(e.parentNode,e)):s.p(n,a)},i(n){i||(gt(s),i=!0)},o(n){wt(s),i=!1},d(n){n&&bt(e),s.d(n)}}}function mw(r){let t,e,i=_i(r[7].filter(r[25])),s=[];for(let a=0;a<i.length;a+=1)s[a]=Pp(Sp(r,i,a));const n=a=>wt(s[a],1,1,()=>{s[a]=null});return{c(){for(let a=0;a<s.length;a+=1)s[a].c();t=fr()},m(a,o){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(a,o);Tt(a,t,o),e=!0},p(a,o){if(o[0]&48322|o[1]&8){i=_i(a[7].filter(a[25]));let l;for(l=0;l<i.length;l+=1){const h=Sp(a,i,l);s[l]?(s[l].p(h,o),gt(s[l],1)):(s[l]=Pp(h),s[l].c(),gt(s[l],1),s[l].m(t.parentNode,t))}for(Ye(),l=i.length;l<s.length;l+=1)n(l);qe()}},i(a){if(!e){for(let o=0;o<i.length;o+=1)gt(s[o]);e=!0}},o(a){s=s.filter(Boolean);for(let o=0;o<s.length;o+=1)wt(s[o]);e=!1},d(a){a&&bt(t),Ca(s,a)}}}function Cp(r){let t,e;return t=new fw({props:{target:r[6],tool:r[8],drawingMode:r[4],transform:{elementToImage:r[10]},viewer:r[3],viewportScale:r[34]}}),t.$on("create",r[14]),{c(){oe(t.$$.fragment)},m(i,s){re(t,i,s),e=!0},p(i,s){const n={};s[0]&64&&(n.target=i[6]),s[0]&256&&(n.tool=i[8]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[1]&8&&(n.viewportScale=i[34]),t.$set(n)},i(i){e||(gt(t.$$.fragment,i),e=!0)},o(i){wt(t.$$.fragment,i),e=!1},d(i){ie(t,i)}}}function Ip(r){let t=r[35].id,e,i,s=Rp(r);return{c(){s.c(),e=fr()},m(n,a){s.m(n,a),Tt(n,e,a),i=!0},p(n,a){a[0]&128&&ae(t,t=n[35].id)?(Ye(),wt(s,1,1,je),qe(),s=Rp(n),s.c(),gt(s,1),s.m(e.parentNode,e)):s.p(n,a)},i(n){i||(gt(s),i=!0)},o(n){wt(s),i=!1},d(n){n&&bt(e),s.d(n)}}}function Rp(r){let t,e;return t=new lw({props:{target:r[6],editor:r[15](r[35].target.selector),annotation:r[35],style:r[1],transform:{elementToImage:r[10]},viewportScale:r[34]}}),t.$on("grab",r[11]),t.$on("change",function(){ee(r[13](r[35]))&&r[13](r[35]).apply(this,arguments)}),t.$on("release",r[12]),{c(){oe(t.$$.fragment)},m(i,s){re(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&64&&(n.target=r[6]),s[0]&128&&(n.editor=r[15](r[35].target.selector)),s[0]&128&&(n.annotation=r[35]),s[0]&2&&(n.style=r[1]),s[1]&8&&(n.viewportScale=r[34]),t.$set(n)},i(i){e||(gt(t.$$.fragment,i),e=!0)},o(i){wt(t.$$.fragment,i),e=!1},d(i){ie(t,i)}}}function Pp(r){let t,e,i=r[36]&&Ip(r);return{c(){i&&i.c(),t=fr()},m(s,n){i&&i.m(s,n),Tt(s,t,n),e=!0},p(s,n){s[36]?i?(i.p(s,n),n[0]&128&&gt(i,1)):(i=Ip(s),i.c(),gt(i,1),i.m(t.parentNode,t)):i&&(Ye(),wt(i,1,1,()=>{i=null}),qe())},i(s){e||(gt(i),e=!0)},o(s){wt(i),e=!1},d(s){s&&bt(t),i&&i.d(s)}}}function gw(r){let t,e,i,s,n,a;const o=[mw,pw],l=[];function h(u,c){return u[6]&&u[7]?0:u[6]&&u[8]&&u[0]?1:-1}return~(i=h(r))&&(s=l[i]=o[i](r)),{c(){t=Dt("svg"),e=Dt("g"),s&&s.c(),W(e,"transform",n=r[33]),W(e,"class","svelte-190cqdf"),W(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-190cqdf"),ks(t,"drawing",r[0])},m(u,c){Tt(u,t,c),dr(t,e),~i&&l[i].m(e,null),r[26](e),a=!0},p(u,c){let d=i;i=h(u),i===d?~i&&l[i].p(u,c):(s&&(Ye(),wt(l[d],1,1,()=>{l[d]=null}),qe()),~i?(s=l[i],s?s.p(u,c):(s=l[i]=o[i](u),s.c()),gt(s,1),s.m(e,null)):s=null),(!a||c[1]&4&&n!==(n=u[33]))&&W(e,"transform",n),(!a||c[0]&1)&&ks(t,"drawing",u[0])},i(u){a||(gt(s),a=!0)},o(u){wt(s),a=!1},d(u){u&&bt(t),~i&&l[i].d(),r[26](null)}}}function yw(r){let t,e;return t=new Ap({props:{viewer:r[3],$$slots:{default:[gw,({transform:i,scale:s})=>({33:i,34:s}),({transform:i,scale:s})=>[0,(i?4:0)|(s?8:0)]]},$$scope:{ctx:r}}}),{c(){oe(t.$$.fragment)},m(i,s){re(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.viewer=i[3]),s[0]&511|s[1]&268&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(gt(t.$$.fragment,i),e=!0)},o(i){wt(t.$$.fragment,i),e=!1},d(i){ie(t,i)}}}function _w(r,t,e){let i,s,n,a,{drawingEnabled:o}=t,{filter:l}=t,{preferredDrawingMode:h}=t,{state:u}=t,{style:c=void 0}=t,{toolName:d=Os()[0]}=t,{user:p}=t,{viewer:f}=t,g=0;const y=()=>e(5,g+=1),m=()=>d,_=()=>o,v=navigator.userAgent.match(/firefox|fxios/i);let x;const{store:b,selection:R,hover:w}=u;Sa(r,R,E=>e(24,a=E));let D,U,M;const F=E=>{b.unobserve(D);const P=E.filter(({editable:B})=>B).map(({id:B})=>B);if(P.length>0){if(e(7,U=P.map(B=>b.getAnnotation(B))),D=B=>{const{updated:G}=B.changes;e(7,U=(G||[]).map(z=>z.newValue))},b.observe(D,{annotations:P}),v){const{width:B}=f.viewport.viewerElementToViewportRectangle(new ne.Rect(0,0,1,1));f.viewport.panBy(new ne.Point(Math.abs(B/10),0))}}else e(7,U=void 0)},S=(E,P)=>{const{x:B,y:G}=f.viewport.viewerElementToImageCoordinates(new ne.Point(E,P));return[B,G]},I=E=>{f.setMouseNavEnabled(!1),M=E.timeStamp},H=E=>{if(f.setMouseNavEnabled(!0),performance.now()-(M||0)<300){const{offsetX:B,offsetY:G}=E.detail,[z,$]=S(B,G),K=b.getAt(z,$);K&&(!l||l(K))&&!U.find(O=>O.id===K.id)&&(w.set(K.id),R.setSelected(K.id))}},j=E=>P=>{var $;const{target:B}=E,G=10*60*1e3,z=(($=B.creator)==null?void 0:$.id)!==p.id||!B.created||new Date().getTime()-B.created.getTime()>G;b.updateTarget({...B,selector:P.detail,created:z?B.created:new Date,updated:z?new Date:void 0,updatedBy:z?p:void 0})},A=E=>{const P=k1(),B={id:P,bodies:[],target:{annotation:P,selector:E.detail,creator:p,created:new Date}};b.addAnnotation(B),R.setSelected(B.id),f.setMouseNavEnabled(!0)},C=E=>Xh(E),T=E=>ui(E);function k(E){Hs[E?"unshift":"push"](()=>{x=E,e(6,x)})}return r.$$set=E=>{"drawingEnabled"in E&&e(0,o=E.drawingEnabled),"filter"in E&&e(16,l=E.filter),"preferredDrawingMode"in E&&e(17,h=E.preferredDrawingMode),"state"in E&&e(18,u=E.state),"style"in E&&e(1,c=E.style),"toolName"in E&&e(2,d=E.toolName),"user"in E&&e(19,p=E.user),"viewer"in E&&e(3,f=E.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(8,{tool:i,opts:s}=Ls(d)||{tool:void 0,opts:void 0},i,(e(23,s),e(2,d))),r.$$.dirty[0]&8519680&&e(4,n=(s==null?void 0:s.drawingMode)||h),r.$$.dirty[0]&25&&(o&&n==="drag"?f.setMouseNavEnabled(!1):f.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&o&&R.clear(),r.$$.dirty[0]&16777241&&a.selected.length===0&&n==="drag"&&o&&f.setMouseNavEnabled(!1),r.$$.dirty[0]&16777216&&F(a.selected)},[o,c,d,f,n,g,x,U,i,R,S,I,H,j,A,C,l,h,u,p,y,m,_,s,a,T,k]}class vw extends ge{constructor(t){super(),me(this,t,_w,yw,ae,{drawingEnabled:0,filter:16,preferredDrawingMode:17,state:18,style:1,toolName:2,user:19,viewer:3,cancelDrawing:20,getDrawingTool:21,isDrawingEnabled:22},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[20]}get getDrawingTool(){return this.$$.ctx[21]}get isDrawingEnabled(){return this.$$.ctx[22]}}function xw(r){let t,e,i,s,n,a,o,l=r[2].appearance.label+"",h,u,c,d;return{c(){t=Dt("g"),e=Dt("rect"),o=Dt("text"),h=Ia(l),W(e,"class","a9s-presence-label-bg svelte-1rehw2p"),W(e,"x",r[0]),W(e,"y",i=r[1]-18/r[3]),W(e,"height",s=18/r[3]),W(e,"fill",n=r[2].appearance.color),W(e,"stroke",a=r[2].appearance.color),W(o,"font-size",u=12/r[3]),W(o,"x",c=r[0]+Math.round(5/r[3])),W(o,"y",d=r[1]-5/r[3]),W(o,"class","svelte-1rehw2p"),W(t,"class","a9s-presence-label")},m(p,f){Tt(p,t,f),dr(t,e),dr(t,o),dr(o,h),r[6](t)},p(p,[f]){f&1&&W(e,"x",p[0]),f&10&&i!==(i=p[1]-18/p[3])&&W(e,"y",i),f&8&&s!==(s=18/p[3])&&W(e,"height",s),f&4&&n!==(n=p[2].appearance.color)&&W(e,"fill",n),f&4&&a!==(a=p[2].appearance.color)&&W(e,"stroke",a),f&4&&l!==(l=p[2].appearance.label+"")&&Qy(h,l),f&8&&u!==(u=12/p[3])&&W(o,"font-size",u),f&9&&c!==(c=p[0]+Math.round(5/p[3]))&&W(o,"x",c),f&10&&d!==(d=p[1]-5/p[3])&&W(o,"y",d)},i:je,o:je,d(p){p&&bt(t),r[6](null)}}}function bw(r,t,e){let{x:i}=t,{y:s}=t,{user:n}=t,{scale:a}=t,{hAlign:o=null}=t,l;const h=c=>{const d=l.querySelector("text"),p=l.querySelector("rect"),f=d.getBBox().width+10/c;o==="CENTER"&&l.setAttribute("style",`transform: translateX(-${f/2}px)`),p.setAttribute("width",`${f}`)};function u(c){Hs[c?"unshift":"push"](()=>{l=c,e(4,l)})}return r.$$set=c=>{"x"in c&&e(0,i=c.x),"y"in c&&e(1,s=c.y),"user"in c&&e(2,n=c.user),"scale"in c&&e(3,a=c.scale),"hAlign"in c&&e(5,o=c.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(a)},[i,s,n,a,l,o,u]}class Mp extends ge{constructor(t){super(),me(this,t,bw,xw,ae,{x:0,y:1,user:2,scale:3,hAlign:5})}}function ww(r){let t,e,i,s,n,a;return e=new Mp({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=Dt("g"),oe(e.$$.fragment),i=Dt("polygon"),W(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),W(i,"stroke",s=r[0].appearance.color),W(i,"fill","transparent"),W(i,"points",n=r[2].points.map(Dp).join(" ")),W(t,"class","a9s-presence-overlay")},m(o,l){Tt(o,t,l),re(e,t,null),dr(t,i),a=!0},p(o,[l]){const h={};l&2&&(h.scale=o[1]),l&1&&(h.user=o[0]),l&8&&(h.x=o[3][0]),l&8&&(h.y=o[3][1]),e.$set(h),(!a||l&1&&s!==(s=o[0].appearance.color))&&W(i,"stroke",s),(!a||l&4&&n!==(n=o[2].points.map(Dp).join(" ")))&&W(i,"points",n)},i(o){a||(gt(e.$$.fragment,o),a=!0)},o(o){wt(e.$$.fragment,o),a=!1},d(o){o&&bt(t),ie(e)}}}const Dp=r=>r.join(",");function Tw(r,t,e){let i,s,{annotation:n}=t,{user:a}=t,{scale:o}=t;const l=h=>{let[u,...c]=h.points;return c.forEach(([d,p])=>{p<u[1]&&(u=[d,p])}),u};return r.$$set=h=>{"annotation"in h&&e(4,n=h.annotation),"user"in h&&e(0,a=h.user),"scale"in h&&e(1,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=n.target.selector.geometry),r.$$.dirty&4&&e(3,s=l(i))},[a,o,i,s,n]}class Ew extends ge{constructor(t){super(),me(this,t,Tw,ww,ae,{annotation:4,user:0,scale:1})}}function Aw(r){let t,e,i,s,n,a,o,l,h;return e=new Mp({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=Dt("g"),oe(e.$$.fragment),i=Dt("rect"),W(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),W(i,"stroke",s=r[0].appearance.color),W(i,"fill","transparent"),W(i,"x",n=r[2].x),W(i,"y",a=r[2].y),W(i,"width",o=r[2].w),W(i,"height",l=r[2].h),W(t,"class","a9s-presence-overlay")},m(u,c){Tt(u,t,c),re(e,t,null),dr(t,i),h=!0},p(u,[c]){const d={};c&2&&(d.scale=u[1]),c&1&&(d.user=u[0]),c&4&&(d.x=u[2].x),c&4&&(d.y=u[2].y),e.$set(d),(!h||c&1&&s!==(s=u[0].appearance.color))&&W(i,"stroke",s),(!h||c&4&&n!==(n=u[2].x))&&W(i,"x",n),(!h||c&4&&a!==(a=u[2].y))&&W(i,"y",a),(!h||c&4&&o!==(o=u[2].w))&&W(i,"width",o),(!h||c&4&&l!==(l=u[2].h))&&W(i,"height",l)},i(u){h||(gt(e.$$.fragment,u),h=!0)},o(u){wt(e.$$.fragment,u),h=!1},d(u){u&&bt(t),ie(e)}}}function Sw(r,t,e){let i,{annotation:s}=t,{user:n}=t,{scale:a}=t;return r.$$set=o=>{"annotation"in o&&e(3,s=o.annotation),"user"in o&&e(0,n=o.user),"scale"in o&&e(1,a=o.scale)},r.$$.update=()=>{r.$$.dirty&8&&e(2,i=s.target.selector.geometry)},[n,a,i,s]}class Cw extends ge{constructor(t){super(),me(this,t,Sw,Aw,ae,{annotation:3,user:0,scale:1})}}const{Boolean:Iw}=Zy;function Bp(r,t,e){const i=r.slice();return i[8]=t[e],i}function Op(r){let t,e;return t=new Ap({props:{viewer:r[0],$$slots:{default:[Mw,({transform:i,scale:s})=>({6:i,7:s}),({transform:i,scale:s})=>(i?64:0)|(s?128:0)]},$$scope:{ctx:r}}}),{c(){oe(t.$$.fragment)},m(i,s){re(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&2244&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(gt(t.$$.fragment,i),e=!0)},o(i){wt(t.$$.fragment,i),e=!1},d(i){ie(t,i)}}}function Lp(r){let t,e,i=_i(r[2]),s=[];for(let a=0;a<i.length;a+=1)s[a]=Fp(Bp(r,i,a));const n=a=>wt(s[a],1,1,()=>{s[a]=null});return{c(){for(let a=0;a<s.length;a+=1)s[a].c();t=fr()},m(a,o){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(a,o);Tt(a,t,o),e=!0},p(a,o){if(o&132){i=_i(a[2]);let l;for(l=0;l<i.length;l+=1){const h=Bp(a,i,l);s[l]?(s[l].p(h,o),gt(s[l],1)):(s[l]=Fp(h),s[l].c(),gt(s[l],1),s[l].m(t.parentNode,t))}for(Ye(),l=i.length;l<s.length;l+=1)n(l);qe()}},i(a){if(!e){for(let o=0;o<i.length;o+=1)gt(s[o]);e=!0}},o(a){s=s.filter(Iw);for(let o=0;o<s.length;o+=1)wt(s[o]);e=!1},d(a){a&&bt(t),Ca(s,a)}}}function Rw(r){let t,e;return t=new Ew({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){oe(t.$$.fragment)},m(i,s){re(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(gt(t.$$.fragment,i),e=!0)},o(i){wt(t.$$.fragment,i),e=!1},d(i){ie(t,i)}}}function Pw(r){let t,e;return t=new Cw({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){oe(t.$$.fragment)},m(i,s){re(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(gt(t.$$.fragment,i),e=!0)},o(i){wt(t.$$.fragment,i),e=!1},d(i){ie(t,i)}}}function Fp(r){let t,e,i,s;const n=[Pw,Rw],a=[];function o(l,h){return l[8].annotation.target.selector.type===Nt.RECTANGLE?0:l[8].annotation.target.selector.type===Nt.POLYGON?1:-1}return~(t=o(r))&&(e=a[t]=n[t](r)),{c(){e&&e.c(),i=fr()},m(l,h){~t&&a[t].m(l,h),Tt(l,i,h),s=!0},p(l,h){let u=t;t=o(l),t===u?~t&&a[t].p(l,h):(e&&(Ye(),wt(a[u],1,1,()=>{a[u]=null}),qe()),~t?(e=a[t],e?e.p(l,h):(e=a[t]=n[t](l),e.c()),gt(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(gt(e),s=!0)},o(l){wt(e),s=!1},d(l){l&&bt(i),~t&&a[t].d(l)}}}function Mw(r){let t,e,i,s,n=r[2].length>0&&Lp(r);return{c(){t=Dt("svg"),e=Dt("g"),n&&n.c(),W(e,"transform",i=r[6]),W(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(a,o){Tt(a,t,o),dr(t,e),n&&n.m(e,null),s=!0},p(a,o){a[2].length>0?n?(n.p(a,o),o&4&&gt(n,1)):(n=Lp(a),n.c(),gt(n,1),n.m(e,null)):n&&(Ye(),wt(n,1,1,()=>{n=null}),qe()),(!s||o&64&&i!==(i=a[6]))&&W(e,"transform",i)},i(a){s||(gt(n),s=!0)},o(a){wt(n),s=!1},d(a){a&&bt(t),n&&n.d()}}}function Dw(r){let t=!!r[1],e,i,s=t&&Op(r);return{c(){s&&s.c(),e=fr()},m(n,a){s&&s.m(n,a),Tt(n,e,a),i=!0},p(n,[a]){a&2&&(t=!!n[1]),t?s?(s.p(n,a),a&2&&gt(s,1)):(s=Op(n),s.c(),gt(s,1),s.m(e.parentNode,e)):s&&(Ye(),wt(s,1,1,()=>{s=null}),qe())},i(n){i||(gt(s),i=!0)},o(n){wt(s),i=!1},d(n){n&&bt(e),s&&s.d(n)}}}function Bw(r,t,e){let{store:i}=t,{viewer:s}=t,{provider:n}=t,a=[],o;const l=(h,u)=>{e(2,a=[...a.filter(({selectedBy:c})=>c.presenceKey!==h.presenceKey),...(u||[]).map(c=>({annotation:i.getAnnotation(c),selectedBy:h}))].filter(({annotation:c})=>(c||console.warn("Selection event on unknown annotation"),!!c))),o&&i.unobserve(o),o=c=>{const{deleted:d,updated:p}=c.changes,f=new Set((d||[]).map(y=>y.id)),g=a.filter(({annotation:y})=>!f.has(y.id)).map(y=>{const m=(p||[]).find(_=>_.oldValue.id===y.annotation.id);return m?{selectedBy:y.selectedBy,annotation:m.newValue}:y});e(2,a=g)},i.observe(o,{annotations:a.map(c=>c.annotation.id)})};return e_(()=>{o&&i.unobserve(o)}),r.$$set=h=>{"store"in h&&e(3,i=h.store),"viewer"in h&&e(0,s=h.viewer),"provider"in h&&e(1,n=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&n&&n.on("selectionChange",l)},[s,n,a,i]}class Ow extends ge{constructor(t){super(),me(this,t,Bw,Dw,ae,{store:3,viewer:0,provider:1})}}const Np=(r,t)=>{t==="auto"?r.addHandler("open",e=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",n=>{const{fullyLoaded:a}=n;if(a){const o=r.canvas.querySelector("canvas"),l=du(o);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},Up=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,a=t.getAnnotation(n);if(!a||!ui(a))return;const o=r.container.getBoundingClientRect(),{padding:l}=s;let[h,u,c,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/o.height,u=u/o.width,c=c/o.height,d=d/o.width;const{minX:p,minY:f,maxX:g,maxY:y}=a.target.selector.geometry.bounds,m=g-p,_=y-f,v=p-d*m,x=f-h*_,b=m+(u+d)*m,R=_+(h+c)*_,w=r.viewport.imageToViewportRectangle(v,x,b,R);r.viewport[e](w,s.immediately)},Lw=(r,t)=>Up(r,t,"fitBounds"),Fw=(r,t)=>Up(r,t,"fitBoundsWithConstraints"),Nw=(r,t={})=>{const e=pu(t,{drawingEnabled:!1,drawingMode:$h?"drag":"click",userSelectAction:ea.EDIT,theme:"light"}),i=cu(e),{hover:s,selection:n,store:a}=i,o=fm(a,e.initialHistory),l=pm(i,o,e.adapter,e.autoSave);let h=wm(),u=e.drawingEnabled,c=e.drawingMode,d=e.modalSelect;const p=gu(o,r.element),f=new L1({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),g=new Ow({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:a,viewer:r}}),y=new vw({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!u,filter:void 0,preferredDrawingMode:c,state:i,style:e.style,user:h,viewer:r}});f.$on("click",E=>{const{originalEvent:P,annotation:B}=E.detail;d?n.isEmpty()&&B&&n.userSelect(B.id,P):B&&!(c==="click"&&u)?n.userSelect(B.id,P):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",E=>{if(s.current){const P=a.getAnnotation(s.current);l.emit("clickAnnotation",P,E)}}),Np(r,e.theme);const m=gm(i,o,e.adapter),_=()=>y.cancelDrawing(),v=()=>{f.$destroy(),g.$destroy(),y.$destroy(),p.destroy(),o.destroy()},x=Lw(r,a),b=Fw(r,a),R=()=>y.getDrawingTool(),w=()=>h,D=()=>y.isDrawingEnabled(),U=(E,P,B)=>Zh(E,P,B),M=(E,P)=>Wh(E,P),F=E=>{if(!Ls(E))throw`No drawing tool named ${E}`;y.$set({toolName:E})},S=E=>{u=E,y.$set({drawingEnabled:E})},I=E=>{f.$set({filter:E}),y.$set({filter:E})},H=E=>d=E,j=E=>{f.$set({style:E}),y.$set({style:E})},A=E=>g.$set({provider:E}),C=E=>Np(r,E),T=E=>{h=E,y.$set({user:E})},k=E=>f.$set({visible:E});return{...m,cancelDrawing:_,destroy:v,fitBounds:x,fitBoundsWithConstraints:b,getDrawingTool:R,getUser:w,isDrawingEnabled:D,listDrawingTools:Os,on:l.on,off:l.off,registerDrawingTool:U,registerShapeEditor:M,setDrawingEnabled:S,setDrawingTool:F,setFilter:I,setModalSelect:H,setPresenceProvider:A,setStyle:j,setTheme:C,setUser:T,setVisible:k,state:i,viewer:r}};Ut.ShapeType=Nt,Ut.UserSelectAction=ea,Ut.W3CImageFormat=Ng,Ut.chainStyles=Cg,Ut.computeStyle=Sg,Ut.createBody=sm,Ut.createImageAnnotator=Yy,Ut.createOSDAnnotator=Nw,Ut.defaultColorProvider=Em,Object.defineProperty(Ut,Symbol.toStringTag,{value:"Module"})});
1148
1148
  //# sourceMappingURL=annotorious-openseadragon.js.map