@annotorious/openseadragon 3.7.12 → 3.7.13

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(qt,se){typeof exports=="object"&&typeof module<"u"?se(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],se):(qt=typeof globalThis<"u"?globalThis:qt||self,se(qt.AnnotoriousOSD={},qt.OpenSeadragon))})(this,function(qt,se){"use strict";var uC=Object.defineProperty;var dC=(qt,se,qr)=>se in qt?uC(qt,se,{enumerable:!0,configurable:!0,writable:!0,value:qr}):qt[se]=qr;var Bh=(qt,se,qr)=>dC(qt,typeof se!="symbol"?se+"":se,qr);var qr=Object.prototype.hasOwnProperty;function Kr(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--&&Kr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(qr.call(r,e)&&++i&&!qr.call(t,e)||!(e in t)||!Kr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}var Go=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(Go||{});const fe=[];for(let r=0;r<256;++r)fe.push((r+256).toString(16).slice(1));function Jm(r,t=0){return(fe[r[t+0]]+fe[r[t+1]]+fe[r[t+2]]+fe[r[t+3]]+"-"+fe[r[t+4]]+fe[r[t+5]]+"-"+fe[r[t+6]]+fe[r[t+7]]+"-"+fe[r[t+8]]+fe[r[t+9]]+"-"+fe[r[t+10]]+fe[r[t+11]]+fe[r[t+12]]+fe[r[t+13]]+fe[r[t+14]]+fe[r[t+15]]).toLowerCase()}let $o;const Qm=new Uint8Array(16);function tg(){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(Qm)}const eg=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),$h={randomUUID:eg};function rg(r,t,e){var i;r=r||{};const n=r.random??((i=r.rng)==null?void 0:i.call(r))??tg();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Jm(n)}function ig(r,t,e){return $h.randomUUID&&!r?$h.randomUUID():rg(r)}const Ho=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)}},ng=(r,t,e,i)=>({id:ig(),annotation:typeof r=="string"?r:r.id,created:e||new Date,creator:i,...t}),sg=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},og=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},ag=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(n=>n.id===e.id);return{newBody:e,oldBody:i&&!Kr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),lg=(r,t)=>!Kr(r.target,t.target),hg=(r,t)=>{const e=sg(r,t),i=og(r,t),n=ag(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:n.length>0?n:void 0,targetUpdated:lg(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Pr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Pr||{});const cg=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),n=new Set((t.created||[]).map(u=>u.id)),s=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!s.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!n.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!s.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(g=>g.oldValue.id===f.id).newValue;return hg(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}};let ug=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,n=e.length;i<n;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(n=>t!==n)}}});const dg=250,fg=(r,t)=>{const e=ug(),i=(t==null?void 0:t.changes)||[];let n=t?t.pointer:-1,s=!1,o=0;const a=p=>{if(!s){const{changes:g}=p,y=performance.now();if(y-o>dg)i.splice(n+1),i.push(g),n=i.length-1;else{const _=i.length-1;i[_]=cg(i[_],g)}o=y}s=!1};r.observe(a,{origin:Pr.LOCAL});const l=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p),h=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),c=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({oldValue:g})=>g)),u=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({newValue:g})=>g)),d=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),f=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p);return{canRedo:()=>i.length-1>n,canUndo:()=>n>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:n}),on:(p,g)=>e.on(p,g),redo:()=>{if(i.length-1>n){s=!0;const{created:p,updated:g,deleted:y}=i[n+1];h(p),u(g),f(y),e.emit("redo",i[n+1]),n+=1}},undo:()=>{if(n>-1){s=!0;const{created:p,updated:g,deleted:y}=i[n];l(p),c(g),d(y),e.emit("undo",i[n]),n-=1}}}},pg=(r,t,e,i)=>{const{hover:n,selection:s,store:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(_,v)=>{l.has(_)?l.get(_).push(v):l.set(_,[v])},f=(_,v)=>{const m=l.get(_);if(m){const b=m.indexOf(v);b!==-1&&m.splice(b,1)}},p=(_,v,m)=>{l.has(_)&&setTimeout(()=>{l.get(_).forEach(b=>{if(e){const S=Array.isArray(v)?v.map(C=>e.serialize(C)):e.serialize(v),R=m?m instanceof PointerEvent?m:e.serialize(m):void 0;b(S,R)}else b(v,m)})},1)},g=()=>{const{selected:_}=s,v=(_||[]).map(({id:m})=>o.getAnnotation(m));v.forEach(m=>{const b=h.find(S=>S.id===m.id);(!b||!Kr(b,m))&&p("updateAnnotation",m,b)}),h=h.map(m=>v.find(({id:S})=>S===m.id)||m)};s.subscribe(({selected:_})=>{if(!(h.length===0&&_.length===0)){if(h.length===0&&_.length>0)h=_.map(({id:v})=>o.getAnnotation(v));else if(h.length>0&&_.length===0)h.forEach(v=>{const m=o.getAnnotation(v.id);m&&!Kr(m,v)&&p("updateAnnotation",m,v)}),h=[];else{const v=new Set(h.map(b=>b.id)),m=new Set(_.map(({id:b})=>b));h.filter(b=>!m.has(b.id)).forEach(b=>{const S=o.getAnnotation(b.id);S&&!Kr(S,b)&&p("updateAnnotation",S,b)}),h=[...h.filter(b=>m.has(b.id)),..._.filter(({id:b})=>!v.has(b)).map(({id:b})=>o.getAnnotation(b))]}p("selectionChanged",h)}}),n.subscribe(_=>{!c&&_?p("mouseEnterAnnotation",o.getAnnotation(_)):c&&!_?p("mouseLeaveAnnotation",o.getAnnotation(c)):c&&_&&(p("mouseLeaveAnnotation",o.getAnnotation(c)),p("mouseEnterAnnotation",o.getAnnotation(_))),c=_}),a==null||a.subscribe(_=>p("viewportIntersect",_.map(v=>o.getAnnotation(v)))),o.observe(_=>{i&&(u&&clearTimeout(u),u=setTimeout(g,1e3));const{created:v,deleted:m}=_.changes;(v||[]).forEach(b=>p("createAnnotation",b)),(m||[]).forEach(b=>p("deleteAnnotation",b)),(_.changes.updated||[]).filter(b=>[...b.bodiesCreated||[],...b.bodiesDeleted||[],...b.bodiesUpdated||[]].length>0).forEach(({oldValue:b,newValue:S})=>{const R=h.find(C=>C.id===b.id)||b;h=h.map(C=>C.id===b.id?S:C),p("updateAnnotation",S,R)})},{origin:Pr.LOCAL}),o.observe(_=>{if(h){const v=new Set(h.map(b=>b.id)),m=(_.changes.updated||[]).filter(({newValue:b})=>v.has(b.id)).map(({newValue:b})=>b);m.length>0&&(h=h.map(b=>m.find(R=>R.id===b.id)||b))}},{origin:Pr.REMOTE});const y=_=>v=>{const{updated:m}=v;_?(m||[]).forEach(b=>p("updateAnnotation",b.oldValue,b.newValue)):(m||[]).forEach(b=>p("updateAnnotation",b.newValue,b.oldValue))};return t.on("undo",y(!0)),t.on("redo",y(!1)),{on:d,off:f,emit:p}},mg=r=>t=>t.reduce((e,i)=>{const{parsed:n,error:s}=r.parse(i);return s?{parsed:e.parsed,failed:[...e.failed,i]}:n?{parsed:[...e.parsed,n],failed:e.failed}:{...e}},{parsed:[],failed:[]}),gg=(r,t,e)=>{const{store:i,selection:n}=r,s=_=>{if(e){const{parsed:v,error:m}=e.parse(_);v?i.addAnnotation(v,Pr.REMOTE):console.error(m)}else i.addAnnotation(Ho(_),Pr.REMOTE)},o=()=>n.clear(),a=()=>i.clear(),l=_=>{const v=i.getAnnotation(_);return e&&v?e.serialize(v):v},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var _;const v=(((_=n.selected)==null?void 0:_.map(m=>m.id))||[]).map(m=>i.getAnnotation(m)).filter(Boolean);return e?v.map(e.serialize):v},u=(_,v=!0)=>fetch(_).then(m=>m.json()).then(m=>(f(m,v),m)),d=_=>{if(typeof _=="string"){const v=i.getAnnotation(_);if(i.deleteAnnotation(_),v)return e?e.serialize(v):v}else{const v=e?e.parse(_).parsed:_;if(v)return i.deleteAnnotation(v),_}},f=(_,v=!0)=>{if(e){const m=e.parseAll||mg(e),{parsed:b,failed:S}=m(_);S.length>0&&console.warn(`Discarded ${S.length} invalid annotations`,S),i.bulkAddAnnotations(b,v,Pr.REMOTE)}else i.bulkAddAnnotations(_.map(Ho),v,Pr.REMOTE)},p=(_,v)=>{_?n.setSelected(_,v):n.clear()},g=_=>{n.setUserSelectAction(_)},y=_=>{if(e){const v=e.parse(_).parsed,m=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),m}else{const v=i.getAnnotation(_.id);return i.updateAnnotation(Ho(_)),v}};return{addAnnotation:s,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:g,undo:t.undo,updateAnnotation:y}},yg="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let _g=r=>crypto.getRandomValues(new Uint8Array(r)),vg=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,n=-~(1.6*i*t/r.length);return(s=t)=>{let o="";for(;;){let a=e(n),l=n|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=s)return o}}},bg=(r,t=21)=>vg(r,t|0,_g),xg=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=yg[e[r]&63];return t};const wg=()=>({isGuest:!0,id:bg("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Eg=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],Tg=()=>{const r=[...Eg];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};xg();var Ag=Object.defineProperty,Sg=(r,t,e)=>t in r?Ag(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hh=(r,t,e)=>Sg(r,typeof t!="symbol"?t+"":t,e);function Rt(){}function Xo(r,t){for(const e in t)r[e]=t[e];return r}function Xh(r){return r()}function Vh(){return Object.create(null)}function Me(r){r.forEach(Xh)}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 Cg(r){return Object.keys(r).length===0}function zh(r,...t){if(r==null){for(const i of t)i(void 0);return Rt}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Vo(r,t,e){r.$$.on_destroy.push(zh(t,e))}function Ig(r,t,e,i){if(r){const n=jh(r,t,e,i);return r[0](n)}}function jh(r,t,e,i){return r[1]&&i?Xo(e.ctx.slice(),r[1](i(t))):e.ctx}function Pg(r,t,e,i){if(r[2]&&i){const n=r[2](i(e));if(t.dirty===void 0)return n;if(typeof n=="object"){const s=[],o=Math.max(t.dirty.length,n.length);for(let a=0;a<o;a+=1)s[a]=t.dirty[a]|n[a];return s}return t.dirty|n}return t.dirty}function Rg(r,t,e,i,n,s){if(n){const o=jh(t,e,i,s);r.p(o,n)}}function Mg(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 Wh(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Ei(r){return r??""}function xt(r,t){r.appendChild(t)}function nt(r,t,e){r.insertBefore(t,e||null)}function rt(r){r.parentNode&&r.parentNode.removeChild(r)}function Zr(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function W(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Yh(r){return document.createTextNode(r)}function we(){return Yh(" ")}function De(){return Yh("")}function St(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function x(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Dg(r){return Array.from(r.childNodes)}function Je(r,t,e){r.classList.toggle(t,!!e)}function Bg(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let yn;function _n(r){yn=r}function qh(){if(!yn)throw new Error("Function called outside component initialization");return yn}function Jr(r){qh().$$.on_mount.push(r)}function Rr(){const r=qh();return(t,e,{cancelable:i=!1}={})=>{const n=r.$$.callbacks[t];if(n){const s=Bg(t,e,{cancelable:i});return n.slice().forEach(o=>{o.call(r,s)}),!s.defaultPrevented}return!0}}function oe(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Ti=[],os=[];let Ai=[];const Kh=[],Zh=Promise.resolve();let zo=!1;function Jh(){zo||(zo=!0,Zh.then(tc))}function Qh(){return Jh(),Zh}function jo(r){Ai.push(r)}const Wo=new Set;let Si=0;function tc(){if(Si!==0)return;const r=yn;do{try{for(;Si<Ti.length;){const t=Ti[Si];Si++,_n(t),Og(t.$$)}}catch(t){throw Ti.length=0,Si=0,t}for(_n(null),Ti.length=0,Si=0;os.length;)os.pop()();for(let t=0;t<Ai.length;t+=1){const e=Ai[t];Wo.has(e)||(Wo.add(e),e())}Ai.length=0}while(Ti.length);for(;Kh.length;)Kh.pop()();zo=!1,Wo.clear(),_n(r)}function Og(r){if(r.fragment!==null){r.update(),Me(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(jo)}}function Lg(r){const t=[],e=[];Ai.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Ai=t}const as=new Set;let Qr;function Ee(){Qr={r:0,c:[],p:Qr}}function Te(){Qr.r||Me(Qr.c),Qr=Qr.p}function lt(r,t){r&&r.i&&(as.delete(r),r.i(t))}function yt(r,t,e,i){if(r&&r.o){if(as.has(r))return;as.add(r),Qr.c.push(()=>{as.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function Ie(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function re(r){r&&r.c()}function Qt(r,t,e){const{fragment:i,after_update:n}=r.$$;i&&i.m(t,e),jo(()=>{const s=r.$$.on_mount.map(Xh).filter(Gt);r.$$.on_destroy?r.$$.on_destroy.push(...s):Me(s),r.$$.on_mount=[]}),n.forEach(jo)}function te(r,t){const e=r.$$;e.fragment!==null&&(Lg(e.after_update),Me(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Ng(r,t){r.$$.dirty[0]===-1&&(Ti.push(r),Jh(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function pe(r,t,e,i,n,s,o=null,a=[-1]){const l=yn;_n(r);const h=r.$$={fragment:null,ctx:[],props:s,update:Rt,not_equal:n,bound:Vh(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Vh(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&n(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&Ng(r,u)),d}):[],h.update(),c=!0,Me(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=Dg(t.target);h.fragment&&h.fragment.l(u),u.forEach(rt)}else h.fragment&&h.fragment.c();t.intro&&lt(r.$$.fragment),Qt(r,t.target,t.anchor),tc()}_n(l)}class me{constructor(){Hh(this,"$$"),Hh(this,"$$set")}$destroy(){te(this,1),this.$destroy=Rt}$on(t,e){if(!Gt(e))return Rt;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const n=i.indexOf(e);n!==-1&&i.splice(n,1)}}$set(t){this.$$set&&!Cg(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Fg="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Fg);var _t=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGON="MULTIPOLYGON",r.POLYGON="POLYGON",r.POLYLINE="POLYLINE",r.RECTANGLE="RECTANGLE",r.LINE="LINE",r))(_t||{}),kg={exports:{}};(function(r){(function(){function t(a,l){var h=a.x-l.x,c=a.y-l.y;return h*h+c*c}function e(a,l,h){var c=l.x,u=l.y,d=h.x-c,f=h.y-u;if(d!==0||f!==0){var p=((a.x-c)*d+(a.y-u)*f)/(d*d+f*f);p>1?(c=h.x,u=h.y):p>0&&(c+=d*p,u+=f*p)}return d=a.x-c,f=a.y-u,d*d+f*f}function i(a,l){for(var h=a[0],c=[h],u,d=1,f=a.length;d<f;d++)u=a[d],t(u,h)>l&&(c.push(u),h=u);return h!==u&&c.push(u),c}function n(a,l,h,c,u){for(var d=c,f,p=l+1;p<h;p++){var g=e(a[p],a[l],a[h]);g>d&&(f=p,d=g)}d>c&&(f-l>1&&n(a,l,f,c,u),u.push(a[f]),h-f>1&&n(a,f,h,c,u))}function s(a,l){var h=a.length-1,c=[a[0]];return n(a,0,h,l,c),c.push(a[h]),c}function o(a,l,h){if(a.length<=2)return a;var c=l!==void 0?l*l:1;return a=h?a:i(a,c),a=s(a,c),a}r.exports=o,r.exports.default=o})()})(kg);const Yo={},Ci=(r,t)=>Yo[r]=t,qo=r=>Yo[r.type].area(r),Ug=(r,t,e,i)=>Yo[r.type].intersects(r,t,e,i),Ae=r=>{let t=1/0,e=1/0,i=-1/0,n=-1/0;return r.forEach(([s,o])=>{t=Math.min(t,s),e=Math.min(e,o),i=Math.max(i,s),n=Math.max(n,o)}),{minX:t,minY:e,maxX:i,maxY:n}},ls=r=>{let t=0,e=r.length-1;for(let i=0;i<r.length;i++)t+=(r[e][0]+r[i][0])*(r[e][1]-r[i][1]),e=i;return Math.abs(.5*t)},hs=(r,t,e)=>{let i=!1;for(let n=0,s=r.length-1;n<r.length;s=n++){const o=r[n][0],a=r[n][1],l=r[s][0],h=r[s][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},Gg=(r,t=!0)=>{let e="M ";return r.forEach(([i,n],s)=>{s===0?e+=`${i},${n}`:e+=` L ${i},${n}`}),t&&(e+=" Z"),e},cs=(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))},$g={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:n,rx:s,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),c=t-i,u=e-n,d=l*c+h*u,f=h*c-l*u;return d*d/(s*s)+f*f/(o*o)<=1}};Ci(_t.ELLIPSE,$g);const Hg={area:r=>0,intersects:(r,t,e,i=2)=>{const[[n,s],[o,a]]=r.geometry.points,l=Math.abs((a-s)*t-(o-n)*e+o*s-a*n),h=cs([n,s],[o,a]);return l/h<=i}};Ci(_t.LINE,Hg);const Xg={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[n,...s]=i.rings,o=ls(n.points),a=s.reduce((l,h)=>l+ls(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const n of i){const[s,...o]=n.rings;if(hs(s.points,t,e)){let a=!1;for(const l of o)if(hs(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},Ko=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return Ae(t)},He=r=>r.rings.map(t=>Gg(t.points)).join(" "),Vg=r=>r.polygons.reduce((t,e)=>[...t,...e.rings.reduce((i,n)=>[...i,...n.points],[])],[]);Ci(_t.MULTIPOLYGON,Xg);const zg={area:r=>{const t=r.geometry.points;return ls(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return hs(i,t,e)}};Ci(_t.POLYGON,zg);const jg={area:r=>{const t=r.geometry;if(!t.closed||t.points.length<3)return 0;const e=Zo(t.points,t.closed);return ls(e)},intersects:(r,t,e,i=2)=>{const n=r.geometry;if(n.closed){const s=Zo(n.points,n.closed);return hs(s,t,e)}else return Wg(n,[t,e],i)}},Zo=(r,t=!1)=>{const e=[];for(let i=0;i<r.length;i++){const n=r[i],s=r[(i+1)%r.length];if(e.push(n.point),(i<r.length-1||t)&&(n.type==="CURVE"||s.type=="CURVE")){const o=ec(n.point,n.type==="CURVE"&&n.outHandle||n.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,10);e.push(...o.slice(1))}}return e},ec=(r,t,e,i,n=10)=>{const s=[];for(let o=0;o<=n;o++){const a=o/n,l=Math.pow(1-a,3)*r[0]+3*Math.pow(1-a,2)*a*t[0]+3*(1-a)*Math.pow(a,2)*e[0]+Math.pow(a,3)*i[0],h=Math.pow(1-a,3)*r[1]+3*Math.pow(1-a,2)*a*t[1]+3*(1-a)*Math.pow(a,2)*e[1]+Math.pow(a,3)*i[1];s.push([l,h])}return s},Wg=(r,t,e)=>{for(let i=0;i<r.points.length-1;i++){const n=r.points[i],s=r.points[i+1];if(n.type==="CURVE"||s.type==="CURVE"){const o=ec(n.point,n.type==="CURVE"&&n.outHandle||n.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,20);for(let a=0;a<o.length-1;a++)if(rc(t,o[a],o[a+1])<=e)return!0}else if(rc(t,n.point,s.point)<=e)return!0}return!1},rc=(r,t,e)=>{const[i,n]=r,[s,o]=t,[a,l]=e,h=a-s,c=l-o,u=Math.sqrt(h*h+c*c);if(u===0)return Math.sqrt((i-s)*(i-s)+(n-o)*(n-o));const d=((i-s)*h+(n-o)*c)/(u*u);return d<=0?Math.sqrt((i-s)*(i-s)+(n-o)*(n-o)):d>=1?Math.sqrt((i-a)*(i-a)+(n-l)*(n-l)):Math.abs((l-o)*i-(a-s)*n+a*o-l*s)/u},Jo=r=>{if(!r.points||r.points.length===0)return"";const t=[],e=r.points[0];t.push(`M ${e.point[0]} ${e.point[1]}`);for(let i=1;i<r.points.length;i++){const n=r.points[i],s=r.points[i-1];if(n.type==="CURVE"||s.type==="CURVE"){const o=s.type==="CURVE"&&s.outHandle||s.point,a=n.type==="CURVE"&&n.inHandle||n.point,l=n.point;t.push(`C ${o[0]} ${o[1]} ${a[0]} ${a[1]} ${l[0]} ${l[1]}`)}else t.push(`L ${n.point[0]} ${n.point[1]}`)}if(r.closed){const i=r.points[r.points.length-1],n=r.points[0];if(i.type==="CURVE"||n.type==="CURVE"){const s=i.outHandle||i.point,o=n.inHandle||n.point,a=n.point;t.push(`C ${s[0]} ${s[1]} ${o[0]} ${o[1]} ${a[0]} ${a[1]}`)}t.push("Z")}return t.join(" ")};Ci(_t.POLYLINE,jg);const Yg={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};Ci(_t.RECTANGLE,Yg);const Le=r=>us(r.target),us=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},qg=(r,t=!1)=>{const e=typeof r=="string"?r:r.value,i=/(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g,n=[...e.matchAll(i)][0],[s,o,a,l,h,c,u]=n;if(o!=="xywh")throw new Error("Unsupported MediaFragment: "+e);if(a&&a!=="pixel")throw new Error(`Unsupported MediaFragment unit: ${a}`);const[d,f,p,g]=[l,h,c,u].map(parseFloat);return{type:_t.RECTANGLE,geometry:{x:d,y:f,w:p,h:g,bounds:{minX:d,minY:t?f-g:f,maxX:d+p,maxY:t?f:f+g}}}},Kg=r=>{const{x:t,y:e,w:i,h:n}=r;return{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=pixel:${t},${e},${i},${n}`}},ic="http://www.w3.org/2000/svg",nc=r=>{const t=i=>{Array.from(i.attributes).forEach(n=>{n.name.startsWith("on")&&i.removeAttribute(n.name)})},e=r.getElementsByTagName("script");return Array.from(e).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(r.querySelectorAll("*")).forEach(t),r},Zg=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${ic}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},ds=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(ic),i=t.lookupNamespaceURI(null);return e||i?nc(t).firstChild:nc(Zg(t)).firstChild},Jg=r=>{const t=sc(r),e=[];let i=[],n=[0,0];for(const s of t)switch(s.type.toUpperCase()){case"M":i.length>0&&(e.push({points:i}),i=[]),n=[s.args[0],s.args[1]],i.push([...n]);break;case"L":n=[s.args[0],s.args[1]],i.push([...n]);break;case"H":n=[s.args[0],n[1]],i.push([...n]);break;case"V":n=[n[0],s.args[0]],i.push([...n]);break;case"C":n=[s.args[4],s.args[5]],i.push([...n]);break;case"Z":break;default:console.warn(`Unsupported SVG path command: ${s.type}`);break}if(i.length>2&&e.push({points:i}),e.length>0){const s=Ae(e[0].points);return{rings:e,bounds:s}}},Qg=r=>{const{point:t,inHandle:e,outHandle:i}=r;if(!e||!i)return!1;const n=e[0]-t[0],s=e[1]-t[1],o=i[0]-t[0],a=i[1]-t[1],l=n*a-s*o;return Math.abs(l)<.01},ty=r=>{const t=sc(r);let e=[],i=[0,0],n=!1;for(let o=0;o<t.length;o++){const a=t[o];switch(a.type.toUpperCase()){case"M":i=[a.args[0],a.args[1]],e.push({type:"CORNER",point:[...i]});break;case"L":i=[a.args[0],a.args[1]],e.push({type:"CORNER",point:[...i]});break;case"C":const l=[a.args[0],a.args[1]],h=[a.args[2],a.args[3]],c=[a.args[4],a.args[5]];if(e.length>0){const d=e[e.length-1];(l[0]!==d.point[0]||l[1]!==d.point[1])&&(d.type="CURVE",d.outHandle=l)}const u={type:h[0]!==c[0]||h[1]!==c[1]?"CURVE":"CORNER",point:c};u.type==="CURVE"&&(u.inHandle=h),e.push(u),i=c;break;case"Z":n=!0;break;default:console.warn(`Unsupported SVG path command: ${a.type}`);break}}e=e.map(o=>Qg(o)?{...o,locked:!0}:o);const s=Ae(Zo(e,n));return{points:e,closed:n,bounds:s}},sc=r=>{const t=[],e=r.replace(/,/g," ").trim(),i=/([MmLlHhVvCcZz])\s*([^MmLlHhVvCcZz]*)/g;let n;for(;(n=i.exec(e))!==null;){const[,s,o]=n,a=o.trim()===""?[]:o.trim().split(/\s+/).map(Number).filter(l=>!isNaN(l));t.push({type:s,args:a})}return t},ey=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],n=i.split(" ").map(s=>s.split(",").map(parseFloat));return{type:_t.POLYGON,geometry:{points:n,bounds:Ae(n)}}},ry=r=>{const t=ds(r),e=parseFloat(t.getAttribute("cx")),i=parseFloat(t.getAttribute("cy")),n=parseFloat(t.getAttribute("rx")),s=parseFloat(t.getAttribute("ry")),o={minX:e-n,minY:i-s,maxX:e+n,maxY:i+s};return{type:_t.ELLIPSE,geometry:{cx:e,cy:i,rx:n,ry:s,bounds:o}}},iy=r=>{const t=ds(r),e=parseFloat(t.getAttribute("x1")),i=parseFloat(t.getAttribute("x2")),n=parseFloat(t.getAttribute("y1")),s=parseFloat(t.getAttribute("y2")),o={minX:Math.min(e,i),minY:Math.min(n,s),maxX:Math.max(e,i),maxY:Math.max(n,s)};return{type:_t.LINE,geometry:{points:[[e,n],[i,s]],bounds:o}}},ny=r=>{const t=ds(r),e=t.nodeName==="path"?t:Array.from(t.querySelectorAll("path"))[0],i=e==null?void 0:e.getAttribute("d");if(!i)throw new Error("Could not parse SVG path");const n=ty(i);if(!n)throw new Error("Could not parse SVG path");return{type:_t.POLYLINE,geometry:n}},sy=r=>{const t=ds(r),e=(t.nodeName==="path"?[t]:Array.from(t.querySelectorAll("path"))).map(s=>s.getAttribute("d")||"").map(s=>Jg(s)).filter(Boolean),i=e.reduce((s,o)=>[...s,...o.rings[0].points],[]),n=Ae(i);return e.length===1&&e[0].rings.length===1?{type:_t.POLYGON,geometry:{points:i,bounds:n}}:{type:_t.MULTIPOLYGON,geometry:{polygons:e,bounds:n}}},oy=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return ey(t);if(t.includes("<path ")&&(t.includes(" C ")||!t.includes("Z")))return ny(t);if(t.includes("<path "))return sy(t);if(t.includes("<ellipse "))return ry(t);if(t.includes("<line "))return iy(t);throw"Unsupported SVG shape: "+t},ay=r=>`<g>${r.polygons.map(t=>`<path fill-rule="evenodd" d="${He(t)}" />`).join("")}</g>`,ly=r=>{let t;switch(r.type){case _t.POLYGON:{const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(n=>n.join(",")).join(" ")}" /></svg>`;break}case _t.ELLIPSE:{const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`;break}case _t.MULTIPOLYGON:{const e=r.geometry;t=`<svg>${ay(e)}</svg>`;break}case _t.LINE:{const e=r.geometry,[[i,n],[s,o]]=e.points;t=`<svg><line x1="${i}" y1="${n}" x2="${s}" y2="${o}" /></svg>`;break}case _t.POLYLINE:t=`<svg><path d="${Jo(r.geometry)}" /></svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`},ge=[];for(let r=0;r<256;++r)ge.push((r+256).toString(16).slice(1));function hy(r,t=0){return(ge[r[t+0]]+ge[r[t+1]]+ge[r[t+2]]+ge[r[t+3]]+"-"+ge[r[t+4]]+ge[r[t+5]]+"-"+ge[r[t+6]]+ge[r[t+7]]+"-"+ge[r[t+8]]+ge[r[t+9]]+"-"+ge[r[t+10]]+ge[r[t+11]]+ge[r[t+12]]+ge[r[t+13]]+ge[r[t+14]]+ge[r[t+15]]).toLowerCase()}let Qo;const cy=new Uint8Array(16);function uy(){if(!Qo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Qo=crypto.getRandomValues.bind(crypto)}return Qo(cy)}const dy=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),oc={randomUUID:dy};function fy(r,t,e){var i;r=r||{};const n=r.random??((i=r.rng)==null?void 0:i.call(r))??uy();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,hy(n)}function ac(r,t,e){return oc.randomUUID&&!r?oc.randomUUID():fy(r)}var lc=Object.prototype.hasOwnProperty;function Mr(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--&&Mr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(lc.call(r,e)&&++i&&!lc.call(t,e)||!(e in t)||!Mr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function ta(){}function py(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const Ii=[];function ea(r,t=ta){let e;const i=new Set;function n(a){if(py(r,a)&&(r=a,e)){const l=!Ii.length;for(const h of i)h[1](),Ii.push(h,r);if(l){for(let h=0;h<Ii.length;h+=2)Ii[h][0](Ii[h+1]);Ii.length=0}}}function s(a){n(a(r))}function o(a,l=ta){const h=[a,l];return i.add(h),i.size===1&&(e=t(n,s)||ta),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:n,update:s,subscribe:o}}const my=r=>{const{subscribe:t,set:e}=ea();let i;return t(n=>i=n),r.observe(({changes:n})=>{if(i){(n.deleted||[]).some(o=>o.id===i)&&e(void 0);const s=(n.updated||[]).find(({oldValue:o})=>o.id===i);s&&e(s.newValue.id)}}),{get current(){return i},subscribe:t,set:e}};var hc=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(hc||{});const fs={selected:[]},gy=(r,t,e)=>{const{subscribe:i,set:n}=ea(fs);let s=t,o=fs;i(g=>o=g);const a=()=>{Mr(o,fs)||n(fs)},l=()=>{var g;return((g=o.selected)==null?void 0:g.length)===0},h=g=>{if(l())return!1;const y=typeof g=="string"?g:g.id;return o.selected.some(_=>_.id===y)},c=(g,y)=>{let _;if(Array.isArray(g)){if(_=g.map(m=>r.getAnnotation(m)).filter(Boolean),_.length<g.length){console.warn("Invalid selection: "+g.filter(m=>!_.some(b=>b.id===m)));return}}else{const m=r.getAnnotation(g);if(!m){console.warn("Invalid selection: "+g);return}_=[m]}const v=_.reduce((m,b)=>{const S=p(b);return S==="EDIT"?[...m,{id:b.id,editable:!0}]:S==="SELECT"?[...m,{id:b.id}]:m},[]);n({selected:v,event:y})},u=(g,y)=>{const _=Array.isArray(g)?g:[g],v=_.map(m=>r.getAnnotation(m)).filter(m=>!!m);n({selected:v.map(m=>{const b=y===void 0?p(m)==="EDIT":y;return{id:m.id,editable:b}})}),v.length!==_.length&&console.warn("Invalid selection",g)},d=g=>{if(l())return!1;const{selected:y}=o;y.some(({id:_})=>g.includes(_))&&n({selected:y.filter(({id:_})=>!g.includes(_))})},f=g=>{s=g,u(o.selected.map(({id:y})=>y))},p=g=>yy(g,s,e);return r.observe(({changes:g})=>d((g.deleted||[]).map(y=>y.id))),{get event(){return o?o.event:null},get selected(){return o?[...o.selected]:null},get userSelectAction(){return s},clear:a,evalSelectAction:p,isEmpty:l,isSelected:h,setSelected:u,setUserSelectAction:f,subscribe:i,userSelect:c}},yy=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"},ye=[];for(let r=0;r<256;++r)ye.push((r+256).toString(16).slice(1));function _y(r,t=0){return(ye[r[t+0]]+ye[r[t+1]]+ye[r[t+2]]+ye[r[t+3]]+"-"+ye[r[t+4]]+ye[r[t+5]]+"-"+ye[r[t+6]]+ye[r[t+7]]+"-"+ye[r[t+8]]+ye[r[t+9]]+"-"+ye[r[t+10]]+ye[r[t+11]]+ye[r[t+12]]+ye[r[t+13]]+ye[r[t+14]]+ye[r[t+15]]).toLowerCase()}let ra;const vy=new Uint8Array(16);function by(){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(vy)}const xy=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cc={randomUUID:xy};function wy(r,t,e){var i;r=r||{};const n=r.random??((i=r.rng)==null?void 0:i.call(r))??by();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,_y(n)}function Ey(r,t,e){return cc.randomUUID&&!r?cc.randomUUID():wy(r)}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)}},Ty=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},Ay=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},Sy=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(n=>n.id===e.id);return{newBody:e,oldBody:i&&!Mr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),Cy=(r,t)=>!Mr(r.target,t.target),uc=(r,t)=>{const e=Ty(r,t),i=Ay(r,t),n=Sy(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:n.length>0?n:void 0,targetUpdated:Cy(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Nt=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Nt||{});const Iy=(r,t)=>{var e,i;const{changes:n,origin:s}=t;if(!(r.options.origin?r.options.origin===s:s!=="SILENT"))return!1;if(r.options.ignore){const{ignore:o}=r.options,a=l=>l&&l.length>0;if(!(a(n.created)||a(n.deleted))){const l=(e=n.updated)==null?void 0:e.some(c=>a(c.bodiesCreated)||a(c.bodiesDeleted)||a(c.bodiesUpdated)),h=(i=n.updated)==null?void 0:i.some(c=>c.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(r.options.annotations){const o=new Set([...(n.created||[]).map(a=>a.id),...(n.deleted||[]).map(a=>a.id),...(n.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},Py=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),n=new Set((t.created||[]).map(u=>u.id)),s=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!s.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!n.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!s.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(g=>g.oldValue.id===f.id).newValue;return uc(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}},ps=r=>{const t=r.id===void 0?Ey():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},Ry=r=>r.id!==void 0,My=()=>{const r=new Map,t=new Map,e=[],i=(P,T={})=>{e.push({onChange:P,options:T})},n=P=>{const T=e.findIndex(E=>E.onChange==P);T>-1&&e.splice(T,1)},s=(P,T)=>{const E={origin:P,changes:{created:T.created||[],updated:T.updated||[],deleted:T.deleted||[]},state:[...r.values()]};e.forEach(A=>{Iy(A,E)&&A.onChange(E)})},o=(P,T=Nt.LOCAL)=>{if(P.id&&r.get(P.id))throw Error(`Cannot add annotation ${P.id} - exists already`);{const E=ps(P);r.set(E.id,E),E.bodies.forEach(A=>t.set(A.id,E.id)),s(T,{created:[E]})}},a=(P,T)=>{const E=ps(typeof P=="string"?T:P),A=typeof P=="string"?P:P.id,L=A&&r.get(A);if(L){const D=uc(L,E);return A===E.id?r.set(A,E):(r.delete(A),r.set(E.id,E)),L.bodies.forEach(N=>t.delete(N.id)),E.bodies.forEach(N=>t.set(N.id,E.id)),D}else console.warn(`Cannot update annotation ${A} - does not exist`)},l=(P,T=Nt.LOCAL,E=Nt.LOCAL)=>{const A=Ry(T)?E:T,L=a(P,T);L&&s(A,{updated:[L]})},h=(P,T=Nt.LOCAL)=>{r.get(P.id)?l(P,T):o(P,T)},c=(P,T=Nt.LOCAL)=>{const E=P.reduce((A,L)=>{const D=a(L);return D?[...A,D]:A},[]);E.length>0&&s(T,{updated:E})},u=(P,T=Nt.LOCAL)=>{const E=P.map(ps),{toAdd:A,toUpdate:L}=E.reduce((N,$)=>r.get($.id)?{...N,toUpdate:[...N.toUpdate,$]}:{...N,toAdd:[...N.toAdd,$]},{toAdd:[],toUpdate:[]}),D=L.map(N=>a(N,T)).filter(Boolean);A.forEach(N=>{r.set(N.id,N),N.bodies.forEach($=>t.set($.id,N.id))}),s(T,{created:A,updated:D})},d=(P,T=Nt.LOCAL)=>{const E=r.get(P.annotation);if(E){const A={...E,bodies:[...E.bodies,P]};r.set(E.id,A),t.set(P.id,A.id),s(T,{updated:[{oldValue:E,newValue:A,bodiesCreated:[P]}]})}else console.warn(`Attempt to add body to missing annotation: ${P.annotation}`)},f=()=>[...r.values()],p=(P=Nt.LOCAL)=>{const T=[...r.values()];r.clear(),t.clear(),s(P,{deleted:T})},g=(P,T=!0,E=Nt.LOCAL)=>{const A=P.map(ps);if(T){const L=[...r.values()];r.clear(),t.clear(),A.forEach(D=>{r.set(D.id,D),D.bodies.forEach(N=>t.set(N.id,D.id))}),s(E,{created:A,deleted:L})}else{const L=P.reduce((D,N)=>{const $=N.id&&r.get(N.id);return $?[...D,$]:D},[]);if(L.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${L.map(D=>D.id).join(", ")}`);A.forEach(D=>{r.set(D.id,D),D.bodies.forEach(N=>t.set(N.id,D.id))}),s(E,{created:A})}},y=P=>{const T=typeof P=="string"?P:P.id,E=r.get(T);if(E)return r.delete(T),E.bodies.forEach(A=>t.delete(A.id)),E;console.warn(`Attempt to delete missing annotation: ${T}`)},_=(P,T=Nt.LOCAL)=>{const E=y(P);E&&s(T,{deleted:[E]})},v=(P,T=Nt.LOCAL)=>{const E=P.reduce((A,L)=>{const D=y(L);return D?[...A,D]:A},[]);E.length>0&&s(T,{deleted:E})},m=P=>{const T=r.get(P.annotation);if(T){const E=T.bodies.find(A=>A.id===P.id);if(E){t.delete(E.id);const A={...T,bodies:T.bodies.filter(L=>L.id!==P.id)};return r.set(T.id,A),{oldValue:T,newValue:A,bodiesDeleted:[E]}}else console.warn(`Attempt to delete missing body ${P.id} from annotation ${P.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${P.annotation}`)},b=(P,T=Nt.LOCAL)=>{const E=m(P);E&&s(T,{updated:[E]})},S=(P,T=Nt.LOCAL)=>{const E=P.map(A=>m(A)).filter(Boolean);E.length>0&&s(T,{updated:E})},R=P=>{const T=r.get(P);return T?{...T}:void 0},C=P=>{const T=t.get(P);if(T){const E=R(T).bodies.find(A=>A.id===P);if(E)return E;console.error(`Store integrity error: body ${P} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${P}`)},I=(P,T)=>{if(P.annotation!==T.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const E=r.get(P.annotation);if(E){const A=E.bodies.find(D=>D.id===P.id),L={...E,bodies:E.bodies.map(D=>D.id===A.id?T:D)};return r.set(E.id,L),A.id!==T.id&&(t.delete(A.id),t.set(T.id,L.id)),{oldValue:E,newValue:L,bodiesUpdated:[{oldBody:A,newBody:T}]}}else console.warn(`Attempt to add body to missing annotation ${P.annotation}`)},M=(P,T,E=Nt.LOCAL)=>{const A=I(P,T);A&&s(E,{updated:[A]})},F=(P,T=Nt.LOCAL)=>{const E=P.map(A=>I({id:A.id,annotation:A.annotation},A)).filter(Boolean);s(T,{updated:E})},U=P=>{const T=r.get(P.annotation);if(T){const E={...T,target:{...T.target,...P}};return r.set(T.id,E),{oldValue:T,newValue:E,targetUpdated:{oldTarget:T.target,newTarget:P}}}else console.warn(`Attempt to update target on missing annotation: ${P.annotation}`)};return{addAnnotation:o,addBody:d,all:f,bulkAddAnnotations:g,bulkDeleteAnnotations:v,bulkDeleteBodies:S,bulkUpdateAnnotations:c,bulkUpdateBodies:F,bulkUpdateTargets:(P,T=Nt.LOCAL)=>{const E=P.map(A=>U(A)).filter(Boolean);E.length>0&&s(T,{updated:E})},bulkUpsertAnnotations:u,clear:p,deleteAnnotation:_,deleteBody:b,getAnnotation:R,getBody:C,observe:i,unobserve:n,updateAnnotation:l,updateBody:M,updateTarget:(P,T=Nt.LOCAL)=>{const E=U(P);E&&s(T,{updated:[E]})},upsertAnnotation:h}},Dy=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let By=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,n=e.length;i<n;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(n=>t!==n)}}});const Oy=250,Ly=(r,t)=>{const e=By(),i=(t==null?void 0:t.changes)||[];let n=t?t.pointer:-1,s=!1,o=0;const a=p=>{if(!s){const{changes:g}=p,y=performance.now();if(y-o>Oy)i.splice(n+1),i.push(g),n=i.length-1;else{const _=i.length-1;i[_]=Py(i[_],g)}o=y}s=!1};r.observe(a,{origin:Nt.LOCAL});const l=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p),h=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),c=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({oldValue:g})=>g)),u=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({newValue:g})=>g)),d=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),f=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p);return{canRedo:()=>i.length-1>n,canUndo:()=>n>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:n}),on:(p,g)=>e.on(p,g),redo:()=>{if(i.length-1>n){s=!0;const{created:p,updated:g,deleted:y}=i[n+1];h(p),u(g),f(y),e.emit("redo",i[n+1]),n+=1}},undo:()=>{if(n>-1){s=!0;const{created:p,updated:g,deleted:y}=i[n];l(p),c(g),d(y),e.emit("undo",i[n]),n-=1}}}},Ny=()=>{const{subscribe:r,set:t}=ea([]);return{subscribe:r,set:t}},Fy=(r,t,e,i)=>{const{hover:n,selection:s,store:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(_,v)=>{l.has(_)?l.get(_).push(v):l.set(_,[v])},f=(_,v)=>{const m=l.get(_);if(m){const b=m.indexOf(v);b!==-1&&m.splice(b,1)}},p=(_,v,m)=>{l.has(_)&&setTimeout(()=>{l.get(_).forEach(b=>{if(e){const S=Array.isArray(v)?v.map(C=>e.serialize(C)):e.serialize(v),R=m?m instanceof PointerEvent?m:e.serialize(m):void 0;b(S,R)}else b(v,m)})},1)},g=()=>{const{selected:_}=s,v=(_||[]).map(({id:m})=>o.getAnnotation(m));v.forEach(m=>{const b=h.find(S=>S.id===m.id);(!b||!Mr(b,m))&&p("updateAnnotation",m,b)}),h=h.map(m=>v.find(({id:b})=>b===m.id)||m)};s.subscribe(({selected:_})=>{if(!(h.length===0&&_.length===0)){if(h.length===0&&_.length>0)h=_.map(({id:v})=>o.getAnnotation(v));else if(h.length>0&&_.length===0)h.forEach(v=>{const m=o.getAnnotation(v.id);m&&!Mr(m,v)&&p("updateAnnotation",m,v)}),h=[];else{const v=new Set(h.map(b=>b.id)),m=new Set(_.map(({id:b})=>b));h.filter(b=>!m.has(b.id)).forEach(b=>{const S=o.getAnnotation(b.id);S&&!Mr(S,b)&&p("updateAnnotation",S,b)}),h=[...h.filter(b=>m.has(b.id)),..._.filter(({id:b})=>!v.has(b)).map(({id:b})=>o.getAnnotation(b))]}p("selectionChanged",h)}}),n.subscribe(_=>{!c&&_?p("mouseEnterAnnotation",o.getAnnotation(_)):c&&!_?p("mouseLeaveAnnotation",o.getAnnotation(c)):c&&_&&(p("mouseLeaveAnnotation",o.getAnnotation(c)),p("mouseEnterAnnotation",o.getAnnotation(_))),c=_}),a==null||a.subscribe(_=>p("viewportIntersect",_.map(v=>o.getAnnotation(v)))),o.observe(_=>{i&&(u&&clearTimeout(u),u=setTimeout(g,1e3));const{created:v,deleted:m}=_.changes;(v||[]).forEach(b=>p("createAnnotation",b)),(m||[]).forEach(b=>p("deleteAnnotation",b)),(_.changes.updated||[]).filter(b=>[...b.bodiesCreated||[],...b.bodiesDeleted||[],...b.bodiesUpdated||[]].length>0).forEach(({oldValue:b,newValue:S})=>{const R=h.find(C=>C.id===b.id)||b;h=h.map(C=>C.id===b.id?S:C),p("updateAnnotation",S,R)})},{origin:Nt.LOCAL}),o.observe(_=>{if(h){const v=new Set(h.map(b=>b.id)),m=(_.changes.updated||[]).filter(({newValue:b})=>v.has(b.id)).map(({newValue:b})=>b);m.length>0&&(h=h.map(b=>m.find(S=>S.id===b.id)||b))}},{origin:Nt.REMOTE});const y=_=>v=>{const{updated:m}=v;_?(m||[]).forEach(b=>p("updateAnnotation",b.oldValue,b.newValue)):(m||[]).forEach(b=>p("updateAnnotation",b.newValue,b.oldValue))};return t.on("undo",y(!0)),t.on("redo",y(!1)),{on:d,off:f,emit:p}},ky=r=>t=>t.reduce((e,i)=>{const{parsed:n,error:s}=r.parse(i);return s?{parsed:e.parsed,failed:[...e.failed,i]}:n?{parsed:[...e.parsed,n],failed:e.failed}:{...e}},{parsed:[],failed:[]}),Uy=(r,t,e)=>{const{store:i,selection:n}=r,s=_=>{if(e){const{parsed:v,error:m}=e.parse(_);v?i.addAnnotation(v,Nt.REMOTE):console.error(m)}else i.addAnnotation(ia(_),Nt.REMOTE)},o=()=>n.clear(),a=()=>i.clear(),l=_=>{const v=i.getAnnotation(_);return e&&v?e.serialize(v):v},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var _;const v=(((_=n.selected)==null?void 0:_.map(m=>m.id))||[]).map(m=>i.getAnnotation(m)).filter(Boolean);return e?v.map(e.serialize):v},u=(_,v=!0)=>fetch(_).then(m=>m.json()).then(m=>(f(m,v),m)),d=_=>{if(typeof _=="string"){const v=i.getAnnotation(_);if(i.deleteAnnotation(_),v)return e?e.serialize(v):v}else{const v=e?e.parse(_).parsed:_;if(v)return i.deleteAnnotation(v),_}},f=(_,v=!0)=>{if(e){const m=e.parseAll||ky(e),{parsed:b,failed:S}=m(_);S.length>0&&console.warn(`Discarded ${S.length} invalid annotations`,S),i.bulkAddAnnotations(b,v,Nt.REMOTE)}else i.bulkAddAnnotations(_.map(ia),v,Nt.REMOTE)},p=(_,v)=>{_?n.setSelected(_,v):n.clear()},g=_=>{n.setUserSelectAction(_)},y=_=>{if(e){const v=e.parse(_).parsed,m=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),m}else{const v=i.getAnnotation(_.id);return i.updateAnnotation(ia(_)),v}};return{addAnnotation:s,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:g,undo:t.undo,updateAnnotation:y}},Gy=(r,t,e)=>typeof t=="function"?t(r,e):t,$y=(r,t)=>typeof r!="function"&&typeof t!="function"?{...r||{},...t||{}}:(e,i)=>{const n=typeof r=="function"?r(e,i):r,s=typeof t=="function"?t(e,i):t;return{...n||{},...s||{}}},Hy="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Xy=r=>crypto.getRandomValues(new Uint8Array(r)),Vy=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,n=-~(1.6*i*t/r.length);return(s=t)=>{let o="";for(;;){let a=e(n),l=n|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=s)return o}}},zy=(r,t=21)=>Vy(r,t|0,Xy),jy=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Hy[e[r]&63];return t};const Wy=()=>({isGuest:!0,id:zy("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Yy=r=>{const t=JSON.stringify(r);let e=0;for(let i=0,n=t.length;i<n;i++){let s=t.charCodeAt(i);e=(e<<5)-e+s,e|=0}return`${e}`},dc=r=>r?typeof r=="object"?{...r}:r:void 0,qy=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:n,purpose:s,value:o,created:a,modified:l,creator:h,...c}=e;return{id:i||`temp-${Yy(e)}`,annotation:t,type:n,purpose:s,value:o,creator:dc(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...c}}),Ky=r=>r.map(t=>{var e;const{annotation:i,created:n,updated:s,...o}=t,a={...o,created:n==null?void 0:n.toISOString(),modified:s==null?void 0:s.toISOString()};return(e=a.id)!=null&&e.startsWith("temp-")&&delete a.id,a});jy();const Zy=(r,t={strict:!0,invertY:!1})=>({parse:e=>Jy(e,t),serialize:e=>Qy(e,r,t)}),Jy=(r,t={strict:!0,invertY:!1})=>{const e=r.id||ac(),{creator:i,created:n,modified:s,body:o,...a}=r,l=qy(o||[],e),h=Array.isArray(r.target)?r.target[0]:r.target,c=typeof h=="string"?h:Array.isArray(h.selector)?h.selector[0]:h.selector,u=typeof c=="string"||(c==null?void 0:c.type)==="FragmentSelector"?qg(c,t.invertY):(c==null?void 0:c.type)==="SvgSelector"?oy(c):void 0,d=Array.isArray(a.target)?a.target[0]:a.targret;return u||!t.strict?{parsed:{...a,id:e,bodies:l,target:{created:n?new Date(n):void 0,creator:dc(i),updated:s?new Date(s):void 0,...typeof d=="string"?{}:d,annotation:e,selector:u||c}}}:{error:Error(`Invalid selector: ${JSON.stringify(c)}`)}},Qy=(r,t,e={strict:!0,invertY:!1})=>{const{selector:i,creator:n,created:s,updated:o,updatedBy:a,...l}=r.target;let h;try{h=i.type==_t.RECTANGLE?Kg(i.geometry):ly(i)}catch(u){if(e.strict)throw u;h=i}const c={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:Ky(r.bodies),created:s==null?void 0:s.toISOString(),creator:n,modified:o==null?void 0:o.toISOString(),target:{...l,source:t,type:"SpecificResource",selector:h}};return delete c.bodies,"annotation"in c.target&&delete c.target.annotation,c},Pi=[];function t0(r,t=Rt){let e;const i=new Set;function n(a){if(Kt(r,a)&&(r=a,e)){const l=!Pi.length;for(const h of i)h[1](),Pi.push(h,r);if(l){for(let h=0;h<Pi.length;h+=2)Pi[h][0](Pi[h+1]);Pi.length=0}}}function s(a){n(a(r))}function o(a,l=Rt){const h=[a,l];return i.add(h),i.size===1&&(e=t(n,s)||Rt),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:n,update:s,subscribe:o}}const e0=(r,t)=>{const{naturalWidth:e,naturalHeight:i}=r;if(!e&&!i){const{width:n,height:s}=r;t.setAttribute("viewBox",`0 0 ${n} ${s}`),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}`)},r0=(r,t)=>{e0(r,t);const{subscribe:e,set:i}=t0(1);let n;return window.ResizeObserver&&(n=new ResizeObserver(()=>{const s=t.getBoundingClientRect(),{width:o,height:a}=t.viewBox.baseVal,l=Math.max(s.width/o,s.height/a);i(l)}),n.observe(t.parentElement)),{destroy:()=>{n&&n.disconnect()},subscribe:e}},ti=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:n,stroke:s,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`),n||n===0?l+=`fill-opacity:${n};`:i&&(l+="fill-opacity:0.25;"),s&&(l+=`stroke:${s};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}},ms=(r,t=0)=>{const{minX:e,minY:i,maxX:n,maxY:s}=r;return{x:e-t,y:i-t,w:n-e+2*t,h:s-i+2*t}},Ne=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,i0=r=>({}),fc=r=>({grab:r[0]});function n0(r){let t,e,i,n;const s=r[8].default,o=Ig(s,r,r[7],fc);return{c(){t=W("g"),o&&o.c(),x(t,"class","a9s-annotation selected")},m(a,l){nt(a,t,l),o&&o.m(t,null),e=!0,i||(n=[St(t,"pointerup",r[2]),St(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&128)&&Rg(o,s,a,a[7],e?Pg(s,a[7],l,i0):Mg(a[7]),fc)},i(a){e||(lt(o,a),e=!0)},o(a){yt(o,a),e=!1},d(a){a&&rt(t),o&&o.d(a),i=!1,Me(n)}}}function s0(r,t,e){let{$$slots:i={},$$scope:n}=t;const s=Rr();let{shape:o}=t,{editor:a}=t,{transform:l}=t,{svgEl:h}=t,c,u,d;const f=y=>_=>{if(c=y,h){const{left:v,top:m}=h.getBoundingClientRect(),b=_.clientX-v,S=_.clientY-m;u=l.elementToImage(b,S)}else{const{offsetX:v,offsetY:m}=_;u=l.elementToImage(v,m)}d=o,_.target.setPointerCapture(_.pointerId),s("grab",_)},p=y=>{if(c){const[_,v]=l.elementToImage(y.offsetX,y.offsetY),m=[_-u[0],v-u[1]];e(3,o=a(d,c,m)),s("change",o)}},g=y=>{y.target.releasePointerCapture(y.pointerId),c=void 0,d=o,s("release",y)};return r.$$set=y=>{"shape"in y&&e(3,o=y.shape),"editor"in y&&e(4,a=y.editor),"transform"in y&&e(5,l=y.transform),"svgEl"in y&&e(6,h=y.svgEl),"$$scope"in y&&e(7,n=y.$$scope)},[f,p,g,o,a,l,h,n,i]}class na extends me{constructor(t){super(),pe(this,t,s0,n0,Kt,{shape:3,editor:4,transform:5,svgEl:6})}}function o0(r){let t,e,i,n,s,o,a,l,h=r[3]&&pc(r);return{c(){t=W("g"),e=W("circle"),h&&h.c(),n=W("circle"),x(e,"class","a9s-handle-buffer svelte-qtyc7s"),x(e,"cx",r[0]),x(e,"cy",r[1]),x(e,"r",i=r[5]+6/r[2]),x(e,"role","button"),x(e,"tabindex","0"),x(n,"class",s=Ei(`a9s-handle-dot${r[3]?" selected":""}`)+" svelte-qtyc7s"),x(n,"cx",r[0]),x(n,"cy",r[1]),x(n,"r",r[5]),x(t,"class",o=`a9s-handle ${r[8].class||""}`.trim())},m(c,u){nt(c,t,u),xt(t,e),h&&h.m(t,null),xt(t,n),a||(l=[St(e,"dblclick",r[12]),St(e,"pointerenter",r[13]),St(e,"pointerleave",r[14]),St(e,"pointerdown",r[15]),St(e,"pointerdown",r[6]),St(e,"pointerup",r[16]),St(e,"pointerup",r[7])],a=!0)},p(c,u){u&1&&x(e,"cx",c[0]),u&2&&x(e,"cy",c[1]),u&36&&i!==(i=c[5]+6/c[2])&&x(e,"r",i),c[3]?h?h.p(c,u):(h=pc(c),h.c(),h.m(t,n)):h&&(h.d(1),h=null),u&8&&s!==(s=Ei(`a9s-handle-dot${c[3]?" selected":""}`)+" svelte-qtyc7s")&&x(n,"class",s),u&1&&x(n,"cx",c[0]),u&2&&x(n,"cy",c[1]),u&32&&x(n,"r",c[5]),u&256&&o!==(o=`a9s-handle ${c[8].class||""}`.trim())&&x(t,"class",o)},d(c){c&&rt(t),h&&h.d(),a=!1,Me(l)}}}function a0(r){let t,e,i,n,s,o,a,l,h;return{c(){t=W("g"),e=W("circle"),n=W("circle"),o=W("circle"),x(e,"cx",r[0]),x(e,"cy",r[1]),x(e,"r",i=r[5]*10),x(e,"class","a9s-touch-halo"),Je(e,"touched",r[4]),x(n,"cx",r[0]),x(n,"cy",r[1]),x(n,"r",s=r[5]+10/r[2]),x(n,"class","a9s-handle-buffer svelte-qtyc7s"),x(n,"role","button"),x(n,"tabindex","0"),x(o,"class","a9s-handle-dot"),x(o,"cx",r[0]),x(o,"cy",r[1]),x(o,"r",a=r[5]+2/r[2]),x(t,"class","a9s-touch-handle")},m(c,u){nt(c,t,u),xt(t,e),xt(t,n),xt(t,o),l||(h=[St(n,"dblclick",r[9]),St(n,"pointerdown",r[10]),St(n,"pointerdown",r[6]),St(n,"pointerup",r[11]),St(n,"pointerup",r[7])],l=!0)},p(c,u){u&1&&x(e,"cx",c[0]),u&2&&x(e,"cy",c[1]),u&32&&i!==(i=c[5]*10)&&x(e,"r",i),u&16&&Je(e,"touched",c[4]),u&1&&x(n,"cx",c[0]),u&2&&x(n,"cy",c[1]),u&36&&s!==(s=c[5]+10/c[2])&&x(n,"r",s),u&1&&x(o,"cx",c[0]),u&2&&x(o,"cy",c[1]),u&36&&a!==(a=c[5]+2/c[2])&&x(o,"r",a)},d(c){c&&rt(t),l=!1,Me(h)}}}function pc(r){let t,e;return{c(){t=W("circle"),x(t,"class","a9s-handle-selected"),x(t,"cx",r[0]),x(t,"cy",r[1]),x(t,"r",e=r[5]+8/r[2])},m(i,n){nt(i,t,n)},p(i,n){n&1&&x(t,"cx",i[0]),n&2&&x(t,"cy",i[1]),n&36&&e!==(e=i[5]+8/i[2])&&x(t,"r",e)},d(i){i&&rt(t)}}}function l0(r){let t;function e(n,s){return Ne?a0:o0}let i=e()(r);return{c(){i.c(),t=De()},m(n,s){i.m(n,s),nt(n,t,s)},p(n,[s]){i.p(n,s)},i:Rt,o:Rt,d(n){n&&rt(t),i.d(n)}}}function h0(r,t,e){let i,{x:n}=t,{y:s}=t,{scale:o}=t,{selected:a=void 0}=t,l=!1;const h=m=>{m.pointerType==="touch"&&e(4,l=!0)},c=()=>e(4,l=!1);function u(m){oe.call(this,r,m)}function d(m){oe.call(this,r,m)}function f(m){oe.call(this,r,m)}function p(m){oe.call(this,r,m)}function g(m){oe.call(this,r,m)}function y(m){oe.call(this,r,m)}function _(m){oe.call(this,r,m)}function v(m){oe.call(this,r,m)}return r.$$set=m=>{e(8,t=Xo(Xo({},t),Wh(m))),"x"in m&&e(0,n=m.x),"y"in m&&e(1,s=m.y),"scale"in m&&e(2,o=m.scale),"selected"in m&&e(3,a=m.selected)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=4/o)},t=Wh(t),[n,s,o,a,l,i,h,c,t,u,d,f,p,g,y,_,v]}class Ri extends me{constructor(t){super(),pe(this,t,h0,l0,Kt,{x:0,y:1,scale:2,selected:3})}}function c0(r){let t,e,i,n,s,o,a;return{c(){t=W("g"),e=W("circle"),n=W("circle"),s=W("circle"),x(e,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),x(e,"cx",r[0]),x(e,"cy",r[1]),x(e,"r",i=1.75*r[2]),x(n,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),x(n,"cx",r[0]),x(n,"cy",r[1]),x(n,"r",r[2]),x(s,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),x(s,"cx",r[0]),x(s,"cy",r[1]),x(s,"r",r[2]),x(t,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){nt(l,t,h),xt(t,e),xt(t,n),xt(t,s),o||(a=[St(e,"pointerdown",r[5]),St(e,"pointerdown",r[3])],o=!0)},p(l,h){h&1&&x(e,"cx",l[0]),h&2&&x(e,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&x(e,"r",i),h&1&&x(n,"cx",l[0]),h&2&&x(n,"cy",l[1]),h&4&&x(n,"r",l[2]),h&1&&x(s,"cx",l[0]),h&2&&x(s,"cy",l[1]),h&4&&x(s,"r",l[2])},d(l){l&&rt(t),o=!1,Me(a)}}}function u0(r){let t;return{c(){t=W("circle"),x(t,"cx",r[0]),x(t,"cy",r[1]),x(t,"r",r[2])},m(e,i){nt(e,t,i)},p(e,i){i&1&&x(t,"cx",e[0]),i&2&&x(t,"cy",e[1]),i&4&&x(t,"r",e[2])},d(e){e&&rt(t)}}}function d0(r){let t;function e(n,s){return Ne?u0:c0}let i=e()(r);return{c(){i.c(),t=De()},m(n,s){i.m(n,s),nt(n,t,s)},p(n,[s]){i.p(n,s)},i:Rt,o:Rt,d(n){n&&rt(t),i.d(n)}}}function f0(r,t,e){let i,{x:n}=t,{y:s}=t,{scale:o}=t;const a=h=>{h.pointerType};function l(h){oe.call(this,r,h)}return r.$$set=h=>{"x"in h&&e(0,n=h.x),"y"in h&&e(1,s=h.y),"scale"in h&&e(4,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=4/o)},[n,s,i,a,o,l]}class mc extends me{constructor(t){super(),pe(this,t,f0,d0,Kt,{x:0,y:1,scale:4})}}function sa(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function gc(r,t,e){const i=r.slice();return i[28]=t[e],i[30]=e,i}function oa(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function aa(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function yc(r){let t,e,i,n;return{c(){t=W("circle"),x(t,"cx",e=r[28][0]),x(t,"cy",i=r[28][1]),x(t,"r",n=vn/r[3]),x(t,"class","svelte-1h2slbm")},m(s,o){nt(s,t,o)},p(s,o){o[0]&1088&&e!==(e=s[28][0])&&x(t,"cx",e),o[0]&1088&&i!==(i=s[28][1])&&x(t,"cy",i),o[0]&8&&n!==(n=vn/s[3])&&x(t,"r",n)},d(s){s&&rt(t)}}}function _c(r){let t,e,i,n,s,o,a,l,h,c;return{c(){t=W("mask"),e=W("rect"),a=W("circle"),x(e,"x",i=r[9].x),x(e,"y",n=r[9].y),x(e,"width",s=r[9].w),x(e,"height",o=r[9].h),x(e,"class","svelte-1h2slbm"),x(a,"cx",l=r[28][0]),x(a,"cy",h=r[28][1]),x(a,"r",c=vn/r[3]),x(a,"class","svelte-1h2slbm"),x(t,"id",`${r[19]}-inner`),x(t,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(u,d){nt(u,t,d),xt(t,e),xt(t,a)},p(u,d){d[0]&512&&i!==(i=u[9].x)&&x(e,"x",i),d[0]&512&&n!==(n=u[9].y)&&x(e,"y",n),d[0]&512&&s!==(s=u[9].w)&&x(e,"width",s),d[0]&512&&o!==(o=u[9].h)&&x(e,"height",o),d[0]&1088&&l!==(l=u[28][0])&&x(a,"cx",l),d[0]&1088&&h!==(h=u[28][1])&&x(a,"cy",h),d[0]&8&&c!==(c=vn/u[3])&&x(a,"r",c)},d(u){u&&rt(t)}}}function vc(r){let t,e;return t=new Ri({props:{class:"a9s-corner-handle",x:r[28][0],y:r[28][1],scale:r[3],selected:r[8].includes(r[30])}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[15]),t.$on("pointerdown",function(){Gt(r[27](`HANDLE-${r[30]}`))&&r[27](`HANDLE-${r[30]}`).apply(this,arguments)}),t.$on("pointerup",r[16](r[30])),{c(){re(t.$$.fragment)},m(i,n){Qt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&32&&(s.x=r[28][0]),n[0]&32&&(s.y=r[28][1]),n[0]&8&&(s.scale=r[3]),n[0]&256&&(s.selected=r[8].includes(r[30])),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function bc(r){let t,e;return t=new mc({props:{x:r[28][0],y:r[28][1],scale:r[3]}}),t.$on("pointerdown",function(){Gt(r[18](r[6]))&&r[18](r[6]).apply(this,arguments)}),{c(){re(t.$$.fragment)},m(i,n){Qt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&1088&&(s.x=r[28][0]),n[0]&1088&&(s.y=r[28][1]),n[0]&8&&(s.scale=r[3]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function p0(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v,m,b,S,R=r[6]!==void 0&&!r[7]&&yc(aa(r)),C=r[6]!==void 0&&!r[7]&&_c(oa(r)),I=Ie(r[5].points),M=[];for(let P=0;P<I.length;P+=1)M[P]=vc(gc(r,I,P));const F=P=>yt(M[P],1,1,()=>{M[P]=null});let U=r[6]!==void 0&&!r[7]&&bc(sa(r));return{c(){t=W("defs"),e=W("mask"),i=W("rect"),l=W("polygon"),R&&R.c(),C&&C.c(),c=we(),u=W("polygon"),f=we(),p=W("polygon"),y=we();for(let P=0;P<M.length;P+=1)M[P].c();_=we(),U&&U.c(),v=De(),x(i,"x",n=r[9].x),x(i,"y",s=r[9].y),x(i,"width",o=r[9].w),x(i,"height",a=r[9].h),x(i,"class","svelte-1h2slbm"),x(l,"points",h=r[5].points.map(xc).join(" ")),x(l,"class","svelte-1h2slbm"),x(e,"id",`${r[19]}-outer`),x(e,"class","a9s-polygon-editor-mask svelte-1h2slbm"),x(u,"class","a9s-outer"),x(u,"mask",`url(#${r[19]}-outer)`),x(u,"points",d=r[5].points.map(wc).join(" ")),x(p,"class","a9s-inner a9s-shape-handle"),x(p,"mask",`url(#${r[19]}-inner)`),x(p,"style",r[1]),x(p,"points",g=r[5].points.map(Ec).join(" "))},m(P,T){nt(P,t,T),xt(t,e),xt(e,i),xt(e,l),R&&R.m(e,null),C&&C.m(t,null),nt(P,c,T),nt(P,u,T),nt(P,f,T),nt(P,p,T),nt(P,y,T);for(let E=0;E<M.length;E+=1)M[E]&&M[E].m(P,T);nt(P,_,T),U&&U.m(P,T),nt(P,v,T),m=!0,b||(S=[St(u,"pointerup",r[14]),St(u,"pointerdown",function(){Gt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)}),St(p,"pointermove",r[13]),St(p,"pointerup",r[14]),St(p,"pointerdown",function(){Gt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)})],b=!0)},p(P,T){if(r=P,(!m||T[0]&512&&n!==(n=r[9].x))&&x(i,"x",n),(!m||T[0]&512&&s!==(s=r[9].y))&&x(i,"y",s),(!m||T[0]&512&&o!==(o=r[9].w))&&x(i,"width",o),(!m||T[0]&512&&a!==(a=r[9].h))&&x(i,"height",a),(!m||T[0]&32&&h!==(h=r[5].points.map(xc).join(" ")))&&x(l,"points",h),r[6]!==void 0&&!r[7]?R?R.p(aa(r),T):(R=yc(aa(r)),R.c(),R.m(e,null)):R&&(R.d(1),R=null),r[6]!==void 0&&!r[7]?C?C.p(oa(r),T):(C=_c(oa(r)),C.c(),C.m(t,null)):C&&(C.d(1),C=null),(!m||T[0]&32&&d!==(d=r[5].points.map(wc).join(" ")))&&x(u,"points",d),(!m||T[0]&2)&&x(p,"style",r[1]),(!m||T[0]&32&&g!==(g=r[5].points.map(Ec).join(" ")))&&x(p,"points",g),T[0]&134322472){I=Ie(r[5].points);let E;for(E=0;E<I.length;E+=1){const A=gc(r,I,E);M[E]?(M[E].p(A,T),lt(M[E],1)):(M[E]=vc(A),M[E].c(),lt(M[E],1),M[E].m(_.parentNode,_))}for(Ee(),E=I.length;E<M.length;E+=1)F(E);Te()}r[6]!==void 0&&!r[7]?U?(U.p(sa(r),T),T[0]&192&&lt(U,1)):(U=bc(sa(r)),U.c(),lt(U,1),U.m(v.parentNode,v)):U&&(Ee(),yt(U,1,1,()=>{U=null}),Te())},i(P){if(!m){for(let T=0;T<I.length;T+=1)lt(M[T]);lt(U),m=!0}},o(P){M=M.filter(Boolean);for(let T=0;T<M.length;T+=1)yt(M[T]);yt(U),m=!1},d(P){P&&(rt(t),rt(c),rt(u),rt(f),rt(p),rt(y),rt(_),rt(v)),R&&R.d(),C&&C.d(),Zr(M,P),U&&U.d(P),b=!1,Me(S)}}}function m0(r){let t,e;return t=new na({props:{shape:r[0],transform:r[2],editor:r[17],svgEl:r[4],$$slots:{default:[p0,({grab:i})=>({27:i}),({grab:i})=>[i?134217728:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){re(t.$$.fragment)},m(i,n){Qt(t,i,n),e=!0},p(i,n){const s={};n[0]&1&&(s.shape=i[0]),n[0]&4&&(s.transform=i[2]),n[0]&16&&(s.svgEl=i[4]),n[0]&134219754|n[1]&1&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}const g0=250,y0=1e3,_0=12,vn=4.5,xc=r=>r.join(","),wc=r=>r.join(","),Ec=r=>r.join(",");function v0(r,t,e){let i,n,s;const o=Rr();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:c=1}=t,{svgEl:u}=t,d,f=!1,p,g=[];const y=()=>e(7,f=!0),_=()=>e(7,f=!1),v=E=>{if(g.length>0||!n.some(B=>B.visible)){e(6,d=void 0);return}const[A,L]=h.elementToImage(E.offsetX,E.offsetY),D=B=>Math.pow(B[0]-A,2)+Math.pow(B[1]-L,2),N=i.points.reduce((B,k)=>D(k)<D(B)?k:B),$=n.filter(B=>B.visible).reduce((B,k)=>D(k.point)<D(B.point)?k:B),O=Math.pow(y0/c,2);D(N)<O||D($.point)<O?e(6,d=n.indexOf($)):e(6,d=void 0)},m=()=>{document.activeElement!==u&&u.focus()},b=()=>{e(8,g=[]),m()},S=E=>{e(7,f=!0),E.preventDefault(),E.stopPropagation(),p=performance.now()},R=E=>A=>{if(!p||Ne||performance.now()-p>g0)return;const L=g.includes(E);A.metaKey||A.ctrlKey||A.shiftKey?L?e(8,g=g.filter(D=>D!==E)):e(8,g=[...g,E]):L&&g.length>1?e(8,g=[E]):L?e(8,g=[]):e(8,g=[E]),m()},C=(E,A,L)=>{m();let D;const N=E.geometry;g.length>1?D=N.points.map(([O,B],k)=>g.includes(k)?[O+L[0],B+L[1]]:[O,B]):A==="SHAPE"?D=N.points.map(([O,B])=>[O+L[0],B+L[1]]):D=N.points.map(([O,B],k)=>A===`HANDLE-${k}`?[O+L[0],B+L[1]]:[O,B]);const $=Ae(D);return{...E,geometry:{points:D,bounds:$}}},I=E=>async A=>{A.stopPropagation();const L=[...i.points.slice(0,E+1),n[E].point,...i.points.slice(E+1)],D=Ae(L);o("change",{...a,geometry:{points:L,bounds:D}}),await Qh();const N=[...document.querySelectorAll(".a9s-handle")][E+1];if(N!=null&&N.firstChild){const $=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:A.clientX,clientY:A.clientY,pointerId:A.pointerId,pointerType:A.pointerType,isPrimary:A.isPrimary,buttons:A.buttons});N.firstChild.dispatchEvent($)}},M=()=>{if(i.points.length-g.length<3)return;const E=i.points.filter((L,D)=>!g.includes(D)),A=Ae(E);o("change",{...a,geometry:{points:E,bounds:A}}),e(8,g=[])};Jr(()=>{if(Ne)return;const E=A=>{(A.key==="Delete"||A.key==="Backspace")&&(A.preventDefault(),M())};return u.addEventListener("pointermove",v),u.addEventListener("keydown",E),()=>{u.removeEventListener("pointermove",v),u.removeEventListener("keydown",E)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function U(E){oe.call(this,r,E)}function P(E){oe.call(this,r,E)}function T(E){oe.call(this,r,E)}return r.$$set=E=>{"shape"in E&&e(0,a=E.shape),"computedStyle"in E&&e(1,l=E.computedStyle),"transform"in E&&e(2,h=E.transform),"viewportScale"in E&&e(3,c=E.viewportScale),"svgEl"in E&&e(4,u=E.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,n=Ne?[]:i.points.map((E,A)=>{const L=A===i.points.length-1?i.points[0]:i.points[A+1],D=(E[0]+L[0])/2,N=(E[1]+L[1])/2,$=Math.sqrt(Math.pow(L[0]-D,2)+Math.pow(L[1]-N,2))>_0/c;return{point:[D,N],visible:$}})),r.$$.dirty[0]&40&&e(9,s=ms(i.bounds,vn/c))},[a,l,h,c,u,i,d,f,g,s,n,y,_,v,b,S,R,C,I,F,U,P,T]}class b0 extends me{constructor(t){super(),pe(this,t,v0,m0,Kt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function x0(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v,m,b,S,R,C,I,M,F,U,P,T,E,A,L,D,N,$,O,B,k,V,z,K,X,ft,H,mt,J,ut,gt,Et,Dt,Yt,Vt,et,$e,ts;return J=new Ri({props:{class:"a9s-corner-handle-topleft",x:r[5].x,y:r[5].y,scale:r[3]}}),J.$on("pointerdown",function(){Gt(r[12]("TOP_LEFT"))&&r[12]("TOP_LEFT").apply(this,arguments)}),gt=new Ri({props:{class:"a9s-corner-handle-topright",x:r[5].x+r[5].w,y:r[5].y,scale:r[3]}}),gt.$on("pointerdown",function(){Gt(r[12]("TOP_RIGHT"))&&r[12]("TOP_RIGHT").apply(this,arguments)}),Dt=new Ri({props:{class:"a9s-corner-handle-bottomright",x:r[5].x+r[5].w,y:r[5].y+r[5].h,scale:r[3]}}),Dt.$on("pointerdown",function(){Gt(r[12]("BOTTOM_RIGHT"))&&r[12]("BOTTOM_RIGHT").apply(this,arguments)}),Vt=new Ri({props:{class:"a9s-corner-handle-bottomleft",x:r[5].x,y:r[5].y+r[5].h,scale:r[3]}}),Vt.$on("pointerdown",function(){Gt(r[12]("BOTTOM_LEFT"))&&r[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=W("defs"),e=W("mask"),i=W("rect"),l=W("rect"),f=we(),p=W("rect"),m=we(),b=W("rect"),M=we(),F=W("rect"),E=we(),A=W("rect"),$=we(),O=W("rect"),z=we(),K=W("rect"),mt=we(),re(J.$$.fragment),ut=we(),re(gt.$$.fragment),Et=we(),re(Dt.$$.fragment),Yt=we(),re(Vt.$$.fragment),x(i,"class","rect-mask-bg svelte-1njczvj"),x(i,"x",n=r[6].x),x(i,"y",s=r[6].y),x(i,"width",o=r[6].w),x(i,"height",a=r[6].h),x(l,"class","rect-mask-fg svelte-1njczvj"),x(l,"x",h=r[5].x),x(l,"y",c=r[5].y),x(l,"width",u=r[5].w),x(l,"height",d=r[5].h),x(e,"id",r[8]),x(e,"class","a9s-rectangle-editor-mask svelte-1njczvj"),x(p,"class","a9s-outer"),x(p,"mask",`url(#${r[8]})`),x(p,"x",g=r[5].x),x(p,"y",y=r[5].y),x(p,"width",_=r[5].w),x(p,"height",v=r[5].h),x(b,"class","a9s-inner a9s-shape-handle"),x(b,"style",r[1]),x(b,"x",S=r[5].x),x(b,"y",R=r[5].y),x(b,"width",C=r[5].w),x(b,"height",I=r[5].h),x(F,"class","a9s-edge-handle a9s-edge-handle-top"),x(F,"x",U=r[5].x),x(F,"y",P=r[5].y),x(F,"height",1),x(F,"width",T=r[5].w),x(A,"class","a9s-edge-handle a9s-edge-handle-right"),x(A,"x",L=r[5].x+r[5].w),x(A,"y",D=r[5].y),x(A,"height",N=r[5].h),x(A,"width",1),x(O,"class","a9s-edge-handle a9s-edge-handle-bottom"),x(O,"x",B=r[5].x),x(O,"y",k=r[5].y+r[5].h),x(O,"height",1),x(O,"width",V=r[5].w),x(K,"class","a9s-edge-handle a9s-edge-handle-left"),x(K,"x",X=r[5].x),x(K,"y",ft=r[5].y),x(K,"height",H=r[5].h),x(K,"width",1)},m(Y,G){nt(Y,t,G),xt(t,e),xt(e,i),xt(e,l),nt(Y,f,G),nt(Y,p,G),nt(Y,m,G),nt(Y,b,G),nt(Y,M,G),nt(Y,F,G),nt(Y,E,G),nt(Y,A,G),nt(Y,$,G),nt(Y,O,G),nt(Y,z,G),nt(Y,K,G),nt(Y,mt,G),Qt(J,Y,G),nt(Y,ut,G),Qt(gt,Y,G),nt(Y,Et,G),Qt(Dt,Y,G),nt(Y,Yt,G),Qt(Vt,Y,G),et=!0,$e||(ts=[St(p,"pointerdown",function(){Gt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),St(b,"pointerdown",function(){Gt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),St(F,"pointerdown",function(){Gt(r[12]("TOP"))&&r[12]("TOP").apply(this,arguments)}),St(A,"pointerdown",function(){Gt(r[12]("RIGHT"))&&r[12]("RIGHT").apply(this,arguments)}),St(O,"pointerdown",function(){Gt(r[12]("BOTTOM"))&&r[12]("BOTTOM").apply(this,arguments)}),St(K,"pointerdown",function(){Gt(r[12]("LEFT"))&&r[12]("LEFT").apply(this,arguments)})],$e=!0)},p(Y,G){r=Y,(!et||G&64&&n!==(n=r[6].x))&&x(i,"x",n),(!et||G&64&&s!==(s=r[6].y))&&x(i,"y",s),(!et||G&64&&o!==(o=r[6].w))&&x(i,"width",o),(!et||G&64&&a!==(a=r[6].h))&&x(i,"height",a),(!et||G&32&&h!==(h=r[5].x))&&x(l,"x",h),(!et||G&32&&c!==(c=r[5].y))&&x(l,"y",c),(!et||G&32&&u!==(u=r[5].w))&&x(l,"width",u),(!et||G&32&&d!==(d=r[5].h))&&x(l,"height",d),(!et||G&32&&g!==(g=r[5].x))&&x(p,"x",g),(!et||G&32&&y!==(y=r[5].y))&&x(p,"y",y),(!et||G&32&&_!==(_=r[5].w))&&x(p,"width",_),(!et||G&32&&v!==(v=r[5].h))&&x(p,"height",v),(!et||G&2)&&x(b,"style",r[1]),(!et||G&32&&S!==(S=r[5].x))&&x(b,"x",S),(!et||G&32&&R!==(R=r[5].y))&&x(b,"y",R),(!et||G&32&&C!==(C=r[5].w))&&x(b,"width",C),(!et||G&32&&I!==(I=r[5].h))&&x(b,"height",I),(!et||G&32&&U!==(U=r[5].x))&&x(F,"x",U),(!et||G&32&&P!==(P=r[5].y))&&x(F,"y",P),(!et||G&32&&T!==(T=r[5].w))&&x(F,"width",T),(!et||G&32&&L!==(L=r[5].x+r[5].w))&&x(A,"x",L),(!et||G&32&&D!==(D=r[5].y))&&x(A,"y",D),(!et||G&32&&N!==(N=r[5].h))&&x(A,"height",N),(!et||G&32&&B!==(B=r[5].x))&&x(O,"x",B),(!et||G&32&&k!==(k=r[5].y+r[5].h))&&x(O,"y",k),(!et||G&32&&V!==(V=r[5].w))&&x(O,"width",V),(!et||G&32&&X!==(X=r[5].x))&&x(K,"x",X),(!et||G&32&&ft!==(ft=r[5].y))&&x(K,"y",ft),(!et||G&32&&H!==(H=r[5].h))&&x(K,"height",H);const Ar={};G&32&&(Ar.x=r[5].x),G&32&&(Ar.y=r[5].y),G&8&&(Ar.scale=r[3]),J.$set(Ar);const Sr={};G&32&&(Sr.x=r[5].x+r[5].w),G&32&&(Sr.y=r[5].y),G&8&&(Sr.scale=r[3]),gt.$set(Sr);const Cr={};G&32&&(Cr.x=r[5].x+r[5].w),G&32&&(Cr.y=r[5].y+r[5].h),G&8&&(Cr.scale=r[3]),Dt.$set(Cr);const Ir={};G&32&&(Ir.x=r[5].x),G&32&&(Ir.y=r[5].y+r[5].h),G&8&&(Ir.scale=r[3]),Vt.$set(Ir)},i(Y){et||(lt(J.$$.fragment,Y),lt(gt.$$.fragment,Y),lt(Dt.$$.fragment,Y),lt(Vt.$$.fragment,Y),et=!0)},o(Y){yt(J.$$.fragment,Y),yt(gt.$$.fragment,Y),yt(Dt.$$.fragment,Y),yt(Vt.$$.fragment,Y),et=!1},d(Y){Y&&(rt(t),rt(f),rt(p),rt(m),rt(b),rt(M),rt(F),rt(E),rt(A),rt($),rt(O),rt(z),rt(K),rt(mt),rt(ut),rt(Et),rt(Yt)),te(J,Y),te(gt,Y),te(Dt,Y),te(Vt,Y),$e=!1,Me(ts)}}}function w0(r){let t,e;return t=new na({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[x0,({grab:i})=>({12:i}),({grab:i})=>i?4096:0]},$$scope:{ctx:r}}}),t.$on("grab",r[9]),t.$on("change",r[10]),t.$on("release",r[11]),{c(){re(t.$$.fragment)},m(i,n){Qt(t,i,n),e=!0},p(i,[n]){const s={};n&1&&(s.shape=i[0]),n&4&&(s.transform=i[2]),n&16&&(s.svgEl=i[4]),n&12394&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function E0(r,t,e){let i,n,{shape:s}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const c=(g,y,_)=>{const v=g.geometry.bounds;let[m,b]=[v.minX,v.minY],[S,R]=[v.maxX,v.maxY];const[C,I]=_;if(y==="SHAPE")m+=C,S+=C,b+=I,R+=I;else{switch(y){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{b+=I;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{R+=I;break}}switch(y){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{m+=C;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{S+=C;break}}}const M=Math.min(m,S),F=Math.min(b,R),U=Math.abs(S-m),P=Math.abs(R-b);return{...g,geometry:{x:M,y:F,w:U,h:P,bounds:{minX:M,minY:F,maxX:M+U,maxY:F+P}}}},u=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(g){oe.call(this,r,g)}function f(g){oe.call(this,r,g)}function p(g){oe.call(this,r,g)}return r.$$set=g=>{"shape"in g&&e(0,s=g.shape),"computedStyle"in g&&e(1,o=g.computedStyle),"transform"in g&&e(2,a=g.transform),"viewportScale"in g&&e(3,l=g.viewportScale),"svgEl"in g&&e(4,h=g.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=s.geometry),r.$$.dirty&40&&e(6,n=ms(i.bounds,2/l))},[s,o,a,l,h,i,n,c,u,d,f,p]}class T0 extends me{constructor(t){super(),pe(this,t,E0,w0,Kt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var Tc=Object.prototype.hasOwnProperty;function la(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--&&la(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Tc.call(r,e)&&++i&&!Tc.call(t,e)||!(e in t)||!la(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}const A0=12,S0=(r,t)=>r.polygons.reduce((e,i,n)=>{const s=i.rings.reduce((o,a,l)=>{const h=a.points.map((c,u)=>{const d=u===a.points.length-1?a.points[0]:a.points[u+1],f=(c[0]+d[0])/2,p=(c[1]+d[1])/2,g=Math.sqrt(Math.pow(d[0]-f,2)+Math.pow(d[1]-p,2))>A0/t;return{point:[f,p],visible:g,elementIdx:n,ringIdx:l,pointIdx:u}});return[...o,...h]},[]);return[...e,...s]},[]);function ha(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Ac(r,t,e){const i=r.slice();return i[30]=t[e],i[32]=e,i}function Sc(r,t,e){const i=r.slice();return i[33]=t[e],i[35]=e,i}function Cc(r,t,e){const i=r.slice();return i[29]=t[e],i[37]=e,i}function ca(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function ua(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Ic(r){let t,e,i,n;return{c(){t=W("circle"),x(t,"cx",e=r[29][0]),x(t,"cy",i=r[29][1]),x(t,"r",n=bn/r[3]),x(t,"class","svelte-1vxo6dc")},m(s,o){nt(s,t,o)},p(s,o){o[0]&1088&&e!==(e=s[29][0])&&x(t,"cx",e),o[0]&1088&&i!==(i=s[29][1])&&x(t,"cy",i),o[0]&8&&n!==(n=bn/s[3])&&x(t,"r",n)},d(s){s&&rt(t)}}}function Pc(r){let t,e,i,n,s,o,a,l,h,c;return{c(){t=W("mask"),e=W("rect"),a=W("circle"),x(e,"x",i=r[9].x),x(e,"y",n=r[9].y),x(e,"width",s=r[9].w),x(e,"height",o=r[9].h),x(e,"class","svelte-1vxo6dc"),x(a,"cx",l=r[29][0]),x(a,"cy",h=r[29][1]),x(a,"r",c=bn/r[3]),x(a,"class","svelte-1vxo6dc"),x(t,"id",`${r[18]}-${r[32]}-inner`),x(t,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc")},m(u,d){nt(u,t,d),xt(t,e),xt(t,a)},p(u,d){d[0]&512&&i!==(i=u[9].x)&&x(e,"x",i),d[0]&512&&n!==(n=u[9].y)&&x(e,"y",n),d[0]&512&&s!==(s=u[9].w)&&x(e,"width",s),d[0]&512&&o!==(o=u[9].h)&&x(e,"height",o),d[0]&1088&&l!==(l=u[29][0])&&x(a,"cx",l),d[0]&1088&&h!==(h=u[29][1])&&x(a,"cy",h),d[0]&8&&c!==(c=bn/u[3])&&x(a,"r",c)},d(u){u&&rt(t)}}}function Rc(r){let t,e;function i(...n){return r[19](r[32],r[35],r[37],...n)}return t=new Ri({props:{class:"a9s-corner-handle",x:r[29][0],y:r[29][1],scale:r[3],selected:r[8].some(i)}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[14]),t.$on("pointerdown",function(){Gt(r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`))&&r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`).apply(this,arguments)}),t.$on("pointerup",r[15](r[32],r[35],r[37])),{c(){re(t.$$.fragment)},m(n,s){Qt(t,n,s),e=!0},p(n,s){r=n;const o={};s[0]&32&&(o.x=r[29][0]),s[0]&32&&(o.y=r[29][1]),s[0]&8&&(o.scale=r[3]),s[0]&256&&(o.selected=r[8].some(i)),t.$set(o)},i(n){e||(lt(t.$$.fragment,n),e=!0)},o(n){yt(t.$$.fragment,n),e=!1},d(n){te(t,n)}}}function Mc(r){let t,e,i=Ie(r[33].points),n=[];for(let o=0;o<i.length;o+=1)n[o]=Rc(Cc(r,i,o));const s=o=>yt(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=De()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);nt(o,t,a),e=!0},p(o,a){if(a[0]&268491048){i=Ie(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=Cc(o,i,l);n[l]?(n[l].p(h,a),lt(n[l],1)):(n[l]=Rc(h),n[l].c(),lt(n[l],1),n[l].m(t.parentNode,t))}for(Ee(),l=i.length;l<n.length;l+=1)s(l);Te()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)lt(n[a]);e=!0}},o(o){n=n.filter(Boolean);for(let a=0;a<n.length;a+=1)yt(n[a]);e=!1},d(o){o&&rt(t),Zr(n,o)}}}function Dc(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v=r[6]!==void 0&&!r[7]&&Ic(ua(r)),m=r[6]!==void 0&&!r[7]&&Pc(ca(r)),b=Ie(r[30].rings),S=[];for(let C=0;C<b.length;C+=1)S[C]=Mc(Sc(r,b,C));const R=C=>yt(S[C],1,1,()=>{S[C]=null});return{c(){t=W("g"),e=W("defs"),i=W("mask"),n=W("rect"),h=W("path"),v&&v.c(),m&&m.c(),u=W("path"),f=W("path");for(let C=0;C<S.length;C+=1)S[C].c();x(n,"x",s=r[9].x),x(n,"y",o=r[9].y),x(n,"width",a=r[9].w),x(n,"height",l=r[9].h),x(n,"class","svelte-1vxo6dc"),x(h,"d",c=He(r[30])),x(h,"class","svelte-1vxo6dc"),x(i,"id",`${r[18]}-${r[32]}-outer`),x(i,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc"),x(u,"class","a9s-outer"),x(u,"mask",`url(#${r[18]}-${r[32]}-outer)`),x(u,"fill-rule","evenodd"),x(u,"d",d=He(r[30])),x(f,"class","a9s-inner"),x(f,"mask",`url(#${r[18]}-${r[32]}-inner)`),x(f,"style",r[1]),x(f,"fill-rule","evenodd"),x(f,"d",p=He(r[30]))},m(C,I){nt(C,t,I),xt(t,e),xt(e,i),xt(i,n),xt(i,h),v&&v.m(i,null),m&&m.m(e,null),xt(t,u),xt(t,f);for(let M=0;M<S.length;M+=1)S[M]&&S[M].m(t,null);g=!0,y||(_=[St(u,"pointerup",r[13]),St(u,"pointerdown",function(){Gt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)}),St(f,"pointerup",r[13]),St(f,"pointerdown",function(){Gt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)})],y=!0)},p(C,I){if(r=C,(!g||I[0]&512&&s!==(s=r[9].x))&&x(n,"x",s),(!g||I[0]&512&&o!==(o=r[9].y))&&x(n,"y",o),(!g||I[0]&512&&a!==(a=r[9].w))&&x(n,"width",a),(!g||I[0]&512&&l!==(l=r[9].h))&&x(n,"height",l),(!g||I[0]&32&&c!==(c=He(r[30])))&&x(h,"d",c),r[6]!==void 0&&!r[7]?v?v.p(ua(r),I):(v=Ic(ua(r)),v.c(),v.m(i,null)):v&&(v.d(1),v=null),r[6]!==void 0&&!r[7]?m?m.p(ca(r),I):(m=Pc(ca(r)),m.c(),m.m(e,null)):m&&(m.d(1),m=null),(!g||I[0]&32&&d!==(d=He(r[30])))&&x(u,"d",d),(!g||I[0]&2)&&x(f,"style",r[1]),(!g||I[0]&32&&p!==(p=He(r[30])))&&x(f,"d",p),I[0]&268491048){b=Ie(r[30].rings);let M;for(M=0;M<b.length;M+=1){const F=Sc(r,b,M);S[M]?(S[M].p(F,I),lt(S[M],1)):(S[M]=Mc(F),S[M].c(),lt(S[M],1),S[M].m(t,null))}for(Ee(),M=b.length;M<S.length;M+=1)R(M);Te()}},i(C){if(!g){for(let I=0;I<b.length;I+=1)lt(S[I]);g=!0}},o(C){S=S.filter(Boolean);for(let I=0;I<S.length;I+=1)yt(S[I]);g=!1},d(C){C&&rt(t),v&&v.d(),m&&m.d(),Zr(S,C),y=!1,Me(_)}}}function Bc(r){let t,e;return t=new mc({props:{x:r[29][0],y:r[29][1],scale:r[3]}}),t.$on("pointerdown",function(){Gt(r[17](r[6]))&&r[17](r[6]).apply(this,arguments)}),{c(){re(t.$$.fragment)},m(i,n){Qt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&1088&&(s.x=r[29][0]),n[0]&1088&&(s.y=r[29][1]),n[0]&8&&(s.scale=r[3]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function C0(r){let t,e,i,n=Ie(r[5].polygons),s=[];for(let l=0;l<n.length;l+=1)s[l]=Dc(Ac(r,n,l));const o=l=>yt(s[l],1,1,()=>{s[l]=null});let a=r[6]!==void 0&&!r[7]&&Bc(ha(r));return{c(){for(let l=0;l<s.length;l+=1)s[l].c();t=we(),a&&a.c(),e=De()},m(l,h){for(let c=0;c<s.length;c+=1)s[c]&&s[c].m(l,h);nt(l,t,h),a&&a.m(l,h),nt(l,e,h),i=!0},p(l,h){if(h[0]&268763114){n=Ie(l[5].polygons);let c;for(c=0;c<n.length;c+=1){const u=Ac(l,n,c);s[c]?(s[c].p(u,h),lt(s[c],1)):(s[c]=Dc(u),s[c].c(),lt(s[c],1),s[c].m(t.parentNode,t))}for(Ee(),c=n.length;c<s.length;c+=1)o(c);Te()}l[6]!==void 0&&!l[7]?a?(a.p(ha(l),h),h[0]&192&&lt(a,1)):(a=Bc(ha(l)),a.c(),lt(a,1),a.m(e.parentNode,e)):a&&(Ee(),yt(a,1,1,()=>{a=null}),Te())},i(l){if(!i){for(let h=0;h<n.length;h+=1)lt(s[h]);lt(a),i=!0}},o(l){s=s.filter(Boolean);for(let h=0;h<s.length;h+=1)yt(s[h]);yt(a),i=!1},d(l){l&&(rt(t),rt(e)),Zr(s,l),a&&a.d(l)}}}function I0(r){let t,e;return t=new na({props:{shape:r[0],transform:r[2],editor:r[16],svgEl:r[4],$$slots:{default:[C0,({grab:i})=>({28:i}),({grab:i})=>[i?268435456:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){re(t.$$.fragment)},m(i,n){Qt(t,i,n),e=!0},p(i,n){const s={};n[0]&1&&(s.shape=i[0]),n[0]&4&&(s.transform=i[2]),n[0]&16&&(s.svgEl=i[4]),n[0]&268437482|n[1]&128&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}const P0=250,R0=1e3,bn=4.5;function M0(r,t,e){let i,n,s;const o=Rr();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:c=1}=t,{svgEl:u}=t,d,f=!1,p,g=[];const y=()=>e(7,f=!0),_=()=>e(7,f=!1),v=A=>{if(g.length>0||!n.some(k=>k.visible)){e(6,d=void 0);return}const[L,D]=h.elementToImage(A.offsetX,A.offsetY),N=k=>Math.pow(k[0]-L,2)+Math.pow(k[1]-D,2),$=Vg(i).reduce((k,V)=>N(V)<N(k)?V:k),O=n.filter(k=>k.visible).reduce((k,V)=>N(V.point)<N(k.point)?V:k),B=Math.pow(R0/c,2);N($)<B||N(O.point)<B?e(6,d=n.indexOf(O)):e(6,d=void 0)},m=()=>{document.activeElement!==u&&u.focus()},b=()=>{e(8,g=[]),m()},S=A=>{e(7,f=!0),A.preventDefault(),A.stopPropagation(),p=performance.now()},R=(A,L,D)=>N=>{if(!p||Ne||performance.now()-p>P0)return;const $=B=>B.polygon===A&&B.ring===L&&B.point===D,O=g.some($);N.metaKey||N.ctrlKey||N.shiftKey?O?e(8,g=g.filter(B=>!$(B))):e(8,g=[...g,{polygon:A,ring:L,point:D}]):O&&g.length>1?e(8,g=[{polygon:A,ring:L,point:D}]):O?e(8,g=[]):e(8,g=[{polygon:A,ring:L,point:D}]),m()},C=(A,L,D)=>{m();const N=A.geometry.polygons;let $;if(L==="SHAPE")$=N.map(O=>{const B=O.rings.map((V,z)=>({points:V.points.map((K,X)=>[K[0]+D[0],K[1]+D[1]])})),k=Ae(B[0].points);return{rings:B,bounds:k}});else{const[O,B,k,V]=L.split("-").map(z=>parseInt(z));$=N.map((z,K)=>{if(K===B){const X=z.rings.map((H,mt)=>mt===k?{points:H.points.map((J,ut)=>ut===V?[J[0]+D[0],J[1]+D[1]]:J)}:H),ft=Ae(X[0].points);return{rings:X,bounds:ft}}else return z})}return{...A,geometry:{polygons:$,bounds:Ko($)}}},I=A=>async L=>{L.stopPropagation();const D=n[A],N=i.polygons.map((O,B)=>{if(B===D.elementIdx){const k=O.rings.map((z,K)=>K===D.ringIdx?{points:[...z.points.slice(0,D.pointIdx+1),D.point,...z.points.slice(D.pointIdx+1)]}:z),V=Ae(k[0].points);return{rings:k,bounds:V}}else return O});o("change",{...a,geometry:{polygons:N,bounds:Ko(N)}}),await Qh();const $=[...document.querySelectorAll(".a9s-handle")][A+1];if($!=null&&$.firstChild){const O=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:L.clientX,clientY:L.clientY,pointerId:L.pointerId,pointerType:L.pointerType,isPrimary:L.isPrimary,buttons:L.buttons});$.firstChild.dispatchEvent(O)}},M=()=>{const A=i.polygons.map((L,D)=>{if(g.some(N=>N.polygon===D)){const N=L.rings.map((O,B)=>{const k=g.filter(V=>V.polygon===D&&V.ring===B);return k.length&&O.points.length-k.length>=3?{points:O.points.filter((V,z)=>!k.some(K=>K.point===z))}:O}),$=Ae(N[0].points);return{rings:N,bounds:$}}else return L});!la(i.polygons,A)&&(o("change",{...a,geometry:{polygons:A,bounds:Ko(A)}}),e(8,g=[]))};Jr(()=>{if(Ne)return;const A=L=>{(L.key==="Delete"||L.key==="Backspace")&&(L.preventDefault(),M())};return u.addEventListener("pointermove",v),u.addEventListener("keydown",A),()=>{u.removeEventListener("pointermove",v),u.removeEventListener("keydown",A)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,U=(A,L,D,{polygon:N,ring:$,point:O})=>N===A&&$===L&&O===D;function P(A){oe.call(this,r,A)}function T(A){oe.call(this,r,A)}function E(A){oe.call(this,r,A)}return r.$$set=A=>{"shape"in A&&e(0,a=A.shape),"computedStyle"in A&&e(1,l=A.computedStyle),"transform"in A&&e(2,h=A.transform),"viewportScale"in A&&e(3,c=A.viewportScale),"svgEl"in A&&e(4,u=A.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,n=Ne?[]:S0(i,c)),r.$$.dirty[0]&40&&e(9,s=ms(i.bounds,bn/c))},[a,l,h,c,u,i,d,f,g,s,n,y,_,b,S,R,C,I,F,U,P,T,E]}class D0 extends me{constructor(t){super(),pe(this,t,M0,I0,Kt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}const Oc=new Map([[_t.RECTANGLE,T0],[_t.POLYGON,b0],[_t.MULTIPOLYGON,D0]]),da=r=>Oc.get(r.type),Lc=(r,t)=>Oc.set(r,t);function B0(r,t,e){let i;const n=Rr();let{annotation:s}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return Jr(()=>(e(6,u=new o({target:l,props:{shape:s.target.selector,computedStyle:i,transform:h,viewportScale:c,svgEl:l.closest("svg")}})),u.$on("change",d=>{u.$$set({shape:d.detail}),n("change",d.detail)}),u.$on("grab",d=>n("grab",d.detail)),u.$on("release",d=>n("release",d.detail)),()=>{u.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,s=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,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=ti(s,a)),r.$$.dirty&65&&s&&(u==null||u.$set({shape:s.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c}),r.$$.dirty&192&&u&&i&&u.$set({computedStyle:i})},[s,o,a,l,h,c,u,i]}class O0 extends me{constructor(t){super(),pe(this,t,B0,null,Kt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function L0(r,t,e){const i=Rr();let{drawingMode:n}=t,{target:s}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return Jr(()=>{const c=s.closest("svg"),u=[],d=(f,p,g)=>{c==null||c.addEventListener(f,p,g),u.push(()=>c==null?void 0:c.removeEventListener(f,p,g))};return e(5,h=new o({target:s,props:{addEventListener:d,drawingMode:n,transform:a,viewportScale:l}})),h.$on("create",f=>i("create",f.detail)),()=>{u.forEach(f=>f()),h.$destroy()}}),r.$$set=c=>{"drawingMode"in c&&e(0,n=c.drawingMode),"target"in c&&e(1,s=c.target),"tool"in c&&e(2,o=c.tool),"transform"in c&&e(3,a=c.transform),"viewportScale"in c&&e(4,l=c.viewportScale)},r.$$.update=()=>{r.$$.dirty&40&&h&&h.$set({transform:a}),r.$$.dirty&48&&h&&h.$set({viewportScale:l})},[n,s,o,a,l,h]}class N0 extends me{constructor(t){super(),pe(this,t,L0,null,Kt,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function Nc(r){let t,e,i,n,s,o,a,l,h,c;return{c(){t=W("defs"),e=W("mask"),i=W("rect"),l=W("rect"),h=W("rect"),c=W("rect"),x(i,"class","rect-mask-bg svelte-1a76qe7"),x(i,"x",n=r[1]-r[5]),x(i,"y",s=r[2]-r[5]),x(i,"width",o=r[3]+2*r[5]),x(i,"height",a=r[4]+2*r[5]),x(l,"class","rect-mask-fg svelte-1a76qe7"),x(l,"x",r[1]),x(l,"y",r[2]),x(l,"width",r[3]),x(l,"height",r[4]),x(e,"id",r[6]),x(e,"class","a9s-rubberband-rectangle-mask svelte-1a76qe7"),x(h,"class","a9s-outer"),x(h,"mask",`url(#${r[6]})`),x(h,"x",r[1]),x(h,"y",r[2]),x(h,"width",r[3]),x(h,"height",r[4]),x(c,"class","a9s-inner"),x(c,"x",r[1]),x(c,"y",r[2]),x(c,"width",r[3]),x(c,"height",r[4])},m(u,d){nt(u,t,d),xt(t,e),xt(e,i),xt(e,l),nt(u,h,d),nt(u,c,d)},p(u,d){d&34&&n!==(n=u[1]-u[5])&&x(i,"x",n),d&36&&s!==(s=u[2]-u[5])&&x(i,"y",s),d&40&&o!==(o=u[3]+2*u[5])&&x(i,"width",o),d&48&&a!==(a=u[4]+2*u[5])&&x(i,"height",a),d&2&&x(l,"x",u[1]),d&4&&x(l,"y",u[2]),d&8&&x(l,"width",u[3]),d&16&&x(l,"height",u[4]),d&2&&x(h,"x",u[1]),d&4&&x(h,"y",u[2]),d&8&&x(h,"width",u[3]),d&16&&x(h,"height",u[4]),d&2&&x(c,"x",u[1]),d&4&&x(c,"y",u[2]),d&8&&x(c,"width",u[3]),d&16&&x(c,"height",u[4])},d(u){u&&(rt(t),rt(h),rt(c))}}}function F0(r){let t,e=r[0]&&Nc(r);return{c(){t=W("g"),e&&e.c(),x(t,"class","a9s-annotation a9s-rubberband")},m(i,n){nt(i,t,n),e&&e.m(t,null)},p(i,[n]){i[0]?e?e.p(i,n):(e=Nc(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Rt,o:Rt,d(i){i&&rt(t),e&&e.d()}}}function k0(r,t,e){let i;const n=Rr();let{addEventListener:s}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,c,u,d,f,p,g;const y=S=>{const R=S;h=performance.now(),o==="drag"&&(e(0,c=a.elementToImage(R.offsetX,R.offsetY)),u=c,e(1,d=c[0]),e(2,f=c[1]),e(3,p=1),e(4,g=1))},_=S=>{const R=S;c&&(u=a.elementToImage(R.offsetX,R.offsetY),e(1,d=Math.min(u[0],c[0])),e(2,f=Math.min(u[1],c[1])),e(3,p=Math.abs(u[0]-c[0])),e(4,g=Math.abs(u[1]-c[1])))},v=S=>{const R=S,C=performance.now()-h;if(o==="click"){if(C>300)return;c?m():(e(0,c=a.elementToImage(R.offsetX,R.offsetY)),u=c,e(1,d=c[0]),e(2,f=c[1]),e(3,p=1),e(4,g=1))}else c&&(C>300||p*g>100?(R.stopPropagation(),m()):(e(0,c=void 0),u=void 0))},m=()=>{if(p*g>15){const S={type:_t.RECTANGLE,geometry:{bounds:{minX:d,minY:f,maxX:d+p,maxY:f+g},x:d,y:f,w:p,h:g}};n("create",S)}e(0,c=void 0),u=void 0};Jr(()=>{s("pointerdown",y),s("pointermove",_),s("pointerup",v,!0)});const b=`rect-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=S=>{"addEventListener"in S&&e(7,s=S.addEventListener),"drawingMode"in S&&e(8,o=S.drawingMode),"transform"in S&&e(9,a=S.transform),"viewportScale"in S&&e(10,l=S.viewportScale)},r.$$.update=()=>{r.$$.dirty&1024&&e(5,i=2/l)},[c,d,f,p,g,i,b,s,o,a,l]}class U0 extends me{constructor(t){super(),pe(this,t,k0,F0,Kt,{addEventListener:7,drawingMode:8,transform:9,viewportScale:10})}}function fa(r){const t=r.slice(),e=t[2].map(i=>i.join(",")).join(" ");return t[19]=e,t}function Fc(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g=r[1]&&kc(r);return{c(){t=W("defs"),e=W("mask"),i=W("rect"),l=W("polygon"),c=W("polygon"),d=W("polygon"),g&&g.c(),p=De(),x(i,"x",n=r[3].x),x(i,"y",s=r[3].y),x(i,"width",o=r[3].w),x(i,"height",a=r[3].h),x(i,"class","svelte-18wrg3t"),x(l,"points",h=r[19]),x(l,"class","svelte-18wrg3t"),x(e,"id",r[5]),x(e,"class","a9s-rubberband-polygon-mask svelte-18wrg3t"),x(c,"class","a9s-outer"),x(c,"mask",`url(#${r[5]})`),x(c,"points",u=r[19]),x(d,"class","a9s-inner"),x(d,"points",f=r[19])},m(y,_){nt(y,t,_),xt(t,e),xt(e,i),xt(e,l),nt(y,c,_),nt(y,d,_),g&&g.m(y,_),nt(y,p,_)},p(y,_){_&8&&n!==(n=y[3].x)&&x(i,"x",n),_&8&&s!==(s=y[3].y)&&x(i,"y",s),_&8&&o!==(o=y[3].w)&&x(i,"width",o),_&8&&a!==(a=y[3].h)&&x(i,"height",a),_&4&&h!==(h=y[19])&&x(l,"points",h),_&4&&u!==(u=y[19])&&x(c,"points",u),_&4&&f!==(f=y[19])&&x(d,"points",f),y[1]?g?g.p(y,_):(g=kc(y),g.c(),g.m(p.parentNode,p)):g&&(g.d(1),g=null)},d(y){y&&(rt(t),rt(c),rt(d),rt(p)),g&&g.d(y)}}}function kc(r){let t,e,i;return{c(){t=W("circle"),x(t,"class","a9s-handle svelte-18wrg3t"),x(t,"cx",e=r[0][0][0]),x(t,"cy",i=r[0][0][1]),x(t,"r",r[4])},m(n,s){nt(n,t,s)},p(n,s){s&1&&e!==(e=n[0][0][0])&&x(t,"cx",e),s&1&&i!==(i=n[0][0][1])&&x(t,"cy",i),s&16&&x(t,"r",n[4])},d(n){n&&rt(t)}}}function G0(r){let t,e=r[3]&&Fc(fa(r));return{c(){t=W("g"),e&&e.c(),x(t,"class","a9s-annotation a9s-rubberband")},m(i,n){nt(i,t,n),e&&e.m(t,null)},p(i,[n]){i[3]?e?e.p(fa(i),n):(e=Fc(fa(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Rt,o:Rt,d(i){i&&rt(t),e&&e.d()}}}const $0=20,H0=1500;function X0(r,t,e){let i,n,s;const o=Rr();let{addEventListener:a}=t,{drawingMode:l}=t,{transform:h}=t,{viewportScale:c=1}=t,u,d=[],f,p,g=!1;const y=R=>{const C=R,{timeStamp:I,offsetX:M,offsetY:F}=C;if(u={timeStamp:I,offsetX:M,offsetY:F},l==="drag"&&d.length===0){const U=h.elementToImage(C.offsetX,C.offsetY);d.push(U),e(10,f=U)}},_=R=>{const C=R;if(p&&clearTimeout(p),d.length>0){if(e(10,f=h.elementToImage(C.offsetX,C.offsetY)),d.length>2){const I=cs(f,d[0])*c;e(1,g=I<$0)}C.pointerType==="touch"&&(p=setTimeout(()=>{m()},H0))}},v=R=>{const C=R;if(p&&clearTimeout(p),l==="click"){const I=C.timeStamp-u.timeStamp,M=cs([u.offsetX,u.offsetY],[C.offsetX,C.offsetY]);if(I>300||M>15)return;if(g)b();else if(d.length===0){const F=h.elementToImage(C.offsetX,C.offsetY);d.push(F),e(10,f=F)}else f&&d.push(f)}else{if(!f)return;if(d.length===1&&cs(d[0],f)<=4){e(0,d=[]),e(10,f=void 0);return}C.stopImmediatePropagation(),g?b():d.push(f)}},m=()=>{if(!f)return;const R=d.slice(0,-1);if(R.length<3)return;const C={type:_t.POLYGON,geometry:{bounds:Ae(d),points:R}};qo(C)>4&&(e(0,d=[]),e(10,f=void 0),o("create",C))},b=()=>{const R={type:_t.POLYGON,geometry:{bounds:Ae(d),points:[...d]}};e(0,d=[]),e(10,f=void 0),o("create",R)};Jr(()=>{a("pointerdown",y,!0),a("pointermove",_),a("pointerup",v,!0),a("dblclick",m,!0)});const S=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=R=>{"addEventListener"in R&&e(6,a=R.addEventListener),"drawingMode"in R&&e(7,l=R.drawingMode),"transform"in R&&e(8,h=R.transform),"viewportScale"in R&&e(9,c=R.viewportScale)},r.$$.update=()=>{r.$$.dirty&512&&e(4,i=4/c),r.$$.dirty&1027&&e(2,n=f?g?d:[...d,f]:[]),r.$$.dirty&516&&e(3,s=n.length>0?ms(Ae(n),2/c):void 0)},[d,g,n,s,i,S,a,l,h,c,f]}class V0 extends me{constructor(t){super(),pe(this,t,X0,G0,Kt,{addEventListener:6,drawingMode:7,transform:8,viewportScale:9})}}const pa=new Map([["rectangle",{tool:U0}],["polygon",{tool:V0}]]),gs=()=>[...pa.keys()],ys=r=>pa.get(r),Uc=(r,t,e={})=>pa.set(r,{tool:t,opts:e});function z0(r){let t,e,i,n,s;return{c(){t=W("g"),e=W("ellipse"),n=W("ellipse"),x(e,"class","a9s-outer"),x(e,"style",i=r[1]?"display:none;":void 0),x(e,"cx",r[2]),x(e,"cy",r[3]),x(e,"rx",r[4]),x(e,"ry",r[5]),x(n,"class","a9s-inner"),x(n,"style",r[1]),x(n,"cx",r[2]),x(n,"cy",r[3]),x(n,"rx",r[4]),x(n,"ry",r[5]),x(t,"class","a9s-annotation"),x(t,"data-id",s=r[0].id)},m(o,a){nt(o,t,a),xt(t,e),xt(t,n)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&x(e,"style",i),a&2&&x(n,"style",o[1]),a&1&&s!==(s=o[0].id)&&x(t,"data-id",s)},i:Rt,o:Rt,d(o){o&&rt(t)}}}function j0(r,t,e){let i,{annotation:n}=t,{geom:s}=t,{style:o}=t;const{cx:a,cy:l,rx:h,ry:c}=s;return r.$$set=u=>{"annotation"in u&&e(0,n=u.annotation),"geom"in u&&e(6,s=u.geom),"style"in u&&e(7,o=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=ti(n,o))},[n,i,a,l,h,c,s,o]}class W0 extends me{constructor(t){super(),pe(this,t,j0,z0,Kt,{annotation:0,geom:6,style:7})}}function Y0(r){let t,e,i,n,s;return{c(){t=W("g"),e=W("line"),n=W("line"),x(e,"class","a9s-outer"),x(e,"style",i=r[1]?"display:none;":void 0),x(e,"x1",r[2]),x(e,"y1",r[3]),x(e,"x2",r[4]),x(e,"y2",r[5]),x(n,"class","a9s-inner"),x(n,"style",r[1]),x(n,"x1",r[2]),x(n,"y1",r[3]),x(n,"x2",r[4]),x(n,"y2",r[5]),x(t,"class","a9s-annotation"),x(t,"data-id",s=r[0].id)},m(o,a){nt(o,t,a),xt(t,e),xt(t,n)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&x(e,"style",i),a&2&&x(n,"style",o[1]),a&1&&s!==(s=o[0].id)&&x(t,"data-id",s)},i:Rt,o:Rt,d(o){o&&rt(t)}}}function q0(r,t,e){let i,{annotation:n}=t,{geom:s}=t,{style:o}=t;const{points:a}=s,[[l,h],[c,u]]=a;return r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"geom"in d&&e(6,s=d.geom),"style"in d&&e(7,o=d.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=ti(n,o))},[n,i,l,h,c,u,s,o]}class K0 extends me{constructor(t){super(),pe(this,t,q0,Y0,Kt,{annotation:0,geom:6,style:7})}}function Gc(r,t,e){const i=r.slice();return i[5]=t[e],i}function $c(r){let t,e,i;return{c(){t=W("path"),i=W("path"),x(t,"class","a9s-outer"),x(t,"style",e=r[1]?"display:none;":void 0),x(t,"fill-rule","evenodd"),x(t,"d",He(r[5])),x(i,"class","a9s-inner"),x(i,"style",r[1]),x(i,"fill-rule","evenodd"),x(i,"d",He(r[5]))},m(n,s){nt(n,t,s),nt(n,i,s)},p(n,s){s&2&&e!==(e=n[1]?"display:none;":void 0)&&x(t,"style",e),s&2&&x(i,"style",n[1])},d(n){n&&(rt(t),rt(i))}}}function Z0(r){let t,e,i=Ie(r[2]),n=[];for(let s=0;s<i.length;s+=1)n[s]=$c(Gc(r,i,s));return{c(){t=W("g");for(let s=0;s<n.length;s+=1)n[s].c();x(t,"class","a9s-annotation"),x(t,"data-id",e=r[0].id)},m(s,o){nt(s,t,o);for(let a=0;a<n.length;a+=1)n[a]&&n[a].m(t,null)},p(s,[o]){if(o&6){i=Ie(s[2]);let a;for(a=0;a<i.length;a+=1){const l=Gc(s,i,a);n[a]?n[a].p(l,o):(n[a]=$c(l),n[a].c(),n[a].m(t,null))}for(;a<n.length;a+=1)n[a].d(1);n.length=i.length}o&1&&e!==(e=s[0].id)&&x(t,"data-id",e)},i:Rt,o:Rt,d(s){s&&rt(t),Zr(n,s)}}}function J0(r,t,e){let i,{annotation:n}=t,{geom:s}=t,{style:o}=t;const{polygons:a}=s;return r.$$set=l=>{"annotation"in l&&e(0,n=l.annotation),"geom"in l&&e(3,s=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=ti(n,o))},[n,i,a,s,o]}class Q0 extends me{constructor(t){super(),pe(this,t,J0,Z0,Kt,{annotation:0,geom:3,style:4})}}function t_(r){let t,e,i,n,s;return{c(){t=W("g"),e=W("polygon"),n=W("polygon"),x(e,"class","a9s-outer"),x(e,"style",i=r[1]?"display:none;":void 0),x(e,"points",r[2].map(e_).join(" ")),x(n,"class","a9s-inner"),x(n,"style",r[1]),x(n,"points",r[2].map(r_).join(" ")),x(t,"class","a9s-annotation"),x(t,"data-id",s=r[0].id)},m(o,a){nt(o,t,a),xt(t,e),xt(t,n)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&x(e,"style",i),a&2&&x(n,"style",o[1]),a&1&&s!==(s=o[0].id)&&x(t,"data-id",s)},i:Rt,o:Rt,d(o){o&&rt(t)}}}const e_=r=>r.join(","),r_=r=>r.join(",");function i_(r,t,e){let i,{annotation:n}=t,{geom:s}=t,{style:o}=t;const{points:a}=s;return r.$$set=l=>{"annotation"in l&&e(0,n=l.annotation),"geom"in l&&e(3,s=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=ti(n,o))},[n,i,a,s,o]}class n_ extends me{constructor(t){super(),pe(this,t,i_,t_,Kt,{annotation:0,geom:3,style:4})}}function s_(r){let t,e,i,n,s,o,a;return{c(){t=W("g"),e=W("path"),s=W("path"),x(e,"class",i=Ei(`a9s-outer ${r[1]}`)+" svelte-1w0132l"),x(e,"style",n=r[3]?"display:none;":void 0),x(e,"d",r[2]),x(s,"class",o=Ei(`a9s-inner ${r[1]}`)+" svelte-1w0132l"),x(s,"style",r[3]),x(s,"d",r[2]),x(t,"class","a9s-annotation"),x(t,"data-id",a=r[0].id)},m(l,h){nt(l,t,h),xt(t,e),xt(t,s)},p(l,[h]){h&2&&i!==(i=Ei(`a9s-outer ${l[1]}`)+" svelte-1w0132l")&&x(e,"class",i),h&8&&n!==(n=l[3]?"display:none;":void 0)&&x(e,"style",n),h&4&&x(e,"d",l[2]),h&2&&o!==(o=Ei(`a9s-inner ${l[1]}`)+" svelte-1w0132l")&&x(s,"class",o),h&8&&x(s,"style",l[3]),h&4&&x(s,"d",l[2]),h&1&&a!==(a=l[0].id)&&x(t,"data-id",a)},i:Rt,o:Rt,d(l){l&&rt(t)}}}function o_(r,t,e){let i,n,s,{annotation:o}=t,{geom:a}=t,{style:l}=t;return r.$$set=h=>{"annotation"in h&&e(0,o=h.annotation),"geom"in h&&e(4,a=h.geom),"style"in h&&e(5,l=h.style)},r.$$.update=()=>{r.$$.dirty&33&&e(3,i=ti(o,l)),r.$$.dirty&16&&e(2,n=Jo(a)),r.$$.dirty&16&&e(1,s=a.closed?"closed":"open")},[o,s,n,i,a,l]}class a_ extends me{constructor(t){super(),pe(this,t,o_,s_,Kt,{annotation:0,geom:4,style:5})}}function l_(r){let t,e,i,n,s;return{c(){t=W("g"),e=W("rect"),n=W("rect"),x(e,"class","a9s-outer"),x(e,"style",i=r[5]?"display:none;":void 0),x(e,"x",r[4]),x(e,"y",r[3]),x(e,"width",r[2]),x(e,"height",r[1]),x(n,"class","a9s-inner"),x(n,"style",r[5]),x(n,"x",r[4]),x(n,"y",r[3]),x(n,"width",r[2]),x(n,"height",r[1]),x(t,"class","a9s-annotation"),x(t,"data-id",s=r[0].id)},m(o,a){nt(o,t,a),xt(t,e),xt(t,n)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&x(e,"style",i),a&16&&x(e,"x",o[4]),a&8&&x(e,"y",o[3]),a&4&&x(e,"width",o[2]),a&2&&x(e,"height",o[1]),a&32&&x(n,"style",o[5]),a&16&&x(n,"x",o[4]),a&8&&x(n,"y",o[3]),a&4&&x(n,"width",o[2]),a&2&&x(n,"height",o[1]),a&1&&s!==(s=o[0].id)&&x(t,"data-id",s)},i:Rt,o:Rt,d(o){o&&rt(t)}}}function h_(r,t,e){let i,n,s,o,a,{annotation:l}=t,{geom:h}=t,{style:c}=t;return r.$$set=u=>{"annotation"in u&&e(0,l=u.annotation),"geom"in u&&e(6,h=u.geom),"style"in u&&e(7,c=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=ti(l,c)),r.$$.dirty&64&&e(4,{x:n,y:s,w:o,h:a}=h,n,(e(3,s),e(6,h)),(e(2,o),e(6,h)),(e(1,a),e(6,h)))},[l,a,o,s,n,i,h,c]}class c_ extends me{constructor(t){super(),pe(this,t,h_,l_,Kt,{annotation:0,geom:6,style:7})}}const u_=r=>({elementToImage:(t,e)=>{const i=r.getBoundingClientRect(),n=r.createSVGPoint();n.x=t+i.x,n.y=e+i.y;const{x:s,y:o}=n.matrixTransform(r.getScreenCTM().inverse());return[s,o]}}),d_=250,f_=(r,t)=>{const e=Rr();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:n=>{if(performance.now()-i<d_){const{x:s,y:o}=Hc(n,r),a=Ne?10:2,l=t.getAt(s,o,void 0,a);l?e("click",{originalEvent:n,annotation:l}):e("click",{originalEvent:n})}}}},Hc=(r,t)=>{const e=t.createSVGPoint(),i=t.getBoundingClientRect(),n=r.clientX-i.x,s=r.clientY-i.y,{left:o,top:a}=t.getBoundingClientRect();return e.x=n+o,e.y=s+a,e.matrixTransform(t.getScreenCTM().inverse())};function Xc(r,t,e){const i=r.slice();return i[39]=t[e],i}function Vc(r,t,e){const i=r.slice();return i[42]=t[e],i}function ma(r){const t=r.slice(),e=t[42].target.selector;return t[45]=e,t}function zc(r){let t=r[42],e,i,n=jc(r);return{c(){n.c(),e=De()},m(s,o){n.m(s,o),nt(s,e,o),i=!0},p(s,o){o[0]&131072&&Kt(t,t=s[42])?(Ee(),yt(n,1,1,Rt),Te(),n=jc(s),n.c(),lt(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(lt(n),i=!0)},o(s){yt(n),i=!1},d(s){s&&rt(e),n.d(s)}}}function p_(r){let t,e;return t=new K0({props:{annotation:r[42],geom:r[45].geometry,style:r[1]}}),{c(){re(t.$$.fragment)},m(i,n){Qt(t,i,n),e=!0},p(i,n){const s={};n[0]&131072&&(s.annotation=i[42]),n[0]&131072&&(s.geom=i[45].geometry),n[0]&2&&(s.style=i[1]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function m_(r){let t,e;return t=new a_({props:{annotation:r[42],geom:r[45].geometry,style:r[1]}}),{c(){re(t.$$.fragment)},m(i,n){Qt(t,i,n),e=!0},p(i,n){const s={};n[0]&131072&&(s.annotation=i[42]),n[0]&131072&&(s.geom=i[45].geometry),n[0]&2&&(s.style=i[1]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function g_(r){let t,e;return t=new Q0({props:{annotation:r[42],geom:r[45].geometry,style:r[1]}}),{c(){re(t.$$.fragment)},m(i,n){Qt(t,i,n),e=!0},p(i,n){const s={};n[0]&131072&&(s.annotation=i[42]),n[0]&131072&&(s.geom=i[45].geometry),n[0]&2&&(s.style=i[1]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function y_(r){let t,e;return t=new n_({props:{annotation:r[42],geom:r[45].geometry,style:r[1]}}),{c(){re(t.$$.fragment)},m(i,n){Qt(t,i,n),e=!0},p(i,n){const s={};n[0]&131072&&(s.annotation=i[42]),n[0]&131072&&(s.geom=i[45].geometry),n[0]&2&&(s.style=i[1]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function __(r){let t,e;return t=new c_({props:{annotation:r[42],geom:r[45].geometry,style:r[1]}}),{c(){re(t.$$.fragment)},m(i,n){Qt(t,i,n),e=!0},p(i,n){const s={};n[0]&131072&&(s.annotation=i[42]),n[0]&131072&&(s.geom=i[45].geometry),n[0]&2&&(s.style=i[1]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function v_(r){var t;let e,i;return e=new W0({props:{annotation:r[42],geom:(t=r[45])==null?void 0:t.geometry,style:r[1]}}),{c(){re(e.$$.fragment)},m(n,s){Qt(e,n,s),i=!0},p(n,s){var o;const a={};s[0]&131072&&(a.annotation=n[42]),s[0]&131072&&(a.geom=(o=n[45])==null?void 0:o.geometry),s[0]&2&&(a.style=n[1]),e.$set(a)},i(n){i||(lt(e.$$.fragment,n),i=!0)},o(n){yt(e.$$.fragment,n),i=!1},d(n){te(e,n)}}}function jc(r){let t,e,i,n;const s=[v_,__,y_,g_,m_,p_],o=[];function a(l,h){var c,u,d,f,p,g;return((c=l[45])==null?void 0:c.type)===_t.ELLIPSE?0:((u=l[45])==null?void 0:u.type)===_t.RECTANGLE?1:((d=l[45])==null?void 0:d.type)===_t.POLYGON?2:((f=l[45])==null?void 0:f.type)===_t.MULTIPOLYGON?3:((p=l[45])==null?void 0:p.type)===_t.POLYLINE?4:((g=l[45])==null?void 0:g.type)===_t.LINE?5:-1}return~(t=a(r))&&(e=o[t]=s[t](r)),{c(){e&&e.c(),i=De()},m(l,h){~t&&o[t].m(l,h),nt(l,i,h),n=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(Ee(),yt(o[c],1,1,()=>{o[c]=null}),Te()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=s[t](l),e.c()),lt(e,1),e.m(i.parentNode,i)):e=null)},i(l){n||(lt(e),n=!0)},o(l){yt(e),n=!1},d(l){l&&rt(i),~t&&o[t].d(l)}}}function Wc(r){let t=Le(r[42])&&!r[10](r[42]),e,i,n=t&&zc(ma(r));return{c(){n&&n.c(),e=De()},m(s,o){n&&n.m(s,o),nt(s,e,o),i=!0},p(s,o){o[0]&132096&&(t=Le(s[42])&&!s[10](s[42])),t?n?(n.p(ma(s),o),o[0]&132096&&lt(n,1)):(n=zc(ma(s)),n.c(),lt(n,1),n.m(e.parentNode,e)):n&&(Ee(),yt(n,1,1,()=>{n=null}),Te())},i(s){i||(lt(n),i=!0)},o(s){yt(n),i=!1},d(s){s&&rt(e),n&&n.d(s)}}}function Yc(r){let t,e,i,n;const s=[x_,b_],o=[];function a(l,h){return l[6]?0:l[15]&&l[0]?1:-1}return~(t=a(r))&&(e=o[t]=s[t](r)),{c(){e&&e.c(),i=De()},m(l,h){~t&&o[t].m(l,h),nt(l,i,h),n=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(Ee(),yt(o[c],1,1,()=>{o[c]=null}),Te()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=s[t](l),e.c()),lt(e,1),e.m(i.parentNode,i)):e=null)},i(l){n||(lt(e),n=!0)},o(l){yt(e),n=!1},d(l){l&&rt(i),~t&&o[t].d(l)}}}function b_(r){let t=`${r[2]}-${r[7]}`,e,i,n=qc(r);return{c(){n.c(),e=De()},m(s,o){n.m(s,o),nt(s,e,o),i=!0},p(s,o){o[0]&132&&Kt(t,t=`${s[2]}-${s[7]}`)?(Ee(),yt(n,1,1,Rt),Te(),n=qc(s),n.c(),lt(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(lt(n),i=!0)},o(s){yt(n),i=!1},d(s){s&&rt(e),n.d(s)}}}function x_(r){let t,e,i=Ie(r[6]),n=[];for(let o=0;o<i.length;o+=1)n[o]=Zc(Xc(r,i,o));const s=o=>yt(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=De()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);nt(o,t,a),e=!0},p(o,a){if(a[0]&8659266){i=Ie(o[6]);let l;for(l=0;l<i.length;l+=1){const h=Xc(o,i,l);n[l]?(n[l].p(h,a),lt(n[l],1)):(n[l]=Zc(h),n[l].c(),lt(n[l],1),n[l].m(t.parentNode,t))}for(Ee(),l=i.length;l<n.length;l+=1)s(l);Te()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)lt(n[a]);e=!0}},o(o){n=n.filter(Boolean);for(let a=0;a<n.length;a+=1)yt(n[a]);e=!1},d(o){o&&rt(t),Zr(n,o)}}}function qc(r){let t,e;return t=new N0({props:{target:r[8],tool:r[15],drawingMode:r[14],transform:r[13],viewportScale:r[18]}}),t.$on("create",r[22]),{c(){re(t.$$.fragment)},m(i,n){Qt(t,i,n),e=!0},p(i,n){const s={};n[0]&256&&(s.target=i[8]),n[0]&32768&&(s.tool=i[15]),n[0]&16384&&(s.drawingMode=i[14]),n[0]&8192&&(s.transform=i[13]),n[0]&262144&&(s.viewportScale=i[18]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function Kc(r){let t,e;return t=new O0({props:{target:r[8],editor:r[39].editor,annotation:r[39].annotation,style:r[1],transform:r[13],viewportScale:r[18]}}),t.$on("change",function(){Gt(r[23](r[39].annotation))&&r[23](r[39].annotation).apply(this,arguments)}),{c(){re(t.$$.fragment)},m(i,n){Qt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&256&&(s.target=r[8]),n[0]&64&&(s.editor=r[39].editor),n[0]&64&&(s.annotation=r[39].annotation),n[0]&2&&(s.style=r[1]),n[0]&8192&&(s.transform=r[13]),n[0]&262144&&(s.viewportScale=r[18]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function Zc(r){let t=r[39].annotation.id,e,i,n=Kc(r);return{c(){n.c(),e=De()},m(s,o){n.m(s,o),nt(s,e,o),i=!0},p(s,o){o[0]&64&&Kt(t,t=s[39].annotation.id)?(Ee(),yt(n,1,1,Rt),Te(),n=Kc(s),n.c(),lt(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(lt(n),i=!0)},o(s){yt(n),i=!1},d(s){s&&rt(e),n.d(s)}}}function w_(r){let t,e,i,n,s,o,a=Ie(r[17].filter(r[34])),l=[];for(let u=0;u<a.length;u+=1)l[u]=Wc(Vc(r,a,u));const h=u=>yt(l[u],1,1,()=>{l[u]=null});let c=r[8]&&Yc(r);return{c(){t=W("svg"),e=W("g");for(let u=0;u<l.length;u+=1)l[u].c();i=W("g"),c&&c.c(),x(i,"class","drawing"),x(t,"role","application"),x(t,"tabindex",0),x(t,"class","a9s-annotationlayer"),Je(t,"drawing",r[15]),Je(t,"editing",r[5]),Je(t,"hidden",!r[3]),Je(t,"hover",r[16])},m(u,d){nt(u,t,d),xt(t,e);for(let f=0;f<l.length;f+=1)l[f]&&l[f].m(e,null);xt(t,i),c&&c.m(i,null),r[35](i),r[36](t),n=!0,s||(o=[St(t,"pointerup",function(){Gt(r[11])&&r[11].apply(this,arguments)}),St(t,"pointerdown",function(){Gt(r[12])&&r[12].apply(this,arguments)}),St(t,"pointermove",r[24])],s=!0)},p(u,d){if(r=u,d[0]&132098){a=Ie(r[17].filter(r[34]));let f;for(f=0;f<a.length;f+=1){const p=Vc(r,a,f);l[f]?(l[f].p(p,d),lt(l[f],1)):(l[f]=Wc(p),l[f].c(),lt(l[f],1),l[f].m(e,null))}for(Ee(),f=a.length;f<l.length;f+=1)h(f);Te()}r[8]?c?(c.p(r,d),d[0]&256&&lt(c,1)):(c=Yc(r),c.c(),lt(c,1),c.m(i,null)):c&&(Ee(),yt(c,1,1,()=>{c=null}),Te()),(!n||d[0]&32768)&&Je(t,"drawing",r[15]),(!n||d[0]&32)&&Je(t,"editing",r[5]),(!n||d[0]&8)&&Je(t,"hidden",!r[3]),(!n||d[0]&65536)&&Je(t,"hover",r[16])},i(u){if(!n){for(let d=0;d<a.length;d+=1)lt(l[d]);lt(c),n=!0}},o(u){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)yt(l[d]);yt(c),n=!1},d(u){u&&rt(t),Zr(l,u),c&&c.d(),r[35](null),r[36](null),s=!1,Me(o)}}}function E_(r,t,e){let i,n,s,o,a,l,h,c,u,d,f,p,g=Rt,y=()=>(g(),g=zh(A,H=>e(18,p=H)),A);r.$$.on_destroy.push(()=>g());let{drawingEnabled:_}=t,{image:v}=t,{preferredDrawingMode:m}=t,{state:b}=t,{style:S=void 0}=t,{toolName:R=gs()[0]}=t,{user:C}=t,{visible:I=!0}=t,M=0;const F=()=>e(7,M+=1),U=()=>R,P=()=>_;let T,E,A;Jr(()=>y(e(9,A=r0(v,E))));const{hover:L,selection:D,store:N}=b;Vo(r,L,H=>e(16,u=H)),Vo(r,D,H=>e(33,d=H)),Vo(r,N,H=>e(17,f=H));let $,O;const B=H=>{$&&N.unobserve($);const mt=H.filter(({editable:J})=>J).map(({id:J})=>J);mt.length>0?(e(5,O=mt.map(J=>N.getAnnotation(J)).filter(J=>J&&Le(J))),$=J=>{const{updated:ut}=J.changes;e(5,O=ut==null?void 0:ut.map(gt=>gt.newValue))},N.observe($,{annotations:mt})):e(5,O=void 0)},k=H=>{const mt=ac(),J={id:mt,bodies:[],target:{annotation:mt,selector:H.detail,creator:C,created:new Date}};N.addAnnotation(J),D.setSelected(J.id)},V=H=>mt=>{var J;const{target:ut}=H,gt=10*60*1e3,Et=((J=ut.creator)==null?void 0:J.id)!==C.id||!ut.created||new Date().getTime()-ut.created.getTime()>gt;N.updateTarget({...ut,selector:mt.detail,created:Et?ut.created:new Date,updated:Et?new Date:void 0,updatedBy:Et?C:void 0})},z=H=>{const{x:mt,y:J}=Hc(H,E),ut=N.getAt(mt,J,void 0,2);ut?u!==ut.id&&L.set(ut.id):L.set(void 0)},K=H=>Le(H);function X(H){os[H?"unshift":"push"](()=>{T=H,e(8,T)})}function ft(H){os[H?"unshift":"push"](()=>{E=H,e(4,E)})}return r.$$set=H=>{"drawingEnabled"in H&&e(0,_=H.drawingEnabled),"image"in H&&e(25,v=H.image),"preferredDrawingMode"in H&&e(26,m=H.preferredDrawingMode),"state"in H&&e(27,b=H.state),"style"in H&&e(1,S=H.style),"toolName"in H&&e(2,R=H.toolName),"user"in H&&e(28,C=H.user),"visible"in H&&e(3,I=H.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(15,{tool:i,opts:n}=ys(R)||{tool:void 0,opts:void 0},i,(e(32,n),e(2,R))),r.$$.dirty[0]&67108864|r.$$.dirty[1]&2&&e(14,s=(n==null?void 0:n.drawingMode)||m),r.$$.dirty[0]&16&&e(13,o=u_(E)),r.$$.dirty[0]&16&&e(12,{onPointerDown:a,onPointerUp:l}=f_(E,N),a,(e(11,l),e(4,E))),r.$$.dirty[1]&4&&B(d.selected),r.$$.dirty[0]&32&&e(6,h=O?O.map(H=>({annotation:H,editor:da(H.target.selector)})).filter(H=>H.editor):void 0),r.$$.dirty[0]&64&&e(10,c=H=>h&&h.some(mt=>mt.annotation.id===H.id))},[_,S,R,I,E,O,h,M,T,A,c,l,a,o,s,i,u,f,p,L,D,N,k,V,z,v,m,b,C,F,U,P,n,d,K,X,ft]}class T_ extends me{constructor(t){super(),pe(this,t,E_,w_,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 Jc(r,t,e=0,i=r.length-1,n=A_){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*u/l+d)),p=Math.min(i,Math.floor(t+(l-h)*u/l+d));Jc(r,t,f,p,n)}const s=r[t];let o=e,a=i;for(xn(r,e,t),n(r[i],s)>0&&xn(r,e,i);o<a;){for(xn(r,o,a),o++,a--;n(r[o],s)<0;)o++;for(;n(r[a],s)>0;)a--}n(r[e],s)===0?xn(r,e,a):(a++,xn(r,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function xn(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function A_(r,t){return r<t?-1:r>t?1:0}class S_{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(!vs(t,e))return i;const n=this.toBBox,s=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?n(a):a;vs(t,l)&&(e.leaf?i.push(a):ya(t,l)?this._all(a,i):s.push(a))}e=s.pop()}return i}collides(t){let e=this.data;if(!vs(t,e))return!1;const i=[];for(;e;){for(let n=0;n<e.children.length;n++){const s=e.children[n],o=e.leaf?this.toBBox(s):s;if(vs(t,o)){if(e.leaf||ya(t,o))return!0;i.push(s)}}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=Di([]),this}remove(t,e){if(!t)return this;let i=this.data;const n=this.toBBox(t),s=[],o=[];let a,l,h;for(;i||s.length;){if(i||(i=s.pop(),l=s[s.length-1],a=o.pop(),h=!0),i.leaf){const c=C_(t,i.children,e);if(c!==-1)return i.children.splice(c,1),s.push(i),this._condense(s),this}!h&&!i.leaf&&ya(i,n)?(s.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,n){const s=i-e+1;let o=this._maxEntries,a;if(s<=o)return a=Di(t.slice(e,i+1)),Mi(a,this.toBBox),a;n||(n=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,n-1))),a=Di([]),a.leaf=!1,a.height=n;const l=Math.ceil(s/o),h=l*Math.ceil(Math.sqrt(o));Qc(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);Qc(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,n-1))}}return Mi(a,this.toBBox),a}_chooseSubtree(t,e,i,n){for(;n.push(e),!(e.leaf||n.length-1===i);){let s=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=ga(h),u=R_(t,h)-c;u<o?(o=u,s=c<s?c:s,a=h):u===o&&c<s&&(s=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const n=i?t:this.toBBox(t),s=[],o=this._chooseSubtree(n,this.data,e,s);for(o.children.push(t),En(o,n);e>=0&&s[e].children.length>this._maxEntries;)this._split(s,e),e--;this._adjustParentBBoxes(n,s,e)}_split(t,e){const i=t[e],n=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,n);const o=this._chooseSplitIndex(i,s,n),a=Di(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,Mi(i,this.toBBox),Mi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Di([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Mi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let n,s=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=wn(t,0,a,this.toBBox),h=wn(t,a,i,this.toBBox),c=M_(l,h),u=ga(l)+ga(h);c<s?(s=c,n=a,o=u<o?u:o):c===s&&u<o&&(o=u,n=a)}return n||i-e}_chooseSplitAxis(t,e,i){const n=t.leaf?this.compareMinX:I_,s=t.leaf?this.compareMinY:P_,o=this._allDistMargin(t,e,i,n),a=this._allDistMargin(t,e,i,s);o<a&&t.children.sort(n)}_allDistMargin(t,e,i,n){t.children.sort(n);const s=this.toBBox,o=wn(t,0,e,s),a=wn(t,i-e,i,s);let l=_s(o)+_s(a);for(let h=e;h<i-e;h++){const c=t.children[h];En(o,t.leaf?s(c):c),l+=_s(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];En(a,t.leaf?s(c):c),l+=_s(a)}return l}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)En(e[n],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():Mi(t[e],this.toBBox)}}function C_(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 Mi(r,t){wn(r,0,r.children.length,t,r)}function wn(r,t,e,i,n){n||(n=Di(null)),n.minX=1/0,n.minY=1/0,n.maxX=-1/0,n.maxY=-1/0;for(let s=t;s<e;s++){const o=r.children[s];En(n,r.leaf?i(o):o)}return n}function En(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 I_(r,t){return r.minX-t.minX}function P_(r,t){return r.minY-t.minY}function ga(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function _s(r){return r.maxX-r.minX+(r.maxY-r.minY)}function R_(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 M_(r,t){const e=Math.max(r.minX,t.minX),i=Math.max(r.minY,t.minY),n=Math.min(r.maxX,t.maxX),s=Math.min(r.maxY,t.maxY);return Math.max(0,n-e)*Math.max(0,s-i)}function ya(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function vs(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function Di(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Qc(r,t,e,i,n){const s=[t,e];for(;s.length;){if(e=s.pop(),t=s.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;Jc(r,o,t,e,n),s.push(t,o,o,e)}}const D_=()=>{const r=new S_,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},n=o=>{if(!us(o))return;const{minX:a,minY:l,maxX:h,maxY:c}=o.selector.geometry.bounds,u={minX:a,minY:l,maxX:h,maxY:c,target:o};r.insert(u),t.set(o.annotation,u)},s=o=>{if(!us(o))return;const a=t.get(o.annotation);a&&r.remove(a),t.delete(o.annotation)};return{all:e,clear:i,getAt:(o,a,l=0)=>{const h=r.search({minX:o-l,minY:a-l,maxX:o+l,maxY:a+l}).map(c=>c.target).filter(c=>c.selector.type===_t.RECTANGLE||Ug(c.selector,o,a,l));return h.length>0?(h.sort((c,u)=>qo(c.selector)-qo(u.selector)),h):[]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(c=>c.target),insert:n,remove:s,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,c)=>{if(us(c)){const{minX:u,minY:d,maxX:f,maxY:p}=c.selector.geometry.bounds;return[...h,{minX:u,minY:d,maxX:f,maxY:p,target:c}]}else return h},[]);l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{s(o),n(a)}}},tu=r=>{const t=My(),e=D_(),i=gy(t,r.userSelectAction,r.adapter),n=my(t),s=Ny();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,l,h)=>{const c=e.getAt(o,a,h);if(l)return c.map(u=>t.getAnnotation(u.annotation)).filter(Boolean).filter(l)[0];{const u=c[0];return u?t.getAnnotation(u.annotation):void 0}},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(c=>t.getAnnotation(c.annotation)).filter(Boolean)},selection:i,hover:n,viewport:s}},B_=r=>{const t=tu(r);return{...t,store:Dy(t.store)}},O_=r=>{let t,e;if(r.nodeName==="CANVAS")t=r,e=t.getContext("2d",{willReadFrequently:!0});else{const n=r;t=document.createElement("canvas"),t.width=n.width,t.height=n.height,e=t.getContext("2d",{willReadFrequently:!0}),e.drawImage(n,0,0,n.width,n.height)}let i=0;for(let n=1;n<10;n++)for(let s=1;s<10;s++){const o=Math.round(s*t.width/10),a=Math.round(n*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=O_(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},ru=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?eu(r):e),iu=(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}),nu=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,su=(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()},n=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?r.redo():r.undo())},s=()=>{nu?e.removeEventListener("keydown",n):e.removeEventListener("keydown",i)};return nu?e.addEventListener("keydown",n):e.addEventListener("keydown",i),{destroy:s}},L_=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=iu(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:hc.EDIT,theme:"light"}),n=B_(i),{selection:s,store:o}=n,a=Ly(o,i.initialHistory),l=Fy(n,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 c=su(a);let u=Wy();ru(e,h,i.theme);const d=new T_({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:n,style:i.style,user:u}});d.$on("click",P=>{const{originalEvent:T,annotation:E}=P.detail;E?s.userSelect(E.id,T):s.isEmpty()||s.clear()});const f=Uy(n,a,i.adapter),p=()=>d.cancelDrawing(),g=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),c.destroy(),a.destroy()},y=()=>d.getDrawingTool(),_=()=>u,v=()=>d.isDrawingEnabled(),m=(P,T,E)=>Uc(P,T,E),b=(P,T)=>Lc(P,T),S=P=>{if(!ys(P))throw`No drawing tool named ${P}`;d.$set({toolName:P})},R=P=>d.$set({drawingEnabled:P}),C=P=>{console.warn("Filter not implemented yet")},I=P=>d.$set({style:P}),M=P=>ru(e,h,P),F=P=>{u=P,d.$set({user:P})},U=P=>d.$set({visible:P});return{...f,cancelDrawing:p,destroy:g,getDrawingTool:y,getUser:_,isDrawingEnabled:v,listDrawingTools:gs,on:l.on,off:l.off,registerDrawingTool:m,registerShapeEditor:b,setDrawingEnabled:R,setDrawingTool:S,setFilter:C,setStyle:I,setTheme:M,setUser:F,setVisible:U,element:h,state:n}};function Ft(){}function _a(r,t){for(const e in t)r[e]=t[e];return r}function ou(r){return r()}function au(){return Object.create(null)}function Fe(r){r.forEach(ou)}function Zt(r){return typeof r=="function"}function Ut(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function N_(r){return Object.keys(r).length===0}function F_(r,...t){if(r==null){for(const i of t)i(void 0);return Ft}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Tn(r,t,e){r.$$.on_destroy.push(F_(t,e))}function lu(r,t,e,i){if(r){const n=hu(r,t,e,i);return r[0](n)}}function hu(r,t,e,i){return r[1]&&i?_a(e.ctx.slice(),r[1](i(t))):e.ctx}function cu(r,t,e,i){if(r[2]&&i){const n=r[2](i(e));if(t.dirty===void 0)return n;if(typeof n=="object"){const s=[],o=Math.max(t.dirty.length,n.length);for(let a=0;a<o;a+=1)s[a]=t.dirty[a]|n[a];return s}return t.dirty|n}return t.dirty}function uu(r,t,e,i,n,s){if(n){const o=hu(t,e,i,s);r.p(o,n)}}function du(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 pu(r){return r??""}const va=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ct(r,t){r.appendChild(t)}function ot(r,t,e){r.insertBefore(t,e||null)}function st(r){r.parentNode&&r.parentNode.removeChild(r)}function Dr(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function it(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function ba(r){return document.createTextNode(r)}function Se(){return ba(" ")}function Pe(){return ba("")}function Pt(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 k_(r){return Array.from(r.childNodes)}function U_(r,t){t=""+t,r.data!==t&&(r.data=t)}function Br(r,t,e){r.classList.toggle(t,!!e)}function G_(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let An;function Sn(r){An=r}function xa(){if(!An)throw new Error("Function called outside component initialization");return An}function ei(r){xa().$$.on_mount.push(r)}function $_(r){xa().$$.on_destroy.push(r)}function Bi(){const r=xa();return(t,e,{cancelable:i=!1}={})=>{const n=r.$$.callbacks[t];if(n){const s=G_(t,e,{cancelable:i});return n.slice().forEach(o=>{o.call(r,s)}),!s.defaultPrevented}return!0}}function ae(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Oi=[],bs=[];let Li=[];const mu=[],gu=Promise.resolve();let wa=!1;function yu(){wa||(wa=!0,gu.then(vu))}function _u(){return yu(),gu}function Ea(r){Li.push(r)}const Ta=new Set;let Ni=0;function vu(){if(Ni!==0)return;const r=An;do{try{for(;Ni<Oi.length;){const t=Oi[Ni];Ni++,Sn(t),H_(t.$$)}}catch(t){throw Oi.length=0,Ni=0,t}for(Sn(null),Oi.length=0,Ni=0;bs.length;)bs.pop()();for(let t=0;t<Li.length;t+=1){const e=Li[t];Ta.has(e)||(Ta.add(e),e())}Li.length=0}while(Oi.length);for(;mu.length;)mu.pop()();wa=!1,Ta.clear(),Sn(r)}function H_(r){if(r.fragment!==null){r.update(),Fe(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Ea)}}function X_(r){const t=[],e=[];Li.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Li=t}const xs=new Set;let ri;function le(){ri={r:0,c:[],p:ri}}function he(){ri.r||Fe(ri.c),ri=ri.p}function q(r,t){r&&r.i&&(xs.delete(r),r.i(t))}function at(r,t,e,i){if(r&&r.o){if(xs.has(r))return;xs.add(r),ri.c.push(()=>{xs.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function xe(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function Lt(r){r&&r.c()}function Bt(r,t,e){const{fragment:i,after_update:n}=r.$$;i&&i.m(t,e),Ea(()=>{const s=r.$$.on_mount.map(ou).filter(Zt);r.$$.on_destroy?r.$$.on_destroy.push(...s):Fe(s),r.$$.on_mount=[]}),n.forEach(Ea)}function Ot(r,t){const e=r.$$;e.fragment!==null&&(X_(e.after_update),Fe(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function V_(r,t){r.$$.dirty[0]===-1&&(Oi.push(r),yu(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function zt(r,t,e,i,n,s,o=null,a=[-1]){const l=An;Sn(r);const h=r.$$={fragment:null,ctx:[],props:s,update:Ft,not_equal:n,bound:au(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:au(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&n(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&V_(r,u)),d}):[],h.update(),c=!0,Fe(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=k_(t.target);h.fragment&&h.fragment.l(u),u.forEach(st)}else h.fragment&&h.fragment.c();t.intro&&q(r.$$.fragment),Bt(r,t.target,t.anchor),vu()}Sn(l)}class jt{constructor(){Bh(this,"$$");Bh(this,"$$set")}$destroy(){Ot(this,1),this.$destroy=Ft}$on(t,e){if(!Zt(e))return Ft;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const n=i.indexOf(e);n!==-1&&i.splice(n,1)}}$set(t){this.$$set&&!N_(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const z_="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(z_);var Qe=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGON="MULTIPOLYGON",r.POLYGON="POLYGON",r.POLYLINE="POLYLINE",r.RECTANGLE="RECTANGLE",r.LINE="LINE",r))(Qe||{}),Cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Aa(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function j_(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 n=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return r[i]}})}),e}var bu={exports:{}};(function(r){(function(){function t(a,l){var h=a.x-l.x,c=a.y-l.y;return h*h+c*c}function e(a,l,h){var c=l.x,u=l.y,d=h.x-c,f=h.y-u;if(d!==0||f!==0){var p=((a.x-c)*d+(a.y-u)*f)/(d*d+f*f);p>1?(c=h.x,u=h.y):p>0&&(c+=d*p,u+=f*p)}return d=a.x-c,f=a.y-u,d*d+f*f}function i(a,l){for(var h=a[0],c=[h],u,d=1,f=a.length;d<f;d++)u=a[d],t(u,h)>l&&(c.push(u),h=u);return h!==u&&c.push(u),c}function n(a,l,h,c,u){for(var d=c,f,p=l+1;p<h;p++){var g=e(a[p],a[l],a[h]);g>d&&(f=p,d=g)}d>c&&(f-l>1&&n(a,l,f,c,u),u.push(a[f]),h-f>1&&n(a,f,h,c,u))}function s(a,l){var h=a.length-1,c=[a[0]];return n(a,0,h,l,c),c.push(a[h]),c}function o(a,l,h){if(a.length<=2)return a;var c=l!==void 0?l*l:1;return a=h?a:i(a,c),a=s(a,c),a}r.exports=o,r.exports.default=o})()})(bu);var W_=bu.exports;const Y_=Aa(W_),Fi=(r,t)=>t,tr=r=>{let t=1/0,e=1/0,i=-1/0,n=-1/0;return r.forEach(([s,o])=>{t=Math.min(t,s),e=Math.min(e,o),i=Math.max(i,s),n=Math.max(n,o)}),{minX:t,minY:e,maxX:i,maxY:n}},ws=r=>{let t=0,e=r.length-1;for(let i=0;i<r.length;i++)t+=(r[e][0]+r[i][0])*(r[e][1]-r[i][1]),e=i;return Math.abs(.5*t)},Es=(r,t,e)=>{let i=!1;for(let n=0,s=r.length-1;n<r.length;s=n++){const o=r[n][0],a=r[n][1],l=r[s][0],h=r[s][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},q_=(r,t=!0)=>{let e="M ";return r.forEach(([i,n],s)=>{s===0?e+=`${i},${n}`:e+=` L ${i},${n}`}),t&&(e+=" Z"),e},xu=(r,t=1)=>{const e=r.map(([i,n])=>({x:i,y:n}));return Y_(e,t,!0).map(i=>[i.x,i.y])},K_=(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))},Z_={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:n,rx:s,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),c=t-i,u=e-n,d=l*c+h*u,f=h*c-l*u;return d*d/(s*s)+f*f/(o*o)<=1}};Fi(Qe.ELLIPSE,Z_);const J_={area:r=>0,intersects:(r,t,e,i=2)=>{const[[n,s],[o,a]]=r.geometry.points,l=Math.abs((a-s)*t-(o-n)*e+o*s-a*n),h=K_([n,s],[o,a]);return l/h<=i}};Fi(Qe.LINE,J_);const Q_={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[n,...s]=i.rings,o=ws(n.points),a=s.reduce((l,h)=>l+ws(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const n of i){const[s,...o]=n.rings;if(Es(s.points,t,e)){let a=!1;for(const l of o)if(Es(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},Ts=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return tr(t)},ki=r=>r.rings.map(e=>q_(e.points)).join(" "),tv=r=>r.polygons.reduce((t,e)=>[...t,...e.rings.reduce((i,n)=>[...i,...n.points],[])],[]),ev=(r,t=1)=>{const e=r.geometry.polygons.map(n=>{const s=n.rings.map(a=>{const l=xu(a.points,t);return{...a,points:l}}),o=tr(s[0].points);return{...n,rings:s,bounds:o}}),i=Ts(e);return{...r,geometry:{...r.geometry,polygons:e,bounds:i}}};Fi(Qe.MULTIPOLYGON,Q_);const rv={area:r=>{const t=r.geometry.points;return ws(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return Es(i,t,e)}},iv=(r,t=1)=>{const e=xu(r.geometry.points,t),i=tr(e);return{...r,geometry:{...r.geometry,bounds:i,points:e}}};Fi(Qe.POLYGON,rv);const nv={area:r=>{const t=r.geometry;if(!t.closed||t.points.length<3)return 0;const e=wu(t.points,t.closed);return ws(e)},intersects:(r,t,e,i=2)=>{const n=r.geometry;if(n.closed){const s=wu(n.points,n.closed);return Es(s,t,e)}else return sv(n,[t,e],i)}},wu=(r,t=!1)=>{const e=[];for(let i=0;i<r.length;i++){const n=r[i],s=r[(i+1)%r.length];if(e.push(n.point),(i<r.length-1||t)&&(n.type==="CURVE"||s.type=="CURVE")){const a=Eu(n.point,n.type==="CURVE"&&n.outHandle||n.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,10);e.push(...a.slice(1))}}return e},Eu=(r,t,e,i,n=10)=>{const s=[];for(let o=0;o<=n;o++){const a=o/n,l=Math.pow(1-a,3)*r[0]+3*Math.pow(1-a,2)*a*t[0]+3*(1-a)*Math.pow(a,2)*e[0]+Math.pow(a,3)*i[0],h=Math.pow(1-a,3)*r[1]+3*Math.pow(1-a,2)*a*t[1]+3*(1-a)*Math.pow(a,2)*e[1]+Math.pow(a,3)*i[1];s.push([l,h])}return s},sv=(r,t,e)=>{for(let i=0;i<r.points.length-1;i++){const n=r.points[i],s=r.points[i+1];if(n.type==="CURVE"||s.type==="CURVE"){const a=Eu(n.point,n.type==="CURVE"&&n.outHandle||n.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,20);for(let l=0;l<a.length-1;l++)if(Tu(t,a[l],a[l+1])<=e)return!0}else if(Tu(t,n.point,s.point)<=e)return!0}return!1},Tu=(r,t,e)=>{const[i,n]=r,[s,o]=t,[a,l]=e,h=a-s,c=l-o,u=Math.sqrt(h*h+c*c);if(u===0)return Math.sqrt((i-s)*(i-s)+(n-o)*(n-o));const d=((i-s)*h+(n-o)*c)/(u*u);return d<=0?Math.sqrt((i-s)*(i-s)+(n-o)*(n-o)):d>=1?Math.sqrt((i-a)*(i-a)+(n-l)*(n-l)):Math.abs((l-o)*i-(a-s)*n+a*o-l*s)/u};Fi(Qe.POLYLINE,nv);const ov={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};Fi(Qe.RECTANGLE,ov);const _e=[];for(let r=0;r<256;++r)_e.push((r+256).toString(16).slice(1));function av(r,t=0){return(_e[r[t+0]]+_e[r[t+1]]+_e[r[t+2]]+_e[r[t+3]]+"-"+_e[r[t+4]]+_e[r[t+5]]+"-"+_e[r[t+6]]+_e[r[t+7]]+"-"+_e[r[t+8]]+_e[r[t+9]]+"-"+_e[r[t+10]]+_e[r[t+11]]+_e[r[t+12]]+_e[r[t+13]]+_e[r[t+14]]+_e[r[t+15]]).toLowerCase()}let Sa;const lv=new Uint8Array(16);function hv(){if(!Sa){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Sa=crypto.getRandomValues.bind(crypto)}return Sa(lv)}const Au={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function cv(r,t,e){var n;r=r||{};const i=r.random??((n=r.rng)==null?void 0:n.call(r))??hv();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,av(i)}function uv(r,t,e){return Au.randomUUID&&!r?Au.randomUUID():cv(r)}const dv=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:n,stroke:s,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`),n||n===0?l+=`fill-opacity:${n};`:i&&(l+="fill-opacity:0.25;"),s&&(l+=`stroke:${s};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}},Ca=(r,t=0)=>{const{minX:e,minY:i,maxX:n,maxY:s}=r;return{x:e-t,y:i-t,w:n-e+2*t,h:s-i+2*t}},Or=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,fv=r=>({}),Su=r=>({grab:r[0]});function pv(r){let t,e,i,n;const s=r[8].default,o=lu(s,r,r[7],Su);return{c(){t=it("g"),o&&o.c(),w(t,"class","a9s-annotation selected")},m(a,l){ot(a,t,l),o&&o.m(t,null),e=!0,i||(n=[Pt(t,"pointerup",r[2]),Pt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&128)&&uu(o,s,a,a[7],e?cu(s,a[7],l,fv):du(a[7]),Su)},i(a){e||(q(o,a),e=!0)},o(a){at(o,a),e=!1},d(a){a&&st(t),o&&o.d(a),i=!1,Fe(n)}}}function mv(r,t,e){let{$$slots:i={},$$scope:n}=t;const s=Bi();let{shape:o}=t,{editor:a}=t,{transform:l}=t,{svgEl:h}=t,c,u,d;const f=y=>_=>{if(c=y,h){const{left:m,top:b}=h.getBoundingClientRect(),S=_.clientX-m,R=_.clientY-b;u=l.elementToImage(S,R)}else{const{offsetX:m,offsetY:b}=_;u=l.elementToImage(m,b)}d=o,_.target.setPointerCapture(_.pointerId),s("grab",_)},p=y=>{if(c){const[_,v]=l.elementToImage(y.offsetX,y.offsetY),m=[_-u[0],v-u[1]];e(3,o=a(d,c,m)),s("change",o)}},g=y=>{y.target.releasePointerCapture(y.pointerId),c=void 0,d=o,s("release",y)};return r.$$set=y=>{"shape"in y&&e(3,o=y.shape),"editor"in y&&e(4,a=y.editor),"transform"in y&&e(5,l=y.transform),"svgEl"in y&&e(6,h=y.svgEl),"$$scope"in y&&e(7,n=y.$$scope)},[f,p,g,o,a,l,h,n,i]}class Ia extends jt{constructor(t){super(),zt(this,t,mv,pv,Ut,{shape:3,editor:4,transform:5,svgEl:6})}}function gv(r){let t,e,i,n,s,o,a,l,h=r[3]&&Cu(r);return{c(){t=it("g"),e=it("circle"),h&&h.c(),n=it("circle"),w(e,"class","a9s-handle-buffer svelte-qtyc7s"),w(e,"cx",r[0]),w(e,"cy",r[1]),w(e,"r",i=r[5]+6/r[2]),w(e,"role","button"),w(e,"tabindex","0"),w(n,"class",s=pu(`a9s-handle-dot${r[3]?" selected":""}`)+" svelte-qtyc7s"),w(n,"cx",r[0]),w(n,"cy",r[1]),w(n,"r",r[5]),w(t,"class",o=`a9s-handle ${r[8].class||""}`.trim())},m(c,u){ot(c,t,u),Ct(t,e),h&&h.m(t,null),Ct(t,n),a||(l=[Pt(e,"dblclick",r[12]),Pt(e,"pointerenter",r[13]),Pt(e,"pointerleave",r[14]),Pt(e,"pointerdown",r[15]),Pt(e,"pointerdown",r[6]),Pt(e,"pointerup",r[16]),Pt(e,"pointerup",r[7])],a=!0)},p(c,u){u&1&&w(e,"cx",c[0]),u&2&&w(e,"cy",c[1]),u&36&&i!==(i=c[5]+6/c[2])&&w(e,"r",i),c[3]?h?h.p(c,u):(h=Cu(c),h.c(),h.m(t,n)):h&&(h.d(1),h=null),u&8&&s!==(s=pu(`a9s-handle-dot${c[3]?" selected":""}`)+" svelte-qtyc7s")&&w(n,"class",s),u&1&&w(n,"cx",c[0]),u&2&&w(n,"cy",c[1]),u&32&&w(n,"r",c[5]),u&256&&o!==(o=`a9s-handle ${c[8].class||""}`.trim())&&w(t,"class",o)},d(c){c&&st(t),h&&h.d(),a=!1,Fe(l)}}}function yv(r){let t,e,i,n,s,o,a,l,h;return{c(){t=it("g"),e=it("circle"),n=it("circle"),o=it("circle"),w(e,"cx",r[0]),w(e,"cy",r[1]),w(e,"r",i=r[5]*10),w(e,"class","a9s-touch-halo"),Br(e,"touched",r[4]),w(n,"cx",r[0]),w(n,"cy",r[1]),w(n,"r",s=r[5]+10/r[2]),w(n,"class","a9s-handle-buffer svelte-qtyc7s"),w(n,"role","button"),w(n,"tabindex","0"),w(o,"class","a9s-handle-dot"),w(o,"cx",r[0]),w(o,"cy",r[1]),w(o,"r",a=r[5]+2/r[2]),w(t,"class","a9s-touch-handle")},m(c,u){ot(c,t,u),Ct(t,e),Ct(t,n),Ct(t,o),l||(h=[Pt(n,"dblclick",r[9]),Pt(n,"pointerdown",r[10]),Pt(n,"pointerdown",r[6]),Pt(n,"pointerup",r[11]),Pt(n,"pointerup",r[7])],l=!0)},p(c,u){u&1&&w(e,"cx",c[0]),u&2&&w(e,"cy",c[1]),u&32&&i!==(i=c[5]*10)&&w(e,"r",i),u&16&&Br(e,"touched",c[4]),u&1&&w(n,"cx",c[0]),u&2&&w(n,"cy",c[1]),u&36&&s!==(s=c[5]+10/c[2])&&w(n,"r",s),u&1&&w(o,"cx",c[0]),u&2&&w(o,"cy",c[1]),u&36&&a!==(a=c[5]+2/c[2])&&w(o,"r",a)},d(c){c&&st(t),l=!1,Fe(h)}}}function Cu(r){let t,e;return{c(){t=it("circle"),w(t,"class","a9s-handle-selected"),w(t,"cx",r[0]),w(t,"cy",r[1]),w(t,"r",e=r[5]+8/r[2])},m(i,n){ot(i,t,n)},p(i,n){n&1&&w(t,"cx",i[0]),n&2&&w(t,"cy",i[1]),n&36&&e!==(e=i[5]+8/i[2])&&w(t,"r",e)},d(i){i&&st(t)}}}function _v(r){let t;function e(s,o){return Or?yv:gv}let n=e()(r);return{c(){n.c(),t=Pe()},m(s,o){n.m(s,o),ot(s,t,o)},p(s,[o]){n.p(s,o)},i:Ft,o:Ft,d(s){s&&st(t),n.d(s)}}}function vv(r,t,e){let i,{x:n}=t,{y:s}=t,{scale:o}=t,{selected:a=void 0}=t,l=!1;const h=m=>{m.pointerType==="touch"&&e(4,l=!0)},c=()=>e(4,l=!1);function u(m){ae.call(this,r,m)}function d(m){ae.call(this,r,m)}function f(m){ae.call(this,r,m)}function p(m){ae.call(this,r,m)}function g(m){ae.call(this,r,m)}function y(m){ae.call(this,r,m)}function _(m){ae.call(this,r,m)}function v(m){ae.call(this,r,m)}return r.$$set=m=>{e(8,t=_a(_a({},t),fu(m))),"x"in m&&e(0,n=m.x),"y"in m&&e(1,s=m.y),"scale"in m&&e(2,o=m.scale),"selected"in m&&e(3,a=m.selected)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=4/o)},t=fu(t),[n,s,o,a,l,i,h,c,t,u,d,f,p,g,y,_,v]}class Ui extends jt{constructor(t){super(),zt(this,t,vv,_v,Ut,{x:0,y:1,scale:2,selected:3})}}function bv(r){let t,e,i,n,s,o,a;return{c(){t=it("g"),e=it("circle"),n=it("circle"),s=it("circle"),w(e,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),w(e,"cx",r[0]),w(e,"cy",r[1]),w(e,"r",i=1.75*r[2]),w(n,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),w(n,"cx",r[0]),w(n,"cy",r[1]),w(n,"r",r[2]),w(s,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),w(s,"cx",r[0]),w(s,"cy",r[1]),w(s,"r",r[2]),w(t,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){ot(l,t,h),Ct(t,e),Ct(t,n),Ct(t,s),o||(a=[Pt(e,"pointerdown",r[5]),Pt(e,"pointerdown",r[3])],o=!0)},p(l,h){h&1&&w(e,"cx",l[0]),h&2&&w(e,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&w(e,"r",i),h&1&&w(n,"cx",l[0]),h&2&&w(n,"cy",l[1]),h&4&&w(n,"r",l[2]),h&1&&w(s,"cx",l[0]),h&2&&w(s,"cy",l[1]),h&4&&w(s,"r",l[2])},d(l){l&&st(t),o=!1,Fe(a)}}}function xv(r){let t;return{c(){t=it("circle"),w(t,"cx",r[0]),w(t,"cy",r[1]),w(t,"r",r[2])},m(e,i){ot(e,t,i)},p(e,i){i&1&&w(t,"cx",e[0]),i&2&&w(t,"cy",e[1]),i&4&&w(t,"r",e[2])},d(e){e&&st(t)}}}function wv(r){let t;function e(s,o){return Or?xv:bv}let n=e()(r);return{c(){n.c(),t=Pe()},m(s,o){n.m(s,o),ot(s,t,o)},p(s,[o]){n.p(s,o)},i:Ft,o:Ft,d(s){s&&st(t),n.d(s)}}}function Ev(r,t,e){let i,{x:n}=t,{y:s}=t,{scale:o}=t;const a=h=>{h.pointerType};function l(h){ae.call(this,r,h)}return r.$$set=h=>{"x"in h&&e(0,n=h.x),"y"in h&&e(1,s=h.y),"scale"in h&&e(4,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=4/o)},[n,s,i,a,o,l]}class Iu extends jt{constructor(t){super(),zt(this,t,Ev,wv,Ut,{x:0,y:1,scale:4})}}function Pa(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Pu(r,t,e){const i=r.slice();return i[28]=t[e],i[30]=e,i}function Ra(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Ma(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Ru(r){let t,e,i,n;return{c(){t=it("circle"),w(t,"cx",e=r[28][0]),w(t,"cy",i=r[28][1]),w(t,"r",n=In/r[3]),w(t,"class","svelte-1h2slbm")},m(s,o){ot(s,t,o)},p(s,o){o[0]&1088&&e!==(e=s[28][0])&&w(t,"cx",e),o[0]&1088&&i!==(i=s[28][1])&&w(t,"cy",i),o[0]&8&&n!==(n=In/s[3])&&w(t,"r",n)},d(s){s&&st(t)}}}function Mu(r){let t,e,i,n,s,o,a,l,h,c;return{c(){t=it("mask"),e=it("rect"),a=it("circle"),w(e,"x",i=r[9].x),w(e,"y",n=r[9].y),w(e,"width",s=r[9].w),w(e,"height",o=r[9].h),w(e,"class","svelte-1h2slbm"),w(a,"cx",l=r[28][0]),w(a,"cy",h=r[28][1]),w(a,"r",c=In/r[3]),w(a,"class","svelte-1h2slbm"),w(t,"id",`${r[19]}-inner`),w(t,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(u,d){ot(u,t,d),Ct(t,e),Ct(t,a)},p(u,d){d[0]&512&&i!==(i=u[9].x)&&w(e,"x",i),d[0]&512&&n!==(n=u[9].y)&&w(e,"y",n),d[0]&512&&s!==(s=u[9].w)&&w(e,"width",s),d[0]&512&&o!==(o=u[9].h)&&w(e,"height",o),d[0]&1088&&l!==(l=u[28][0])&&w(a,"cx",l),d[0]&1088&&h!==(h=u[28][1])&&w(a,"cy",h),d[0]&8&&c!==(c=In/u[3])&&w(a,"r",c)},d(u){u&&st(t)}}}function Du(r){let t,e;return t=new Ui({props:{class:"a9s-corner-handle",x:r[28][0],y:r[28][1],scale:r[3],selected:r[8].includes(r[30])}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[15]),t.$on("pointerdown",function(){Zt(r[27](`HANDLE-${r[30]}`))&&r[27](`HANDLE-${r[30]}`).apply(this,arguments)}),t.$on("pointerup",r[16](r[30])),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&32&&(s.x=r[28][0]),n[0]&32&&(s.y=r[28][1]),n[0]&8&&(s.scale=r[3]),n[0]&256&&(s.selected=r[8].includes(r[30])),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Bu(r){let t,e;return t=new Iu({props:{x:r[28][0],y:r[28][1],scale:r[3]}}),t.$on("pointerdown",function(){Zt(r[18](r[6]))&&r[18](r[6]).apply(this,arguments)}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&1088&&(s.x=r[28][0]),n[0]&1088&&(s.y=r[28][1]),n[0]&8&&(s.scale=r[3]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Tv(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v,m,b,S,R=r[6]!==void 0&&!r[7]&&Ru(Ma(r)),C=r[6]!==void 0&&!r[7]&&Mu(Ra(r)),I=xe(r[5].points),M=[];for(let P=0;P<I.length;P+=1)M[P]=Du(Pu(r,I,P));const F=P=>at(M[P],1,1,()=>{M[P]=null});let U=r[6]!==void 0&&!r[7]&&Bu(Pa(r));return{c(){t=it("defs"),e=it("mask"),i=it("rect"),l=it("polygon"),R&&R.c(),C&&C.c(),c=Se(),u=it("polygon"),f=Se(),p=it("polygon"),y=Se();for(let P=0;P<M.length;P+=1)M[P].c();_=Se(),U&&U.c(),v=Pe(),w(i,"x",n=r[9].x),w(i,"y",s=r[9].y),w(i,"width",o=r[9].w),w(i,"height",a=r[9].h),w(i,"class","svelte-1h2slbm"),w(l,"points",h=r[5].points.map(Ou).join(" ")),w(l,"class","svelte-1h2slbm"),w(e,"id",`${r[19]}-outer`),w(e,"class","a9s-polygon-editor-mask svelte-1h2slbm"),w(u,"class","a9s-outer"),w(u,"mask",`url(#${r[19]}-outer)`),w(u,"points",d=r[5].points.map(Lu).join(" ")),w(p,"class","a9s-inner a9s-shape-handle"),w(p,"mask",`url(#${r[19]}-inner)`),w(p,"style",r[1]),w(p,"points",g=r[5].points.map(Nu).join(" "))},m(P,T){ot(P,t,T),Ct(t,e),Ct(e,i),Ct(e,l),R&&R.m(e,null),C&&C.m(t,null),ot(P,c,T),ot(P,u,T),ot(P,f,T),ot(P,p,T),ot(P,y,T);for(let E=0;E<M.length;E+=1)M[E]&&M[E].m(P,T);ot(P,_,T),U&&U.m(P,T),ot(P,v,T),m=!0,b||(S=[Pt(u,"pointerup",r[14]),Pt(u,"pointerdown",function(){Zt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)}),Pt(p,"pointermove",r[13]),Pt(p,"pointerup",r[14]),Pt(p,"pointerdown",function(){Zt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)})],b=!0)},p(P,T){if(r=P,(!m||T[0]&512&&n!==(n=r[9].x))&&w(i,"x",n),(!m||T[0]&512&&s!==(s=r[9].y))&&w(i,"y",s),(!m||T[0]&512&&o!==(o=r[9].w))&&w(i,"width",o),(!m||T[0]&512&&a!==(a=r[9].h))&&w(i,"height",a),(!m||T[0]&32&&h!==(h=r[5].points.map(Ou).join(" ")))&&w(l,"points",h),r[6]!==void 0&&!r[7]?R?R.p(Ma(r),T):(R=Ru(Ma(r)),R.c(),R.m(e,null)):R&&(R.d(1),R=null),r[6]!==void 0&&!r[7]?C?C.p(Ra(r),T):(C=Mu(Ra(r)),C.c(),C.m(t,null)):C&&(C.d(1),C=null),(!m||T[0]&32&&d!==(d=r[5].points.map(Lu).join(" ")))&&w(u,"points",d),(!m||T[0]&2)&&w(p,"style",r[1]),(!m||T[0]&32&&g!==(g=r[5].points.map(Nu).join(" ")))&&w(p,"points",g),T[0]&134322472){I=xe(r[5].points);let E;for(E=0;E<I.length;E+=1){const A=Pu(r,I,E);M[E]?(M[E].p(A,T),q(M[E],1)):(M[E]=Du(A),M[E].c(),q(M[E],1),M[E].m(_.parentNode,_))}for(le(),E=I.length;E<M.length;E+=1)F(E);he()}r[6]!==void 0&&!r[7]?U?(U.p(Pa(r),T),T[0]&192&&q(U,1)):(U=Bu(Pa(r)),U.c(),q(U,1),U.m(v.parentNode,v)):U&&(le(),at(U,1,1,()=>{U=null}),he())},i(P){if(!m){for(let T=0;T<I.length;T+=1)q(M[T]);q(U),m=!0}},o(P){M=M.filter(Boolean);for(let T=0;T<M.length;T+=1)at(M[T]);at(U),m=!1},d(P){P&&(st(t),st(c),st(u),st(f),st(p),st(y),st(_),st(v)),R&&R.d(),C&&C.d(),Dr(M,P),U&&U.d(P),b=!1,Fe(S)}}}function Av(r){let t,e;return t=new Ia({props:{shape:r[0],transform:r[2],editor:r[17],svgEl:r[4],$$slots:{default:[Tv,({grab:i})=>({27:i}),({grab:i})=>[i?134217728:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n[0]&1&&(s.shape=i[0]),n[0]&4&&(s.transform=i[2]),n[0]&16&&(s.svgEl=i[4]),n[0]&134219754|n[1]&1&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}const Sv=250,Cv=1e3,Iv=12,In=4.5,Ou=r=>r.join(","),Lu=r=>r.join(","),Nu=r=>r.join(",");function Pv(r,t,e){let i,n,s;const o=Bi();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:c=1}=t,{svgEl:u}=t,d,f=!1,p,g=[];const y=()=>e(7,f=!0),_=()=>e(7,f=!1),v=E=>{if(g.length>0||!n.some(k=>k.visible)){e(6,d=void 0);return}const[A,L]=h.elementToImage(E.offsetX,E.offsetY),D=k=>Math.pow(k[0]-A,2)+Math.pow(k[1]-L,2),N=i.points.reduce((k,V)=>D(V)<D(k)?V:k),$=n.filter(k=>k.visible).reduce((k,V)=>D(V.point)<D(k.point)?V:k),O=Math.pow(Cv/c,2);D(N)<O||D($.point)<O?e(6,d=n.indexOf($)):e(6,d=void 0)},m=()=>{document.activeElement!==u&&u.focus()},b=()=>{e(8,g=[]),m()},S=E=>{e(7,f=!0),E.preventDefault(),E.stopPropagation(),p=performance.now()},R=E=>A=>{if(!p||Or||performance.now()-p>Sv)return;const L=g.includes(E);A.metaKey||A.ctrlKey||A.shiftKey?L?e(8,g=g.filter(D=>D!==E)):e(8,g=[...g,E]):L&&g.length>1?e(8,g=[E]):L?e(8,g=[]):e(8,g=[E]),m()},C=(E,A,L)=>{m();let D;const N=E.geometry;g.length>1?D=N.points.map(([O,B],k)=>g.includes(k)?[O+L[0],B+L[1]]:[O,B]):A==="SHAPE"?D=N.points.map(([O,B])=>[O+L[0],B+L[1]]):D=N.points.map(([O,B],k)=>A===`HANDLE-${k}`?[O+L[0],B+L[1]]:[O,B]);const $=tr(D);return{...E,geometry:{points:D,bounds:$}}},I=E=>async A=>{A.stopPropagation();const L=[...i.points.slice(0,E+1),n[E].point,...i.points.slice(E+1)],D=tr(L);o("change",{...a,geometry:{points:L,bounds:D}}),await _u();const N=[...document.querySelectorAll(".a9s-handle")][E+1];if(N!=null&&N.firstChild){const $=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:A.clientX,clientY:A.clientY,pointerId:A.pointerId,pointerType:A.pointerType,isPrimary:A.isPrimary,buttons:A.buttons});N.firstChild.dispatchEvent($)}},M=()=>{if(i.points.length-g.length<3)return;const E=i.points.filter((L,D)=>!g.includes(D)),A=tr(E);o("change",{...a,geometry:{points:E,bounds:A}}),e(8,g=[])};ei(()=>{if(Or)return;const E=A=>{(A.key==="Delete"||A.key==="Backspace")&&(A.preventDefault(),M())};return u.addEventListener("pointermove",v),u.addEventListener("keydown",E),()=>{u.removeEventListener("pointermove",v),u.removeEventListener("keydown",E)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function U(E){ae.call(this,r,E)}function P(E){ae.call(this,r,E)}function T(E){ae.call(this,r,E)}return r.$$set=E=>{"shape"in E&&e(0,a=E.shape),"computedStyle"in E&&e(1,l=E.computedStyle),"transform"in E&&e(2,h=E.transform),"viewportScale"in E&&e(3,c=E.viewportScale),"svgEl"in E&&e(4,u=E.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,n=Or?[]:i.points.map((E,A)=>{const L=A===i.points.length-1?i.points[0]:i.points[A+1],D=(E[0]+L[0])/2,N=(E[1]+L[1])/2,O=Math.sqrt(Math.pow(L[0]-D,2)+Math.pow(L[1]-N,2))>Iv/c;return{point:[D,N],visible:O}})),r.$$.dirty[0]&40&&e(9,s=Ca(i.bounds,In/c))},[a,l,h,c,u,i,d,f,g,s,n,y,_,v,b,S,R,C,I,F,U,P,T]}class Rv extends jt{constructor(t){super(),zt(this,t,Pv,Av,Ut,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function Mv(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v,m,b,S,R,C,I,M,F,U,P,T,E,A,L,D,N,$,O,B,k,V,z,K,X,ft,H,mt,J,ut,gt,Et,Dt,Yt,Vt,et,$e,ts;return J=new Ui({props:{class:"a9s-corner-handle-topleft",x:r[5].x,y:r[5].y,scale:r[3]}}),J.$on("pointerdown",function(){Zt(r[12]("TOP_LEFT"))&&r[12]("TOP_LEFT").apply(this,arguments)}),gt=new Ui({props:{class:"a9s-corner-handle-topright",x:r[5].x+r[5].w,y:r[5].y,scale:r[3]}}),gt.$on("pointerdown",function(){Zt(r[12]("TOP_RIGHT"))&&r[12]("TOP_RIGHT").apply(this,arguments)}),Dt=new Ui({props:{class:"a9s-corner-handle-bottomright",x:r[5].x+r[5].w,y:r[5].y+r[5].h,scale:r[3]}}),Dt.$on("pointerdown",function(){Zt(r[12]("BOTTOM_RIGHT"))&&r[12]("BOTTOM_RIGHT").apply(this,arguments)}),Vt=new Ui({props:{class:"a9s-corner-handle-bottomleft",x:r[5].x,y:r[5].y+r[5].h,scale:r[3]}}),Vt.$on("pointerdown",function(){Zt(r[12]("BOTTOM_LEFT"))&&r[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=it("defs"),e=it("mask"),i=it("rect"),l=it("rect"),f=Se(),p=it("rect"),m=Se(),b=it("rect"),M=Se(),F=it("rect"),E=Se(),A=it("rect"),$=Se(),O=it("rect"),z=Se(),K=it("rect"),mt=Se(),Lt(J.$$.fragment),ut=Se(),Lt(gt.$$.fragment),Et=Se(),Lt(Dt.$$.fragment),Yt=Se(),Lt(Vt.$$.fragment),w(i,"class","rect-mask-bg svelte-1njczvj"),w(i,"x",n=r[6].x),w(i,"y",s=r[6].y),w(i,"width",o=r[6].w),w(i,"height",a=r[6].h),w(l,"class","rect-mask-fg svelte-1njczvj"),w(l,"x",h=r[5].x),w(l,"y",c=r[5].y),w(l,"width",u=r[5].w),w(l,"height",d=r[5].h),w(e,"id",r[8]),w(e,"class","a9s-rectangle-editor-mask svelte-1njczvj"),w(p,"class","a9s-outer"),w(p,"mask",`url(#${r[8]})`),w(p,"x",g=r[5].x),w(p,"y",y=r[5].y),w(p,"width",_=r[5].w),w(p,"height",v=r[5].h),w(b,"class","a9s-inner a9s-shape-handle"),w(b,"style",r[1]),w(b,"x",S=r[5].x),w(b,"y",R=r[5].y),w(b,"width",C=r[5].w),w(b,"height",I=r[5].h),w(F,"class","a9s-edge-handle a9s-edge-handle-top"),w(F,"x",U=r[5].x),w(F,"y",P=r[5].y),w(F,"height",1),w(F,"width",T=r[5].w),w(A,"class","a9s-edge-handle a9s-edge-handle-right"),w(A,"x",L=r[5].x+r[5].w),w(A,"y",D=r[5].y),w(A,"height",N=r[5].h),w(A,"width",1),w(O,"class","a9s-edge-handle a9s-edge-handle-bottom"),w(O,"x",B=r[5].x),w(O,"y",k=r[5].y+r[5].h),w(O,"height",1),w(O,"width",V=r[5].w),w(K,"class","a9s-edge-handle a9s-edge-handle-left"),w(K,"x",X=r[5].x),w(K,"y",ft=r[5].y),w(K,"height",H=r[5].h),w(K,"width",1)},m(Y,G){ot(Y,t,G),Ct(t,e),Ct(e,i),Ct(e,l),ot(Y,f,G),ot(Y,p,G),ot(Y,m,G),ot(Y,b,G),ot(Y,M,G),ot(Y,F,G),ot(Y,E,G),ot(Y,A,G),ot(Y,$,G),ot(Y,O,G),ot(Y,z,G),ot(Y,K,G),ot(Y,mt,G),Bt(J,Y,G),ot(Y,ut,G),Bt(gt,Y,G),ot(Y,Et,G),Bt(Dt,Y,G),ot(Y,Yt,G),Bt(Vt,Y,G),et=!0,$e||(ts=[Pt(p,"pointerdown",function(){Zt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Pt(b,"pointerdown",function(){Zt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Pt(F,"pointerdown",function(){Zt(r[12]("TOP"))&&r[12]("TOP").apply(this,arguments)}),Pt(A,"pointerdown",function(){Zt(r[12]("RIGHT"))&&r[12]("RIGHT").apply(this,arguments)}),Pt(O,"pointerdown",function(){Zt(r[12]("BOTTOM"))&&r[12]("BOTTOM").apply(this,arguments)}),Pt(K,"pointerdown",function(){Zt(r[12]("LEFT"))&&r[12]("LEFT").apply(this,arguments)})],$e=!0)},p(Y,G){r=Y,(!et||G&64&&n!==(n=r[6].x))&&w(i,"x",n),(!et||G&64&&s!==(s=r[6].y))&&w(i,"y",s),(!et||G&64&&o!==(o=r[6].w))&&w(i,"width",o),(!et||G&64&&a!==(a=r[6].h))&&w(i,"height",a),(!et||G&32&&h!==(h=r[5].x))&&w(l,"x",h),(!et||G&32&&c!==(c=r[5].y))&&w(l,"y",c),(!et||G&32&&u!==(u=r[5].w))&&w(l,"width",u),(!et||G&32&&d!==(d=r[5].h))&&w(l,"height",d),(!et||G&32&&g!==(g=r[5].x))&&w(p,"x",g),(!et||G&32&&y!==(y=r[5].y))&&w(p,"y",y),(!et||G&32&&_!==(_=r[5].w))&&w(p,"width",_),(!et||G&32&&v!==(v=r[5].h))&&w(p,"height",v),(!et||G&2)&&w(b,"style",r[1]),(!et||G&32&&S!==(S=r[5].x))&&w(b,"x",S),(!et||G&32&&R!==(R=r[5].y))&&w(b,"y",R),(!et||G&32&&C!==(C=r[5].w))&&w(b,"width",C),(!et||G&32&&I!==(I=r[5].h))&&w(b,"height",I),(!et||G&32&&U!==(U=r[5].x))&&w(F,"x",U),(!et||G&32&&P!==(P=r[5].y))&&w(F,"y",P),(!et||G&32&&T!==(T=r[5].w))&&w(F,"width",T),(!et||G&32&&L!==(L=r[5].x+r[5].w))&&w(A,"x",L),(!et||G&32&&D!==(D=r[5].y))&&w(A,"y",D),(!et||G&32&&N!==(N=r[5].h))&&w(A,"height",N),(!et||G&32&&B!==(B=r[5].x))&&w(O,"x",B),(!et||G&32&&k!==(k=r[5].y+r[5].h))&&w(O,"y",k),(!et||G&32&&V!==(V=r[5].w))&&w(O,"width",V),(!et||G&32&&X!==(X=r[5].x))&&w(K,"x",X),(!et||G&32&&ft!==(ft=r[5].y))&&w(K,"y",ft),(!et||G&32&&H!==(H=r[5].h))&&w(K,"height",H);const Ar={};G&32&&(Ar.x=r[5].x),G&32&&(Ar.y=r[5].y),G&8&&(Ar.scale=r[3]),J.$set(Ar);const Sr={};G&32&&(Sr.x=r[5].x+r[5].w),G&32&&(Sr.y=r[5].y),G&8&&(Sr.scale=r[3]),gt.$set(Sr);const Cr={};G&32&&(Cr.x=r[5].x+r[5].w),G&32&&(Cr.y=r[5].y+r[5].h),G&8&&(Cr.scale=r[3]),Dt.$set(Cr);const Ir={};G&32&&(Ir.x=r[5].x),G&32&&(Ir.y=r[5].y+r[5].h),G&8&&(Ir.scale=r[3]),Vt.$set(Ir)},i(Y){et||(q(J.$$.fragment,Y),q(gt.$$.fragment,Y),q(Dt.$$.fragment,Y),q(Vt.$$.fragment,Y),et=!0)},o(Y){at(J.$$.fragment,Y),at(gt.$$.fragment,Y),at(Dt.$$.fragment,Y),at(Vt.$$.fragment,Y),et=!1},d(Y){Y&&(st(t),st(f),st(p),st(m),st(b),st(M),st(F),st(E),st(A),st($),st(O),st(z),st(K),st(mt),st(ut),st(Et),st(Yt)),Ot(J,Y),Ot(gt,Y),Ot(Dt,Y),Ot(Vt,Y),$e=!1,Fe(ts)}}}function Dv(r){let t,e;return t=new Ia({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[Mv,({grab:i})=>({12:i}),({grab:i})=>i?4096:0]},$$scope:{ctx:r}}}),t.$on("grab",r[9]),t.$on("change",r[10]),t.$on("release",r[11]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,[n]){const s={};n&1&&(s.shape=i[0]),n&4&&(s.transform=i[2]),n&16&&(s.svgEl=i[4]),n&12394&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Bv(r,t,e){let i,n,{shape:s}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const c=(g,y,_)=>{const v=g.geometry.bounds;let[m,b]=[v.minX,v.minY],[S,R]=[v.maxX,v.maxY];const[C,I]=_;if(y==="SHAPE")m+=C,S+=C,b+=I,R+=I;else{switch(y){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{b+=I;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{R+=I;break}}switch(y){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{m+=C;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{S+=C;break}}}const M=Math.min(m,S),F=Math.min(b,R),U=Math.abs(S-m),P=Math.abs(R-b);return{...g,geometry:{x:M,y:F,w:U,h:P,bounds:{minX:M,minY:F,maxX:M+U,maxY:F+P}}}},u=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(g){ae.call(this,r,g)}function f(g){ae.call(this,r,g)}function p(g){ae.call(this,r,g)}return r.$$set=g=>{"shape"in g&&e(0,s=g.shape),"computedStyle"in g&&e(1,o=g.computedStyle),"transform"in g&&e(2,a=g.transform),"viewportScale"in g&&e(3,l=g.viewportScale),"svgEl"in g&&e(4,h=g.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=s.geometry),r.$$.dirty&40&&e(6,n=Ca(i.bounds,2/l))},[s,o,a,l,h,i,n,c,u,d,f,p]}class Ov extends jt{constructor(t){super(),zt(this,t,Bv,Dv,Ut,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var Fu=Object.prototype.hasOwnProperty;function Da(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--&&Da(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Fu.call(r,e)&&++i&&!Fu.call(t,e)||!(e in t)||!Da(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}const Lv=12,Nv=(r,t)=>r.polygons.reduce((e,i,n)=>{const s=i.rings.reduce((o,a,l)=>{const h=a.points.map((c,u)=>{const d=u===a.points.length-1?a.points[0]:a.points[u+1],f=(c[0]+d[0])/2,p=(c[1]+d[1])/2,y=Math.sqrt(Math.pow(d[0]-f,2)+Math.pow(d[1]-p,2))>Lv/t;return{point:[f,p],visible:y,elementIdx:n,ringIdx:l,pointIdx:u}});return[...o,...h]},[]);return[...e,...s]},[]);function Ba(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function ku(r,t,e){const i=r.slice();return i[30]=t[e],i[32]=e,i}function Uu(r,t,e){const i=r.slice();return i[33]=t[e],i[35]=e,i}function Gu(r,t,e){const i=r.slice();return i[29]=t[e],i[37]=e,i}function Oa(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function La(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function $u(r){let t,e,i,n;return{c(){t=it("circle"),w(t,"cx",e=r[29][0]),w(t,"cy",i=r[29][1]),w(t,"r",n=Pn/r[3]),w(t,"class","svelte-1vxo6dc")},m(s,o){ot(s,t,o)},p(s,o){o[0]&1088&&e!==(e=s[29][0])&&w(t,"cx",e),o[0]&1088&&i!==(i=s[29][1])&&w(t,"cy",i),o[0]&8&&n!==(n=Pn/s[3])&&w(t,"r",n)},d(s){s&&st(t)}}}function Hu(r){let t,e,i,n,s,o,a,l,h,c;return{c(){t=it("mask"),e=it("rect"),a=it("circle"),w(e,"x",i=r[9].x),w(e,"y",n=r[9].y),w(e,"width",s=r[9].w),w(e,"height",o=r[9].h),w(e,"class","svelte-1vxo6dc"),w(a,"cx",l=r[29][0]),w(a,"cy",h=r[29][1]),w(a,"r",c=Pn/r[3]),w(a,"class","svelte-1vxo6dc"),w(t,"id",`${r[18]}-${r[32]}-inner`),w(t,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc")},m(u,d){ot(u,t,d),Ct(t,e),Ct(t,a)},p(u,d){d[0]&512&&i!==(i=u[9].x)&&w(e,"x",i),d[0]&512&&n!==(n=u[9].y)&&w(e,"y",n),d[0]&512&&s!==(s=u[9].w)&&w(e,"width",s),d[0]&512&&o!==(o=u[9].h)&&w(e,"height",o),d[0]&1088&&l!==(l=u[29][0])&&w(a,"cx",l),d[0]&1088&&h!==(h=u[29][1])&&w(a,"cy",h),d[0]&8&&c!==(c=Pn/u[3])&&w(a,"r",c)},d(u){u&&st(t)}}}function Xu(r){let t,e;function i(...n){return r[19](r[32],r[35],r[37],...n)}return t=new Ui({props:{class:"a9s-corner-handle",x:r[29][0],y:r[29][1],scale:r[3],selected:r[8].some(i)}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[14]),t.$on("pointerdown",function(){Zt(r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`))&&r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`).apply(this,arguments)}),t.$on("pointerup",r[15](r[32],r[35],r[37])),{c(){Lt(t.$$.fragment)},m(n,s){Bt(t,n,s),e=!0},p(n,s){r=n;const o={};s[0]&32&&(o.x=r[29][0]),s[0]&32&&(o.y=r[29][1]),s[0]&8&&(o.scale=r[3]),s[0]&256&&(o.selected=r[8].some(i)),t.$set(o)},i(n){e||(q(t.$$.fragment,n),e=!0)},o(n){at(t.$$.fragment,n),e=!1},d(n){Ot(t,n)}}}function Vu(r){let t,e,i=xe(r[33].points),n=[];for(let o=0;o<i.length;o+=1)n[o]=Xu(Gu(r,i,o));const s=o=>at(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=Pe()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);ot(o,t,a),e=!0},p(o,a){if(a[0]&268491048){i=xe(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=Gu(o,i,l);n[l]?(n[l].p(h,a),q(n[l],1)):(n[l]=Xu(h),n[l].c(),q(n[l],1),n[l].m(t.parentNode,t))}for(le(),l=i.length;l<n.length;l+=1)s(l);he()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(n[a]);e=!0}},o(o){n=n.filter(Boolean);for(let a=0;a<n.length;a+=1)at(n[a]);e=!1},d(o){o&&st(t),Dr(n,o)}}}function zu(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v=r[6]!==void 0&&!r[7]&&$u(La(r)),m=r[6]!==void 0&&!r[7]&&Hu(Oa(r)),b=xe(r[30].rings),S=[];for(let C=0;C<b.length;C+=1)S[C]=Vu(Uu(r,b,C));const R=C=>at(S[C],1,1,()=>{S[C]=null});return{c(){t=it("g"),e=it("defs"),i=it("mask"),n=it("rect"),h=it("path"),v&&v.c(),m&&m.c(),u=it("path"),f=it("path");for(let C=0;C<S.length;C+=1)S[C].c();w(n,"x",s=r[9].x),w(n,"y",o=r[9].y),w(n,"width",a=r[9].w),w(n,"height",l=r[9].h),w(n,"class","svelte-1vxo6dc"),w(h,"d",c=ki(r[30])),w(h,"class","svelte-1vxo6dc"),w(i,"id",`${r[18]}-${r[32]}-outer`),w(i,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc"),w(u,"class","a9s-outer"),w(u,"mask",`url(#${r[18]}-${r[32]}-outer)`),w(u,"fill-rule","evenodd"),w(u,"d",d=ki(r[30])),w(f,"class","a9s-inner"),w(f,"mask",`url(#${r[18]}-${r[32]}-inner)`),w(f,"style",r[1]),w(f,"fill-rule","evenodd"),w(f,"d",p=ki(r[30]))},m(C,I){ot(C,t,I),Ct(t,e),Ct(e,i),Ct(i,n),Ct(i,h),v&&v.m(i,null),m&&m.m(e,null),Ct(t,u),Ct(t,f);for(let M=0;M<S.length;M+=1)S[M]&&S[M].m(t,null);g=!0,y||(_=[Pt(u,"pointerup",r[13]),Pt(u,"pointerdown",function(){Zt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)}),Pt(f,"pointerup",r[13]),Pt(f,"pointerdown",function(){Zt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)})],y=!0)},p(C,I){if(r=C,(!g||I[0]&512&&s!==(s=r[9].x))&&w(n,"x",s),(!g||I[0]&512&&o!==(o=r[9].y))&&w(n,"y",o),(!g||I[0]&512&&a!==(a=r[9].w))&&w(n,"width",a),(!g||I[0]&512&&l!==(l=r[9].h))&&w(n,"height",l),(!g||I[0]&32&&c!==(c=ki(r[30])))&&w(h,"d",c),r[6]!==void 0&&!r[7]?v?v.p(La(r),I):(v=$u(La(r)),v.c(),v.m(i,null)):v&&(v.d(1),v=null),r[6]!==void 0&&!r[7]?m?m.p(Oa(r),I):(m=Hu(Oa(r)),m.c(),m.m(e,null)):m&&(m.d(1),m=null),(!g||I[0]&32&&d!==(d=ki(r[30])))&&w(u,"d",d),(!g||I[0]&2)&&w(f,"style",r[1]),(!g||I[0]&32&&p!==(p=ki(r[30])))&&w(f,"d",p),I[0]&268491048){b=xe(r[30].rings);let M;for(M=0;M<b.length;M+=1){const F=Uu(r,b,M);S[M]?(S[M].p(F,I),q(S[M],1)):(S[M]=Vu(F),S[M].c(),q(S[M],1),S[M].m(t,null))}for(le(),M=b.length;M<S.length;M+=1)R(M);he()}},i(C){if(!g){for(let I=0;I<b.length;I+=1)q(S[I]);g=!0}},o(C){S=S.filter(Boolean);for(let I=0;I<S.length;I+=1)at(S[I]);g=!1},d(C){C&&st(t),v&&v.d(),m&&m.d(),Dr(S,C),y=!1,Fe(_)}}}function ju(r){let t,e;return t=new Iu({props:{x:r[29][0],y:r[29][1],scale:r[3]}}),t.$on("pointerdown",function(){Zt(r[17](r[6]))&&r[17](r[6]).apply(this,arguments)}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&1088&&(s.x=r[29][0]),n[0]&1088&&(s.y=r[29][1]),n[0]&8&&(s.scale=r[3]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Fv(r){let t,e,i,n=xe(r[5].polygons),s=[];for(let l=0;l<n.length;l+=1)s[l]=zu(ku(r,n,l));const o=l=>at(s[l],1,1,()=>{s[l]=null});let a=r[6]!==void 0&&!r[7]&&ju(Ba(r));return{c(){for(let l=0;l<s.length;l+=1)s[l].c();t=Se(),a&&a.c(),e=Pe()},m(l,h){for(let c=0;c<s.length;c+=1)s[c]&&s[c].m(l,h);ot(l,t,h),a&&a.m(l,h),ot(l,e,h),i=!0},p(l,h){if(h[0]&268763114){n=xe(l[5].polygons);let c;for(c=0;c<n.length;c+=1){const u=ku(l,n,c);s[c]?(s[c].p(u,h),q(s[c],1)):(s[c]=zu(u),s[c].c(),q(s[c],1),s[c].m(t.parentNode,t))}for(le(),c=n.length;c<s.length;c+=1)o(c);he()}l[6]!==void 0&&!l[7]?a?(a.p(Ba(l),h),h[0]&192&&q(a,1)):(a=ju(Ba(l)),a.c(),q(a,1),a.m(e.parentNode,e)):a&&(le(),at(a,1,1,()=>{a=null}),he())},i(l){if(!i){for(let h=0;h<n.length;h+=1)q(s[h]);q(a),i=!0}},o(l){s=s.filter(Boolean);for(let h=0;h<s.length;h+=1)at(s[h]);at(a),i=!1},d(l){l&&(st(t),st(e)),Dr(s,l),a&&a.d(l)}}}function kv(r){let t,e;return t=new Ia({props:{shape:r[0],transform:r[2],editor:r[16],svgEl:r[4],$$slots:{default:[Fv,({grab:i})=>({28:i}),({grab:i})=>[i?268435456:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n[0]&1&&(s.shape=i[0]),n[0]&4&&(s.transform=i[2]),n[0]&16&&(s.svgEl=i[4]),n[0]&268437482|n[1]&128&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}const Uv=250,Gv=1e3,Pn=4.5;function $v(r,t,e){let i,n,s;const o=Bi();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:c=1}=t,{svgEl:u}=t,d,f=!1,p,g=[];const y=()=>e(7,f=!0),_=()=>e(7,f=!1),v=A=>{if(g.length>0||!n.some(V=>V.visible)){e(6,d=void 0);return}const[L,D]=h.elementToImage(A.offsetX,A.offsetY),N=V=>Math.pow(V[0]-L,2)+Math.pow(V[1]-D,2),$=tv(i).reduce((V,z)=>N(z)<N(V)?z:V),O=n.filter(V=>V.visible).reduce((V,z)=>N(z.point)<N(V.point)?z:V),B=Math.pow(Gv/c,2);N($)<B||N(O.point)<B?e(6,d=n.indexOf(O)):e(6,d=void 0)},m=()=>{document.activeElement!==u&&u.focus()},b=()=>{e(8,g=[]),m()},S=A=>{e(7,f=!0),A.preventDefault(),A.stopPropagation(),p=performance.now()},R=(A,L,D)=>N=>{if(!p||Or||performance.now()-p>Uv)return;const $=B=>B.polygon===A&&B.ring===L&&B.point===D,O=g.some($);N.metaKey||N.ctrlKey||N.shiftKey?O?e(8,g=g.filter(B=>!$(B))):e(8,g=[...g,{polygon:A,ring:L,point:D}]):O&&g.length>1?e(8,g=[{polygon:A,ring:L,point:D}]):O?e(8,g=[]):e(8,g=[{polygon:A,ring:L,point:D}]),m()},C=(A,L,D)=>{m();const N=A.geometry.polygons;let $;if(L==="SHAPE")$=N.map(O=>{const B=O.rings.map((V,z)=>({points:V.points.map((X,ft)=>[X[0]+D[0],X[1]+D[1]])})),k=tr(B[0].points);return{rings:B,bounds:k}});else{const[O,B,k,V]=L.split("-").map(z=>parseInt(z));$=N.map((z,K)=>{if(K===B){const X=z.rings.map((H,mt)=>mt===k?{points:H.points.map((ut,gt)=>gt===V?[ut[0]+D[0],ut[1]+D[1]]:ut)}:H),ft=tr(X[0].points);return{rings:X,bounds:ft}}else return z})}return{...A,geometry:{polygons:$,bounds:Ts($)}}},I=A=>async L=>{L.stopPropagation();const D=n[A],N=i.polygons.map((O,B)=>{if(B===D.elementIdx){const k=O.rings.map((z,K)=>K===D.ringIdx?{points:[...z.points.slice(0,D.pointIdx+1),D.point,...z.points.slice(D.pointIdx+1)]}:z),V=tr(k[0].points);return{rings:k,bounds:V}}else return O});o("change",{...a,geometry:{polygons:N,bounds:Ts(N)}}),await _u();const $=[...document.querySelectorAll(".a9s-handle")][A+1];if($!=null&&$.firstChild){const O=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:L.clientX,clientY:L.clientY,pointerId:L.pointerId,pointerType:L.pointerType,isPrimary:L.isPrimary,buttons:L.buttons});$.firstChild.dispatchEvent(O)}},M=()=>{const A=i.polygons.map((D,N)=>{if(g.some(O=>O.polygon===N)){const O=D.rings.map((k,V)=>{const z=g.filter(K=>K.polygon===N&&K.ring===V);return z.length&&k.points.length-z.length>=3?{points:k.points.filter((X,ft)=>!z.some(H=>H.point===ft))}:k}),B=tr(O[0].points);return{rings:O,bounds:B}}else return D});!Da(i.polygons,A)&&(o("change",{...a,geometry:{polygons:A,bounds:Ts(A)}}),e(8,g=[]))};ei(()=>{if(Or)return;const A=L=>{(L.key==="Delete"||L.key==="Backspace")&&(L.preventDefault(),M())};return u.addEventListener("pointermove",v),u.addEventListener("keydown",A),()=>{u.removeEventListener("pointermove",v),u.removeEventListener("keydown",A)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,U=(A,L,D,{polygon:N,ring:$,point:O})=>N===A&&$===L&&O===D;function P(A){ae.call(this,r,A)}function T(A){ae.call(this,r,A)}function E(A){ae.call(this,r,A)}return r.$$set=A=>{"shape"in A&&e(0,a=A.shape),"computedStyle"in A&&e(1,l=A.computedStyle),"transform"in A&&e(2,h=A.transform),"viewportScale"in A&&e(3,c=A.viewportScale),"svgEl"in A&&e(4,u=A.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,n=Or?[]:Nv(i,c)),r.$$.dirty[0]&40&&e(9,s=Ca(i.bounds,Pn/c))},[a,l,h,c,u,i,d,f,g,s,n,y,_,b,S,R,C,I,F,U,P,T,E]}class Hv extends jt{constructor(t){super(),zt(this,t,$v,kv,Ut,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}Qe.RECTANGLE,Qe.POLYGON,Qe.MULTIPOLYGON;function Xv(r,t,e){let i;const n=Bi();let{annotation:s}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return ei(()=>(e(6,u=new o({target:l,props:{shape:s.target.selector,computedStyle:i,transform:h,viewportScale:c,svgEl:l.closest("svg")}})),u.$on("change",d=>{u.$$set({shape:d.detail}),n("change",d.detail)}),u.$on("grab",d=>n("grab",d.detail)),u.$on("release",d=>n("release",d.detail)),()=>{u.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,s=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,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=dv(s,a)),r.$$.dirty&65&&s&&(u==null||u.$set({shape:s.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c}),r.$$.dirty&192&&u&&i&&u.$set({computedStyle:i})},[s,o,a,l,h,c,u,i]}class Vv extends jt{constructor(t){super(),zt(this,t,Xv,null,Ut,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;var ii=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(ii||{}),Wu=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Wu||{}),Na=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(Na||{}),vt=(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))(vt||{}),er=(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))(er||{}),j=(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))(j||{}),Gi=(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))(Gi||{}),pt=(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))(pt||{}),Q=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(Q||{}),mr=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(mr||{}),Lr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Lr||{}),rr=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(rr||{}),Re=(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))(Re||{}),ir=(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))(ir||{}),Fa=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(Fa||{}),ke=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(ke||{}),ie=(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))(ie||{}),ee=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(ee||{}),nr=(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))(nr||{});const tt={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 ka=/iPhone/i,Yu=/iPod/i,qu=/iPad/i,Ku=/\biOS-universal(?:.+)Mac\b/i,Ua=/\bAndroid(?:.+)Mobile\b/i,Zu=/Android/i,$i=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,As=/Silk/i,gr=/Windows Phone/i,Ju=/\bWindows(?:.+)ARM\b/i,Qu=/BlackBerry/i,td=/BB10/i,ed=/Opera Mini/i,rd=/\b(CriOS|Chrome)(?:.+)Mobile/i,id=/Mobile(?:.+)Firefox\b/i,nd=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function zv(r){return function(t){return t.test(r)}}function sd(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 n=zv(e),s={apple:{phone:n(ka)&&!n(gr),ipod:n(Yu),tablet:!n(ka)&&(n(qu)||nd(t))&&!n(gr),universal:n(Ku),device:(n(ka)||n(Yu)||n(qu)||n(Ku)||nd(t))&&!n(gr)},amazon:{phone:n($i),tablet:!n($i)&&n(As),device:n($i)||n(As)},android:{phone:!n(gr)&&n($i)||!n(gr)&&n(Ua),tablet:!n(gr)&&!n($i)&&!n(Ua)&&(n(As)||n(Zu)),device:!n(gr)&&(n($i)||n(As)||n(Ua)||n(Zu))||n(/\bokhttp\b/i)},windows:{phone:n(gr),tablet:n(Ju),device:n(gr)||n(Ju)},other:{blackberry:n(Qu),blackberry10:n(td),opera:n(ed),firefox:n(id),chrome:n(rd),device:n(Qu)||n(td)||n(ed)||n(id)||n(rd)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}const jv=sd.default??sd,yr=jv(globalThis.navigator);tt.RETINA_PREFIX=/@([0-9\.]+)x/,tt.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var od={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function n(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function s(l,h,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new n(c,u||l,d),p=e?e+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,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=[],c,u;if(this._eventsCount===0)return h;for(u in c=this._events)t.call(c,u)&&h.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=e?e+h:h,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(h){var c=e?e+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,f,p){var g=e?e+h:h;if(!this._events[g])return!1;var y=this._events[g],_=arguments.length,v,m;if(y.fn){switch(y.once&&this.removeListener(h,y.fn,void 0,!0),_){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,c),!0;case 3:return y.fn.call(y.context,c,u),!0;case 4:return y.fn.call(y.context,c,u,d),!0;case 5:return y.fn.call(y.context,c,u,d,f),!0;case 6:return y.fn.call(y.context,c,u,d,f,p),!0}for(m=1,v=new Array(_-1);m<_;m++)v[m-1]=arguments[m];y.fn.apply(y.context,v)}else{var b=y.length,S;for(m=0;m<b;m++)switch(y[m].once&&this.removeListener(h,y[m].fn,void 0,!0),_){case 1:y[m].fn.call(y[m].context);break;case 2:y[m].fn.call(y[m].context,c);break;case 3:y[m].fn.call(y[m].context,c,u);break;case 4:y[m].fn.call(y[m].context,c,u,d);break;default:if(!v)for(S=1,v=new Array(_-1);S<_;S++)v[S-1]=arguments[S];y[m].fn.apply(y[m].context,v)}}return!0},a.prototype.on=function(h,c,u){return s(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return s(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var f=e?e+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var g=0,y=[],_=p.length;g<_;g++)(p[g].fn!==c||d&&!p[g].once||u&&p[g].context!==u)&&y.push(p[g]);y.length?this._events[f]=y.length===1?y[0]:y:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=e?e+h:h,this._events[c]&&o(this,c)):(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})(od);var Wv=od.exports;const Rn=Aa(Wv);var Ga={exports:{}};Ga.exports=Ss,Ga.exports.default=Ss;function Ss(r,t,e){e=e||2;var i=t&&t.length,n=i?t[0]*e:r.length,s=ad(r,0,n,e,!0),o=[];if(!s||s.next===s.prev)return o;var a,l,h,c,u,d,f;if(i&&(s=Jv(r,t,s,e)),r.length>80*e){a=h=r[0],l=c=r[1];for(var p=e;p<n;p+=e)u=r[p],d=r[p+1],u<a&&(a=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);f=Math.max(h-a,c-l),f=f!==0?32767/f:0}return Mn(s,o,e,a,l,f,0),o}function ad(r,t,e,i,n){var s,o;if(n===Xa(r,t,e,i)>0)for(s=t;s<e;s+=i)o=cd(s,r[s],r[s+1],o);else for(s=e-i;s>=t;s-=i)o=cd(s,r[s],r[s+1],o);return o&&Cs(o,o.next)&&(Bn(o),o=o.next),o}function ni(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Cs(e,e.next)||$t(e.prev,e,e.next)===0)){if(Bn(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Mn(r,t,e,i,n,s,o){if(r){!o&&s&&i1(r,i,n,s);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,s?qv(r,i,n,s):Yv(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),Bn(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=Kv(ni(r),t,e),Mn(r,t,e,i,n,s,2)):o===2&&Zv(r,t,e,i,n,s):Mn(ni(r),t,e,i,n,s,1);break}}}}function Yv(r){var t=r.prev,e=r,i=r.next;if($t(t,e,i)>=0)return!1;for(var n=t.x,s=e.x,o=i.x,a=t.y,l=e.y,h=i.y,c=n<s?n<o?n:o:s<o?s:o,u=a<l?a<h?a:h:l<h?l:h,d=n>s?n>o?n:o:s>o?s:o,f=a>l?a>h?a:h:l>h?l:h,p=i.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&Hi(n,a,s,l,o,h,p.x,p.y)&&$t(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function qv(r,t,e,i){var n=r.prev,s=r,o=r.next;if($t(n,s,o)>=0)return!1;for(var a=n.x,l=s.x,h=o.x,c=n.y,u=s.y,d=o.y,f=a<l?a<h?a:h:l<h?l:h,p=c<u?c<d?c:d:u<d?u:d,g=a>l?a>h?a:h:l>h?l:h,y=c>u?c>d?c:d:u>d?u:d,_=$a(f,p,t,e,i),v=$a(g,y,t,e,i),m=r.prevZ,b=r.nextZ;m&&m.z>=_&&b&&b.z<=v;){if(m.x>=f&&m.x<=g&&m.y>=p&&m.y<=y&&m!==n&&m!==o&&Hi(a,c,l,u,h,d,m.x,m.y)&&$t(m.prev,m,m.next)>=0||(m=m.prevZ,b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==n&&b!==o&&Hi(a,c,l,u,h,d,b.x,b.y)&&$t(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;m&&m.z>=_;){if(m.x>=f&&m.x<=g&&m.y>=p&&m.y<=y&&m!==n&&m!==o&&Hi(a,c,l,u,h,d,m.x,m.y)&&$t(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==n&&b!==o&&Hi(a,c,l,u,h,d,b.x,b.y)&&$t(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Kv(r,t,e){var i=r;do{var n=i.prev,s=i.next.next;!Cs(n,s)&&ld(n,i,i.next,s)&&Dn(n,s)&&Dn(s,n)&&(t.push(n.i/e|0),t.push(i.i/e|0),t.push(s.i/e|0),Bn(i),Bn(i.next),i=r=s),i=i.next}while(i!==r);return ni(i)}function Zv(r,t,e,i,n,s){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&o1(o,a)){var l=hd(o,a);o=ni(o,o.next),l=ni(l,l.next),Mn(o,t,e,i,n,s,0),Mn(l,t,e,i,n,s,0);return}a=a.next}o=o.next}while(o!==r)}function Jv(r,t,e,i){var n=[],s,o,a,l,h;for(s=0,o=t.length;s<o;s++)a=t[s]*i,l=s<o-1?t[s+1]*i:r.length,h=ad(r,a,l,i,!1),h===h.next&&(h.steiner=!0),n.push(s1(h));for(n.sort(Qv),s=0;s<n.length;s++)e=t1(n[s],e);return e}function Qv(r,t){return r.x-t.x}function t1(r,t){var e=e1(r,t);if(!e)return t;var i=hd(e,r);return ni(i,i.next),ni(e,e.next)}function e1(r,t){var e=t,i=r.x,n=r.y,s=-1/0,o;do{if(n<=e.y&&n>=e.next.y&&e.next.y!==e.y){var a=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>s&&(s=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,c=o.y,u=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&Hi(n<c?i:s,n,h,c,n<c?s:i,n,e.x,e.y)&&(d=Math.abs(n-e.y)/(i-e.x),Dn(e,r)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&r1(o,e)))&&(o=e,u=d)),e=e.next;while(e!==l);return o}function r1(r,t){return $t(r.prev,r,t.prev)<0&&$t(t.next,r,r.next)<0}function i1(r,t,e,i){var n=r;do n.z===0&&(n.z=$a(n.x,n.y,t,e,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==r);n.prevZ.nextZ=null,n.prevZ=null,n1(n)}function n1(r){var t,e,i,n,s,o,a,l,h=1;do{for(e=r,r=null,s=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)?(n=e,e=e.nextZ,a--):(n=i,i=i.nextZ,l--),s?s.nextZ=n:r=n,n.prevZ=s,s=n;e=i}s.nextZ=null,h*=2}while(o>1);return r}function $a(r,t,e,i,n){return r=(r-e)*n|0,t=(t-i)*n|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 s1(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 Hi(r,t,e,i,n,s,o,a){return(n-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(n-o)*(i-a)}function o1(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!a1(r,t)&&(Dn(r,t)&&Dn(t,r)&&l1(r,t)&&($t(r.prev,r,t.prev)||$t(r,t.prev,t))||Cs(r,t)&&$t(r.prev,r,r.next)>0&&$t(t.prev,t,t.next)>0)}function $t(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Cs(r,t){return r.x===t.x&&r.y===t.y}function ld(r,t,e,i){var n=Ps($t(r,t,e)),s=Ps($t(r,t,i)),o=Ps($t(e,i,r)),a=Ps($t(e,i,t));return!!(n!==s&&o!==a||n===0&&Is(r,e,t)||s===0&&Is(r,i,t)||o===0&&Is(e,r,i)||a===0&&Is(e,t,i))}function Is(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 Ps(r){return r>0?1:r<0?-1:0}function a1(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&&ld(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Dn(r,t){return $t(r.prev,r,r.next)<0?$t(r,t,r.next)>=0&&$t(r,r.prev,t)>=0:$t(r,t,r.prev)<0||$t(r,r.next,t)<0}function l1(r,t){var e=r,i=!1,n=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&n<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function hd(r,t){var e=new Ha(r.i,r.x,r.y),i=new Ha(t.i,t.x,t.y),n=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=n,n.prev=e,i.next=e,e.prev=i,s.next=i,i.prev=s,i}function cd(r,t,e,i){var n=new Ha(r,t,e);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function Bn(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 Ha(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}Ss.deviation=function(r,t,e,i){var n=t&&t.length,s=n?t[0]*e:r.length,o=Math.abs(Xa(r,0,s,e));if(n)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,c=a<l-1?t[a+1]*e:r.length;o-=Math.abs(Xa(r,h,c,e))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,f=i[a+1]*e,p=i[a+2]*e;u+=Math.abs((r[d]-r[p])*(r[f+1]-r[d+1])-(r[d]-r[f])*(r[p+1]-r[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function Xa(r,t,e,i){for(var n=0,s=t,o=e-i;s<e;s+=i)n+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return n}Ss.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,n=0;n<r.length;n++){for(var s=0;s<r[n].length;s++)for(var o=0;o<t;o++)e.vertices.push(r[n][s][o]);n>0&&(i+=r[n-1].length,e.holes.push(i))}return e};var h1=Ga.exports;const c1=Aa(h1);var Rs={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */Rs.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,n=r&&!r.nodeType&&r,s=typeof Cn=="object"&&Cn;(s.global===s||s.window===s||s.self===s)&&(e=s);var o,a=2147483647,l=36,h=1,c=26,u=38,d=700,f=72,p=128,g="-",y=/^xn--/,_=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,m={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},b=l-h,S=Math.floor,R=String.fromCharCode,C;function I(O){throw new RangeError(m[O])}function M(O,B){for(var k=O.length,V=[];k--;)V[k]=B(O[k]);return V}function F(O,B){var k=O.split("@"),V="";k.length>1&&(V=k[0]+"@",O=k[1]),O=O.replace(v,".");var z=O.split("."),K=M(z,B).join(".");return V+K}function U(O){for(var B=[],k=0,V=O.length,z,K;k<V;)z=O.charCodeAt(k++),z>=55296&&z<=56319&&k<V?(K=O.charCodeAt(k++),(K&64512)==56320?B.push(((z&1023)<<10)+(K&1023)+65536):(B.push(z),k--)):B.push(z);return B}function P(O){return M(O,function(B){var k="";return B>65535&&(B-=65536,k+=R(B>>>10&1023|55296),B=56320|B&1023),k+=R(B),k}).join("")}function T(O){return O-48<10?O-22:O-65<26?O-65:O-97<26?O-97:l}function E(O,B){return O+22+75*(O<26)-((B!=0)<<5)}function A(O,B,k){var V=0;for(O=k?S(O/d):O>>1,O+=S(O/B);O>b*c>>1;V+=l)O=S(O/b);return S(V+(b+1)*O/(O+u))}function L(O){var B=[],k=O.length,V,z=0,K=p,X=f,ft,H,mt,J,ut,gt,Et,Dt,Yt;for(ft=O.lastIndexOf(g),ft<0&&(ft=0),H=0;H<ft;++H)O.charCodeAt(H)>=128&&I("not-basic"),B.push(O.charCodeAt(H));for(mt=ft>0?ft+1:0;mt<k;){for(J=z,ut=1,gt=l;mt>=k&&I("invalid-input"),Et=T(O.charCodeAt(mt++)),(Et>=l||Et>S((a-z)/ut))&&I("overflow"),z+=Et*ut,Dt=gt<=X?h:gt>=X+c?c:gt-X,!(Et<Dt);gt+=l)Yt=l-Dt,ut>S(a/Yt)&&I("overflow"),ut*=Yt;V=B.length+1,X=A(z-J,V,J==0),S(z/V)>a-K&&I("overflow"),K+=S(z/V),z%=V,B.splice(z++,0,K)}return P(B)}function D(O){var B,k,V,z,K,X,ft,H,mt,J,ut,gt=[],Et,Dt,Yt,Vt;for(O=U(O),Et=O.length,B=p,k=0,K=f,X=0;X<Et;++X)ut=O[X],ut<128&&gt.push(R(ut));for(V=z=gt.length,z&&gt.push(g);V<Et;){for(ft=a,X=0;X<Et;++X)ut=O[X],ut>=B&&ut<ft&&(ft=ut);for(Dt=V+1,ft-B>S((a-k)/Dt)&&I("overflow"),k+=(ft-B)*Dt,B=ft,X=0;X<Et;++X)if(ut=O[X],ut<B&&++k>a&&I("overflow"),ut==B){for(H=k,mt=l;J=mt<=K?h:mt>=K+c?c:mt-K,!(H<J);mt+=l)Vt=H-J,Yt=l-J,gt.push(R(E(J+Vt%Yt,0))),H=S(Vt/Yt);gt.push(R(E(H,0))),K=A(k,Dt,V==z),k=0,++V}++k,++B}return gt.join("")}function N(O){return F(O,function(B){return y.test(B)?L(B.slice(4).toLowerCase()):B})}function $(O){return F(O,function(B){return _.test(B)?"xn--"+D(B):B})}if(o={version:"1.4.1",ucs2:{decode:U,encode:P},decode:L,encode:D,toASCII:$,toUnicode:N},i&&n)if(r.exports==i)n.exports=o;else for(C in o)o.hasOwnProperty(C)&&(i[C]=o[C]);else e.punycode=o})(Cn)}(Rs,Rs.exports);var u1=Rs.exports,Xi=TypeError;const d1=j_(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Va=typeof Map=="function"&&Map.prototype,za=Object.getOwnPropertyDescriptor&&Va?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Ms=Va&&za&&typeof za.get=="function"?za.get:null,ud=Va&&Map.prototype.forEach,ja=typeof Set=="function"&&Set.prototype,Wa=Object.getOwnPropertyDescriptor&&ja?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Ds=ja&&Wa&&typeof Wa.get=="function"?Wa.get:null,dd=ja&&Set.prototype.forEach,f1=typeof WeakMap=="function"&&WeakMap.prototype,On=f1?WeakMap.prototype.has:null,p1=typeof WeakSet=="function"&&WeakSet.prototype,Ln=p1?WeakSet.prototype.has:null,m1=typeof WeakRef=="function"&&WeakRef.prototype,fd=m1?WeakRef.prototype.deref:null,g1=Boolean.prototype.valueOf,y1=Object.prototype.toString,_1=Function.prototype.toString,v1=String.prototype.match,Ya=String.prototype.slice,Nr=String.prototype.replace,b1=String.prototype.toUpperCase,pd=String.prototype.toLowerCase,md=RegExp.prototype.test,gd=Array.prototype.concat,sr=Array.prototype.join,x1=Array.prototype.slice,yd=Math.floor,qa=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ka=Object.getOwnPropertySymbols,Za=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Vi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Nn=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Vi||!0)?Symbol.toStringTag:null,_d=Object.prototype.propertyIsEnumerable,vd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function bd(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||md.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-yd(-r):yd(r);if(i!==r){var n=String(i),s=Ya.call(t,n.length+1);return Nr.call(n,e,"$&_")+"."+Nr.call(Nr.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Nr.call(t,e,"$&_")}var Ja=d1,xd=Ja.custom,wd=Sd(xd)?xd:null,Ed={__proto__:null,double:'"',single:"'"},w1={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Bs=function r(t,e,i,n){var s=e||{};if(_r(s,"quoteStyle")&&!_r(Ed,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(_r(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=_r(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(_r(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(_r(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.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 Id(t,s);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?bd(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?bd(t,h):h}var c=typeof s.depth>"u"?5:s.depth;if(typeof i>"u"&&(i=0),i>=c&&c>0&&typeof t=="object")return Qa(t)?"[Array]":"[Object]";var u=G1(s,i);if(typeof n>"u")n=[];else if(Cd(n,t)>=0)return"[Circular]";function d(T,E,A){if(E&&(n=x1.call(n),n.push(E)),A){var L={depth:s.depth};return _r(s,"quoteStyle")&&(L.quoteStyle=s.quoteStyle),r(T,L,i+1,n)}return r(T,s,i+1,n)}if(typeof t=="function"&&!Ad(t)){var f=M1(t),p=Os(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+sr.call(p,", ")+" }":"")}if(Sd(t)){var g=Vi?Nr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Za.call(t);return typeof t=="object"&&!Vi?Fn(g):g}if(F1(t)){for(var y="<"+pd.call(String(t.nodeName)),_=t.attributes||[],v=0;v<_.length;v++)y+=" "+_[v].name+"="+Td(E1(_[v].value),"double",s);return y+=">",t.childNodes&&t.childNodes.length&&(y+="..."),y+="</"+pd.call(String(t.nodeName))+">",y}if(Qa(t)){if(t.length===0)return"[]";var m=Os(t,d);return u&&!U1(m)?"["+el(m,u)+"]":"[ "+sr.call(m,", ")+" ]"}if(A1(t)){var b=Os(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!_d.call(t,"cause")?"{ ["+String(t)+"] "+sr.call(gd.call("[cause]: "+d(t.cause),b),", ")+" }":b.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+sr.call(b,", ")+" }"}if(typeof t=="object"&&o){if(wd&&typeof t[wd]=="function"&&Ja)return Ja(t,{depth:c-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(D1(t)){var S=[];return ud&&ud.call(t,function(T,E){S.push(d(E,t,!0)+" => "+d(T,t))}),Pd("Map",Ms.call(t),S,u)}if(L1(t)){var R=[];return dd&&dd.call(t,function(T){R.push(d(T,t))}),Pd("Set",Ds.call(t),R,u)}if(B1(t))return tl("WeakMap");if(N1(t))return tl("WeakSet");if(O1(t))return tl("WeakRef");if(C1(t))return Fn(d(Number(t)));if(P1(t))return Fn(d(qa.call(t)));if(I1(t))return Fn(g1.call(t));if(S1(t))return Fn(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof Cn<"u"&&t===Cn)return"{ [object globalThis] }";if(!T1(t)&&!Ad(t)){var C=Os(t,d),I=vd?vd(t)===Object.prototype:t instanceof Object||t.constructor===Object,M=t instanceof Object?"":"null prototype",F=!I&&Nn&&Object(t)===t&&Nn in t?Ya.call(Fr(t),8,-1):M?"Object":"",U=I||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",P=U+(F||M?"["+sr.call(gd.call([],F||[],M||[]),": ")+"] ":"");return C.length===0?P+"{}":u?P+"{"+el(C,u)+"}":P+"{ "+sr.call(C,", ")+" }"}return String(t)};function Td(r,t,e){var i=e.quoteStyle||t,n=Ed[i];return n+r+n}function E1(r){return Nr.call(String(r),/"/g,"&quot;")}function si(r){return!Nn||!(typeof r=="object"&&(Nn in r||typeof r[Nn]<"u"))}function Qa(r){return Fr(r)==="[object Array]"&&si(r)}function T1(r){return Fr(r)==="[object Date]"&&si(r)}function Ad(r){return Fr(r)==="[object RegExp]"&&si(r)}function A1(r){return Fr(r)==="[object Error]"&&si(r)}function S1(r){return Fr(r)==="[object String]"&&si(r)}function C1(r){return Fr(r)==="[object Number]"&&si(r)}function I1(r){return Fr(r)==="[object Boolean]"&&si(r)}function Sd(r){if(Vi)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Za)return!1;try{return Za.call(r),!0}catch{}return!1}function P1(r){if(!r||typeof r!="object"||!qa)return!1;try{return qa.call(r),!0}catch{}return!1}var R1=Object.prototype.hasOwnProperty||function(r){return r in this};function _r(r,t){return R1.call(r,t)}function Fr(r){return y1.call(r)}function M1(r){if(r.name)return r.name;var t=v1.call(_1.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Cd(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 D1(r){if(!Ms||!r||typeof r!="object")return!1;try{Ms.call(r);try{Ds.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function B1(r){if(!On||!r||typeof r!="object")return!1;try{On.call(r,On);try{Ln.call(r,Ln)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function O1(r){if(!fd||!r||typeof r!="object")return!1;try{return fd.call(r),!0}catch{}return!1}function L1(r){if(!Ds||!r||typeof r!="object")return!1;try{Ds.call(r);try{Ms.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function N1(r){if(!Ln||!r||typeof r!="object")return!1;try{Ln.call(r,Ln);try{On.call(r,On)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function F1(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Id(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return Id(Ya.call(r,0,t.maxStringLength),t)+i}var n=w1[t.quoteStyle||"single"];n.lastIndex=0;var s=Nr.call(Nr.call(r,n,"\\$1"),/[\x00-\x1f]/g,k1);return Td(s,"single",t)}function k1(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":"")+b1.call(t.toString(16))}function Fn(r){return"Object("+r+")"}function tl(r){return r+" { ? }"}function Pd(r,t,e,i){var n=i?el(e,i):sr.call(e,", ");return r+" ("+t+") {"+n+"}"}function U1(r){for(var t=0;t<r.length;t++)if(Cd(r[t],`
2
- `)>=0)return!1;return!0}function G1(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=sr.call(Array(r.indent+1)," ");else return null;return{base:e,prev:sr.call(Array(t+1),e)}}function el(r,t){if(r.length===0)return"";var e=`
3
- `+t.prev+t.base;return e+sr.call(r,","+e)+`
4
- `+t.prev}function Os(r,t){var e=Qa(r),i=[];if(e){i.length=r.length;for(var n=0;n<r.length;n++)i[n]=_r(r,n)?t(r[n],r):""}var s=typeof Ka=="function"?Ka(r):[],o;if(Vi){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var l in r)_r(r,l)&&(e&&String(Number(l))===l&&l<r.length||Vi&&o["$"+l]instanceof Symbol||(md.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof Ka=="function")for(var h=0;h<s.length;h++)_d.call(r,s[h])&&i.push("["+t(s[h])+"]: "+t(r[s[h]],r));return i}var $1=Bs,H1=Xi,Ls=function(r,t,e){for(var i=r,n;(n=i.next)!=null;i=n)if(n.key===t)return i.next=n.next,e||(n.next=r.next,r.next=n),n},X1=function(r,t){if(r){var e=Ls(r,t);return e&&e.value}},V1=function(r,t,e){var i=Ls(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},z1=function(r,t){return r?!!Ls(r,t):!1},j1=function(r,t){if(r)return Ls(r,t,!0)},W1=function(){var t,e={assert:function(i){if(!e.has(i))throw new H1("Side channel does not contain "+$1(i))},delete:function(i){var n=t&&t.next,s=j1(t,i);return s&&n&&n===s&&(t=void 0),!!s},get:function(i){return X1(t,i)},has:function(i){return z1(t,i)},set:function(i,n){t||(t={next:void 0}),V1(t,i,n)}};return e},Rd=Object,Y1=Error,q1=EvalError,K1=RangeError,Z1=ReferenceError,J1=SyntaxError,Q1=URIError,tb=Math.abs,eb=Math.floor,rb=Math.max,ib=Math.min,nb=Math.pow,sb=Math.round,ob=Number.isNaN||function(t){return t!==t},ab=ob,lb=function(t){return ab(t)||t===0?t:t<0?-1:1},hb=Object.getOwnPropertyDescriptor,Ns=hb;if(Ns)try{Ns([],"length")}catch{Ns=null}var Md=Ns,Fs=Object.defineProperty||!1;if(Fs)try{Fs({},"a",{value:1})}catch{Fs=!1}var cb=Fs,rl,Dd;function ub(){return Dd||(Dd=1,rl=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 n=42;t[e]=n;for(var s 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!==n||a.enumerable!==!0)return!1}return!0}),rl}var il,Bd;function db(){if(Bd)return il;Bd=1;var r=typeof Symbol<"u"&&Symbol,t=ub();return il=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},il}var nl,Od;function Ld(){return Od||(Od=1,nl=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),nl}var sl,Nd;function Fd(){if(Nd)return sl;Nd=1;var r=Rd;return sl=r.getPrototypeOf||null,sl}var fb="Function.prototype.bind called on incompatible ",pb=Object.prototype.toString,mb=Math.max,gb="[object Function]",kd=function(t,e){for(var i=[],n=0;n<t.length;n+=1)i[n]=t[n];for(var s=0;s<e.length;s+=1)i[s+t.length]=e[s];return i},yb=function(t,e){for(var i=[],n=e,s=0;n<t.length;n+=1,s+=1)i[s]=t[n];return i},_b=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},vb=function(t){var e=this;if(typeof e!="function"||pb.apply(e)!==gb)throw new TypeError(fb+e);for(var i=yb(arguments,1),n,s=function(){if(this instanceof n){var c=e.apply(this,kd(i,arguments));return Object(c)===c?c:this}return e.apply(t,kd(i,arguments))},o=mb(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(n=Function("binder","return function ("+_b(a,",")+"){ return binder.apply(this,arguments); }")(s),e.prototype){var h=function(){};h.prototype=e.prototype,n.prototype=new h,h.prototype=null}return n},bb=vb,ks=Function.prototype.bind||bb,ol=Function.prototype.call,al,Ud;function Gd(){return Ud||(Ud=1,al=Function.prototype.apply),al}var xb=typeof Reflect<"u"&&Reflect&&Reflect.apply,wb=ks,Eb=Gd(),Tb=ol,Ab=xb,Sb=Ab||wb.call(Tb,Eb),Cb=ks,Ib=Xi,Pb=ol,Rb=Sb,$d=function(t){if(t.length<1||typeof t[0]!="function")throw new Ib("a function is required");return Rb(Cb,Pb,t)},ll,Hd;function Mb(){if(Hd)return ll;Hd=1;var r=$d,t=Md,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__"),n=Object,s=n.getPrototypeOf;return ll=i&&typeof i.get=="function"?r([i.get]):typeof s=="function"?function(a){return s(a==null?a:n(a))}:!1,ll}var hl,Xd;function Db(){if(Xd)return hl;Xd=1;var r=Ld(),t=Fd(),e=Mb();return hl=r?function(n){return r(n)}:t?function(n){if(!n||typeof n!="object"&&typeof n!="function")throw new TypeError("getProto: not an object");return t(n)}:e?function(n){return e(n)}:null,hl}var cl,Vd;function Bb(){if(Vd)return cl;Vd=1;var r=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=ks;return cl=e.call(r,t),cl}var Tt,Ob=Rd,Lb=Y1,Nb=q1,Fb=K1,kb=Z1,zi=J1,ji=Xi,Ub=Q1,Gb=tb,$b=eb,Hb=rb,Xb=ib,Vb=nb,zb=sb,jb=lb,zd=Function,ul=function(r){try{return zd('"use strict"; return ('+r+").constructor;")()}catch{}},kn=Md,Wb=cb,dl=function(){throw new ji},Yb=kn?function(){try{return arguments.callee,dl}catch{try{return kn(arguments,"callee").get}catch{return dl}}}():dl,Wi=db()(),ce=Db(),qb=Fd(),Kb=Ld(),jd=Gd(),Un=ol,Yi={},Zb=typeof Uint8Array>"u"||!ce?Tt:ce(Uint8Array),oi={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?Tt:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Tt:ArrayBuffer,"%ArrayIteratorPrototype%":Wi&&ce?ce([][Symbol.iterator]()):Tt,"%AsyncFromSyncIteratorPrototype%":Tt,"%AsyncFunction%":Yi,"%AsyncGenerator%":Yi,"%AsyncGeneratorFunction%":Yi,"%AsyncIteratorPrototype%":Yi,"%Atomics%":typeof Atomics>"u"?Tt:Atomics,"%BigInt%":typeof BigInt>"u"?Tt:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Tt:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Tt:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Tt:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Lb,"%eval%":eval,"%EvalError%":Nb,"%Float16Array%":typeof Float16Array>"u"?Tt:Float16Array,"%Float32Array%":typeof Float32Array>"u"?Tt:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Tt:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Tt:FinalizationRegistry,"%Function%":zd,"%GeneratorFunction%":Yi,"%Int8Array%":typeof Int8Array>"u"?Tt:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Tt:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Tt:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Wi&&ce?ce(ce([][Symbol.iterator]())):Tt,"%JSON%":typeof JSON=="object"?JSON:Tt,"%Map%":typeof Map>"u"?Tt:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Wi||!ce?Tt:ce(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Ob,"%Object.getOwnPropertyDescriptor%":kn,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Tt:Promise,"%Proxy%":typeof Proxy>"u"?Tt:Proxy,"%RangeError%":Fb,"%ReferenceError%":kb,"%Reflect%":typeof Reflect>"u"?Tt:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Tt:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Wi||!ce?Tt:ce(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Tt:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Wi&&ce?ce(""[Symbol.iterator]()):Tt,"%Symbol%":Wi?Symbol:Tt,"%SyntaxError%":zi,"%ThrowTypeError%":Yb,"%TypedArray%":Zb,"%TypeError%":ji,"%Uint8Array%":typeof Uint8Array>"u"?Tt:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Tt:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Tt:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Tt:Uint32Array,"%URIError%":Ub,"%WeakMap%":typeof WeakMap>"u"?Tt:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Tt:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Tt:WeakSet,"%Function.prototype.call%":Un,"%Function.prototype.apply%":jd,"%Object.defineProperty%":Wb,"%Object.getPrototypeOf%":qb,"%Math.abs%":Gb,"%Math.floor%":$b,"%Math.max%":Hb,"%Math.min%":Xb,"%Math.pow%":Vb,"%Math.round%":zb,"%Math.sign%":jb,"%Reflect.getPrototypeOf%":Kb};if(ce)try{null.error}catch(r){var Jb=ce(ce(r));oi["%Error.prototype%"]=Jb}var Qb=function r(t){var e;if(t==="%AsyncFunction%")e=ul("async function () {}");else if(t==="%GeneratorFunction%")e=ul("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=ul("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var n=r("%AsyncGenerator%");n&&ce&&(e=ce(n.prototype))}return oi[t]=e,e},Wd={__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"]},Gn=ks,Us=Bb(),tx=Gn.call(Un,Array.prototype.concat),ex=Gn.call(jd,Array.prototype.splice),Yd=Gn.call(Un,String.prototype.replace),Gs=Gn.call(Un,String.prototype.slice),rx=Gn.call(Un,RegExp.prototype.exec),ix=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,nx=/\\(\\)?/g,sx=function(t){var e=Gs(t,0,1),i=Gs(t,-1);if(e==="%"&&i!=="%")throw new zi("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new zi("invalid intrinsic syntax, expected opening `%`");var n=[];return Yd(t,ix,function(s,o,a,l){n[n.length]=a?Yd(l,nx,"$1"):o||s}),n},ox=function(t,e){var i=t,n;if(Us(Wd,i)&&(n=Wd[i],i="%"+n[0]+"%"),Us(oi,i)){var s=oi[i];if(s===Yi&&(s=Qb(i)),typeof s>"u"&&!e)throw new ji("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:n,name:i,value:s}}throw new zi("intrinsic "+t+" does not exist!")},fl=function(t,e){if(typeof t!="string"||t.length===0)throw new ji("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new ji('"allowMissing" argument must be a boolean');if(rx(/^%?[^%]*%?$/,t)===null)throw new zi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=sx(t),n=i.length>0?i[0]:"",s=ox("%"+n+"%",e),o=s.name,a=s.value,l=!1,h=s.alias;h&&(n=h[0],ex(i,tx([0,1],h)));for(var c=1,u=!0;c<i.length;c+=1){var d=i[c],f=Gs(d,0,1),p=Gs(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new zi("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(l=!0),n+="."+d,o="%"+n+"%",Us(oi,o))a=oi[o];else if(a!=null){if(!(d in a)){if(!e)throw new ji("base intrinsic for "+t+" exists, but the property is not available.");return}if(kn&&c+1>=i.length){var g=kn(a,d);u=!!g,u&&"get"in g&&!("originalValue"in g.get)?a=g.get:a=a[d]}else u=Us(a,d),a=a[d];u&&!l&&(oi[o]=a)}}return a},qd=fl,Kd=$d,ax=Kd([qd("%String.prototype.indexOf%")]),Zd=function(t,e){var i=qd(t,!!e);return typeof i=="function"&&ax(t,".prototype.")>-1?Kd([i]):i},lx=fl,$n=Zd,hx=Bs,cx=Xi,Jd=lx("%Map%",!0),ux=$n("Map.prototype.get",!0),dx=$n("Map.prototype.set",!0),fx=$n("Map.prototype.has",!0),px=$n("Map.prototype.delete",!0),mx=$n("Map.prototype.size",!0),Qd=!!Jd&&function(){var t,e={assert:function(i){if(!e.has(i))throw new cx("Side channel does not contain "+hx(i))},delete:function(i){if(t){var n=px(t,i);return mx(t)===0&&(t=void 0),n}return!1},get:function(i){if(t)return ux(t,i)},has:function(i){return t?fx(t,i):!1},set:function(i,n){t||(t=new Jd),dx(t,i,n)}};return e},gx=fl,$s=Zd,yx=Bs,Hs=Qd,_x=Xi,qi=gx("%WeakMap%",!0),vx=$s("WeakMap.prototype.get",!0),bx=$s("WeakMap.prototype.set",!0),xx=$s("WeakMap.prototype.has",!0),wx=$s("WeakMap.prototype.delete",!0),Ex=qi?function(){var t,e,i={assert:function(n){if(!i.has(n))throw new _x("Side channel does not contain "+yx(n))},delete:function(n){if(qi&&n&&(typeof n=="object"||typeof n=="function")){if(t)return wx(t,n)}else if(Hs&&e)return e.delete(n);return!1},get:function(n){return qi&&n&&(typeof n=="object"||typeof n=="function")&&t?vx(t,n):e&&e.get(n)},has:function(n){return qi&&n&&(typeof n=="object"||typeof n=="function")&&t?xx(t,n):!!e&&e.has(n)},set:function(n,s){qi&&n&&(typeof n=="object"||typeof n=="function")?(t||(t=new qi),bx(t,n,s)):Hs&&(e||(e=Hs()),e.set(n,s))}};return i}:Hs,Tx=Xi,Ax=Bs,Sx=W1,Cx=Qd,Ix=Ex,Px=Ix||Cx||Sx,Rx=function(){var t,e={assert:function(i){if(!e.has(i))throw new Tx("Side channel does not contain "+Ax(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,n){t||(t=Px()),t.set(i,n)}};return e},Mx=String.prototype.replace,Dx=/%20/g,pl={RFC1738:"RFC1738",RFC3986:"RFC3986"},ml={default:pl.RFC3986,formatters:{RFC1738:function(r){return Mx.call(r,Dx,"+")},RFC3986:function(r){return String(r)}},RFC1738:pl.RFC1738,RFC3986:pl.RFC3986},Bx=ml,gl=Object.prototype.hasOwnProperty,ai=Array.isArray,or=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),Ox=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(ai(i)){for(var n=[],s=0;s<i.length;++s)typeof i[s]<"u"&&n.push(i[s]);e.obj[e.prop]=n}}},tf=function(t,e){for(var i=e&&e.plainObjects?{__proto__:null}:{},n=0;n<t.length;++n)typeof t[n]<"u"&&(i[n]=t[n]);return i},Lx=function r(t,e,i){if(!e)return t;if(typeof e!="object"&&typeof e!="function"){if(ai(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!gl.call(Object.prototype,e))&&(t[e]=!0);else return[t,e];return t}if(!t||typeof t!="object")return[t].concat(e);var n=t;return ai(t)&&!ai(e)&&(n=tf(t,i)),ai(t)&&ai(e)?(e.forEach(function(s,o){if(gl.call(t,o)){var a=t[o];a&&typeof a=="object"&&s&&typeof s=="object"?t[o]=r(a,s,i):t.push(s)}else t[o]=s}),t):Object.keys(e).reduce(function(s,o){var a=e[o];return gl.call(s,o)?s[o]=r(s[o],a,i):s[o]=a,s},n)},Nx=function(t,e){return Object.keys(e).reduce(function(i,n){return i[n]=e[n],i},t)},Fx=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}},yl=1024,kx=function(t,e,i,n,s){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(f){return"%26%23"+parseInt(f.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;l+=yl){for(var h=o.length>=yl?o.slice(l,l+yl):o,c=[],u=0;u<h.length;++u){var d=h.charCodeAt(u);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||s===Bx.RFC1738&&(d===40||d===41)){c[c.length]=h.charAt(u);continue}if(d<128){c[c.length]=or[d];continue}if(d<2048){c[c.length]=or[192|d>>6]+or[128|d&63];continue}if(d<55296||d>=57344){c[c.length]=or[224|d>>12]+or[128|d>>6&63]+or[128|d&63];continue}u+=1,d=65536+((d&1023)<<10|h.charCodeAt(u)&1023),c[c.length]=or[240|d>>18]+or[128|d>>12&63]+or[128|d>>6&63]+or[128|d&63]}a+=c.join("")}return a},Ux=function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],n=0;n<e.length;++n)for(var s=e[n],o=s.obj[s.prop],a=Object.keys(o),l=0;l<a.length;++l){var h=a[l],c=o[h];typeof c=="object"&&c!==null&&i.indexOf(c)===-1&&(e.push({obj:o,prop:h}),i.push(c))}return Ox(e),t},Gx=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},$x=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},Hx=function(t,e){return[].concat(t,e)},Xx=function(t,e){if(ai(t)){for(var i=[],n=0;n<t.length;n+=1)i.push(e(t[n]));return i}return e(t)},ef={arrayToObject:tf,assign:Nx,combine:Hx,compact:Ux,decode:Fx,encode:kx,isBuffer:$x,isRegExp:Gx,maybeMap:Xx,merge:Lx},rf=Rx,Xs=ef,Hn=ml,Vx=Object.prototype.hasOwnProperty,nf={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},ar=Array.isArray,zx=Array.prototype.push,sf=function(r,t){zx.apply(r,ar(t)?t:[t])},jx=Date.prototype.toISOString,of=Hn.default,ne={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Xs.encode,encodeValuesOnly:!1,filter:void 0,format:of,formatter:Hn.formatters[of],indices:!1,serializeDate:function(t){return jx.call(t)},skipNulls:!1,strictNullHandling:!1},Wx=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},_l={},Yx=function r(t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v){for(var m=t,b=v,S=0,R=!1;(b=b.get(_l))!==void 0&&!R;){var C=b.get(t);if(S+=1,typeof C<"u"){if(C===S)throw new RangeError("Cyclic object value");R=!0}typeof b.get(_l)>"u"&&(S=0)}if(typeof c=="function"?m=c(e,m):m instanceof Date?m=f(m):i==="comma"&&ar(m)&&(m=Xs.maybeMap(m,function(O){return O instanceof Date?f(O):O})),m===null){if(o)return h&&!y?h(e,ne.encoder,_,"key",p):e;m=""}if(Wx(m)||Xs.isBuffer(m)){if(h){var I=y?e:h(e,ne.encoder,_,"key",p);return[g(I)+"="+g(h(m,ne.encoder,_,"value",p))]}return[g(e)+"="+g(String(m))]}var M=[];if(typeof m>"u")return M;var F;if(i==="comma"&&ar(m))y&&h&&(m=Xs.maybeMap(m,h)),F=[{value:m.length>0?m.join(",")||null:void 0}];else if(ar(c))F=c;else{var U=Object.keys(m);F=u?U.sort(u):U}var P=l?String(e).replace(/\./g,"%2E"):String(e),T=n&&ar(m)&&m.length===1?P+"[]":P;if(s&&ar(m)&&m.length===0)return T+"[]";for(var E=0;E<F.length;++E){var A=F[E],L=typeof A=="object"&&A&&typeof A.value<"u"?A.value:m[A];if(!(a&&L===null)){var D=d&&l?String(A).replace(/\./g,"%2E"):String(A),N=ar(m)?typeof i=="function"?i(T,D):T:T+(d?"."+D:"["+D+"]");v.set(t,S);var $=rf();$.set(_l,v),sf(M,r(L,N,i,n,s,o,a,l,i==="comma"&&y&&ar(m)?null:h,c,u,d,f,p,g,y,_,$))}}return M},qx=function(t){if(!t)return ne;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||ne.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=Hn.default;if(typeof t.format<"u"){if(!Vx.call(Hn.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var n=Hn.formatters[i],s=ne.filter;(typeof t.filter=="function"||ar(t.filter))&&(s=t.filter);var o;if(t.arrayFormat in nf?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=ne.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:ne.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:ne.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:ne.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:ne.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?ne.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:ne.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:ne.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:ne.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:ne.encodeValuesOnly,filter:s,format:i,formatter:n,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:ne.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:ne.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:ne.strictNullHandling}},Kx=function(r,t){var e=r,i=qx(t),n,s;typeof i.filter=="function"?(s=i.filter,e=s("",e)):ar(i.filter)&&(s=i.filter,n=s);var o=[];if(typeof e!="object"||e===null)return"";var a=nf[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;n||(n=Object.keys(e)),i.sort&&n.sort(i.sort);for(var h=rf(),c=0;c<n.length;++c){var u=n[c],d=e[u];i.skipNulls&&d===null||sf(o,Yx(d,u,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 f=o.join(i.delimiter),p=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?p+="utf8=%26%2310003%3B&":p+="utf8=%E2%9C%93&"),f.length>0?p+f:""},li=ef,vl=Object.prototype.hasOwnProperty,af=Array.isArray,Wt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:li.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},Zx=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},lf=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},Jx="utf8=%26%2310003%3B",Qx="utf8=%E2%9C%93",tw=function(t,e){var i={__proto__:null},n=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;n=n.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var s=e.parameterLimit===1/0?void 0:e.parameterLimit,o=n.split(e.delimiter,e.throwOnLimitExceeded?s+1:s);if(e.throwOnLimitExceeded&&o.length>s)throw new RangeError("Parameter limit exceeded. Only "+s+" parameter"+(s===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]===Qx?h="utf-8":o[l]===Jx&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var c=o[l],u=c.indexOf("]="),d=u===-1?c.indexOf("="):u+1,f,p;d===-1?(f=e.decoder(c,Wt.decoder,h,"key"),p=e.strictNullHandling?null:""):(f=e.decoder(c.slice(0,d),Wt.decoder,h,"key"),p=li.maybeMap(lf(c.slice(d+1),e,af(i[f])?i[f].length:0),function(y){return e.decoder(y,Wt.decoder,h,"value")})),p&&e.interpretNumericEntities&&h==="iso-8859-1"&&(p=Zx(String(p))),c.indexOf("[]=")>-1&&(p=af(p)?[p]:p);var g=vl.call(i,f);g&&e.duplicates==="combine"?i[f]=li.combine(i[f],p):(!g||e.duplicates==="last")&&(i[f]=p)}return i},ew=function(r,t,e,i){var n=0;if(r.length>0&&r[r.length-1]==="[]"){var s=r.slice(0,-1).join("");n=Array.isArray(t)&&t[s]?t[s].length:0}for(var o=i?t:lf(t,e,n),a=r.length-1;a>=0;--a){var l,h=r[a];if(h==="[]"&&e.parseArrays)l=e.allowEmptyArrays&&(o===""||e.strictNullHandling&&o===null)?[]:li.combine([],o);else{l=e.plainObjects?{__proto__:null}:{};var c=h.charAt(0)==="["&&h.charAt(h.length-1)==="]"?h.slice(1,-1):h,u=e.decodeDotInKeys?c.replace(/%2E/g,"."):c,d=parseInt(u,10);!e.parseArrays&&u===""?l={0:o}:!isNaN(d)&&h!==u&&String(d)===u&&d>=0&&e.parseArrays&&d<=e.arrayLimit?(l=[],l[d]=o):u!=="__proto__"&&(l[u]=o)}o=l}return o},rw=function(t,e,i,n){if(t){var s=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=i.depth>0&&o.exec(s),h=l?s.slice(0,l.index):s,c=[];if(h){if(!i.plainObjects&&vl.call(Object.prototype,h)&&!i.allowPrototypes)return;c.push(h)}for(var u=0;i.depth>0&&(l=a.exec(s))!==null&&u<i.depth;){if(u+=1,!i.plainObjects&&vl.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;c.push(l[1])}if(l){if(i.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+i.depth+" and strictDepth is true");c.push("["+s.slice(l.index)+"]")}return ew(c,e,i,n)}},iw=function(t){if(!t)return Wt;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"?Wt.charset:t.charset,i=typeof t.duplicates>"u"?Wt.duplicates:t.duplicates;if(i!=="combine"&&i!=="first"&&i!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var n=typeof t.allowDots>"u"?t.decodeDotInKeys===!0?!0:Wt.allowDots:!!t.allowDots;return{allowDots:n,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Wt.allowEmptyArrays,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Wt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Wt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Wt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Wt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Wt.comma,decodeDotInKeys:typeof t.decodeDotInKeys=="boolean"?t.decodeDotInKeys:Wt.decodeDotInKeys,decoder:typeof t.decoder=="function"?t.decoder:Wt.decoder,delimiter:typeof t.delimiter=="string"||li.isRegExp(t.delimiter)?t.delimiter:Wt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Wt.depth,duplicates:i,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Wt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Wt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Wt.plainObjects,strictDepth:typeof t.strictDepth=="boolean"?!!t.strictDepth:Wt.strictDepth,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Wt.strictNullHandling,throwOnLimitExceeded:typeof t.throwOnLimitExceeded=="boolean"?t.throwOnLimitExceeded:!1}},nw=function(r,t){var e=iw(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?{__proto__:null}:{};for(var i=typeof r=="string"?tw(r,e):r,n=e.plainObjects?{__proto__:null}:{},s=Object.keys(i),o=0;o<s.length;++o){var a=s[o],l=rw(a,i[a],e,typeof r=="string");n=li.merge(n,l,e)}return e.allowSparse===!0?n:li.compact(n)},sw=Kx,ow=nw,aw=ml,lw={formats:aw,parse:ow,stringify:sw},hw=u1;function vr(){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 cw=/^([a-z0-9.+-]+:)/i,uw=/:[0-9]*$/,dw=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,fw=["<",">",'"',"`"," ","\r",`
5
- `," "],pw=["{","}","|","\\","^","`"].concat(fw),bl=["'"].concat(pw),hf=["%","/","?",";","#"].concat(bl),cf=["/","?","#"],mw=255,uf=/^[+a-z0-9A-Z_-]{0,63}$/,gw=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,yw={javascript:!0,"javascript:":!0},xl={javascript:!0,"javascript:":!0},Ki={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},wl=lw;function _w(r,t,e){if(r&&typeof r=="object"&&r instanceof vr)return r;var i=new vr;return i.parse(r,t,e),i}vr.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("?"),n=i!==-1&&i<r.indexOf("#")?"?":"#",s=r.split(n),o=/\\/g;s[0]=s[0].replace(o,"/"),r=s.join(n);var a=r;if(a=a.trim(),!e&&r.split("#").length===1){var l=dw.exec(a);if(l)return this.path=a,this.href=a,this.pathname=l[1],l[2]?(this.search=l[2],t?this.query=wl.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=cw.exec(a);if(h){h=h[0];var c=h.toLowerCase();this.protocol=c,a=a.substr(h.length)}if(e||h||a.match(/^\/\/[^@/]+@[^@/]+/)){var u=a.substr(0,2)==="//";u&&!(h&&xl[h])&&(a=a.substr(2),this.slashes=!0)}if(!xl[h]&&(u||h&&!Ki[h])){for(var d=-1,f=0;f<cf.length;f++){var p=a.indexOf(cf[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var g,y;d===-1?y=a.lastIndexOf("@"):y=a.lastIndexOf("@",d),y!==-1&&(g=a.slice(0,y),a=a.slice(y+1),this.auth=decodeURIComponent(g)),d=-1;for(var f=0;f<hf.length;f++){var p=a.indexOf(hf[f]);p!==-1&&(d===-1||p<d)&&(d=p)}d===-1&&(d=a.length),this.host=a.slice(0,d),a=a.slice(d),this.parseHost(),this.hostname=this.hostname||"";var _=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!_)for(var v=this.hostname.split(/\./),f=0,m=v.length;f<m;f++){var b=v[f];if(b&&!b.match(uf)){for(var S="",R=0,C=b.length;R<C;R++)b.charCodeAt(R)>127?S+="x":S+=b[R];if(!S.match(uf)){var I=v.slice(0,f),M=v.slice(f+1),F=b.match(gw);F&&(I.push(F[1]),M.unshift(F[2])),M.length&&(a="/"+M.join(".")+a),this.hostname=I.join(".");break}}}this.hostname.length>mw?this.hostname="":this.hostname=this.hostname.toLowerCase(),_||(this.hostname=hw.toASCII(this.hostname));var U=this.port?":"+this.port:"",P=this.hostname||"";this.host=P+U,this.href+=this.host,_&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!yw[c])for(var f=0,m=bl.length;f<m;f++){var T=bl[f];if(a.indexOf(T)!==-1){var E=encodeURIComponent(T);E===T&&(E=escape(T)),a=a.split(T).join(E)}}var A=a.indexOf("#");A!==-1&&(this.hash=a.substr(A),a=a.slice(0,A));var L=a.indexOf("?");if(L!==-1?(this.search=a.substr(L),this.query=a.substr(L+1),t&&(this.query=wl.parse(this.query)),a=a.slice(0,L)):t&&(this.search="",this.query={}),a&&(this.pathname=a),Ki[c]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var U=this.pathname||"",D=this.search||"";this.path=U+D}return this.href=this.format(),this},vr.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||"",n=!1,s="";this.host?n=r+this.host:this.hostname&&(n=r+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(n+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(s=wl.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||s&&"?"+s||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||Ki[t])&&n!==!1?(n="//"+(n||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):n||(n=""),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+n+e+o+i},vr.prototype.resolve=function(r){return this.resolveObject(_w(r,!1,!0)).format()},vr.prototype.resolveObject=function(r){if(typeof r=="string"){var t=new vr;t.parse(r,!1,!0),r=t}for(var e=new vr,i=Object.keys(this),n=0;n<i.length;n++){var s=i[n];e[s]=this[s]}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 Ki[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(!Ki[r.protocol]){for(var h=Object.keys(r),c=0;c<h.length;c++){var u=h[c];e[u]=r[u]}return e.href=e.format(),e}if(e.protocol=r.protocol,!r.host&&!xl[r.protocol]){for(var m=(r.pathname||"").split("/");m.length&&!(r.host=m.shift()););r.host||(r.host=""),r.hostname||(r.hostname=""),m[0]!==""&&m.unshift(""),m.length<2&&m.unshift(""),e.pathname=m.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||"",f=e.search||"";e.path=d+f}return e.slashes=e.slashes||r.slashes,e.href=e.format(),e}var p=e.pathname&&e.pathname.charAt(0)==="/",g=r.host||r.pathname&&r.pathname.charAt(0)==="/",y=g||p||e.host&&r.pathname,_=y,v=e.pathname&&e.pathname.split("/")||[],m=r.pathname&&r.pathname.split("/")||[],b=e.protocol&&!Ki[e.protocol];if(b&&(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&&(m[0]===""?m[0]=r.host:m.unshift(r.host)),r.host=null),y=y&&(m[0]===""||v[0]==="")),g)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=m;else if(m.length)v||(v=[]),v.pop(),v=v.concat(m),e.search=r.search,e.query=r.query;else if(r.search!=null){if(b){e.host=v.shift(),e.hostname=e.host;var S=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;S&&(e.auth=S.shift(),e.hostname=S.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 R=v.slice(-1)[0],C=(e.host||r.host||v.length>1)&&(R==="."||R==="..")||R==="",I=0,M=v.length;M>=0;M--)R=v[M],R==="."?v.splice(M,1):R===".."?(v.splice(M,1),I++):I&&(v.splice(M,1),I--);if(!y&&!_)for(;I--;I)v.unshift("..");y&&v[0]!==""&&(!v[0]||v[0].charAt(0)!=="/")&&v.unshift(""),C&&v.join("/").substr(-1)!=="/"&&v.push("");var F=v[0]===""||v[0]&&v[0].charAt(0)==="/";if(b){e.hostname=F?"":v.length?v.shift():"",e.host=e.hostname;var S=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;S&&(e.auth=S.shift(),e.hostname=S.shift(),e.host=e.hostname)}return y=y||e.host&&v.length,y&&!F&&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},vr.prototype.parseHost=function(){var r=this.host,t=uw.exec(r);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),r=r.substr(0,r.length-t.length)),r&&(this.hostname=r)};const df={};function At(r,t,e=3){if(df[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
1
+ (function(qt,se){typeof exports=="object"&&typeof module<"u"?se(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],se):(qt=typeof globalThis<"u"?globalThis:qt||self,se(qt.AnnotoriousOSD={},qt.OpenSeadragon))})(this,function(qt,se){"use strict";var dC=Object.defineProperty;var fC=(qt,se,Zr)=>se in qt?dC(qt,se,{enumerable:!0,configurable:!0,writable:!0,value:Zr}):qt[se]=Zr;var Oh=(qt,se,Zr)=>fC(qt,typeof se!="symbol"?se+"":se,Zr);var Zr=Object.prototype.hasOwnProperty;function Qr(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--&&Qr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Zr.call(r,e)&&++i&&!Zr.call(t,e)||!(e in t)||!Qr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}var $o=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))($o||{});const fe=[];for(let r=0;r<256;++r)fe.push((r+256).toString(16).slice(1));function Jm(r,t=0){return(fe[r[t+0]]+fe[r[t+1]]+fe[r[t+2]]+fe[r[t+3]]+"-"+fe[r[t+4]]+fe[r[t+5]]+"-"+fe[r[t+6]]+fe[r[t+7]]+"-"+fe[r[t+8]]+fe[r[t+9]]+"-"+fe[r[t+10]]+fe[r[t+11]]+fe[r[t+12]]+fe[r[t+13]]+fe[r[t+14]]+fe[r[t+15]]).toLowerCase()}let Ho;const tg=new Uint8Array(16);function eg(){if(!Ho){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ho=crypto.getRandomValues.bind(crypto)}return Ho(tg)}const rg=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Hh={randomUUID:rg};function ig(r,t,e){var i;r=r||{};const n=r.random??((i=r.rng)==null?void 0:i.call(r))??eg();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Jm(n)}function ng(r,t,e){return Hh.randomUUID&&!r?Hh.randomUUID():ig(r)}const Xo=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)}},sg=(r,t,e,i)=>({id:ng(),annotation:typeof r=="string"?r:r.id,created:e||new Date,creator:i,...t}),og=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},ag=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},lg=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(n=>n.id===e.id);return{newBody:e,oldBody:i&&!Qr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),hg=(r,t)=>!Qr(r.target,t.target),cg=(r,t)=>{const e=og(r,t),i=ag(r,t),n=lg(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:n.length>0?n:void 0,targetUpdated:hg(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Rr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Rr||{});const ug=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),n=new Set((t.created||[]).map(u=>u.id)),s=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!s.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!n.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!s.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(g=>g.oldValue.id===f.id).newValue;return cg(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}};let dg=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,n=e.length;i<n;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(n=>t!==n)}}});const fg=250,pg=(r,t)=>{const e=dg(),i=(t==null?void 0:t.changes)||[];let n=t?t.pointer:-1,s=!1,o=0;const a=p=>{if(!s){const{changes:g}=p,y=performance.now();if(y-o>fg)i.splice(n+1),i.push(g),n=i.length-1;else{const _=i.length-1;i[_]=ug(i[_],g)}o=y}s=!1};r.observe(a,{origin:Rr.LOCAL});const l=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p),h=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),c=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({oldValue:g})=>g)),u=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({newValue:g})=>g)),d=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),f=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p);return{canRedo:()=>i.length-1>n,canUndo:()=>n>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:n}),on:(p,g)=>e.on(p,g),redo:()=>{if(i.length-1>n){s=!0;const{created:p,updated:g,deleted:y}=i[n+1];h(p),u(g),f(y),e.emit("redo",i[n+1]),n+=1}},undo:()=>{if(n>-1){s=!0;const{created:p,updated:g,deleted:y}=i[n];l(p),c(g),d(y),e.emit("undo",i[n]),n-=1}}}},mg=(r,t,e,i)=>{const{hover:n,selection:s,store:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(_,v)=>{l.has(_)?l.get(_).push(v):l.set(_,[v])},f=(_,v)=>{const m=l.get(_);if(m){const b=m.indexOf(v);b!==-1&&m.splice(b,1)}},p=(_,v,m)=>{l.has(_)&&setTimeout(()=>{l.get(_).forEach(b=>{if(e){const S=Array.isArray(v)?v.map(C=>e.serialize(C)):e.serialize(v),R=m?m instanceof PointerEvent?m:e.serialize(m):void 0;b(S,R)}else b(v,m)})},1)},g=()=>{const{selected:_}=s,v=(_||[]).map(({id:m})=>o.getAnnotation(m));v.forEach(m=>{const b=h.find(S=>S.id===m.id);(!b||!Qr(b,m))&&p("updateAnnotation",m,b)}),h=h.map(m=>v.find(({id:S})=>S===m.id)||m)};s.subscribe(({selected:_})=>{if(!(h.length===0&&_.length===0)){if(h.length===0&&_.length>0)h=_.map(({id:v})=>o.getAnnotation(v));else if(h.length>0&&_.length===0)h.forEach(v=>{const m=o.getAnnotation(v.id);m&&!Qr(m,v)&&p("updateAnnotation",m,v)}),h=[];else{const v=new Set(h.map(b=>b.id)),m=new Set(_.map(({id:b})=>b));h.filter(b=>!m.has(b.id)).forEach(b=>{const S=o.getAnnotation(b.id);S&&!Qr(S,b)&&p("updateAnnotation",S,b)}),h=[...h.filter(b=>m.has(b.id)),..._.filter(({id:b})=>!v.has(b)).map(({id:b})=>o.getAnnotation(b))]}p("selectionChanged",h)}}),n.subscribe(_=>{!c&&_?p("mouseEnterAnnotation",o.getAnnotation(_)):c&&!_?p("mouseLeaveAnnotation",o.getAnnotation(c)):c&&_&&(p("mouseLeaveAnnotation",o.getAnnotation(c)),p("mouseEnterAnnotation",o.getAnnotation(_))),c=_}),a==null||a.subscribe(_=>p("viewportIntersect",_.map(v=>o.getAnnotation(v)))),o.observe(_=>{i&&(u&&clearTimeout(u),u=setTimeout(g,1e3));const{created:v,deleted:m}=_.changes;(v||[]).forEach(b=>p("createAnnotation",b)),(m||[]).forEach(b=>p("deleteAnnotation",b)),(_.changes.updated||[]).filter(b=>[...b.bodiesCreated||[],...b.bodiesDeleted||[],...b.bodiesUpdated||[]].length>0).forEach(({oldValue:b,newValue:S})=>{const R=h.find(C=>C.id===b.id)||b;h=h.map(C=>C.id===b.id?S:C),p("updateAnnotation",S,R)})},{origin:Rr.LOCAL}),o.observe(_=>{if(h){const v=new Set(h.map(b=>b.id)),m=(_.changes.updated||[]).filter(({newValue:b})=>v.has(b.id)).map(({newValue:b})=>b);m.length>0&&(h=h.map(b=>m.find(R=>R.id===b.id)||b))}},{origin:Rr.REMOTE});const y=_=>v=>{const{updated:m}=v;_?(m||[]).forEach(b=>p("updateAnnotation",b.oldValue,b.newValue)):(m||[]).forEach(b=>p("updateAnnotation",b.newValue,b.oldValue))};return t.on("undo",y(!0)),t.on("redo",y(!1)),{on:d,off:f,emit:p}},gg=r=>t=>t.reduce((e,i)=>{const{parsed:n,error:s}=r.parse(i);return s?{parsed:e.parsed,failed:[...e.failed,i]}:n?{parsed:[...e.parsed,n],failed:e.failed}:{...e}},{parsed:[],failed:[]}),yg=(r,t,e)=>{const{store:i,selection:n}=r,s=_=>{if(e){const{parsed:v,error:m}=e.parse(_);v?i.addAnnotation(v,Rr.REMOTE):console.error(m)}else i.addAnnotation(Xo(_),Rr.REMOTE)},o=()=>n.clear(),a=()=>i.clear(),l=_=>{const v=i.getAnnotation(_);return e&&v?e.serialize(v):v},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var _;const v=(((_=n.selected)==null?void 0:_.map(m=>m.id))||[]).map(m=>i.getAnnotation(m)).filter(Boolean);return e?v.map(e.serialize):v},u=(_,v=!0)=>fetch(_).then(m=>m.json()).then(m=>(f(m,v),m)),d=_=>{if(typeof _=="string"){const v=i.getAnnotation(_);if(i.deleteAnnotation(_),v)return e?e.serialize(v):v}else{const v=e?e.parse(_).parsed:_;if(v)return i.deleteAnnotation(v),_}},f=(_,v=!0)=>{if(e){const m=e.parseAll||gg(e),{parsed:b,failed:S}=m(_);S.length>0&&console.warn(`Discarded ${S.length} invalid annotations`,S),i.bulkAddAnnotations(b,v,Rr.REMOTE)}else i.bulkAddAnnotations(_.map(Xo),v,Rr.REMOTE)},p=(_,v)=>{_?n.setSelected(_,v):n.clear()},g=_=>{n.setUserSelectAction(_)},y=_=>{if(e){const v=e.parse(_).parsed,m=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),m}else{const v=i.getAnnotation(_.id);return i.updateAnnotation(Xo(_)),v}};return{addAnnotation:s,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:g,undo:t.undo,updateAnnotation:y}},_g="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let vg=r=>crypto.getRandomValues(new Uint8Array(r)),bg=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,n=-~(1.6*i*t/r.length);return(s=t)=>{let o="";for(;;){let a=e(n),l=n|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=s)return o}}},xg=(r,t=21)=>bg(r,t|0,vg),wg=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=_g[e[r]&63];return t};const Eg=()=>({isGuest:!0,id:xg("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Tg=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],Ag=()=>{const r=[...Tg];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};wg();var Sg=Object.defineProperty,Cg=(r,t,e)=>t in r?Sg(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xh=(r,t,e)=>Cg(r,typeof t!="symbol"?t+"":t,e);function Rt(){}function Vo(r,t){for(const e in t)r[e]=t[e];return r}function Vh(r){return r()}function zh(){return Object.create(null)}function Me(r){r.forEach(Vh)}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 Ig(r){return Object.keys(r).length===0}function jh(r,...t){if(r==null){for(const i of t)i(void 0);return Rt}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function zo(r,t,e){r.$$.on_destroy.push(jh(t,e))}function Pg(r,t,e,i){if(r){const n=Wh(r,t,e,i);return r[0](n)}}function Wh(r,t,e,i){return r[1]&&i?Vo(e.ctx.slice(),r[1](i(t))):e.ctx}function Rg(r,t,e,i){if(r[2]&&i){const n=r[2](i(e));if(t.dirty===void 0)return n;if(typeof n=="object"){const s=[],o=Math.max(t.dirty.length,n.length);for(let a=0;a<o;a+=1)s[a]=t.dirty[a]|n[a];return s}return t.dirty|n}return t.dirty}function Mg(r,t,e,i,n,s){if(n){const o=Wh(t,e,i,s);r.p(o,n)}}function Dg(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 Yh(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Ai(r){return r??""}function xt(r,t){r.appendChild(t)}function nt(r,t,e){r.insertBefore(t,e||null)}function rt(r){r.parentNode&&r.parentNode.removeChild(r)}function Jr(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function W(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function qh(r){return document.createTextNode(r)}function we(){return qh(" ")}function De(){return qh("")}function St(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function x(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Bg(r){return Array.from(r.childNodes)}function Je(r,t,e){r.classList.toggle(t,!!e)}function Og(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let _n;function vn(r){_n=r}function Kh(){if(!_n)throw new Error("Function called outside component initialization");return _n}function ti(r){Kh().$$.on_mount.push(r)}function Mr(){const r=Kh();return(t,e,{cancelable:i=!1}={})=>{const n=r.$$.callbacks[t];if(n){const s=Og(t,e,{cancelable:i});return n.slice().forEach(o=>{o.call(r,s)}),!s.defaultPrevented}return!0}}function oe(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Si=[],as=[];let Ci=[];const Zh=[],Qh=Promise.resolve();let jo=!1;function Jh(){jo||(jo=!0,Qh.then(ec))}function tc(){return Jh(),Qh}function Wo(r){Ci.push(r)}const Yo=new Set;let Ii=0;function ec(){if(Ii!==0)return;const r=_n;do{try{for(;Ii<Si.length;){const t=Si[Ii];Ii++,vn(t),Lg(t.$$)}}catch(t){throw Si.length=0,Ii=0,t}for(vn(null),Si.length=0,Ii=0;as.length;)as.pop()();for(let t=0;t<Ci.length;t+=1){const e=Ci[t];Yo.has(e)||(Yo.add(e),e())}Ci.length=0}while(Si.length);for(;Zh.length;)Zh.pop()();jo=!1,Yo.clear(),vn(r)}function Lg(r){if(r.fragment!==null){r.update(),Me(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Wo)}}function Ng(r){const t=[],e=[];Ci.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Ci=t}const ls=new Set;let ei;function Ee(){ei={r:0,c:[],p:ei}}function Te(){ei.r||Me(ei.c),ei=ei.p}function lt(r,t){r&&r.i&&(ls.delete(r),r.i(t))}function yt(r,t,e,i){if(r&&r.o){if(ls.has(r))return;ls.add(r),ei.c.push(()=>{ls.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function Ie(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function re(r){r&&r.c()}function Jt(r,t,e){const{fragment:i,after_update:n}=r.$$;i&&i.m(t,e),Wo(()=>{const s=r.$$.on_mount.map(Vh).filter(Gt);r.$$.on_destroy?r.$$.on_destroy.push(...s):Me(s),r.$$.on_mount=[]}),n.forEach(Wo)}function te(r,t){const e=r.$$;e.fragment!==null&&(Ng(e.after_update),Me(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Fg(r,t){r.$$.dirty[0]===-1&&(Si.push(r),Jh(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function pe(r,t,e,i,n,s,o=null,a=[-1]){const l=_n;vn(r);const h=r.$$={fragment:null,ctx:[],props:s,update:Rt,not_equal:n,bound:zh(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:zh(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&n(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&Fg(r,u)),d}):[],h.update(),c=!0,Me(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=Bg(t.target);h.fragment&&h.fragment.l(u),u.forEach(rt)}else h.fragment&&h.fragment.c();t.intro&&lt(r.$$.fragment),Jt(r,t.target,t.anchor),ec()}vn(l)}class me{constructor(){Xh(this,"$$"),Xh(this,"$$set")}$destroy(){te(this,1),this.$destroy=Rt}$on(t,e){if(!Gt(e))return Rt;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const n=i.indexOf(e);n!==-1&&i.splice(n,1)}}$set(t){this.$$set&&!Ig(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const kg="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(kg);var _t=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGON="MULTIPOLYGON",r.POLYGON="POLYGON",r.POLYLINE="POLYLINE",r.RECTANGLE="RECTANGLE",r.LINE="LINE",r))(_t||{}),Ug={exports:{}};(function(r){(function(){function t(a,l){var h=a.x-l.x,c=a.y-l.y;return h*h+c*c}function e(a,l,h){var c=l.x,u=l.y,d=h.x-c,f=h.y-u;if(d!==0||f!==0){var p=((a.x-c)*d+(a.y-u)*f)/(d*d+f*f);p>1?(c=h.x,u=h.y):p>0&&(c+=d*p,u+=f*p)}return d=a.x-c,f=a.y-u,d*d+f*f}function i(a,l){for(var h=a[0],c=[h],u,d=1,f=a.length;d<f;d++)u=a[d],t(u,h)>l&&(c.push(u),h=u);return h!==u&&c.push(u),c}function n(a,l,h,c,u){for(var d=c,f,p=l+1;p<h;p++){var g=e(a[p],a[l],a[h]);g>d&&(f=p,d=g)}d>c&&(f-l>1&&n(a,l,f,c,u),u.push(a[f]),h-f>1&&n(a,f,h,c,u))}function s(a,l){var h=a.length-1,c=[a[0]];return n(a,0,h,l,c),c.push(a[h]),c}function o(a,l,h){if(a.length<=2)return a;var c=l!==void 0?l*l:1;return a=h?a:i(a,c),a=s(a,c),a}r.exports=o,r.exports.default=o})()})(Ug);const qo={},Pi=(r,t)=>qo[r]=t,Ko=r=>qo[r.type].area(r),Gg=(r,t,e,i)=>qo[r.type].intersects(r,t,e,i),Ae=r=>{let t=1/0,e=1/0,i=-1/0,n=-1/0;return r.forEach(([s,o])=>{t=Math.min(t,s),e=Math.min(e,o),i=Math.max(i,s),n=Math.max(n,o)}),{minX:t,minY:e,maxX:i,maxY:n}},hs=r=>{let t=0,e=r.length-1;for(let i=0;i<r.length;i++)t+=(r[e][0]+r[i][0])*(r[e][1]-r[i][1]),e=i;return Math.abs(.5*t)},cs=(r,t,e)=>{let i=!1;for(let n=0,s=r.length-1;n<r.length;s=n++){const o=r[n][0],a=r[n][1],l=r[s][0],h=r[s][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},$g=(r,t=!0)=>{let e="M ";return r.forEach(([i,n],s)=>{s===0?e+=`${i},${n}`:e+=` L ${i},${n}`}),t&&(e+=" Z"),e},us=(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))},Hg={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:n,rx:s,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),c=t-i,u=e-n,d=l*c+h*u,f=h*c-l*u;return d*d/(s*s)+f*f/(o*o)<=1}};Pi(_t.ELLIPSE,Hg);const Xg={area:r=>0,intersects:(r,t,e,i=2)=>{const[[n,s],[o,a]]=r.geometry.points,l=Math.abs((a-s)*t-(o-n)*e+o*s-a*n),h=us([n,s],[o,a]);return l/h<=i}};Pi(_t.LINE,Xg);const Vg={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[n,...s]=i.rings,o=hs(n.points),a=s.reduce((l,h)=>l+hs(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const n of i){const[s,...o]=n.rings;if(cs(s.points,t,e)){let a=!1;for(const l of o)if(cs(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},Zo=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return Ae(t)},He=r=>r.rings.map(t=>$g(t.points)).join(" "),zg=r=>r.polygons.reduce((t,e)=>[...t,...e.rings.reduce((i,n)=>[...i,...n.points],[])],[]);Pi(_t.MULTIPOLYGON,Vg);const jg={area:r=>{const t=r.geometry.points;return hs(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return cs(i,t,e)}};Pi(_t.POLYGON,jg);const Wg={area:r=>{const t=r.geometry;if(!t.closed||t.points.length<3)return 0;const e=Qo(t.points,t.closed);return hs(e)},intersects:(r,t,e,i=2)=>{const n=r.geometry;if(n.closed){const s=Qo(n.points,n.closed);return cs(s,t,e)}else return Yg(n,[t,e],i)}},Qo=(r,t=!1)=>{const e=[];for(let i=0;i<r.length;i++){const n=r[i],s=r[(i+1)%r.length];if(e.push(n.point),(i<r.length-1||t)&&(n.type==="CURVE"||s.type=="CURVE")){const o=rc(n.point,n.type==="CURVE"&&n.outHandle||n.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,10);e.push(...o.slice(1))}}return e},rc=(r,t,e,i,n=10)=>{const s=[];for(let o=0;o<=n;o++){const a=o/n,l=Math.pow(1-a,3)*r[0]+3*Math.pow(1-a,2)*a*t[0]+3*(1-a)*Math.pow(a,2)*e[0]+Math.pow(a,3)*i[0],h=Math.pow(1-a,3)*r[1]+3*Math.pow(1-a,2)*a*t[1]+3*(1-a)*Math.pow(a,2)*e[1]+Math.pow(a,3)*i[1];s.push([l,h])}return s},Yg=(r,t,e)=>{for(let i=0;i<r.points.length-1;i++){const n=r.points[i],s=r.points[i+1];if(n.type==="CURVE"||s.type==="CURVE"){const o=rc(n.point,n.type==="CURVE"&&n.outHandle||n.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,20);for(let a=0;a<o.length-1;a++)if(ic(t,o[a],o[a+1])<=e)return!0}else if(ic(t,n.point,s.point)<=e)return!0}return!1},ic=(r,t,e)=>{const[i,n]=r,[s,o]=t,[a,l]=e,h=a-s,c=l-o,u=Math.sqrt(h*h+c*c);if(u===0)return Math.sqrt((i-s)*(i-s)+(n-o)*(n-o));const d=((i-s)*h+(n-o)*c)/(u*u);return d<=0?Math.sqrt((i-s)*(i-s)+(n-o)*(n-o)):d>=1?Math.sqrt((i-a)*(i-a)+(n-l)*(n-l)):Math.abs((l-o)*i-(a-s)*n+a*o-l*s)/u},Jo=r=>{if(!r.points||r.points.length===0)return"";const t=[],e=r.points[0];t.push(`M ${e.point[0]} ${e.point[1]}`);for(let i=1;i<r.points.length;i++){const n=r.points[i],s=r.points[i-1];if(n.type==="CURVE"||s.type==="CURVE"){const o=s.type==="CURVE"&&s.outHandle||s.point,a=n.type==="CURVE"&&n.inHandle||n.point,l=n.point;t.push(`C ${o[0]} ${o[1]} ${a[0]} ${a[1]} ${l[0]} ${l[1]}`)}else t.push(`L ${n.point[0]} ${n.point[1]}`)}if(r.closed){const i=r.points[r.points.length-1],n=r.points[0];if(i.type==="CURVE"||n.type==="CURVE"){const s=i.outHandle||i.point,o=n.inHandle||n.point,a=n.point;t.push(`C ${s[0]} ${s[1]} ${o[0]} ${o[1]} ${a[0]} ${a[1]}`)}t.push("Z")}return t.join(" ")};Pi(_t.POLYLINE,Wg);const qg={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};Pi(_t.RECTANGLE,qg);const Le=r=>ds(r.target),ds=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},Kg=(r,t=!1)=>{const e=typeof r=="string"?r:r.value,i=/(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g,n=[...e.matchAll(i)][0],[s,o,a,l,h,c,u]=n;if(o!=="xywh")throw new Error("Unsupported MediaFragment: "+e);if(a&&a!=="pixel")throw new Error(`Unsupported MediaFragment unit: ${a}`);const[d,f,p,g]=[l,h,c,u].map(parseFloat);return{type:_t.RECTANGLE,geometry:{x:d,y:f,w:p,h:g,bounds:{minX:d,minY:t?f-g:f,maxX:d+p,maxY:t?f:f+g}}}},Zg=r=>{const{x:t,y:e,w:i,h:n}=r;return{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=pixel:${t},${e},${i},${n}`}},nc="http://www.w3.org/2000/svg",sc=r=>{const t=i=>{Array.from(i.attributes).forEach(n=>{n.name.startsWith("on")&&i.removeAttribute(n.name)})},e=r.getElementsByTagName("script");return Array.from(e).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(r.querySelectorAll("*")).forEach(t),r},Qg=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${nc}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},fs=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(nc),i=t.lookupNamespaceURI(null);return e||i?sc(t).firstChild:sc(Qg(t)).firstChild},Jg=r=>{const t=oc(r),e=[];let i=[],n=[0,0];for(const s of t)switch(s.type.toUpperCase()){case"M":i.length>0&&(e.push({points:i}),i=[]),n=[s.args[0],s.args[1]],i.push([...n]);break;case"L":n=[s.args[0],s.args[1]],i.push([...n]);break;case"H":n=[s.args[0],n[1]],i.push([...n]);break;case"V":n=[n[0],s.args[0]],i.push([...n]);break;case"C":n=[s.args[4],s.args[5]],i.push([...n]);break;case"Z":break;default:console.warn(`Unsupported SVG path command: ${s.type}`);break}if(i.length>2&&e.push({points:i}),e.length>0){const s=Ae(e[0].points);return{rings:e,bounds:s}}},ty=r=>{const{point:t,inHandle:e,outHandle:i}=r;if(!e||!i)return!1;const n=e[0]-t[0],s=e[1]-t[1],o=i[0]-t[0],a=i[1]-t[1],l=n*a-s*o;return Math.abs(l)<.01},ey=r=>{const t=oc(r);let e=[],i=[0,0],n=!1;for(let o=0;o<t.length;o++){const a=t[o];switch(a.type.toUpperCase()){case"M":i=[a.args[0],a.args[1]],e.push({type:"CORNER",point:[...i]});break;case"L":i=[a.args[0],a.args[1]],e.push({type:"CORNER",point:[...i]});break;case"C":const l=[a.args[0],a.args[1]],h=[a.args[2],a.args[3]],c=[a.args[4],a.args[5]];if(e.length>0){const d=e[e.length-1];(l[0]!==d.point[0]||l[1]!==d.point[1])&&(d.type="CURVE",d.outHandle=l)}const u={type:h[0]!==c[0]||h[1]!==c[1]?"CURVE":"CORNER",point:c};u.type==="CURVE"&&(u.inHandle=h),e.push(u),i=c;break;case"Z":n=!0;break;default:console.warn(`Unsupported SVG path command: ${a.type}`);break}}e=e.map(o=>ty(o)?{...o,locked:!0}:o);const s=Ae(Qo(e,n));return{points:e,closed:n,bounds:s}},oc=r=>{const t=[],e=r.replace(/,/g," ").trim(),i=/([MmLlHhVvCcZz])\s*([^MmLlHhVvCcZz]*)/g;let n;for(;(n=i.exec(e))!==null;){const[,s,o]=n,a=o.trim()===""?[]:o.trim().split(/\s+/).map(Number).filter(l=>!isNaN(l));t.push({type:s,args:a})}return t},ry=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],n=i.split(" ").map(s=>s.split(",").map(parseFloat));return{type:_t.POLYGON,geometry:{points:n,bounds:Ae(n)}}},iy=r=>{const t=fs(r),e=parseFloat(t.getAttribute("cx")),i=parseFloat(t.getAttribute("cy")),n=parseFloat(t.getAttribute("rx")),s=parseFloat(t.getAttribute("ry")),o={minX:e-n,minY:i-s,maxX:e+n,maxY:i+s};return{type:_t.ELLIPSE,geometry:{cx:e,cy:i,rx:n,ry:s,bounds:o}}},ny=r=>{const t=fs(r),e=parseFloat(t.getAttribute("x1")),i=parseFloat(t.getAttribute("x2")),n=parseFloat(t.getAttribute("y1")),s=parseFloat(t.getAttribute("y2")),o={minX:Math.min(e,i),minY:Math.min(n,s),maxX:Math.max(e,i),maxY:Math.max(n,s)};return{type:_t.LINE,geometry:{points:[[e,n],[i,s]],bounds:o}}},sy=r=>{const t=fs(r),e=t.nodeName==="path"?t:Array.from(t.querySelectorAll("path"))[0],i=e==null?void 0:e.getAttribute("d");if(!i)throw new Error("Could not parse SVG path");const n=ey(i);if(!n)throw new Error("Could not parse SVG path");return{type:_t.POLYLINE,geometry:n}},oy=r=>{const t=fs(r),e=(t.nodeName==="path"?[t]:Array.from(t.querySelectorAll("path"))).map(s=>s.getAttribute("d")||"").map(s=>Jg(s)).filter(Boolean),i=e.reduce((s,o)=>[...s,...o.rings[0].points],[]),n=Ae(i);return e.length===1&&e[0].rings.length===1?{type:_t.POLYGON,geometry:{points:i,bounds:n}}:{type:_t.MULTIPOLYGON,geometry:{polygons:e,bounds:n}}},ay=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return ry(t);if(t.includes("<path ")&&(t.includes(" C ")||!t.includes("Z")))return sy(t);if(t.includes("<path "))return oy(t);if(t.includes("<ellipse "))return iy(t);if(t.includes("<line "))return ny(t);throw"Unsupported SVG shape: "+t},ly=r=>`<g>${r.polygons.map(t=>`<path fill-rule="evenodd" d="${He(t)}" />`).join("")}</g>`,hy=r=>{let t;switch(r.type){case _t.POLYGON:{const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(n=>n.join(",")).join(" ")}" /></svg>`;break}case _t.ELLIPSE:{const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`;break}case _t.MULTIPOLYGON:{const e=r.geometry;t=`<svg>${ly(e)}</svg>`;break}case _t.LINE:{const e=r.geometry,[[i,n],[s,o]]=e.points;t=`<svg><line x1="${i}" y1="${n}" x2="${s}" y2="${o}" /></svg>`;break}case _t.POLYLINE:t=`<svg><path d="${Jo(r.geometry)}" /></svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`},ge=[];for(let r=0;r<256;++r)ge.push((r+256).toString(16).slice(1));function cy(r,t=0){return(ge[r[t+0]]+ge[r[t+1]]+ge[r[t+2]]+ge[r[t+3]]+"-"+ge[r[t+4]]+ge[r[t+5]]+"-"+ge[r[t+6]]+ge[r[t+7]]+"-"+ge[r[t+8]]+ge[r[t+9]]+"-"+ge[r[t+10]]+ge[r[t+11]]+ge[r[t+12]]+ge[r[t+13]]+ge[r[t+14]]+ge[r[t+15]]).toLowerCase()}let ta;const uy=new Uint8Array(16);function dy(){if(!ta){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ta=crypto.getRandomValues.bind(crypto)}return ta(uy)}const fy=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ac={randomUUID:fy};function py(r,t,e){var i;r=r||{};const n=r.random??((i=r.rng)==null?void 0:i.call(r))??dy();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,cy(n)}function lc(r,t,e){return ac.randomUUID&&!r?ac.randomUUID():py(r)}var hc=Object.prototype.hasOwnProperty;function Dr(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--&&Dr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(hc.call(r,e)&&++i&&!hc.call(t,e)||!(e in t)||!Dr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}let my=Symbol("clean"),Xe=[],Br=0;const ps=4;let ea=r=>{let t=[],e={get(){return e.lc||e.listen(()=>{})(),e.value},lc:0,listen(i){return e.lc=t.push(i),()=>{for(let s=Br+ps;s<Xe.length;)Xe[s]===i?Xe.splice(s,ps):s+=ps;let n=t.indexOf(i);~n&&(t.splice(n,1),--e.lc||e.off())}},notify(i,n){let s=!Xe.length;for(let o of t)Xe.push(o,e.value,i,n);if(s){for(Br=0;Br<Xe.length;Br+=ps)Xe[Br](Xe[Br+1],Xe[Br+2],Xe[Br+3]);Xe.length=0}},off(){},set(i){let n=e.value;n!==i&&(e.value=i,e.notify(n))},subscribe(i){let n=e.listen(i);return i(e.value),n},value:r};return process.env.NODE_ENV!=="production"&&(e[my]=()=>{t=[],e.lc=0,e.off()}),e};const gy=r=>{const t=ea(null);return r.observe(({changes:e})=>{const i=t.get();if(i){(e.deleted||[]).some(s=>s.id===i)&&t.set(null);const n=(e.updated||[]).find(({oldValue:s})=>s.id===i);n&&t.set(n.newValue.id)}}),{get current(){return t.get()},subscribe:t.subscribe.bind(t),set:t.set.bind(t)}};var cc=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(cc||{});const ra={selected:[]},yy=(r,t,e)=>{const i=ea(ra);let n=t;const s=()=>{Dr(i.get(),ra)||i.set(ra)},o=()=>{var f;return((f=i.get().selected)==null?void 0:f.length)===0},a=f=>{if(o())return!1;const p=typeof f=="string"?f:f.id;return i.get().selected.some(g=>g.id===p)},l=(f,p)=>{let g;if(Array.isArray(f)){if(g=f.map(_=>r.getAnnotation(_)).filter(Boolean),g.length<f.length){console.warn("Invalid selection: "+f.filter(_=>!g.some(v=>v.id===_)));return}}else{const _=r.getAnnotation(f);if(!_){console.warn("Invalid selection: "+f);return}g=[_]}const y=g.reduce((_,v)=>{const m=d(v);return m==="EDIT"?[..._,{id:v.id,editable:!0}]:m==="SELECT"?[..._,{id:v.id}]:_},[]);i.set({selected:y,event:p})},h=(f,p)=>{const g=Array.isArray(f)?f:[f],y=g.map(_=>r.getAnnotation(_)).filter(_=>!!_);i.set({selected:y.map(_=>{const v=p===void 0?d(_)==="EDIT":p;return{id:_.id,editable:v}})}),y.length!==g.length&&console.warn("Invalid selection",f)},c=f=>{if(o())return!1;const{selected:p}=i.get();p.some(({id:g})=>f.includes(g))&&i.set({selected:p.filter(({id:g})=>!f.includes(g))})},u=f=>{n=f,h(i.get().selected.map(({id:p})=>p))},d=f=>_y(f,n,e);return r.observe(({changes:f})=>c((f.deleted||[]).map(p=>p.id))),{get event(){const f=i.get();return f?f.event:null},get selected(){const f=i.get();return f?[...f.selected]:null},get userSelectAction(){return n},clear:s,evalSelectAction:d,isEmpty:o,isSelected:a,setSelected:h,setUserSelectAction:u,subscribe:i.subscribe.bind(i),userSelect:l}},_y=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"},ye=[];for(let r=0;r<256;++r)ye.push((r+256).toString(16).slice(1));function vy(r,t=0){return(ye[r[t+0]]+ye[r[t+1]]+ye[r[t+2]]+ye[r[t+3]]+"-"+ye[r[t+4]]+ye[r[t+5]]+"-"+ye[r[t+6]]+ye[r[t+7]]+"-"+ye[r[t+8]]+ye[r[t+9]]+"-"+ye[r[t+10]]+ye[r[t+11]]+ye[r[t+12]]+ye[r[t+13]]+ye[r[t+14]]+ye[r[t+15]]).toLowerCase()}let ia;const by=new Uint8Array(16);function xy(){if(!ia){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ia=crypto.getRandomValues.bind(crypto)}return ia(by)}const wy=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),uc={randomUUID:wy};function Ey(r,t,e){var i;r=r||{};const n=r.random??((i=r.rng)==null?void 0:i.call(r))??xy();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,vy(n)}function Ty(r,t,e){return uc.randomUUID&&!r?uc.randomUUID():Ey(r)}const na=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)}},Ay=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},Sy=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},Cy=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(n=>n.id===e.id);return{newBody:e,oldBody:i&&!Dr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),Iy=(r,t)=>!Dr(r.target,t.target),dc=(r,t)=>{const e=Ay(r,t),i=Sy(r,t),n=Cy(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:n.length>0?n:void 0,targetUpdated:Iy(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Nt=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Nt||{});const Py=(r,t)=>{var e,i;const{changes:n,origin:s}=t;if(!(r.options.origin?r.options.origin===s:s!=="SILENT"))return!1;if(r.options.ignore){const{ignore:o}=r.options,a=l=>l&&l.length>0;if(!(a(n.created)||a(n.deleted))){const l=(e=n.updated)==null?void 0:e.some(c=>a(c.bodiesCreated)||a(c.bodiesDeleted)||a(c.bodiesUpdated)),h=(i=n.updated)==null?void 0:i.some(c=>c.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(r.options.annotations){const o=new Set([...(n.created||[]).map(a=>a.id),...(n.deleted||[]).map(a=>a.id),...(n.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},Ry=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),n=new Set((t.created||[]).map(u=>u.id)),s=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!s.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!n.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!s.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(g=>g.oldValue.id===f.id).newValue;return dc(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}},ms=r=>{const t=r.id===void 0?Ty():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},My=r=>r.id!==void 0,Dy=()=>{const r=new Map,t=new Map,e=[],i=(P,T={})=>{e.push({onChange:P,options:T})},n=P=>{const T=e.findIndex(E=>E.onChange==P);T>-1&&e.splice(T,1)},s=(P,T)=>{const E={origin:P,changes:{created:T.created||[],updated:T.updated||[],deleted:T.deleted||[]},state:[...r.values()]};e.forEach(A=>{Py(A,E)&&A.onChange(E)})},o=(P,T=Nt.LOCAL)=>{if(P.id&&r.get(P.id))throw Error(`Cannot add annotation ${P.id} - exists already`);{const E=ms(P);r.set(E.id,E),E.bodies.forEach(A=>t.set(A.id,E.id)),s(T,{created:[E]})}},a=(P,T)=>{const E=ms(typeof P=="string"?T:P),A=typeof P=="string"?P:P.id,L=A&&r.get(A);if(L){const D=dc(L,E);return A===E.id?r.set(A,E):(r.delete(A),r.set(E.id,E)),L.bodies.forEach(N=>t.delete(N.id)),E.bodies.forEach(N=>t.set(N.id,E.id)),D}else console.warn(`Cannot update annotation ${A} - does not exist`)},l=(P,T=Nt.LOCAL,E=Nt.LOCAL)=>{const A=My(T)?E:T,L=a(P,T);L&&s(A,{updated:[L]})},h=(P,T=Nt.LOCAL)=>{r.get(P.id)?l(P,T):o(P,T)},c=(P,T=Nt.LOCAL)=>{const E=P.reduce((A,L)=>{const D=a(L);return D?[...A,D]:A},[]);E.length>0&&s(T,{updated:E})},u=(P,T=Nt.LOCAL)=>{const E=P.map(ms),{toAdd:A,toUpdate:L}=E.reduce((N,$)=>r.get($.id)?{...N,toUpdate:[...N.toUpdate,$]}:{...N,toAdd:[...N.toAdd,$]},{toAdd:[],toUpdate:[]}),D=L.map(N=>a(N,T)).filter(Boolean);A.forEach(N=>{r.set(N.id,N),N.bodies.forEach($=>t.set($.id,N.id))}),s(T,{created:A,updated:D})},d=(P,T=Nt.LOCAL)=>{const E=r.get(P.annotation);if(E){const A={...E,bodies:[...E.bodies,P]};r.set(E.id,A),t.set(P.id,A.id),s(T,{updated:[{oldValue:E,newValue:A,bodiesCreated:[P]}]})}else console.warn(`Attempt to add body to missing annotation: ${P.annotation}`)},f=()=>[...r.values()],p=(P=Nt.LOCAL)=>{const T=[...r.values()];r.clear(),t.clear(),s(P,{deleted:T})},g=(P,T=!0,E=Nt.LOCAL)=>{const A=P.map(ms);if(T){const L=[...r.values()];r.clear(),t.clear(),A.forEach(D=>{r.set(D.id,D),D.bodies.forEach(N=>t.set(N.id,D.id))}),s(E,{created:A,deleted:L})}else{const L=P.reduce((D,N)=>{const $=N.id&&r.get(N.id);return $?[...D,$]:D},[]);if(L.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${L.map(D=>D.id).join(", ")}`);A.forEach(D=>{r.set(D.id,D),D.bodies.forEach(N=>t.set(N.id,D.id))}),s(E,{created:A})}},y=P=>{const T=typeof P=="string"?P:P.id,E=r.get(T);if(E)return r.delete(T),E.bodies.forEach(A=>t.delete(A.id)),E;console.warn(`Attempt to delete missing annotation: ${T}`)},_=(P,T=Nt.LOCAL)=>{const E=y(P);E&&s(T,{deleted:[E]})},v=(P,T=Nt.LOCAL)=>{const E=P.reduce((A,L)=>{const D=y(L);return D?[...A,D]:A},[]);E.length>0&&s(T,{deleted:E})},m=P=>{const T=r.get(P.annotation);if(T){const E=T.bodies.find(A=>A.id===P.id);if(E){t.delete(E.id);const A={...T,bodies:T.bodies.filter(L=>L.id!==P.id)};return r.set(T.id,A),{oldValue:T,newValue:A,bodiesDeleted:[E]}}else console.warn(`Attempt to delete missing body ${P.id} from annotation ${P.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${P.annotation}`)},b=(P,T=Nt.LOCAL)=>{const E=m(P);E&&s(T,{updated:[E]})},S=(P,T=Nt.LOCAL)=>{const E=P.map(A=>m(A)).filter(Boolean);E.length>0&&s(T,{updated:E})},R=P=>{const T=r.get(P);return T?{...T}:void 0},C=P=>{const T=t.get(P);if(T){const E=R(T).bodies.find(A=>A.id===P);if(E)return E;console.error(`Store integrity error: body ${P} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${P}`)},I=(P,T)=>{if(P.annotation!==T.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const E=r.get(P.annotation);if(E){const A=E.bodies.find(D=>D.id===P.id),L={...E,bodies:E.bodies.map(D=>D.id===A.id?T:D)};return r.set(E.id,L),A.id!==T.id&&(t.delete(A.id),t.set(T.id,L.id)),{oldValue:E,newValue:L,bodiesUpdated:[{oldBody:A,newBody:T}]}}else console.warn(`Attempt to add body to missing annotation ${P.annotation}`)},M=(P,T,E=Nt.LOCAL)=>{const A=I(P,T);A&&s(E,{updated:[A]})},F=(P,T=Nt.LOCAL)=>{const E=P.map(A=>I({id:A.id,annotation:A.annotation},A)).filter(Boolean);s(T,{updated:E})},U=P=>{const T=r.get(P.annotation);if(T){const E={...T,target:{...T.target,...P}};return r.set(T.id,E),{oldValue:T,newValue:E,targetUpdated:{oldTarget:T.target,newTarget:P}}}else console.warn(`Attempt to update target on missing annotation: ${P.annotation}`)};return{addAnnotation:o,addBody:d,all:f,bulkAddAnnotations:g,bulkDeleteAnnotations:v,bulkDeleteBodies:S,bulkUpdateAnnotations:c,bulkUpdateBodies:F,bulkUpdateTargets:(P,T=Nt.LOCAL)=>{const E=P.map(A=>U(A)).filter(Boolean);E.length>0&&s(T,{updated:E})},bulkUpsertAnnotations:u,clear:p,deleteAnnotation:_,deleteBody:b,getAnnotation:R,getBody:C,observe:i,unobserve:n,updateAnnotation:l,updateBody:M,updateTarget:(P,T=Nt.LOCAL)=>{const E=U(P);E&&s(T,{updated:[E]})},upsertAnnotation:h}};let By=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,n=e.length;i<n;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(n=>t!==n)}}});const Oy=250,Ly=(r,t)=>{const e=By(),i=(t==null?void 0:t.changes)||[];let n=t?t.pointer:-1,s=!1,o=0;const a=p=>{if(!s){const{changes:g}=p,y=performance.now();if(y-o>Oy)i.splice(n+1),i.push(g),n=i.length-1;else{const _=i.length-1;i[_]=Ry(i[_],g)}o=y}s=!1};r.observe(a,{origin:Nt.LOCAL});const l=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p),h=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),c=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({oldValue:g})=>g)),u=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({newValue:g})=>g)),d=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),f=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p);return{canRedo:()=>i.length-1>n,canUndo:()=>n>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:n}),on:(p,g)=>e.on(p,g),redo:()=>{if(i.length-1>n){s=!0;const{created:p,updated:g,deleted:y}=i[n+1];h(p),u(g),f(y),e.emit("redo",i[n+1]),n+=1}},undo:()=>{if(n>-1){s=!0;const{created:p,updated:g,deleted:y}=i[n];l(p),c(g),d(y),e.emit("undo",i[n]),n-=1}}}},Ny=()=>{const r=ea([]);return{subscribe:r.subscribe.bind(r),set:r.set.bind(r)}},Fy=(r,t,e,i)=>{const{hover:n,selection:s,store:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(_,v)=>{l.has(_)?l.get(_).push(v):l.set(_,[v])},f=(_,v)=>{const m=l.get(_);if(m){const b=m.indexOf(v);b!==-1&&m.splice(b,1)}},p=(_,v,m)=>{l.has(_)&&setTimeout(()=>{l.get(_).forEach(b=>{if(e){const S=Array.isArray(v)?v.map(C=>e.serialize(C)):e.serialize(v),R=m?m instanceof PointerEvent?m:e.serialize(m):void 0;b(S,R)}else b(v,m)})},1)},g=()=>{const{selected:_}=s,v=(_||[]).map(({id:m})=>o.getAnnotation(m));v.forEach(m=>{const b=h.find(S=>S.id===m.id);(!b||!Dr(b,m))&&p("updateAnnotation",m,b)}),h=h.map(m=>v.find(({id:b})=>b===m.id)||m)};s.subscribe(({selected:_})=>{if(!(h.length===0&&_.length===0)){if(h.length===0&&_.length>0)h=_.map(({id:v})=>o.getAnnotation(v));else if(h.length>0&&_.length===0)h.forEach(v=>{const m=o.getAnnotation(v.id);m&&!Dr(m,v)&&p("updateAnnotation",m,v)}),h=[];else{const v=new Set(h.map(b=>b.id)),m=new Set(_.map(({id:b})=>b));h.filter(b=>!m.has(b.id)).forEach(b=>{const S=o.getAnnotation(b.id);S&&!Dr(S,b)&&p("updateAnnotation",S,b)}),h=[...h.filter(b=>m.has(b.id)),..._.filter(({id:b})=>!v.has(b)).map(({id:b})=>o.getAnnotation(b))]}p("selectionChanged",h)}}),n.subscribe(_=>{!c&&_?p("mouseEnterAnnotation",o.getAnnotation(_)):c&&!_?p("mouseLeaveAnnotation",o.getAnnotation(c)):c&&_&&(p("mouseLeaveAnnotation",o.getAnnotation(c)),p("mouseEnterAnnotation",o.getAnnotation(_))),c=_}),a==null||a.subscribe(_=>p("viewportIntersect",_.map(v=>o.getAnnotation(v)))),o.observe(_=>{i&&(u&&clearTimeout(u),u=setTimeout(g,1e3));const{created:v,deleted:m}=_.changes;(v||[]).forEach(b=>p("createAnnotation",b)),(m||[]).forEach(b=>p("deleteAnnotation",b)),(_.changes.updated||[]).filter(b=>[...b.bodiesCreated||[],...b.bodiesDeleted||[],...b.bodiesUpdated||[]].length>0).forEach(({oldValue:b,newValue:S})=>{const R=h.find(C=>C.id===b.id)||b;h=h.map(C=>C.id===b.id?S:C),p("updateAnnotation",S,R)})},{origin:Nt.LOCAL}),o.observe(_=>{if(h){const v=new Set(h.map(b=>b.id)),m=(_.changes.updated||[]).filter(({newValue:b})=>v.has(b.id)).map(({newValue:b})=>b);m.length>0&&(h=h.map(b=>m.find(S=>S.id===b.id)||b))}},{origin:Nt.REMOTE});const y=_=>v=>{const{updated:m}=v;_?(m||[]).forEach(b=>p("updateAnnotation",b.oldValue,b.newValue)):(m||[]).forEach(b=>p("updateAnnotation",b.newValue,b.oldValue))};return t.on("undo",y(!0)),t.on("redo",y(!1)),{on:d,off:f,emit:p}},ky=r=>t=>t.reduce((e,i)=>{const{parsed:n,error:s}=r.parse(i);return s?{parsed:e.parsed,failed:[...e.failed,i]}:n?{parsed:[...e.parsed,n],failed:e.failed}:{...e}},{parsed:[],failed:[]}),Uy=(r,t,e)=>{const{store:i,selection:n}=r,s=_=>{if(e){const{parsed:v,error:m}=e.parse(_);v?i.addAnnotation(v,Nt.REMOTE):console.error(m)}else i.addAnnotation(na(_),Nt.REMOTE)},o=()=>n.clear(),a=()=>i.clear(),l=_=>{const v=i.getAnnotation(_);return e&&v?e.serialize(v):v},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var _;const v=(((_=n.selected)==null?void 0:_.map(m=>m.id))||[]).map(m=>i.getAnnotation(m)).filter(Boolean);return e?v.map(e.serialize):v},u=(_,v=!0)=>fetch(_).then(m=>m.json()).then(m=>(f(m,v),m)),d=_=>{if(typeof _=="string"){const v=i.getAnnotation(_);if(i.deleteAnnotation(_),v)return e?e.serialize(v):v}else{const v=e?e.parse(_).parsed:_;if(v)return i.deleteAnnotation(v),_}},f=(_,v=!0)=>{if(e){const m=e.parseAll||ky(e),{parsed:b,failed:S}=m(_);S.length>0&&console.warn(`Discarded ${S.length} invalid annotations`,S),i.bulkAddAnnotations(b,v,Nt.REMOTE)}else i.bulkAddAnnotations(_.map(na),v,Nt.REMOTE)},p=(_,v)=>{_?n.setSelected(_,v):n.clear()},g=_=>{n.setUserSelectAction(_)},y=_=>{if(e){const v=e.parse(_).parsed,m=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),m}else{const v=i.getAnnotation(_.id);return i.updateAnnotation(na(_)),v}};return{addAnnotation:s,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:g,undo:t.undo,updateAnnotation:y}},Gy=(r,t,e)=>typeof t=="function"?t(r,e):t,$y=(r,t)=>typeof r!="function"&&typeof t!="function"?{...r||{},...t||{}}:(e,i)=>{const n=typeof r=="function"?r(e,i):r,s=typeof t=="function"?t(e,i):t;return{...n||{},...s||{}}},Hy="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Xy=r=>crypto.getRandomValues(new Uint8Array(r)),Vy=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,n=-~(1.6*i*t/r.length);return(s=t)=>{let o="";for(;;){let a=e(n),l=n|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=s)return o}}},zy=(r,t=21)=>Vy(r,t|0,Xy),jy=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Hy[e[r]&63];return t};const Wy=()=>({isGuest:!0,id:zy("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Yy=r=>{const t=JSON.stringify(r);let e=0;for(let i=0,n=t.length;i<n;i++){let s=t.charCodeAt(i);e=(e<<5)-e+s,e|=0}return`${e}`},fc=r=>r?typeof r=="object"?{...r}:r:void 0,qy=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:n,purpose:s,value:o,created:a,modified:l,creator:h,...c}=e;return{id:i||`temp-${Yy(e)}`,annotation:t,type:n,purpose:s,value:o,creator:fc(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...c}}),Ky=r=>r.map(t=>{var e;const{annotation:i,created:n,updated:s,...o}=t,a={...o,created:n==null?void 0:n.toISOString(),modified:s==null?void 0:s.toISOString()};return(e=a.id)!=null&&e.startsWith("temp-")&&delete a.id,a});jy();const Zy=(r,t={strict:!0,invertY:!1})=>({parse:e=>Qy(e,t),serialize:e=>Jy(e,r,t)}),Qy=(r,t={strict:!0,invertY:!1})=>{const e=r.id||lc(),{creator:i,created:n,modified:s,body:o,...a}=r,l=qy(o||[],e),h=Array.isArray(r.target)?r.target[0]:r.target,c=typeof h=="string"?h:Array.isArray(h.selector)?h.selector[0]:h.selector,u=typeof c=="string"||(c==null?void 0:c.type)==="FragmentSelector"?Kg(c,t.invertY):(c==null?void 0:c.type)==="SvgSelector"?ay(c):void 0,d=Array.isArray(a.target)?a.target[0]:a.targret;return u||!t.strict?{parsed:{...a,id:e,bodies:l,target:{created:n?new Date(n):void 0,creator:fc(i),updated:s?new Date(s):void 0,...typeof d=="string"?{}:d,annotation:e,selector:u||c}}}:{error:Error(`Invalid selector: ${JSON.stringify(c)}`)}},Jy=(r,t,e={strict:!0,invertY:!1})=>{const{selector:i,creator:n,created:s,updated:o,updatedBy:a,...l}=r.target;let h;try{h=i.type==_t.RECTANGLE?Zg(i.geometry):hy(i)}catch(u){if(e.strict)throw u;h=i}const c={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:Ky(r.bodies),created:s==null?void 0:s.toISOString(),creator:n,modified:o==null?void 0:o.toISOString(),target:{...l,source:t,type:"SpecificResource",selector:h}};return delete c.bodies,"annotation"in c.target&&delete c.target.annotation,c},Ri=[];function t0(r,t=Rt){let e;const i=new Set;function n(a){if(Kt(r,a)&&(r=a,e)){const l=!Ri.length;for(const h of i)h[1](),Ri.push(h,r);if(l){for(let h=0;h<Ri.length;h+=2)Ri[h][0](Ri[h+1]);Ri.length=0}}}function s(a){n(a(r))}function o(a,l=Rt){const h=[a,l];return i.add(h),i.size===1&&(e=t(n,s)||Rt),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:n,update:s,subscribe:o}}const e0=(r,t)=>{const{naturalWidth:e,naturalHeight:i}=r;if(!e&&!i){const{width:n,height:s}=r;t.setAttribute("viewBox",`0 0 ${n} ${s}`),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}`)},r0=(r,t)=>{e0(r,t);const{subscribe:e,set:i}=t0(1);let n;return window.ResizeObserver&&(n=new ResizeObserver(()=>{const s=t.getBoundingClientRect(),{width:o,height:a}=t.viewBox.baseVal,l=Math.max(s.width/o,s.height/a);i(l)}),n.observe(t.parentElement)),{destroy:()=>{n&&n.disconnect()},subscribe:e}},ri=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:n,stroke:s,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`),n||n===0?l+=`fill-opacity:${n};`:i&&(l+="fill-opacity:0.25;"),s&&(l+=`stroke:${s};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}},gs=(r,t=0)=>{const{minX:e,minY:i,maxX:n,maxY:s}=r;return{x:e-t,y:i-t,w:n-e+2*t,h:s-i+2*t}},Ne=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,i0=r=>({}),pc=r=>({grab:r[0]});function n0(r){let t,e,i,n;const s=r[8].default,o=Pg(s,r,r[7],pc);return{c(){t=W("g"),o&&o.c(),x(t,"class","a9s-annotation selected")},m(a,l){nt(a,t,l),o&&o.m(t,null),e=!0,i||(n=[St(t,"pointerup",r[2]),St(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&128)&&Mg(o,s,a,a[7],e?Rg(s,a[7],l,i0):Dg(a[7]),pc)},i(a){e||(lt(o,a),e=!0)},o(a){yt(o,a),e=!1},d(a){a&&rt(t),o&&o.d(a),i=!1,Me(n)}}}function s0(r,t,e){let{$$slots:i={},$$scope:n}=t;const s=Mr();let{shape:o}=t,{editor:a}=t,{transform:l}=t,{svgEl:h}=t,c,u,d;const f=y=>_=>{if(c=y,h){const{left:v,top:m}=h.getBoundingClientRect(),b=_.clientX-v,S=_.clientY-m;u=l.elementToImage(b,S)}else{const{offsetX:v,offsetY:m}=_;u=l.elementToImage(v,m)}d=o,_.target.setPointerCapture(_.pointerId),s("grab",_)},p=y=>{if(c){const[_,v]=l.elementToImage(y.offsetX,y.offsetY),m=[_-u[0],v-u[1]];e(3,o=a(d,c,m)),s("change",o)}},g=y=>{y.target.releasePointerCapture(y.pointerId),c=void 0,d=o,s("release",y)};return r.$$set=y=>{"shape"in y&&e(3,o=y.shape),"editor"in y&&e(4,a=y.editor),"transform"in y&&e(5,l=y.transform),"svgEl"in y&&e(6,h=y.svgEl),"$$scope"in y&&e(7,n=y.$$scope)},[f,p,g,o,a,l,h,n,i]}class sa extends me{constructor(t){super(),pe(this,t,s0,n0,Kt,{shape:3,editor:4,transform:5,svgEl:6})}}function o0(r){let t,e,i,n,s,o,a,l,h=r[3]&&mc(r);return{c(){t=W("g"),e=W("circle"),h&&h.c(),n=W("circle"),x(e,"class","a9s-handle-buffer svelte-qtyc7s"),x(e,"cx",r[0]),x(e,"cy",r[1]),x(e,"r",i=r[5]+6/r[2]),x(e,"role","button"),x(e,"tabindex","0"),x(n,"class",s=Ai(`a9s-handle-dot${r[3]?" selected":""}`)+" svelte-qtyc7s"),x(n,"cx",r[0]),x(n,"cy",r[1]),x(n,"r",r[5]),x(t,"class",o=`a9s-handle ${r[8].class||""}`.trim())},m(c,u){nt(c,t,u),xt(t,e),h&&h.m(t,null),xt(t,n),a||(l=[St(e,"dblclick",r[12]),St(e,"pointerenter",r[13]),St(e,"pointerleave",r[14]),St(e,"pointerdown",r[15]),St(e,"pointerdown",r[6]),St(e,"pointerup",r[16]),St(e,"pointerup",r[7])],a=!0)},p(c,u){u&1&&x(e,"cx",c[0]),u&2&&x(e,"cy",c[1]),u&36&&i!==(i=c[5]+6/c[2])&&x(e,"r",i),c[3]?h?h.p(c,u):(h=mc(c),h.c(),h.m(t,n)):h&&(h.d(1),h=null),u&8&&s!==(s=Ai(`a9s-handle-dot${c[3]?" selected":""}`)+" svelte-qtyc7s")&&x(n,"class",s),u&1&&x(n,"cx",c[0]),u&2&&x(n,"cy",c[1]),u&32&&x(n,"r",c[5]),u&256&&o!==(o=`a9s-handle ${c[8].class||""}`.trim())&&x(t,"class",o)},d(c){c&&rt(t),h&&h.d(),a=!1,Me(l)}}}function a0(r){let t,e,i,n,s,o,a,l,h;return{c(){t=W("g"),e=W("circle"),n=W("circle"),o=W("circle"),x(e,"cx",r[0]),x(e,"cy",r[1]),x(e,"r",i=r[5]*10),x(e,"class","a9s-touch-halo"),Je(e,"touched",r[4]),x(n,"cx",r[0]),x(n,"cy",r[1]),x(n,"r",s=r[5]+10/r[2]),x(n,"class","a9s-handle-buffer svelte-qtyc7s"),x(n,"role","button"),x(n,"tabindex","0"),x(o,"class","a9s-handle-dot"),x(o,"cx",r[0]),x(o,"cy",r[1]),x(o,"r",a=r[5]+2/r[2]),x(t,"class","a9s-touch-handle")},m(c,u){nt(c,t,u),xt(t,e),xt(t,n),xt(t,o),l||(h=[St(n,"dblclick",r[9]),St(n,"pointerdown",r[10]),St(n,"pointerdown",r[6]),St(n,"pointerup",r[11]),St(n,"pointerup",r[7])],l=!0)},p(c,u){u&1&&x(e,"cx",c[0]),u&2&&x(e,"cy",c[1]),u&32&&i!==(i=c[5]*10)&&x(e,"r",i),u&16&&Je(e,"touched",c[4]),u&1&&x(n,"cx",c[0]),u&2&&x(n,"cy",c[1]),u&36&&s!==(s=c[5]+10/c[2])&&x(n,"r",s),u&1&&x(o,"cx",c[0]),u&2&&x(o,"cy",c[1]),u&36&&a!==(a=c[5]+2/c[2])&&x(o,"r",a)},d(c){c&&rt(t),l=!1,Me(h)}}}function mc(r){let t,e;return{c(){t=W("circle"),x(t,"class","a9s-handle-selected"),x(t,"cx",r[0]),x(t,"cy",r[1]),x(t,"r",e=r[5]+8/r[2])},m(i,n){nt(i,t,n)},p(i,n){n&1&&x(t,"cx",i[0]),n&2&&x(t,"cy",i[1]),n&36&&e!==(e=i[5]+8/i[2])&&x(t,"r",e)},d(i){i&&rt(t)}}}function l0(r){let t;function e(n,s){return Ne?a0:o0}let i=e()(r);return{c(){i.c(),t=De()},m(n,s){i.m(n,s),nt(n,t,s)},p(n,[s]){i.p(n,s)},i:Rt,o:Rt,d(n){n&&rt(t),i.d(n)}}}function h0(r,t,e){let i,{x:n}=t,{y:s}=t,{scale:o}=t,{selected:a=void 0}=t,l=!1;const h=m=>{m.pointerType==="touch"&&e(4,l=!0)},c=()=>e(4,l=!1);function u(m){oe.call(this,r,m)}function d(m){oe.call(this,r,m)}function f(m){oe.call(this,r,m)}function p(m){oe.call(this,r,m)}function g(m){oe.call(this,r,m)}function y(m){oe.call(this,r,m)}function _(m){oe.call(this,r,m)}function v(m){oe.call(this,r,m)}return r.$$set=m=>{e(8,t=Vo(Vo({},t),Yh(m))),"x"in m&&e(0,n=m.x),"y"in m&&e(1,s=m.y),"scale"in m&&e(2,o=m.scale),"selected"in m&&e(3,a=m.selected)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=4/o)},t=Yh(t),[n,s,o,a,l,i,h,c,t,u,d,f,p,g,y,_,v]}class Mi extends me{constructor(t){super(),pe(this,t,h0,l0,Kt,{x:0,y:1,scale:2,selected:3})}}function c0(r){let t,e,i,n,s,o,a;return{c(){t=W("g"),e=W("circle"),n=W("circle"),s=W("circle"),x(e,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),x(e,"cx",r[0]),x(e,"cy",r[1]),x(e,"r",i=1.75*r[2]),x(n,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),x(n,"cx",r[0]),x(n,"cy",r[1]),x(n,"r",r[2]),x(s,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),x(s,"cx",r[0]),x(s,"cy",r[1]),x(s,"r",r[2]),x(t,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){nt(l,t,h),xt(t,e),xt(t,n),xt(t,s),o||(a=[St(e,"pointerdown",r[5]),St(e,"pointerdown",r[3])],o=!0)},p(l,h){h&1&&x(e,"cx",l[0]),h&2&&x(e,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&x(e,"r",i),h&1&&x(n,"cx",l[0]),h&2&&x(n,"cy",l[1]),h&4&&x(n,"r",l[2]),h&1&&x(s,"cx",l[0]),h&2&&x(s,"cy",l[1]),h&4&&x(s,"r",l[2])},d(l){l&&rt(t),o=!1,Me(a)}}}function u0(r){let t;return{c(){t=W("circle"),x(t,"cx",r[0]),x(t,"cy",r[1]),x(t,"r",r[2])},m(e,i){nt(e,t,i)},p(e,i){i&1&&x(t,"cx",e[0]),i&2&&x(t,"cy",e[1]),i&4&&x(t,"r",e[2])},d(e){e&&rt(t)}}}function d0(r){let t;function e(n,s){return Ne?u0:c0}let i=e()(r);return{c(){i.c(),t=De()},m(n,s){i.m(n,s),nt(n,t,s)},p(n,[s]){i.p(n,s)},i:Rt,o:Rt,d(n){n&&rt(t),i.d(n)}}}function f0(r,t,e){let i,{x:n}=t,{y:s}=t,{scale:o}=t;const a=h=>{h.pointerType};function l(h){oe.call(this,r,h)}return r.$$set=h=>{"x"in h&&e(0,n=h.x),"y"in h&&e(1,s=h.y),"scale"in h&&e(4,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=4/o)},[n,s,i,a,o,l]}class gc extends me{constructor(t){super(),pe(this,t,f0,d0,Kt,{x:0,y:1,scale:4})}}function oa(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function yc(r,t,e){const i=r.slice();return i[28]=t[e],i[30]=e,i}function aa(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function la(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function _c(r){let t,e,i,n;return{c(){t=W("circle"),x(t,"cx",e=r[28][0]),x(t,"cy",i=r[28][1]),x(t,"r",n=bn/r[3]),x(t,"class","svelte-1h2slbm")},m(s,o){nt(s,t,o)},p(s,o){o[0]&1088&&e!==(e=s[28][0])&&x(t,"cx",e),o[0]&1088&&i!==(i=s[28][1])&&x(t,"cy",i),o[0]&8&&n!==(n=bn/s[3])&&x(t,"r",n)},d(s){s&&rt(t)}}}function vc(r){let t,e,i,n,s,o,a,l,h,c;return{c(){t=W("mask"),e=W("rect"),a=W("circle"),x(e,"x",i=r[9].x),x(e,"y",n=r[9].y),x(e,"width",s=r[9].w),x(e,"height",o=r[9].h),x(e,"class","svelte-1h2slbm"),x(a,"cx",l=r[28][0]),x(a,"cy",h=r[28][1]),x(a,"r",c=bn/r[3]),x(a,"class","svelte-1h2slbm"),x(t,"id",`${r[19]}-inner`),x(t,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(u,d){nt(u,t,d),xt(t,e),xt(t,a)},p(u,d){d[0]&512&&i!==(i=u[9].x)&&x(e,"x",i),d[0]&512&&n!==(n=u[9].y)&&x(e,"y",n),d[0]&512&&s!==(s=u[9].w)&&x(e,"width",s),d[0]&512&&o!==(o=u[9].h)&&x(e,"height",o),d[0]&1088&&l!==(l=u[28][0])&&x(a,"cx",l),d[0]&1088&&h!==(h=u[28][1])&&x(a,"cy",h),d[0]&8&&c!==(c=bn/u[3])&&x(a,"r",c)},d(u){u&&rt(t)}}}function bc(r){let t,e;return t=new Mi({props:{class:"a9s-corner-handle",x:r[28][0],y:r[28][1],scale:r[3],selected:r[8].includes(r[30])}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[15]),t.$on("pointerdown",function(){Gt(r[27](`HANDLE-${r[30]}`))&&r[27](`HANDLE-${r[30]}`).apply(this,arguments)}),t.$on("pointerup",r[16](r[30])),{c(){re(t.$$.fragment)},m(i,n){Jt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&32&&(s.x=r[28][0]),n[0]&32&&(s.y=r[28][1]),n[0]&8&&(s.scale=r[3]),n[0]&256&&(s.selected=r[8].includes(r[30])),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function xc(r){let t,e;return t=new gc({props:{x:r[28][0],y:r[28][1],scale:r[3]}}),t.$on("pointerdown",function(){Gt(r[18](r[6]))&&r[18](r[6]).apply(this,arguments)}),{c(){re(t.$$.fragment)},m(i,n){Jt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&1088&&(s.x=r[28][0]),n[0]&1088&&(s.y=r[28][1]),n[0]&8&&(s.scale=r[3]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function p0(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v,m,b,S,R=r[6]!==void 0&&!r[7]&&_c(la(r)),C=r[6]!==void 0&&!r[7]&&vc(aa(r)),I=Ie(r[5].points),M=[];for(let P=0;P<I.length;P+=1)M[P]=bc(yc(r,I,P));const F=P=>yt(M[P],1,1,()=>{M[P]=null});let U=r[6]!==void 0&&!r[7]&&xc(oa(r));return{c(){t=W("defs"),e=W("mask"),i=W("rect"),l=W("polygon"),R&&R.c(),C&&C.c(),c=we(),u=W("polygon"),f=we(),p=W("polygon"),y=we();for(let P=0;P<M.length;P+=1)M[P].c();_=we(),U&&U.c(),v=De(),x(i,"x",n=r[9].x),x(i,"y",s=r[9].y),x(i,"width",o=r[9].w),x(i,"height",a=r[9].h),x(i,"class","svelte-1h2slbm"),x(l,"points",h=r[5].points.map(wc).join(" ")),x(l,"class","svelte-1h2slbm"),x(e,"id",`${r[19]}-outer`),x(e,"class","a9s-polygon-editor-mask svelte-1h2slbm"),x(u,"class","a9s-outer"),x(u,"mask",`url(#${r[19]}-outer)`),x(u,"points",d=r[5].points.map(Ec).join(" ")),x(p,"class","a9s-inner a9s-shape-handle"),x(p,"mask",`url(#${r[19]}-inner)`),x(p,"style",r[1]),x(p,"points",g=r[5].points.map(Tc).join(" "))},m(P,T){nt(P,t,T),xt(t,e),xt(e,i),xt(e,l),R&&R.m(e,null),C&&C.m(t,null),nt(P,c,T),nt(P,u,T),nt(P,f,T),nt(P,p,T),nt(P,y,T);for(let E=0;E<M.length;E+=1)M[E]&&M[E].m(P,T);nt(P,_,T),U&&U.m(P,T),nt(P,v,T),m=!0,b||(S=[St(u,"pointerup",r[14]),St(u,"pointerdown",function(){Gt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)}),St(p,"pointermove",r[13]),St(p,"pointerup",r[14]),St(p,"pointerdown",function(){Gt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)})],b=!0)},p(P,T){if(r=P,(!m||T[0]&512&&n!==(n=r[9].x))&&x(i,"x",n),(!m||T[0]&512&&s!==(s=r[9].y))&&x(i,"y",s),(!m||T[0]&512&&o!==(o=r[9].w))&&x(i,"width",o),(!m||T[0]&512&&a!==(a=r[9].h))&&x(i,"height",a),(!m||T[0]&32&&h!==(h=r[5].points.map(wc).join(" ")))&&x(l,"points",h),r[6]!==void 0&&!r[7]?R?R.p(la(r),T):(R=_c(la(r)),R.c(),R.m(e,null)):R&&(R.d(1),R=null),r[6]!==void 0&&!r[7]?C?C.p(aa(r),T):(C=vc(aa(r)),C.c(),C.m(t,null)):C&&(C.d(1),C=null),(!m||T[0]&32&&d!==(d=r[5].points.map(Ec).join(" ")))&&x(u,"points",d),(!m||T[0]&2)&&x(p,"style",r[1]),(!m||T[0]&32&&g!==(g=r[5].points.map(Tc).join(" ")))&&x(p,"points",g),T[0]&134322472){I=Ie(r[5].points);let E;for(E=0;E<I.length;E+=1){const A=yc(r,I,E);M[E]?(M[E].p(A,T),lt(M[E],1)):(M[E]=bc(A),M[E].c(),lt(M[E],1),M[E].m(_.parentNode,_))}for(Ee(),E=I.length;E<M.length;E+=1)F(E);Te()}r[6]!==void 0&&!r[7]?U?(U.p(oa(r),T),T[0]&192&&lt(U,1)):(U=xc(oa(r)),U.c(),lt(U,1),U.m(v.parentNode,v)):U&&(Ee(),yt(U,1,1,()=>{U=null}),Te())},i(P){if(!m){for(let T=0;T<I.length;T+=1)lt(M[T]);lt(U),m=!0}},o(P){M=M.filter(Boolean);for(let T=0;T<M.length;T+=1)yt(M[T]);yt(U),m=!1},d(P){P&&(rt(t),rt(c),rt(u),rt(f),rt(p),rt(y),rt(_),rt(v)),R&&R.d(),C&&C.d(),Jr(M,P),U&&U.d(P),b=!1,Me(S)}}}function m0(r){let t,e;return t=new sa({props:{shape:r[0],transform:r[2],editor:r[17],svgEl:r[4],$$slots:{default:[p0,({grab:i})=>({27:i}),({grab:i})=>[i?134217728:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){re(t.$$.fragment)},m(i,n){Jt(t,i,n),e=!0},p(i,n){const s={};n[0]&1&&(s.shape=i[0]),n[0]&4&&(s.transform=i[2]),n[0]&16&&(s.svgEl=i[4]),n[0]&134219754|n[1]&1&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}const g0=250,y0=1e3,_0=12,bn=4.5,wc=r=>r.join(","),Ec=r=>r.join(","),Tc=r=>r.join(",");function v0(r,t,e){let i,n,s;const o=Mr();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:c=1}=t,{svgEl:u}=t,d,f=!1,p,g=[];const y=()=>e(7,f=!0),_=()=>e(7,f=!1),v=E=>{if(g.length>0||!n.some(B=>B.visible)){e(6,d=void 0);return}const[A,L]=h.elementToImage(E.offsetX,E.offsetY),D=B=>Math.pow(B[0]-A,2)+Math.pow(B[1]-L,2),N=i.points.reduce((B,k)=>D(k)<D(B)?k:B),$=n.filter(B=>B.visible).reduce((B,k)=>D(k.point)<D(B.point)?k:B),O=Math.pow(y0/c,2);D(N)<O||D($.point)<O?e(6,d=n.indexOf($)):e(6,d=void 0)},m=()=>{document.activeElement!==u&&u.focus()},b=()=>{e(8,g=[]),m()},S=E=>{e(7,f=!0),E.preventDefault(),E.stopPropagation(),p=performance.now()},R=E=>A=>{if(!p||Ne||performance.now()-p>g0)return;const L=g.includes(E);A.metaKey||A.ctrlKey||A.shiftKey?L?e(8,g=g.filter(D=>D!==E)):e(8,g=[...g,E]):L&&g.length>1?e(8,g=[E]):L?e(8,g=[]):e(8,g=[E]),m()},C=(E,A,L)=>{m();let D;const N=E.geometry;g.length>1?D=N.points.map(([O,B],k)=>g.includes(k)?[O+L[0],B+L[1]]:[O,B]):A==="SHAPE"?D=N.points.map(([O,B])=>[O+L[0],B+L[1]]):D=N.points.map(([O,B],k)=>A===`HANDLE-${k}`?[O+L[0],B+L[1]]:[O,B]);const $=Ae(D);return{...E,geometry:{points:D,bounds:$}}},I=E=>async A=>{A.stopPropagation();const L=[...i.points.slice(0,E+1),n[E].point,...i.points.slice(E+1)],D=Ae(L);o("change",{...a,geometry:{points:L,bounds:D}}),await tc();const N=[...document.querySelectorAll(".a9s-handle")][E+1];if(N!=null&&N.firstChild){const $=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:A.clientX,clientY:A.clientY,pointerId:A.pointerId,pointerType:A.pointerType,isPrimary:A.isPrimary,buttons:A.buttons});N.firstChild.dispatchEvent($)}},M=()=>{if(i.points.length-g.length<3)return;const E=i.points.filter((L,D)=>!g.includes(D)),A=Ae(E);o("change",{...a,geometry:{points:E,bounds:A}}),e(8,g=[])};ti(()=>{if(Ne)return;const E=A=>{(A.key==="Delete"||A.key==="Backspace")&&(A.preventDefault(),M())};return u.addEventListener("pointermove",v),u.addEventListener("keydown",E),()=>{u.removeEventListener("pointermove",v),u.removeEventListener("keydown",E)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function U(E){oe.call(this,r,E)}function P(E){oe.call(this,r,E)}function T(E){oe.call(this,r,E)}return r.$$set=E=>{"shape"in E&&e(0,a=E.shape),"computedStyle"in E&&e(1,l=E.computedStyle),"transform"in E&&e(2,h=E.transform),"viewportScale"in E&&e(3,c=E.viewportScale),"svgEl"in E&&e(4,u=E.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,n=Ne?[]:i.points.map((E,A)=>{const L=A===i.points.length-1?i.points[0]:i.points[A+1],D=(E[0]+L[0])/2,N=(E[1]+L[1])/2,$=Math.sqrt(Math.pow(L[0]-D,2)+Math.pow(L[1]-N,2))>_0/c;return{point:[D,N],visible:$}})),r.$$.dirty[0]&40&&e(9,s=gs(i.bounds,bn/c))},[a,l,h,c,u,i,d,f,g,s,n,y,_,v,b,S,R,C,I,F,U,P,T]}class b0 extends me{constructor(t){super(),pe(this,t,v0,m0,Kt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function x0(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v,m,b,S,R,C,I,M,F,U,P,T,E,A,L,D,N,$,O,B,k,V,z,K,X,ft,H,mt,Q,ut,gt,Et,Dt,Yt,Vt,et,$e,es;return Q=new Mi({props:{class:"a9s-corner-handle-topleft",x:r[5].x,y:r[5].y,scale:r[3]}}),Q.$on("pointerdown",function(){Gt(r[12]("TOP_LEFT"))&&r[12]("TOP_LEFT").apply(this,arguments)}),gt=new Mi({props:{class:"a9s-corner-handle-topright",x:r[5].x+r[5].w,y:r[5].y,scale:r[3]}}),gt.$on("pointerdown",function(){Gt(r[12]("TOP_RIGHT"))&&r[12]("TOP_RIGHT").apply(this,arguments)}),Dt=new Mi({props:{class:"a9s-corner-handle-bottomright",x:r[5].x+r[5].w,y:r[5].y+r[5].h,scale:r[3]}}),Dt.$on("pointerdown",function(){Gt(r[12]("BOTTOM_RIGHT"))&&r[12]("BOTTOM_RIGHT").apply(this,arguments)}),Vt=new Mi({props:{class:"a9s-corner-handle-bottomleft",x:r[5].x,y:r[5].y+r[5].h,scale:r[3]}}),Vt.$on("pointerdown",function(){Gt(r[12]("BOTTOM_LEFT"))&&r[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=W("defs"),e=W("mask"),i=W("rect"),l=W("rect"),f=we(),p=W("rect"),m=we(),b=W("rect"),M=we(),F=W("rect"),E=we(),A=W("rect"),$=we(),O=W("rect"),z=we(),K=W("rect"),mt=we(),re(Q.$$.fragment),ut=we(),re(gt.$$.fragment),Et=we(),re(Dt.$$.fragment),Yt=we(),re(Vt.$$.fragment),x(i,"class","rect-mask-bg svelte-1njczvj"),x(i,"x",n=r[6].x),x(i,"y",s=r[6].y),x(i,"width",o=r[6].w),x(i,"height",a=r[6].h),x(l,"class","rect-mask-fg svelte-1njczvj"),x(l,"x",h=r[5].x),x(l,"y",c=r[5].y),x(l,"width",u=r[5].w),x(l,"height",d=r[5].h),x(e,"id",r[8]),x(e,"class","a9s-rectangle-editor-mask svelte-1njczvj"),x(p,"class","a9s-outer"),x(p,"mask",`url(#${r[8]})`),x(p,"x",g=r[5].x),x(p,"y",y=r[5].y),x(p,"width",_=r[5].w),x(p,"height",v=r[5].h),x(b,"class","a9s-inner a9s-shape-handle"),x(b,"style",r[1]),x(b,"x",S=r[5].x),x(b,"y",R=r[5].y),x(b,"width",C=r[5].w),x(b,"height",I=r[5].h),x(F,"class","a9s-edge-handle a9s-edge-handle-top"),x(F,"x",U=r[5].x),x(F,"y",P=r[5].y),x(F,"height",1),x(F,"width",T=r[5].w),x(A,"class","a9s-edge-handle a9s-edge-handle-right"),x(A,"x",L=r[5].x+r[5].w),x(A,"y",D=r[5].y),x(A,"height",N=r[5].h),x(A,"width",1),x(O,"class","a9s-edge-handle a9s-edge-handle-bottom"),x(O,"x",B=r[5].x),x(O,"y",k=r[5].y+r[5].h),x(O,"height",1),x(O,"width",V=r[5].w),x(K,"class","a9s-edge-handle a9s-edge-handle-left"),x(K,"x",X=r[5].x),x(K,"y",ft=r[5].y),x(K,"height",H=r[5].h),x(K,"width",1)},m(Y,G){nt(Y,t,G),xt(t,e),xt(e,i),xt(e,l),nt(Y,f,G),nt(Y,p,G),nt(Y,m,G),nt(Y,b,G),nt(Y,M,G),nt(Y,F,G),nt(Y,E,G),nt(Y,A,G),nt(Y,$,G),nt(Y,O,G),nt(Y,z,G),nt(Y,K,G),nt(Y,mt,G),Jt(Q,Y,G),nt(Y,ut,G),Jt(gt,Y,G),nt(Y,Et,G),Jt(Dt,Y,G),nt(Y,Yt,G),Jt(Vt,Y,G),et=!0,$e||(es=[St(p,"pointerdown",function(){Gt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),St(b,"pointerdown",function(){Gt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),St(F,"pointerdown",function(){Gt(r[12]("TOP"))&&r[12]("TOP").apply(this,arguments)}),St(A,"pointerdown",function(){Gt(r[12]("RIGHT"))&&r[12]("RIGHT").apply(this,arguments)}),St(O,"pointerdown",function(){Gt(r[12]("BOTTOM"))&&r[12]("BOTTOM").apply(this,arguments)}),St(K,"pointerdown",function(){Gt(r[12]("LEFT"))&&r[12]("LEFT").apply(this,arguments)})],$e=!0)},p(Y,G){r=Y,(!et||G&64&&n!==(n=r[6].x))&&x(i,"x",n),(!et||G&64&&s!==(s=r[6].y))&&x(i,"y",s),(!et||G&64&&o!==(o=r[6].w))&&x(i,"width",o),(!et||G&64&&a!==(a=r[6].h))&&x(i,"height",a),(!et||G&32&&h!==(h=r[5].x))&&x(l,"x",h),(!et||G&32&&c!==(c=r[5].y))&&x(l,"y",c),(!et||G&32&&u!==(u=r[5].w))&&x(l,"width",u),(!et||G&32&&d!==(d=r[5].h))&&x(l,"height",d),(!et||G&32&&g!==(g=r[5].x))&&x(p,"x",g),(!et||G&32&&y!==(y=r[5].y))&&x(p,"y",y),(!et||G&32&&_!==(_=r[5].w))&&x(p,"width",_),(!et||G&32&&v!==(v=r[5].h))&&x(p,"height",v),(!et||G&2)&&x(b,"style",r[1]),(!et||G&32&&S!==(S=r[5].x))&&x(b,"x",S),(!et||G&32&&R!==(R=r[5].y))&&x(b,"y",R),(!et||G&32&&C!==(C=r[5].w))&&x(b,"width",C),(!et||G&32&&I!==(I=r[5].h))&&x(b,"height",I),(!et||G&32&&U!==(U=r[5].x))&&x(F,"x",U),(!et||G&32&&P!==(P=r[5].y))&&x(F,"y",P),(!et||G&32&&T!==(T=r[5].w))&&x(F,"width",T),(!et||G&32&&L!==(L=r[5].x+r[5].w))&&x(A,"x",L),(!et||G&32&&D!==(D=r[5].y))&&x(A,"y",D),(!et||G&32&&N!==(N=r[5].h))&&x(A,"height",N),(!et||G&32&&B!==(B=r[5].x))&&x(O,"x",B),(!et||G&32&&k!==(k=r[5].y+r[5].h))&&x(O,"y",k),(!et||G&32&&V!==(V=r[5].w))&&x(O,"width",V),(!et||G&32&&X!==(X=r[5].x))&&x(K,"x",X),(!et||G&32&&ft!==(ft=r[5].y))&&x(K,"y",ft),(!et||G&32&&H!==(H=r[5].h))&&x(K,"height",H);const Sr={};G&32&&(Sr.x=r[5].x),G&32&&(Sr.y=r[5].y),G&8&&(Sr.scale=r[3]),Q.$set(Sr);const Cr={};G&32&&(Cr.x=r[5].x+r[5].w),G&32&&(Cr.y=r[5].y),G&8&&(Cr.scale=r[3]),gt.$set(Cr);const Ir={};G&32&&(Ir.x=r[5].x+r[5].w),G&32&&(Ir.y=r[5].y+r[5].h),G&8&&(Ir.scale=r[3]),Dt.$set(Ir);const Pr={};G&32&&(Pr.x=r[5].x),G&32&&(Pr.y=r[5].y+r[5].h),G&8&&(Pr.scale=r[3]),Vt.$set(Pr)},i(Y){et||(lt(Q.$$.fragment,Y),lt(gt.$$.fragment,Y),lt(Dt.$$.fragment,Y),lt(Vt.$$.fragment,Y),et=!0)},o(Y){yt(Q.$$.fragment,Y),yt(gt.$$.fragment,Y),yt(Dt.$$.fragment,Y),yt(Vt.$$.fragment,Y),et=!1},d(Y){Y&&(rt(t),rt(f),rt(p),rt(m),rt(b),rt(M),rt(F),rt(E),rt(A),rt($),rt(O),rt(z),rt(K),rt(mt),rt(ut),rt(Et),rt(Yt)),te(Q,Y),te(gt,Y),te(Dt,Y),te(Vt,Y),$e=!1,Me(es)}}}function w0(r){let t,e;return t=new sa({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[x0,({grab:i})=>({12:i}),({grab:i})=>i?4096:0]},$$scope:{ctx:r}}}),t.$on("grab",r[9]),t.$on("change",r[10]),t.$on("release",r[11]),{c(){re(t.$$.fragment)},m(i,n){Jt(t,i,n),e=!0},p(i,[n]){const s={};n&1&&(s.shape=i[0]),n&4&&(s.transform=i[2]),n&16&&(s.svgEl=i[4]),n&12394&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function E0(r,t,e){let i,n,{shape:s}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const c=(g,y,_)=>{const v=g.geometry.bounds;let[m,b]=[v.minX,v.minY],[S,R]=[v.maxX,v.maxY];const[C,I]=_;if(y==="SHAPE")m+=C,S+=C,b+=I,R+=I;else{switch(y){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{b+=I;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{R+=I;break}}switch(y){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{m+=C;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{S+=C;break}}}const M=Math.min(m,S),F=Math.min(b,R),U=Math.abs(S-m),P=Math.abs(R-b);return{...g,geometry:{x:M,y:F,w:U,h:P,bounds:{minX:M,minY:F,maxX:M+U,maxY:F+P}}}},u=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(g){oe.call(this,r,g)}function f(g){oe.call(this,r,g)}function p(g){oe.call(this,r,g)}return r.$$set=g=>{"shape"in g&&e(0,s=g.shape),"computedStyle"in g&&e(1,o=g.computedStyle),"transform"in g&&e(2,a=g.transform),"viewportScale"in g&&e(3,l=g.viewportScale),"svgEl"in g&&e(4,h=g.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=s.geometry),r.$$.dirty&40&&e(6,n=gs(i.bounds,2/l))},[s,o,a,l,h,i,n,c,u,d,f,p]}class T0 extends me{constructor(t){super(),pe(this,t,E0,w0,Kt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var Ac=Object.prototype.hasOwnProperty;function ha(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--&&ha(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Ac.call(r,e)&&++i&&!Ac.call(t,e)||!(e in t)||!ha(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}const A0=12,S0=(r,t)=>r.polygons.reduce((e,i,n)=>{const s=i.rings.reduce((o,a,l)=>{const h=a.points.map((c,u)=>{const d=u===a.points.length-1?a.points[0]:a.points[u+1],f=(c[0]+d[0])/2,p=(c[1]+d[1])/2,g=Math.sqrt(Math.pow(d[0]-f,2)+Math.pow(d[1]-p,2))>A0/t;return{point:[f,p],visible:g,elementIdx:n,ringIdx:l,pointIdx:u}});return[...o,...h]},[]);return[...e,...s]},[]);function ca(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Sc(r,t,e){const i=r.slice();return i[30]=t[e],i[32]=e,i}function Cc(r,t,e){const i=r.slice();return i[33]=t[e],i[35]=e,i}function Ic(r,t,e){const i=r.slice();return i[29]=t[e],i[37]=e,i}function ua(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function da(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Pc(r){let t,e,i,n;return{c(){t=W("circle"),x(t,"cx",e=r[29][0]),x(t,"cy",i=r[29][1]),x(t,"r",n=xn/r[3]),x(t,"class","svelte-1vxo6dc")},m(s,o){nt(s,t,o)},p(s,o){o[0]&1088&&e!==(e=s[29][0])&&x(t,"cx",e),o[0]&1088&&i!==(i=s[29][1])&&x(t,"cy",i),o[0]&8&&n!==(n=xn/s[3])&&x(t,"r",n)},d(s){s&&rt(t)}}}function Rc(r){let t,e,i,n,s,o,a,l,h,c;return{c(){t=W("mask"),e=W("rect"),a=W("circle"),x(e,"x",i=r[9].x),x(e,"y",n=r[9].y),x(e,"width",s=r[9].w),x(e,"height",o=r[9].h),x(e,"class","svelte-1vxo6dc"),x(a,"cx",l=r[29][0]),x(a,"cy",h=r[29][1]),x(a,"r",c=xn/r[3]),x(a,"class","svelte-1vxo6dc"),x(t,"id",`${r[18]}-${r[32]}-inner`),x(t,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc")},m(u,d){nt(u,t,d),xt(t,e),xt(t,a)},p(u,d){d[0]&512&&i!==(i=u[9].x)&&x(e,"x",i),d[0]&512&&n!==(n=u[9].y)&&x(e,"y",n),d[0]&512&&s!==(s=u[9].w)&&x(e,"width",s),d[0]&512&&o!==(o=u[9].h)&&x(e,"height",o),d[0]&1088&&l!==(l=u[29][0])&&x(a,"cx",l),d[0]&1088&&h!==(h=u[29][1])&&x(a,"cy",h),d[0]&8&&c!==(c=xn/u[3])&&x(a,"r",c)},d(u){u&&rt(t)}}}function Mc(r){let t,e;function i(...n){return r[19](r[32],r[35],r[37],...n)}return t=new Mi({props:{class:"a9s-corner-handle",x:r[29][0],y:r[29][1],scale:r[3],selected:r[8].some(i)}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[14]),t.$on("pointerdown",function(){Gt(r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`))&&r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`).apply(this,arguments)}),t.$on("pointerup",r[15](r[32],r[35],r[37])),{c(){re(t.$$.fragment)},m(n,s){Jt(t,n,s),e=!0},p(n,s){r=n;const o={};s[0]&32&&(o.x=r[29][0]),s[0]&32&&(o.y=r[29][1]),s[0]&8&&(o.scale=r[3]),s[0]&256&&(o.selected=r[8].some(i)),t.$set(o)},i(n){e||(lt(t.$$.fragment,n),e=!0)},o(n){yt(t.$$.fragment,n),e=!1},d(n){te(t,n)}}}function Dc(r){let t,e,i=Ie(r[33].points),n=[];for(let o=0;o<i.length;o+=1)n[o]=Mc(Ic(r,i,o));const s=o=>yt(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=De()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);nt(o,t,a),e=!0},p(o,a){if(a[0]&268491048){i=Ie(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=Ic(o,i,l);n[l]?(n[l].p(h,a),lt(n[l],1)):(n[l]=Mc(h),n[l].c(),lt(n[l],1),n[l].m(t.parentNode,t))}for(Ee(),l=i.length;l<n.length;l+=1)s(l);Te()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)lt(n[a]);e=!0}},o(o){n=n.filter(Boolean);for(let a=0;a<n.length;a+=1)yt(n[a]);e=!1},d(o){o&&rt(t),Jr(n,o)}}}function Bc(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v=r[6]!==void 0&&!r[7]&&Pc(da(r)),m=r[6]!==void 0&&!r[7]&&Rc(ua(r)),b=Ie(r[30].rings),S=[];for(let C=0;C<b.length;C+=1)S[C]=Dc(Cc(r,b,C));const R=C=>yt(S[C],1,1,()=>{S[C]=null});return{c(){t=W("g"),e=W("defs"),i=W("mask"),n=W("rect"),h=W("path"),v&&v.c(),m&&m.c(),u=W("path"),f=W("path");for(let C=0;C<S.length;C+=1)S[C].c();x(n,"x",s=r[9].x),x(n,"y",o=r[9].y),x(n,"width",a=r[9].w),x(n,"height",l=r[9].h),x(n,"class","svelte-1vxo6dc"),x(h,"d",c=He(r[30])),x(h,"class","svelte-1vxo6dc"),x(i,"id",`${r[18]}-${r[32]}-outer`),x(i,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc"),x(u,"class","a9s-outer"),x(u,"mask",`url(#${r[18]}-${r[32]}-outer)`),x(u,"fill-rule","evenodd"),x(u,"d",d=He(r[30])),x(f,"class","a9s-inner"),x(f,"mask",`url(#${r[18]}-${r[32]}-inner)`),x(f,"style",r[1]),x(f,"fill-rule","evenodd"),x(f,"d",p=He(r[30]))},m(C,I){nt(C,t,I),xt(t,e),xt(e,i),xt(i,n),xt(i,h),v&&v.m(i,null),m&&m.m(e,null),xt(t,u),xt(t,f);for(let M=0;M<S.length;M+=1)S[M]&&S[M].m(t,null);g=!0,y||(_=[St(u,"pointerup",r[13]),St(u,"pointerdown",function(){Gt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)}),St(f,"pointerup",r[13]),St(f,"pointerdown",function(){Gt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)})],y=!0)},p(C,I){if(r=C,(!g||I[0]&512&&s!==(s=r[9].x))&&x(n,"x",s),(!g||I[0]&512&&o!==(o=r[9].y))&&x(n,"y",o),(!g||I[0]&512&&a!==(a=r[9].w))&&x(n,"width",a),(!g||I[0]&512&&l!==(l=r[9].h))&&x(n,"height",l),(!g||I[0]&32&&c!==(c=He(r[30])))&&x(h,"d",c),r[6]!==void 0&&!r[7]?v?v.p(da(r),I):(v=Pc(da(r)),v.c(),v.m(i,null)):v&&(v.d(1),v=null),r[6]!==void 0&&!r[7]?m?m.p(ua(r),I):(m=Rc(ua(r)),m.c(),m.m(e,null)):m&&(m.d(1),m=null),(!g||I[0]&32&&d!==(d=He(r[30])))&&x(u,"d",d),(!g||I[0]&2)&&x(f,"style",r[1]),(!g||I[0]&32&&p!==(p=He(r[30])))&&x(f,"d",p),I[0]&268491048){b=Ie(r[30].rings);let M;for(M=0;M<b.length;M+=1){const F=Cc(r,b,M);S[M]?(S[M].p(F,I),lt(S[M],1)):(S[M]=Dc(F),S[M].c(),lt(S[M],1),S[M].m(t,null))}for(Ee(),M=b.length;M<S.length;M+=1)R(M);Te()}},i(C){if(!g){for(let I=0;I<b.length;I+=1)lt(S[I]);g=!0}},o(C){S=S.filter(Boolean);for(let I=0;I<S.length;I+=1)yt(S[I]);g=!1},d(C){C&&rt(t),v&&v.d(),m&&m.d(),Jr(S,C),y=!1,Me(_)}}}function Oc(r){let t,e;return t=new gc({props:{x:r[29][0],y:r[29][1],scale:r[3]}}),t.$on("pointerdown",function(){Gt(r[17](r[6]))&&r[17](r[6]).apply(this,arguments)}),{c(){re(t.$$.fragment)},m(i,n){Jt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&1088&&(s.x=r[29][0]),n[0]&1088&&(s.y=r[29][1]),n[0]&8&&(s.scale=r[3]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function C0(r){let t,e,i,n=Ie(r[5].polygons),s=[];for(let l=0;l<n.length;l+=1)s[l]=Bc(Sc(r,n,l));const o=l=>yt(s[l],1,1,()=>{s[l]=null});let a=r[6]!==void 0&&!r[7]&&Oc(ca(r));return{c(){for(let l=0;l<s.length;l+=1)s[l].c();t=we(),a&&a.c(),e=De()},m(l,h){for(let c=0;c<s.length;c+=1)s[c]&&s[c].m(l,h);nt(l,t,h),a&&a.m(l,h),nt(l,e,h),i=!0},p(l,h){if(h[0]&268763114){n=Ie(l[5].polygons);let c;for(c=0;c<n.length;c+=1){const u=Sc(l,n,c);s[c]?(s[c].p(u,h),lt(s[c],1)):(s[c]=Bc(u),s[c].c(),lt(s[c],1),s[c].m(t.parentNode,t))}for(Ee(),c=n.length;c<s.length;c+=1)o(c);Te()}l[6]!==void 0&&!l[7]?a?(a.p(ca(l),h),h[0]&192&&lt(a,1)):(a=Oc(ca(l)),a.c(),lt(a,1),a.m(e.parentNode,e)):a&&(Ee(),yt(a,1,1,()=>{a=null}),Te())},i(l){if(!i){for(let h=0;h<n.length;h+=1)lt(s[h]);lt(a),i=!0}},o(l){s=s.filter(Boolean);for(let h=0;h<s.length;h+=1)yt(s[h]);yt(a),i=!1},d(l){l&&(rt(t),rt(e)),Jr(s,l),a&&a.d(l)}}}function I0(r){let t,e;return t=new sa({props:{shape:r[0],transform:r[2],editor:r[16],svgEl:r[4],$$slots:{default:[C0,({grab:i})=>({28:i}),({grab:i})=>[i?268435456:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){re(t.$$.fragment)},m(i,n){Jt(t,i,n),e=!0},p(i,n){const s={};n[0]&1&&(s.shape=i[0]),n[0]&4&&(s.transform=i[2]),n[0]&16&&(s.svgEl=i[4]),n[0]&268437482|n[1]&128&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}const P0=250,R0=1e3,xn=4.5;function M0(r,t,e){let i,n,s;const o=Mr();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:c=1}=t,{svgEl:u}=t,d,f=!1,p,g=[];const y=()=>e(7,f=!0),_=()=>e(7,f=!1),v=A=>{if(g.length>0||!n.some(k=>k.visible)){e(6,d=void 0);return}const[L,D]=h.elementToImage(A.offsetX,A.offsetY),N=k=>Math.pow(k[0]-L,2)+Math.pow(k[1]-D,2),$=zg(i).reduce((k,V)=>N(V)<N(k)?V:k),O=n.filter(k=>k.visible).reduce((k,V)=>N(V.point)<N(k.point)?V:k),B=Math.pow(R0/c,2);N($)<B||N(O.point)<B?e(6,d=n.indexOf(O)):e(6,d=void 0)},m=()=>{document.activeElement!==u&&u.focus()},b=()=>{e(8,g=[]),m()},S=A=>{e(7,f=!0),A.preventDefault(),A.stopPropagation(),p=performance.now()},R=(A,L,D)=>N=>{if(!p||Ne||performance.now()-p>P0)return;const $=B=>B.polygon===A&&B.ring===L&&B.point===D,O=g.some($);N.metaKey||N.ctrlKey||N.shiftKey?O?e(8,g=g.filter(B=>!$(B))):e(8,g=[...g,{polygon:A,ring:L,point:D}]):O&&g.length>1?e(8,g=[{polygon:A,ring:L,point:D}]):O?e(8,g=[]):e(8,g=[{polygon:A,ring:L,point:D}]),m()},C=(A,L,D)=>{m();const N=A.geometry.polygons;let $;if(L==="SHAPE")$=N.map(O=>{const B=O.rings.map((V,z)=>({points:V.points.map((K,X)=>[K[0]+D[0],K[1]+D[1]])})),k=Ae(B[0].points);return{rings:B,bounds:k}});else{const[O,B,k,V]=L.split("-").map(z=>parseInt(z));$=N.map((z,K)=>{if(K===B){const X=z.rings.map((H,mt)=>mt===k?{points:H.points.map((Q,ut)=>ut===V?[Q[0]+D[0],Q[1]+D[1]]:Q)}:H),ft=Ae(X[0].points);return{rings:X,bounds:ft}}else return z})}return{...A,geometry:{polygons:$,bounds:Zo($)}}},I=A=>async L=>{L.stopPropagation();const D=n[A],N=i.polygons.map((O,B)=>{if(B===D.elementIdx){const k=O.rings.map((z,K)=>K===D.ringIdx?{points:[...z.points.slice(0,D.pointIdx+1),D.point,...z.points.slice(D.pointIdx+1)]}:z),V=Ae(k[0].points);return{rings:k,bounds:V}}else return O});o("change",{...a,geometry:{polygons:N,bounds:Zo(N)}}),await tc();const $=[...document.querySelectorAll(".a9s-handle")][A+1];if($!=null&&$.firstChild){const O=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:L.clientX,clientY:L.clientY,pointerId:L.pointerId,pointerType:L.pointerType,isPrimary:L.isPrimary,buttons:L.buttons});$.firstChild.dispatchEvent(O)}},M=()=>{const A=i.polygons.map((L,D)=>{if(g.some(N=>N.polygon===D)){const N=L.rings.map((O,B)=>{const k=g.filter(V=>V.polygon===D&&V.ring===B);return k.length&&O.points.length-k.length>=3?{points:O.points.filter((V,z)=>!k.some(K=>K.point===z))}:O}),$=Ae(N[0].points);return{rings:N,bounds:$}}else return L});!ha(i.polygons,A)&&(o("change",{...a,geometry:{polygons:A,bounds:Zo(A)}}),e(8,g=[]))};ti(()=>{if(Ne)return;const A=L=>{(L.key==="Delete"||L.key==="Backspace")&&(L.preventDefault(),M())};return u.addEventListener("pointermove",v),u.addEventListener("keydown",A),()=>{u.removeEventListener("pointermove",v),u.removeEventListener("keydown",A)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,U=(A,L,D,{polygon:N,ring:$,point:O})=>N===A&&$===L&&O===D;function P(A){oe.call(this,r,A)}function T(A){oe.call(this,r,A)}function E(A){oe.call(this,r,A)}return r.$$set=A=>{"shape"in A&&e(0,a=A.shape),"computedStyle"in A&&e(1,l=A.computedStyle),"transform"in A&&e(2,h=A.transform),"viewportScale"in A&&e(3,c=A.viewportScale),"svgEl"in A&&e(4,u=A.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,n=Ne?[]:S0(i,c)),r.$$.dirty[0]&40&&e(9,s=gs(i.bounds,xn/c))},[a,l,h,c,u,i,d,f,g,s,n,y,_,b,S,R,C,I,F,U,P,T,E]}class D0 extends me{constructor(t){super(),pe(this,t,M0,I0,Kt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}const Lc=new Map([[_t.RECTANGLE,T0],[_t.POLYGON,b0],[_t.MULTIPOLYGON,D0]]),fa=r=>Lc.get(r.type),Nc=(r,t)=>Lc.set(r,t);function B0(r,t,e){let i;const n=Mr();let{annotation:s}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return ti(()=>(e(6,u=new o({target:l,props:{shape:s.target.selector,computedStyle:i,transform:h,viewportScale:c,svgEl:l.closest("svg")}})),u.$on("change",d=>{u.$$set({shape:d.detail}),n("change",d.detail)}),u.$on("grab",d=>n("grab",d.detail)),u.$on("release",d=>n("release",d.detail)),()=>{u.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,s=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,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=ri(s,a)),r.$$.dirty&65&&s&&(u==null||u.$set({shape:s.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c}),r.$$.dirty&192&&u&&i&&u.$set({computedStyle:i})},[s,o,a,l,h,c,u,i]}class O0 extends me{constructor(t){super(),pe(this,t,B0,null,Kt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function L0(r,t,e){const i=Mr();let{drawingMode:n}=t,{target:s}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return ti(()=>{const c=s.closest("svg"),u=[],d=(f,p,g)=>{c==null||c.addEventListener(f,p,g),u.push(()=>c==null?void 0:c.removeEventListener(f,p,g))};return e(5,h=new o({target:s,props:{addEventListener:d,drawingMode:n,transform:a,viewportScale:l}})),h.$on("create",f=>i("create",f.detail)),()=>{u.forEach(f=>f()),h.$destroy()}}),r.$$set=c=>{"drawingMode"in c&&e(0,n=c.drawingMode),"target"in c&&e(1,s=c.target),"tool"in c&&e(2,o=c.tool),"transform"in c&&e(3,a=c.transform),"viewportScale"in c&&e(4,l=c.viewportScale)},r.$$.update=()=>{r.$$.dirty&40&&h&&h.$set({transform:a}),r.$$.dirty&48&&h&&h.$set({viewportScale:l})},[n,s,o,a,l,h]}class N0 extends me{constructor(t){super(),pe(this,t,L0,null,Kt,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function Fc(r){let t,e,i,n,s,o,a,l,h,c;return{c(){t=W("defs"),e=W("mask"),i=W("rect"),l=W("rect"),h=W("rect"),c=W("rect"),x(i,"class","rect-mask-bg svelte-1a76qe7"),x(i,"x",n=r[1]-r[5]),x(i,"y",s=r[2]-r[5]),x(i,"width",o=r[3]+2*r[5]),x(i,"height",a=r[4]+2*r[5]),x(l,"class","rect-mask-fg svelte-1a76qe7"),x(l,"x",r[1]),x(l,"y",r[2]),x(l,"width",r[3]),x(l,"height",r[4]),x(e,"id",r[6]),x(e,"class","a9s-rubberband-rectangle-mask svelte-1a76qe7"),x(h,"class","a9s-outer"),x(h,"mask",`url(#${r[6]})`),x(h,"x",r[1]),x(h,"y",r[2]),x(h,"width",r[3]),x(h,"height",r[4]),x(c,"class","a9s-inner"),x(c,"x",r[1]),x(c,"y",r[2]),x(c,"width",r[3]),x(c,"height",r[4])},m(u,d){nt(u,t,d),xt(t,e),xt(e,i),xt(e,l),nt(u,h,d),nt(u,c,d)},p(u,d){d&34&&n!==(n=u[1]-u[5])&&x(i,"x",n),d&36&&s!==(s=u[2]-u[5])&&x(i,"y",s),d&40&&o!==(o=u[3]+2*u[5])&&x(i,"width",o),d&48&&a!==(a=u[4]+2*u[5])&&x(i,"height",a),d&2&&x(l,"x",u[1]),d&4&&x(l,"y",u[2]),d&8&&x(l,"width",u[3]),d&16&&x(l,"height",u[4]),d&2&&x(h,"x",u[1]),d&4&&x(h,"y",u[2]),d&8&&x(h,"width",u[3]),d&16&&x(h,"height",u[4]),d&2&&x(c,"x",u[1]),d&4&&x(c,"y",u[2]),d&8&&x(c,"width",u[3]),d&16&&x(c,"height",u[4])},d(u){u&&(rt(t),rt(h),rt(c))}}}function F0(r){let t,e=r[0]&&Fc(r);return{c(){t=W("g"),e&&e.c(),x(t,"class","a9s-annotation a9s-rubberband")},m(i,n){nt(i,t,n),e&&e.m(t,null)},p(i,[n]){i[0]?e?e.p(i,n):(e=Fc(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Rt,o:Rt,d(i){i&&rt(t),e&&e.d()}}}function k0(r,t,e){let i;const n=Mr();let{addEventListener:s}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,c,u,d,f,p,g;const y=S=>{const R=S;h=performance.now(),o==="drag"&&(e(0,c=a.elementToImage(R.offsetX,R.offsetY)),u=c,e(1,d=c[0]),e(2,f=c[1]),e(3,p=1),e(4,g=1))},_=S=>{const R=S;c&&(u=a.elementToImage(R.offsetX,R.offsetY),e(1,d=Math.min(u[0],c[0])),e(2,f=Math.min(u[1],c[1])),e(3,p=Math.abs(u[0]-c[0])),e(4,g=Math.abs(u[1]-c[1])))},v=S=>{const R=S,C=performance.now()-h;if(o==="click"){if(C>300)return;c?m():(e(0,c=a.elementToImage(R.offsetX,R.offsetY)),u=c,e(1,d=c[0]),e(2,f=c[1]),e(3,p=1),e(4,g=1))}else c&&(C>300||p*g>100?(R.stopPropagation(),m()):(e(0,c=void 0),u=void 0))},m=()=>{if(p*g>15){const S={type:_t.RECTANGLE,geometry:{bounds:{minX:d,minY:f,maxX:d+p,maxY:f+g},x:d,y:f,w:p,h:g}};n("create",S)}e(0,c=void 0),u=void 0};ti(()=>{s("pointerdown",y),s("pointermove",_),s("pointerup",v,!0)});const b=`rect-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=S=>{"addEventListener"in S&&e(7,s=S.addEventListener),"drawingMode"in S&&e(8,o=S.drawingMode),"transform"in S&&e(9,a=S.transform),"viewportScale"in S&&e(10,l=S.viewportScale)},r.$$.update=()=>{r.$$.dirty&1024&&e(5,i=2/l)},[c,d,f,p,g,i,b,s,o,a,l]}class U0 extends me{constructor(t){super(),pe(this,t,k0,F0,Kt,{addEventListener:7,drawingMode:8,transform:9,viewportScale:10})}}function pa(r){const t=r.slice(),e=t[2].map(i=>i.join(",")).join(" ");return t[19]=e,t}function kc(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g=r[1]&&Uc(r);return{c(){t=W("defs"),e=W("mask"),i=W("rect"),l=W("polygon"),c=W("polygon"),d=W("polygon"),g&&g.c(),p=De(),x(i,"x",n=r[3].x),x(i,"y",s=r[3].y),x(i,"width",o=r[3].w),x(i,"height",a=r[3].h),x(i,"class","svelte-18wrg3t"),x(l,"points",h=r[19]),x(l,"class","svelte-18wrg3t"),x(e,"id",r[5]),x(e,"class","a9s-rubberband-polygon-mask svelte-18wrg3t"),x(c,"class","a9s-outer"),x(c,"mask",`url(#${r[5]})`),x(c,"points",u=r[19]),x(d,"class","a9s-inner"),x(d,"points",f=r[19])},m(y,_){nt(y,t,_),xt(t,e),xt(e,i),xt(e,l),nt(y,c,_),nt(y,d,_),g&&g.m(y,_),nt(y,p,_)},p(y,_){_&8&&n!==(n=y[3].x)&&x(i,"x",n),_&8&&s!==(s=y[3].y)&&x(i,"y",s),_&8&&o!==(o=y[3].w)&&x(i,"width",o),_&8&&a!==(a=y[3].h)&&x(i,"height",a),_&4&&h!==(h=y[19])&&x(l,"points",h),_&4&&u!==(u=y[19])&&x(c,"points",u),_&4&&f!==(f=y[19])&&x(d,"points",f),y[1]?g?g.p(y,_):(g=Uc(y),g.c(),g.m(p.parentNode,p)):g&&(g.d(1),g=null)},d(y){y&&(rt(t),rt(c),rt(d),rt(p)),g&&g.d(y)}}}function Uc(r){let t,e,i;return{c(){t=W("circle"),x(t,"class","a9s-handle svelte-18wrg3t"),x(t,"cx",e=r[0][0][0]),x(t,"cy",i=r[0][0][1]),x(t,"r",r[4])},m(n,s){nt(n,t,s)},p(n,s){s&1&&e!==(e=n[0][0][0])&&x(t,"cx",e),s&1&&i!==(i=n[0][0][1])&&x(t,"cy",i),s&16&&x(t,"r",n[4])},d(n){n&&rt(t)}}}function G0(r){let t,e=r[3]&&kc(pa(r));return{c(){t=W("g"),e&&e.c(),x(t,"class","a9s-annotation a9s-rubberband")},m(i,n){nt(i,t,n),e&&e.m(t,null)},p(i,[n]){i[3]?e?e.p(pa(i),n):(e=kc(pa(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Rt,o:Rt,d(i){i&&rt(t),e&&e.d()}}}const $0=20,H0=1500;function X0(r,t,e){let i,n,s;const o=Mr();let{addEventListener:a}=t,{drawingMode:l}=t,{transform:h}=t,{viewportScale:c=1}=t,u,d=[],f,p,g=!1;const y=R=>{const C=R,{timeStamp:I,offsetX:M,offsetY:F}=C;if(u={timeStamp:I,offsetX:M,offsetY:F},l==="drag"&&d.length===0){const U=h.elementToImage(C.offsetX,C.offsetY);d.push(U),e(10,f=U)}},_=R=>{const C=R;if(p&&clearTimeout(p),d.length>0){if(e(10,f=h.elementToImage(C.offsetX,C.offsetY)),d.length>2){const I=us(f,d[0])*c;e(1,g=I<$0)}C.pointerType==="touch"&&(p=setTimeout(()=>{m()},H0))}},v=R=>{const C=R;if(p&&clearTimeout(p),l==="click"){const I=C.timeStamp-u.timeStamp,M=us([u.offsetX,u.offsetY],[C.offsetX,C.offsetY]);if(I>300||M>15)return;if(g)b();else if(d.length===0){const F=h.elementToImage(C.offsetX,C.offsetY);d.push(F),e(10,f=F)}else f&&d.push(f)}else{if(!f)return;if(d.length===1&&us(d[0],f)<=4){e(0,d=[]),e(10,f=void 0);return}C.stopImmediatePropagation(),g?b():d.push(f)}},m=()=>{if(!f)return;const R=d.slice(0,-1);if(R.length<3)return;const C={type:_t.POLYGON,geometry:{bounds:Ae(d),points:R}};Ko(C)>4&&(e(0,d=[]),e(10,f=void 0),o("create",C))},b=()=>{const R={type:_t.POLYGON,geometry:{bounds:Ae(d),points:[...d]}};e(0,d=[]),e(10,f=void 0),o("create",R)};ti(()=>{a("pointerdown",y,!0),a("pointermove",_),a("pointerup",v,!0),a("dblclick",m,!0)});const S=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=R=>{"addEventListener"in R&&e(6,a=R.addEventListener),"drawingMode"in R&&e(7,l=R.drawingMode),"transform"in R&&e(8,h=R.transform),"viewportScale"in R&&e(9,c=R.viewportScale)},r.$$.update=()=>{r.$$.dirty&512&&e(4,i=4/c),r.$$.dirty&1027&&e(2,n=f?g?d:[...d,f]:[]),r.$$.dirty&516&&e(3,s=n.length>0?gs(Ae(n),2/c):void 0)},[d,g,n,s,i,S,a,l,h,c,f]}class V0 extends me{constructor(t){super(),pe(this,t,X0,G0,Kt,{addEventListener:6,drawingMode:7,transform:8,viewportScale:9})}}const ma=new Map([["rectangle",{tool:U0}],["polygon",{tool:V0}]]),ys=()=>[...ma.keys()],_s=r=>ma.get(r),Gc=(r,t,e={})=>ma.set(r,{tool:t,opts:e});function z0(r){let t,e,i,n,s;return{c(){t=W("g"),e=W("ellipse"),n=W("ellipse"),x(e,"class","a9s-outer"),x(e,"style",i=r[1]?"display:none;":void 0),x(e,"cx",r[2]),x(e,"cy",r[3]),x(e,"rx",r[4]),x(e,"ry",r[5]),x(n,"class","a9s-inner"),x(n,"style",r[1]),x(n,"cx",r[2]),x(n,"cy",r[3]),x(n,"rx",r[4]),x(n,"ry",r[5]),x(t,"class","a9s-annotation"),x(t,"data-id",s=r[0].id)},m(o,a){nt(o,t,a),xt(t,e),xt(t,n)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&x(e,"style",i),a&2&&x(n,"style",o[1]),a&1&&s!==(s=o[0].id)&&x(t,"data-id",s)},i:Rt,o:Rt,d(o){o&&rt(t)}}}function j0(r,t,e){let i,{annotation:n}=t,{geom:s}=t,{style:o}=t;const{cx:a,cy:l,rx:h,ry:c}=s;return r.$$set=u=>{"annotation"in u&&e(0,n=u.annotation),"geom"in u&&e(6,s=u.geom),"style"in u&&e(7,o=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=ri(n,o))},[n,i,a,l,h,c,s,o]}class W0 extends me{constructor(t){super(),pe(this,t,j0,z0,Kt,{annotation:0,geom:6,style:7})}}function Y0(r){let t,e,i,n,s;return{c(){t=W("g"),e=W("line"),n=W("line"),x(e,"class","a9s-outer"),x(e,"style",i=r[1]?"display:none;":void 0),x(e,"x1",r[2]),x(e,"y1",r[3]),x(e,"x2",r[4]),x(e,"y2",r[5]),x(n,"class","a9s-inner"),x(n,"style",r[1]),x(n,"x1",r[2]),x(n,"y1",r[3]),x(n,"x2",r[4]),x(n,"y2",r[5]),x(t,"class","a9s-annotation"),x(t,"data-id",s=r[0].id)},m(o,a){nt(o,t,a),xt(t,e),xt(t,n)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&x(e,"style",i),a&2&&x(n,"style",o[1]),a&1&&s!==(s=o[0].id)&&x(t,"data-id",s)},i:Rt,o:Rt,d(o){o&&rt(t)}}}function q0(r,t,e){let i,{annotation:n}=t,{geom:s}=t,{style:o}=t;const{points:a}=s,[[l,h],[c,u]]=a;return r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"geom"in d&&e(6,s=d.geom),"style"in d&&e(7,o=d.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=ri(n,o))},[n,i,l,h,c,u,s,o]}class K0 extends me{constructor(t){super(),pe(this,t,q0,Y0,Kt,{annotation:0,geom:6,style:7})}}function $c(r,t,e){const i=r.slice();return i[5]=t[e],i}function Hc(r){let t,e,i;return{c(){t=W("path"),i=W("path"),x(t,"class","a9s-outer"),x(t,"style",e=r[1]?"display:none;":void 0),x(t,"fill-rule","evenodd"),x(t,"d",He(r[5])),x(i,"class","a9s-inner"),x(i,"style",r[1]),x(i,"fill-rule","evenodd"),x(i,"d",He(r[5]))},m(n,s){nt(n,t,s),nt(n,i,s)},p(n,s){s&2&&e!==(e=n[1]?"display:none;":void 0)&&x(t,"style",e),s&2&&x(i,"style",n[1])},d(n){n&&(rt(t),rt(i))}}}function Z0(r){let t,e,i=Ie(r[2]),n=[];for(let s=0;s<i.length;s+=1)n[s]=Hc($c(r,i,s));return{c(){t=W("g");for(let s=0;s<n.length;s+=1)n[s].c();x(t,"class","a9s-annotation"),x(t,"data-id",e=r[0].id)},m(s,o){nt(s,t,o);for(let a=0;a<n.length;a+=1)n[a]&&n[a].m(t,null)},p(s,[o]){if(o&6){i=Ie(s[2]);let a;for(a=0;a<i.length;a+=1){const l=$c(s,i,a);n[a]?n[a].p(l,o):(n[a]=Hc(l),n[a].c(),n[a].m(t,null))}for(;a<n.length;a+=1)n[a].d(1);n.length=i.length}o&1&&e!==(e=s[0].id)&&x(t,"data-id",e)},i:Rt,o:Rt,d(s){s&&rt(t),Jr(n,s)}}}function Q0(r,t,e){let i,{annotation:n}=t,{geom:s}=t,{style:o}=t;const{polygons:a}=s;return r.$$set=l=>{"annotation"in l&&e(0,n=l.annotation),"geom"in l&&e(3,s=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=ri(n,o))},[n,i,a,s,o]}class J0 extends me{constructor(t){super(),pe(this,t,Q0,Z0,Kt,{annotation:0,geom:3,style:4})}}function t_(r){let t,e,i,n,s;return{c(){t=W("g"),e=W("polygon"),n=W("polygon"),x(e,"class","a9s-outer"),x(e,"style",i=r[1]?"display:none;":void 0),x(e,"points",r[2].map(e_).join(" ")),x(n,"class","a9s-inner"),x(n,"style",r[1]),x(n,"points",r[2].map(r_).join(" ")),x(t,"class","a9s-annotation"),x(t,"data-id",s=r[0].id)},m(o,a){nt(o,t,a),xt(t,e),xt(t,n)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&x(e,"style",i),a&2&&x(n,"style",o[1]),a&1&&s!==(s=o[0].id)&&x(t,"data-id",s)},i:Rt,o:Rt,d(o){o&&rt(t)}}}const e_=r=>r.join(","),r_=r=>r.join(",");function i_(r,t,e){let i,{annotation:n}=t,{geom:s}=t,{style:o}=t;const{points:a}=s;return r.$$set=l=>{"annotation"in l&&e(0,n=l.annotation),"geom"in l&&e(3,s=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=ri(n,o))},[n,i,a,s,o]}class n_ extends me{constructor(t){super(),pe(this,t,i_,t_,Kt,{annotation:0,geom:3,style:4})}}function s_(r){let t,e,i,n,s,o,a;return{c(){t=W("g"),e=W("path"),s=W("path"),x(e,"class",i=Ai(`a9s-outer ${r[1]}`)+" svelte-1w0132l"),x(e,"style",n=r[3]?"display:none;":void 0),x(e,"d",r[2]),x(s,"class",o=Ai(`a9s-inner ${r[1]}`)+" svelte-1w0132l"),x(s,"style",r[3]),x(s,"d",r[2]),x(t,"class","a9s-annotation"),x(t,"data-id",a=r[0].id)},m(l,h){nt(l,t,h),xt(t,e),xt(t,s)},p(l,[h]){h&2&&i!==(i=Ai(`a9s-outer ${l[1]}`)+" svelte-1w0132l")&&x(e,"class",i),h&8&&n!==(n=l[3]?"display:none;":void 0)&&x(e,"style",n),h&4&&x(e,"d",l[2]),h&2&&o!==(o=Ai(`a9s-inner ${l[1]}`)+" svelte-1w0132l")&&x(s,"class",o),h&8&&x(s,"style",l[3]),h&4&&x(s,"d",l[2]),h&1&&a!==(a=l[0].id)&&x(t,"data-id",a)},i:Rt,o:Rt,d(l){l&&rt(t)}}}function o_(r,t,e){let i,n,s,{annotation:o}=t,{geom:a}=t,{style:l}=t;return r.$$set=h=>{"annotation"in h&&e(0,o=h.annotation),"geom"in h&&e(4,a=h.geom),"style"in h&&e(5,l=h.style)},r.$$.update=()=>{r.$$.dirty&33&&e(3,i=ri(o,l)),r.$$.dirty&16&&e(2,n=Jo(a)),r.$$.dirty&16&&e(1,s=a.closed?"closed":"open")},[o,s,n,i,a,l]}class a_ extends me{constructor(t){super(),pe(this,t,o_,s_,Kt,{annotation:0,geom:4,style:5})}}function l_(r){let t,e,i,n,s;return{c(){t=W("g"),e=W("rect"),n=W("rect"),x(e,"class","a9s-outer"),x(e,"style",i=r[5]?"display:none;":void 0),x(e,"x",r[4]),x(e,"y",r[3]),x(e,"width",r[2]),x(e,"height",r[1]),x(n,"class","a9s-inner"),x(n,"style",r[5]),x(n,"x",r[4]),x(n,"y",r[3]),x(n,"width",r[2]),x(n,"height",r[1]),x(t,"class","a9s-annotation"),x(t,"data-id",s=r[0].id)},m(o,a){nt(o,t,a),xt(t,e),xt(t,n)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&x(e,"style",i),a&16&&x(e,"x",o[4]),a&8&&x(e,"y",o[3]),a&4&&x(e,"width",o[2]),a&2&&x(e,"height",o[1]),a&32&&x(n,"style",o[5]),a&16&&x(n,"x",o[4]),a&8&&x(n,"y",o[3]),a&4&&x(n,"width",o[2]),a&2&&x(n,"height",o[1]),a&1&&s!==(s=o[0].id)&&x(t,"data-id",s)},i:Rt,o:Rt,d(o){o&&rt(t)}}}function h_(r,t,e){let i,n,s,o,a,{annotation:l}=t,{geom:h}=t,{style:c}=t;return r.$$set=u=>{"annotation"in u&&e(0,l=u.annotation),"geom"in u&&e(6,h=u.geom),"style"in u&&e(7,c=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=ri(l,c)),r.$$.dirty&64&&e(4,{x:n,y:s,w:o,h:a}=h,n,(e(3,s),e(6,h)),(e(2,o),e(6,h)),(e(1,a),e(6,h)))},[l,a,o,s,n,i,h,c]}class c_ extends me{constructor(t){super(),pe(this,t,h_,l_,Kt,{annotation:0,geom:6,style:7})}}const u_=r=>({elementToImage:(t,e)=>{const i=r.getBoundingClientRect(),n=r.createSVGPoint();n.x=t+i.x,n.y=e+i.y;const{x:s,y:o}=n.matrixTransform(r.getScreenCTM().inverse());return[s,o]}}),d_=250,f_=(r,t)=>{const e=Mr();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:n=>{if(performance.now()-i<d_){const{x:s,y:o}=Xc(n,r),a=Ne?10:2,l=t.getAt(s,o,void 0,a);l?e("click",{originalEvent:n,annotation:l}):e("click",{originalEvent:n})}}}},Xc=(r,t)=>{const e=t.createSVGPoint(),i=t.getBoundingClientRect(),n=r.clientX-i.x,s=r.clientY-i.y,{left:o,top:a}=t.getBoundingClientRect();return e.x=n+o,e.y=s+a,e.matrixTransform(t.getScreenCTM().inverse())};function Vc(r,t,e){const i=r.slice();return i[39]=t[e],i}function zc(r,t,e){const i=r.slice();return i[42]=t[e],i}function ga(r){const t=r.slice(),e=t[42].target.selector;return t[45]=e,t}function jc(r){let t=r[42],e,i,n=Wc(r);return{c(){n.c(),e=De()},m(s,o){n.m(s,o),nt(s,e,o),i=!0},p(s,o){o[0]&131072&&Kt(t,t=s[42])?(Ee(),yt(n,1,1,Rt),Te(),n=Wc(s),n.c(),lt(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(lt(n),i=!0)},o(s){yt(n),i=!1},d(s){s&&rt(e),n.d(s)}}}function p_(r){let t,e;return t=new K0({props:{annotation:r[42],geom:r[45].geometry,style:r[1]}}),{c(){re(t.$$.fragment)},m(i,n){Jt(t,i,n),e=!0},p(i,n){const s={};n[0]&131072&&(s.annotation=i[42]),n[0]&131072&&(s.geom=i[45].geometry),n[0]&2&&(s.style=i[1]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function m_(r){let t,e;return t=new a_({props:{annotation:r[42],geom:r[45].geometry,style:r[1]}}),{c(){re(t.$$.fragment)},m(i,n){Jt(t,i,n),e=!0},p(i,n){const s={};n[0]&131072&&(s.annotation=i[42]),n[0]&131072&&(s.geom=i[45].geometry),n[0]&2&&(s.style=i[1]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function g_(r){let t,e;return t=new J0({props:{annotation:r[42],geom:r[45].geometry,style:r[1]}}),{c(){re(t.$$.fragment)},m(i,n){Jt(t,i,n),e=!0},p(i,n){const s={};n[0]&131072&&(s.annotation=i[42]),n[0]&131072&&(s.geom=i[45].geometry),n[0]&2&&(s.style=i[1]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function y_(r){let t,e;return t=new n_({props:{annotation:r[42],geom:r[45].geometry,style:r[1]}}),{c(){re(t.$$.fragment)},m(i,n){Jt(t,i,n),e=!0},p(i,n){const s={};n[0]&131072&&(s.annotation=i[42]),n[0]&131072&&(s.geom=i[45].geometry),n[0]&2&&(s.style=i[1]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function __(r){let t,e;return t=new c_({props:{annotation:r[42],geom:r[45].geometry,style:r[1]}}),{c(){re(t.$$.fragment)},m(i,n){Jt(t,i,n),e=!0},p(i,n){const s={};n[0]&131072&&(s.annotation=i[42]),n[0]&131072&&(s.geom=i[45].geometry),n[0]&2&&(s.style=i[1]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function v_(r){var t;let e,i;return e=new W0({props:{annotation:r[42],geom:(t=r[45])==null?void 0:t.geometry,style:r[1]}}),{c(){re(e.$$.fragment)},m(n,s){Jt(e,n,s),i=!0},p(n,s){var o;const a={};s[0]&131072&&(a.annotation=n[42]),s[0]&131072&&(a.geom=(o=n[45])==null?void 0:o.geometry),s[0]&2&&(a.style=n[1]),e.$set(a)},i(n){i||(lt(e.$$.fragment,n),i=!0)},o(n){yt(e.$$.fragment,n),i=!1},d(n){te(e,n)}}}function Wc(r){let t,e,i,n;const s=[v_,__,y_,g_,m_,p_],o=[];function a(l,h){var c,u,d,f,p,g;return((c=l[45])==null?void 0:c.type)===_t.ELLIPSE?0:((u=l[45])==null?void 0:u.type)===_t.RECTANGLE?1:((d=l[45])==null?void 0:d.type)===_t.POLYGON?2:((f=l[45])==null?void 0:f.type)===_t.MULTIPOLYGON?3:((p=l[45])==null?void 0:p.type)===_t.POLYLINE?4:((g=l[45])==null?void 0:g.type)===_t.LINE?5:-1}return~(t=a(r))&&(e=o[t]=s[t](r)),{c(){e&&e.c(),i=De()},m(l,h){~t&&o[t].m(l,h),nt(l,i,h),n=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(Ee(),yt(o[c],1,1,()=>{o[c]=null}),Te()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=s[t](l),e.c()),lt(e,1),e.m(i.parentNode,i)):e=null)},i(l){n||(lt(e),n=!0)},o(l){yt(e),n=!1},d(l){l&&rt(i),~t&&o[t].d(l)}}}function Yc(r){let t=Le(r[42])&&!r[10](r[42]),e,i,n=t&&jc(ga(r));return{c(){n&&n.c(),e=De()},m(s,o){n&&n.m(s,o),nt(s,e,o),i=!0},p(s,o){o[0]&132096&&(t=Le(s[42])&&!s[10](s[42])),t?n?(n.p(ga(s),o),o[0]&132096&&lt(n,1)):(n=jc(ga(s)),n.c(),lt(n,1),n.m(e.parentNode,e)):n&&(Ee(),yt(n,1,1,()=>{n=null}),Te())},i(s){i||(lt(n),i=!0)},o(s){yt(n),i=!1},d(s){s&&rt(e),n&&n.d(s)}}}function qc(r){let t,e,i,n;const s=[x_,b_],o=[];function a(l,h){return l[6]?0:l[15]&&l[0]?1:-1}return~(t=a(r))&&(e=o[t]=s[t](r)),{c(){e&&e.c(),i=De()},m(l,h){~t&&o[t].m(l,h),nt(l,i,h),n=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(Ee(),yt(o[c],1,1,()=>{o[c]=null}),Te()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=s[t](l),e.c()),lt(e,1),e.m(i.parentNode,i)):e=null)},i(l){n||(lt(e),n=!0)},o(l){yt(e),n=!1},d(l){l&&rt(i),~t&&o[t].d(l)}}}function b_(r){let t=`${r[2]}-${r[7]}`,e,i,n=Kc(r);return{c(){n.c(),e=De()},m(s,o){n.m(s,o),nt(s,e,o),i=!0},p(s,o){o[0]&132&&Kt(t,t=`${s[2]}-${s[7]}`)?(Ee(),yt(n,1,1,Rt),Te(),n=Kc(s),n.c(),lt(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(lt(n),i=!0)},o(s){yt(n),i=!1},d(s){s&&rt(e),n.d(s)}}}function x_(r){let t,e,i=Ie(r[6]),n=[];for(let o=0;o<i.length;o+=1)n[o]=Qc(Vc(r,i,o));const s=o=>yt(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=De()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);nt(o,t,a),e=!0},p(o,a){if(a[0]&8659266){i=Ie(o[6]);let l;for(l=0;l<i.length;l+=1){const h=Vc(o,i,l);n[l]?(n[l].p(h,a),lt(n[l],1)):(n[l]=Qc(h),n[l].c(),lt(n[l],1),n[l].m(t.parentNode,t))}for(Ee(),l=i.length;l<n.length;l+=1)s(l);Te()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)lt(n[a]);e=!0}},o(o){n=n.filter(Boolean);for(let a=0;a<n.length;a+=1)yt(n[a]);e=!1},d(o){o&&rt(t),Jr(n,o)}}}function Kc(r){let t,e;return t=new N0({props:{target:r[8],tool:r[15],drawingMode:r[14],transform:r[13],viewportScale:r[18]}}),t.$on("create",r[22]),{c(){re(t.$$.fragment)},m(i,n){Jt(t,i,n),e=!0},p(i,n){const s={};n[0]&256&&(s.target=i[8]),n[0]&32768&&(s.tool=i[15]),n[0]&16384&&(s.drawingMode=i[14]),n[0]&8192&&(s.transform=i[13]),n[0]&262144&&(s.viewportScale=i[18]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function Zc(r){let t,e;return t=new O0({props:{target:r[8],editor:r[39].editor,annotation:r[39].annotation,style:r[1],transform:r[13],viewportScale:r[18]}}),t.$on("change",function(){Gt(r[23](r[39].annotation))&&r[23](r[39].annotation).apply(this,arguments)}),{c(){re(t.$$.fragment)},m(i,n){Jt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&256&&(s.target=r[8]),n[0]&64&&(s.editor=r[39].editor),n[0]&64&&(s.annotation=r[39].annotation),n[0]&2&&(s.style=r[1]),n[0]&8192&&(s.transform=r[13]),n[0]&262144&&(s.viewportScale=r[18]),t.$set(s)},i(i){e||(lt(t.$$.fragment,i),e=!0)},o(i){yt(t.$$.fragment,i),e=!1},d(i){te(t,i)}}}function Qc(r){let t=r[39].annotation.id,e,i,n=Zc(r);return{c(){n.c(),e=De()},m(s,o){n.m(s,o),nt(s,e,o),i=!0},p(s,o){o[0]&64&&Kt(t,t=s[39].annotation.id)?(Ee(),yt(n,1,1,Rt),Te(),n=Zc(s),n.c(),lt(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(lt(n),i=!0)},o(s){yt(n),i=!1},d(s){s&&rt(e),n.d(s)}}}function w_(r){let t,e,i,n,s,o,a=Ie(r[17].filter(r[34])),l=[];for(let u=0;u<a.length;u+=1)l[u]=Yc(zc(r,a,u));const h=u=>yt(l[u],1,1,()=>{l[u]=null});let c=r[8]&&qc(r);return{c(){t=W("svg"),e=W("g");for(let u=0;u<l.length;u+=1)l[u].c();i=W("g"),c&&c.c(),x(i,"class","drawing"),x(t,"role","application"),x(t,"tabindex",0),x(t,"class","a9s-annotationlayer"),Je(t,"drawing",r[15]),Je(t,"editing",r[5]),Je(t,"hidden",!r[3]),Je(t,"hover",r[16])},m(u,d){nt(u,t,d),xt(t,e);for(let f=0;f<l.length;f+=1)l[f]&&l[f].m(e,null);xt(t,i),c&&c.m(i,null),r[35](i),r[36](t),n=!0,s||(o=[St(t,"pointerup",function(){Gt(r[11])&&r[11].apply(this,arguments)}),St(t,"pointerdown",function(){Gt(r[12])&&r[12].apply(this,arguments)}),St(t,"pointermove",r[24])],s=!0)},p(u,d){if(r=u,d[0]&132098){a=Ie(r[17].filter(r[34]));let f;for(f=0;f<a.length;f+=1){const p=zc(r,a,f);l[f]?(l[f].p(p,d),lt(l[f],1)):(l[f]=Yc(p),l[f].c(),lt(l[f],1),l[f].m(e,null))}for(Ee(),f=a.length;f<l.length;f+=1)h(f);Te()}r[8]?c?(c.p(r,d),d[0]&256&&lt(c,1)):(c=qc(r),c.c(),lt(c,1),c.m(i,null)):c&&(Ee(),yt(c,1,1,()=>{c=null}),Te()),(!n||d[0]&32768)&&Je(t,"drawing",r[15]),(!n||d[0]&32)&&Je(t,"editing",r[5]),(!n||d[0]&8)&&Je(t,"hidden",!r[3]),(!n||d[0]&65536)&&Je(t,"hover",r[16])},i(u){if(!n){for(let d=0;d<a.length;d+=1)lt(l[d]);lt(c),n=!0}},o(u){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)yt(l[d]);yt(c),n=!1},d(u){u&&rt(t),Jr(l,u),c&&c.d(),r[35](null),r[36](null),s=!1,Me(o)}}}function E_(r,t,e){let i,n,s,o,a,l,h,c,u,d,f,p,g=Rt,y=()=>(g(),g=jh(A,H=>e(18,p=H)),A);r.$$.on_destroy.push(()=>g());let{drawingEnabled:_}=t,{image:v}=t,{preferredDrawingMode:m}=t,{state:b}=t,{style:S=void 0}=t,{toolName:R=ys()[0]}=t,{user:C}=t,{visible:I=!0}=t,M=0;const F=()=>e(7,M+=1),U=()=>R,P=()=>_;let T,E,A;ti(()=>y(e(9,A=r0(v,E))));const{hover:L,selection:D,store:N}=b;zo(r,L,H=>e(16,u=H)),zo(r,D,H=>e(33,d=H)),zo(r,N,H=>e(17,f=H));let $,O;const B=H=>{$&&N.unobserve($);const mt=H.filter(({editable:Q})=>Q).map(({id:Q})=>Q);mt.length>0?(e(5,O=mt.map(Q=>N.getAnnotation(Q)).filter(Q=>Q&&Le(Q))),$=Q=>{const{updated:ut}=Q.changes;e(5,O=ut==null?void 0:ut.map(gt=>gt.newValue))},N.observe($,{annotations:mt})):e(5,O=void 0)},k=H=>{const mt=lc(),Q={id:mt,bodies:[],target:{annotation:mt,selector:H.detail,creator:C,created:new Date}};N.addAnnotation(Q),D.setSelected(Q.id)},V=H=>mt=>{var Q;const{target:ut}=H,gt=10*60*1e3,Et=((Q=ut.creator)==null?void 0:Q.id)!==C.id||!ut.created||new Date().getTime()-ut.created.getTime()>gt;N.updateTarget({...ut,selector:mt.detail,created:Et?ut.created:new Date,updated:Et?new Date:void 0,updatedBy:Et?C:void 0})},z=H=>{const{x:mt,y:Q}=Xc(H,E),ut=N.getAt(mt,Q,void 0,2);ut?u!==ut.id&&L.set(ut.id):L.set(void 0)},K=H=>Le(H);function X(H){as[H?"unshift":"push"](()=>{T=H,e(8,T)})}function ft(H){as[H?"unshift":"push"](()=>{E=H,e(4,E)})}return r.$$set=H=>{"drawingEnabled"in H&&e(0,_=H.drawingEnabled),"image"in H&&e(25,v=H.image),"preferredDrawingMode"in H&&e(26,m=H.preferredDrawingMode),"state"in H&&e(27,b=H.state),"style"in H&&e(1,S=H.style),"toolName"in H&&e(2,R=H.toolName),"user"in H&&e(28,C=H.user),"visible"in H&&e(3,I=H.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(15,{tool:i,opts:n}=_s(R)||{tool:void 0,opts:void 0},i,(e(32,n),e(2,R))),r.$$.dirty[0]&67108864|r.$$.dirty[1]&2&&e(14,s=(n==null?void 0:n.drawingMode)||m),r.$$.dirty[0]&16&&e(13,o=u_(E)),r.$$.dirty[0]&16&&e(12,{onPointerDown:a,onPointerUp:l}=f_(E,N),a,(e(11,l),e(4,E))),r.$$.dirty[1]&4&&B(d.selected),r.$$.dirty[0]&32&&e(6,h=O?O.map(H=>({annotation:H,editor:fa(H.target.selector)})).filter(H=>H.editor):void 0),r.$$.dirty[0]&64&&e(10,c=H=>h&&h.some(mt=>mt.annotation.id===H.id))},[_,S,R,I,E,O,h,M,T,A,c,l,a,o,s,i,u,f,p,L,D,N,k,V,z,v,m,b,C,F,U,P,n,d,K,X,ft]}class T_ extends me{constructor(t){super(),pe(this,t,E_,w_,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 Jc(r,t,e=0,i=r.length-1,n=A_){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*u/l+d)),p=Math.min(i,Math.floor(t+(l-h)*u/l+d));Jc(r,t,f,p,n)}const s=r[t];let o=e,a=i;for(wn(r,e,t),n(r[i],s)>0&&wn(r,e,i);o<a;){for(wn(r,o,a),o++,a--;n(r[o],s)<0;)o++;for(;n(r[a],s)>0;)a--}n(r[e],s)===0?wn(r,e,a):(a++,wn(r,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function wn(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function A_(r,t){return r<t?-1:r>t?1:0}class S_{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(!bs(t,e))return i;const n=this.toBBox,s=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?n(a):a;bs(t,l)&&(e.leaf?i.push(a):_a(t,l)?this._all(a,i):s.push(a))}e=s.pop()}return i}collides(t){let e=this.data;if(!bs(t,e))return!1;const i=[];for(;e;){for(let n=0;n<e.children.length;n++){const s=e.children[n],o=e.leaf?this.toBBox(s):s;if(bs(t,o)){if(e.leaf||_a(t,o))return!0;i.push(s)}}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=Bi([]),this}remove(t,e){if(!t)return this;let i=this.data;const n=this.toBBox(t),s=[],o=[];let a,l,h;for(;i||s.length;){if(i||(i=s.pop(),l=s[s.length-1],a=o.pop(),h=!0),i.leaf){const c=C_(t,i.children,e);if(c!==-1)return i.children.splice(c,1),s.push(i),this._condense(s),this}!h&&!i.leaf&&_a(i,n)?(s.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,n){const s=i-e+1;let o=this._maxEntries,a;if(s<=o)return a=Bi(t.slice(e,i+1)),Di(a,this.toBBox),a;n||(n=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,n-1))),a=Bi([]),a.leaf=!1,a.height=n;const l=Math.ceil(s/o),h=l*Math.ceil(Math.sqrt(o));tu(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);tu(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,n-1))}}return Di(a,this.toBBox),a}_chooseSubtree(t,e,i,n){for(;n.push(e),!(e.leaf||n.length-1===i);){let s=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=ya(h),u=R_(t,h)-c;u<o?(o=u,s=c<s?c:s,a=h):u===o&&c<s&&(s=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const n=i?t:this.toBBox(t),s=[],o=this._chooseSubtree(n,this.data,e,s);for(o.children.push(t),Tn(o,n);e>=0&&s[e].children.length>this._maxEntries;)this._split(s,e),e--;this._adjustParentBBoxes(n,s,e)}_split(t,e){const i=t[e],n=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,n);const o=this._chooseSplitIndex(i,s,n),a=Bi(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,Di(i,this.toBBox),Di(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Bi([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Di(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let n,s=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=En(t,0,a,this.toBBox),h=En(t,a,i,this.toBBox),c=M_(l,h),u=ya(l)+ya(h);c<s?(s=c,n=a,o=u<o?u:o):c===s&&u<o&&(o=u,n=a)}return n||i-e}_chooseSplitAxis(t,e,i){const n=t.leaf?this.compareMinX:I_,s=t.leaf?this.compareMinY:P_,o=this._allDistMargin(t,e,i,n),a=this._allDistMargin(t,e,i,s);o<a&&t.children.sort(n)}_allDistMargin(t,e,i,n){t.children.sort(n);const s=this.toBBox,o=En(t,0,e,s),a=En(t,i-e,i,s);let l=vs(o)+vs(a);for(let h=e;h<i-e;h++){const c=t.children[h];Tn(o,t.leaf?s(c):c),l+=vs(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];Tn(a,t.leaf?s(c):c),l+=vs(a)}return l}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)Tn(e[n],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():Di(t[e],this.toBBox)}}function C_(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 Di(r,t){En(r,0,r.children.length,t,r)}function En(r,t,e,i,n){n||(n=Bi(null)),n.minX=1/0,n.minY=1/0,n.maxX=-1/0,n.maxY=-1/0;for(let s=t;s<e;s++){const o=r.children[s];Tn(n,r.leaf?i(o):o)}return n}function Tn(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 I_(r,t){return r.minX-t.minX}function P_(r,t){return r.minY-t.minY}function ya(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function vs(r){return r.maxX-r.minX+(r.maxY-r.minY)}function R_(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 M_(r,t){const e=Math.max(r.minX,t.minX),i=Math.max(r.minY,t.minY),n=Math.min(r.maxX,t.maxX),s=Math.min(r.maxY,t.maxY);return Math.max(0,n-e)*Math.max(0,s-i)}function _a(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function bs(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function Bi(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function tu(r,t,e,i,n){const s=[t,e];for(;s.length;){if(e=s.pop(),t=s.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;Jc(r,o,t,e,n),s.push(t,o,o,e)}}const D_=()=>{const r=new S_,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},n=o=>{if(!ds(o))return;const{minX:a,minY:l,maxX:h,maxY:c}=o.selector.geometry.bounds,u={minX:a,minY:l,maxX:h,maxY:c,target:o};r.insert(u),t.set(o.annotation,u)},s=o=>{if(!ds(o))return;const a=t.get(o.annotation);a&&r.remove(a),t.delete(o.annotation)};return{all:e,clear:i,getAt:(o,a,l=0)=>{const h=r.search({minX:o-l,minY:a-l,maxX:o+l,maxY:a+l}).map(c=>c.target).filter(c=>c.selector.type===_t.RECTANGLE||Gg(c.selector,o,a,l));return h.length>0?(h.sort((c,u)=>Ko(c.selector)-Ko(u.selector)),h):[]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(c=>c.target),insert:n,remove:s,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,c)=>{if(ds(c)){const{minX:u,minY:d,maxX:f,maxY:p}=c.selector.geometry.bounds;return[...h,{minX:u,minY:d,maxX:f,maxY:p,target:c}]}else return h},[]);l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{s(o),n(a)}}},B_=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}}),eu=r=>{const t=Dy(),e=D_(),i=yy(t,r.userSelectAction,r.adapter),n=gy(t),s=Ny();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,l,h)=>{const c=e.getAt(o,a,h);if(l)return c.map(u=>t.getAnnotation(u.annotation)).filter(Boolean).filter(l)[0];{const u=c[0];return u?t.getAnnotation(u.annotation):void 0}},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(c=>t.getAnnotation(c.annotation)).filter(Boolean)},selection:i,hover:n,viewport:s}},O_=r=>{const t=eu(r);return{...t,store:B_(t.store)}},L_=r=>{let t,e;if(r.nodeName==="CANVAS")t=r,e=t.getContext("2d",{willReadFrequently:!0});else{const n=r;t=document.createElement("canvas"),t.width=n.width,t.height=n.height,e=t.getContext("2d",{willReadFrequently:!0}),e.drawImage(n,0,0,n.width,n.height)}let i=0;for(let n=1;n<10;n++)for(let s=1;s<10;s++){const o=Math.round(s*t.width/10),a=Math.round(n*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},ru=r=>{const t=L_(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},iu=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?ru(r):e),nu=(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}),su=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,ou=(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()},n=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?r.redo():r.undo())},s=()=>{su?e.removeEventListener("keydown",n):e.removeEventListener("keydown",i)};return su?e.addEventListener("keydown",n):e.addEventListener("keydown",i),{destroy:s}},N_=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=nu(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:cc.EDIT,theme:"light"}),n=O_(i),{selection:s,store:o}=n,a=Ly(o,i.initialHistory),l=Fy(n,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 c=ou(a);let u=Wy();iu(e,h,i.theme);const d=new T_({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:n,style:i.style,user:u}});d.$on("click",P=>{const{originalEvent:T,annotation:E}=P.detail;E?s.userSelect(E.id,T):s.isEmpty()||s.clear()});const f=Uy(n,a,i.adapter),p=()=>d.cancelDrawing(),g=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),c.destroy(),a.destroy()},y=()=>d.getDrawingTool(),_=()=>u,v=()=>d.isDrawingEnabled(),m=(P,T,E)=>Gc(P,T,E),b=(P,T)=>Nc(P,T),S=P=>{if(!_s(P))throw`No drawing tool named ${P}`;d.$set({toolName:P})},R=P=>d.$set({drawingEnabled:P}),C=P=>{console.warn("Filter not implemented yet")},I=P=>d.$set({style:P}),M=P=>iu(e,h,P),F=P=>{u=P,d.$set({user:P})},U=P=>d.$set({visible:P});return{...f,cancelDrawing:p,destroy:g,getDrawingTool:y,getUser:_,isDrawingEnabled:v,listDrawingTools:ys,on:l.on,off:l.off,registerDrawingTool:m,registerShapeEditor:b,setDrawingEnabled:R,setDrawingTool:S,setFilter:C,setStyle:I,setTheme:M,setUser:F,setVisible:U,element:h,state:n}};function Ft(){}function va(r,t){for(const e in t)r[e]=t[e];return r}function au(r){return r()}function lu(){return Object.create(null)}function Fe(r){r.forEach(au)}function Zt(r){return typeof r=="function"}function Ut(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function F_(r){return Object.keys(r).length===0}function k_(r,...t){if(r==null){for(const i of t)i(void 0);return Ft}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function An(r,t,e){r.$$.on_destroy.push(k_(t,e))}function hu(r,t,e,i){if(r){const n=cu(r,t,e,i);return r[0](n)}}function cu(r,t,e,i){return r[1]&&i?va(e.ctx.slice(),r[1](i(t))):e.ctx}function uu(r,t,e,i){if(r[2]&&i){const n=r[2](i(e));if(t.dirty===void 0)return n;if(typeof n=="object"){const s=[],o=Math.max(t.dirty.length,n.length);for(let a=0;a<o;a+=1)s[a]=t.dirty[a]|n[a];return s}return t.dirty|n}return t.dirty}function du(r,t,e,i,n,s){if(n){const o=cu(t,e,i,s);r.p(o,n)}}function fu(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 pu(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function mu(r){return r??""}const ba=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ct(r,t){r.appendChild(t)}function ot(r,t,e){r.insertBefore(t,e||null)}function st(r){r.parentNode&&r.parentNode.removeChild(r)}function Or(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function it(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function xa(r){return document.createTextNode(r)}function Se(){return xa(" ")}function Pe(){return xa("")}function Pt(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 U_(r){return Array.from(r.childNodes)}function G_(r,t){t=""+t,r.data!==t&&(r.data=t)}function Lr(r,t,e){r.classList.toggle(t,!!e)}function $_(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Sn;function Cn(r){Sn=r}function wa(){if(!Sn)throw new Error("Function called outside component initialization");return Sn}function ii(r){wa().$$.on_mount.push(r)}function H_(r){wa().$$.on_destroy.push(r)}function Oi(){const r=wa();return(t,e,{cancelable:i=!1}={})=>{const n=r.$$.callbacks[t];if(n){const s=$_(t,e,{cancelable:i});return n.slice().forEach(o=>{o.call(r,s)}),!s.defaultPrevented}return!0}}function ae(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Li=[],xs=[];let Ni=[];const gu=[],yu=Promise.resolve();let Ea=!1;function _u(){Ea||(Ea=!0,yu.then(bu))}function vu(){return _u(),yu}function Ta(r){Ni.push(r)}const Aa=new Set;let Fi=0;function bu(){if(Fi!==0)return;const r=Sn;do{try{for(;Fi<Li.length;){const t=Li[Fi];Fi++,Cn(t),X_(t.$$)}}catch(t){throw Li.length=0,Fi=0,t}for(Cn(null),Li.length=0,Fi=0;xs.length;)xs.pop()();for(let t=0;t<Ni.length;t+=1){const e=Ni[t];Aa.has(e)||(Aa.add(e),e())}Ni.length=0}while(Li.length);for(;gu.length;)gu.pop()();Ea=!1,Aa.clear(),Cn(r)}function X_(r){if(r.fragment!==null){r.update(),Fe(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Ta)}}function V_(r){const t=[],e=[];Ni.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Ni=t}const ws=new Set;let ni;function le(){ni={r:0,c:[],p:ni}}function he(){ni.r||Fe(ni.c),ni=ni.p}function q(r,t){r&&r.i&&(ws.delete(r),r.i(t))}function at(r,t,e,i){if(r&&r.o){if(ws.has(r))return;ws.add(r),ni.c.push(()=>{ws.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function xe(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function Lt(r){r&&r.c()}function Bt(r,t,e){const{fragment:i,after_update:n}=r.$$;i&&i.m(t,e),Ta(()=>{const s=r.$$.on_mount.map(au).filter(Zt);r.$$.on_destroy?r.$$.on_destroy.push(...s):Fe(s),r.$$.on_mount=[]}),n.forEach(Ta)}function Ot(r,t){const e=r.$$;e.fragment!==null&&(V_(e.after_update),Fe(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function z_(r,t){r.$$.dirty[0]===-1&&(Li.push(r),_u(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function zt(r,t,e,i,n,s,o=null,a=[-1]){const l=Sn;Cn(r);const h=r.$$={fragment:null,ctx:[],props:s,update:Ft,not_equal:n,bound:lu(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:lu(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&n(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&z_(r,u)),d}):[],h.update(),c=!0,Fe(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=U_(t.target);h.fragment&&h.fragment.l(u),u.forEach(st)}else h.fragment&&h.fragment.c();t.intro&&q(r.$$.fragment),Bt(r,t.target,t.anchor),bu()}Cn(l)}class jt{constructor(){Oh(this,"$$");Oh(this,"$$set")}$destroy(){Ot(this,1),this.$destroy=Ft}$on(t,e){if(!Zt(e))return Ft;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const n=i.indexOf(e);n!==-1&&i.splice(n,1)}}$set(t){this.$$set&&!F_(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const j_="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(j_);var tr=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGON="MULTIPOLYGON",r.POLYGON="POLYGON",r.POLYLINE="POLYLINE",r.RECTANGLE="RECTANGLE",r.LINE="LINE",r))(tr||{}),In=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sa(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function W_(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 n=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return r[i]}})}),e}var xu={exports:{}};(function(r){(function(){function t(a,l){var h=a.x-l.x,c=a.y-l.y;return h*h+c*c}function e(a,l,h){var c=l.x,u=l.y,d=h.x-c,f=h.y-u;if(d!==0||f!==0){var p=((a.x-c)*d+(a.y-u)*f)/(d*d+f*f);p>1?(c=h.x,u=h.y):p>0&&(c+=d*p,u+=f*p)}return d=a.x-c,f=a.y-u,d*d+f*f}function i(a,l){for(var h=a[0],c=[h],u,d=1,f=a.length;d<f;d++)u=a[d],t(u,h)>l&&(c.push(u),h=u);return h!==u&&c.push(u),c}function n(a,l,h,c,u){for(var d=c,f,p=l+1;p<h;p++){var g=e(a[p],a[l],a[h]);g>d&&(f=p,d=g)}d>c&&(f-l>1&&n(a,l,f,c,u),u.push(a[f]),h-f>1&&n(a,f,h,c,u))}function s(a,l){var h=a.length-1,c=[a[0]];return n(a,0,h,l,c),c.push(a[h]),c}function o(a,l,h){if(a.length<=2)return a;var c=l!==void 0?l*l:1;return a=h?a:i(a,c),a=s(a,c),a}r.exports=o,r.exports.default=o})()})(xu);var Y_=xu.exports;const q_=Sa(Y_),ki=(r,t)=>t,er=r=>{let t=1/0,e=1/0,i=-1/0,n=-1/0;return r.forEach(([s,o])=>{t=Math.min(t,s),e=Math.min(e,o),i=Math.max(i,s),n=Math.max(n,o)}),{minX:t,minY:e,maxX:i,maxY:n}},Es=r=>{let t=0,e=r.length-1;for(let i=0;i<r.length;i++)t+=(r[e][0]+r[i][0])*(r[e][1]-r[i][1]),e=i;return Math.abs(.5*t)},Ts=(r,t,e)=>{let i=!1;for(let n=0,s=r.length-1;n<r.length;s=n++){const o=r[n][0],a=r[n][1],l=r[s][0],h=r[s][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},K_=(r,t=!0)=>{let e="M ";return r.forEach(([i,n],s)=>{s===0?e+=`${i},${n}`:e+=` L ${i},${n}`}),t&&(e+=" Z"),e},wu=(r,t=1)=>{const e=r.map(([i,n])=>({x:i,y:n}));return q_(e,t,!0).map(i=>[i.x,i.y])},Z_=(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))},Q_={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:n,rx:s,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),c=t-i,u=e-n,d=l*c+h*u,f=h*c-l*u;return d*d/(s*s)+f*f/(o*o)<=1}};ki(tr.ELLIPSE,Q_);const J_={area:r=>0,intersects:(r,t,e,i=2)=>{const[[n,s],[o,a]]=r.geometry.points,l=Math.abs((a-s)*t-(o-n)*e+o*s-a*n),h=Z_([n,s],[o,a]);return l/h<=i}};ki(tr.LINE,J_);const tv={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[n,...s]=i.rings,o=Es(n.points),a=s.reduce((l,h)=>l+Es(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const n of i){const[s,...o]=n.rings;if(Ts(s.points,t,e)){let a=!1;for(const l of o)if(Ts(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},As=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return er(t)},Ui=r=>r.rings.map(e=>K_(e.points)).join(" "),ev=r=>r.polygons.reduce((t,e)=>[...t,...e.rings.reduce((i,n)=>[...i,...n.points],[])],[]),rv=(r,t=1)=>{const e=r.geometry.polygons.map(n=>{const s=n.rings.map(a=>{const l=wu(a.points,t);return{...a,points:l}}),o=er(s[0].points);return{...n,rings:s,bounds:o}}),i=As(e);return{...r,geometry:{...r.geometry,polygons:e,bounds:i}}};ki(tr.MULTIPOLYGON,tv);const iv={area:r=>{const t=r.geometry.points;return Es(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return Ts(i,t,e)}},nv=(r,t=1)=>{const e=wu(r.geometry.points,t),i=er(e);return{...r,geometry:{...r.geometry,bounds:i,points:e}}};ki(tr.POLYGON,iv);const sv={area:r=>{const t=r.geometry;if(!t.closed||t.points.length<3)return 0;const e=Eu(t.points,t.closed);return Es(e)},intersects:(r,t,e,i=2)=>{const n=r.geometry;if(n.closed){const s=Eu(n.points,n.closed);return Ts(s,t,e)}else return ov(n,[t,e],i)}},Eu=(r,t=!1)=>{const e=[];for(let i=0;i<r.length;i++){const n=r[i],s=r[(i+1)%r.length];if(e.push(n.point),(i<r.length-1||t)&&(n.type==="CURVE"||s.type=="CURVE")){const a=Tu(n.point,n.type==="CURVE"&&n.outHandle||n.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,10);e.push(...a.slice(1))}}return e},Tu=(r,t,e,i,n=10)=>{const s=[];for(let o=0;o<=n;o++){const a=o/n,l=Math.pow(1-a,3)*r[0]+3*Math.pow(1-a,2)*a*t[0]+3*(1-a)*Math.pow(a,2)*e[0]+Math.pow(a,3)*i[0],h=Math.pow(1-a,3)*r[1]+3*Math.pow(1-a,2)*a*t[1]+3*(1-a)*Math.pow(a,2)*e[1]+Math.pow(a,3)*i[1];s.push([l,h])}return s},ov=(r,t,e)=>{for(let i=0;i<r.points.length-1;i++){const n=r.points[i],s=r.points[i+1];if(n.type==="CURVE"||s.type==="CURVE"){const a=Tu(n.point,n.type==="CURVE"&&n.outHandle||n.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,20);for(let l=0;l<a.length-1;l++)if(Au(t,a[l],a[l+1])<=e)return!0}else if(Au(t,n.point,s.point)<=e)return!0}return!1},Au=(r,t,e)=>{const[i,n]=r,[s,o]=t,[a,l]=e,h=a-s,c=l-o,u=Math.sqrt(h*h+c*c);if(u===0)return Math.sqrt((i-s)*(i-s)+(n-o)*(n-o));const d=((i-s)*h+(n-o)*c)/(u*u);return d<=0?Math.sqrt((i-s)*(i-s)+(n-o)*(n-o)):d>=1?Math.sqrt((i-a)*(i-a)+(n-l)*(n-l)):Math.abs((l-o)*i-(a-s)*n+a*o-l*s)/u};ki(tr.POLYLINE,sv);const av={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};ki(tr.RECTANGLE,av);const _e=[];for(let r=0;r<256;++r)_e.push((r+256).toString(16).slice(1));function lv(r,t=0){return(_e[r[t+0]]+_e[r[t+1]]+_e[r[t+2]]+_e[r[t+3]]+"-"+_e[r[t+4]]+_e[r[t+5]]+"-"+_e[r[t+6]]+_e[r[t+7]]+"-"+_e[r[t+8]]+_e[r[t+9]]+"-"+_e[r[t+10]]+_e[r[t+11]]+_e[r[t+12]]+_e[r[t+13]]+_e[r[t+14]]+_e[r[t+15]]).toLowerCase()}let Ca;const hv=new Uint8Array(16);function cv(){if(!Ca){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ca=crypto.getRandomValues.bind(crypto)}return Ca(hv)}const Su={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function uv(r,t,e){var n;r=r||{};const i=r.random??((n=r.rng)==null?void 0:n.call(r))??cv();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,lv(i)}function dv(r,t,e){return Su.randomUUID&&!r?Su.randomUUID():uv(r)}const fv=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:n,stroke:s,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`),n||n===0?l+=`fill-opacity:${n};`:i&&(l+="fill-opacity:0.25;"),s&&(l+=`stroke:${s};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}},Ia=(r,t=0)=>{const{minX:e,minY:i,maxX:n,maxY:s}=r;return{x:e-t,y:i-t,w:n-e+2*t,h:s-i+2*t}},Nr=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,pv=r=>({}),Cu=r=>({grab:r[0]});function mv(r){let t,e,i,n;const s=r[8].default,o=hu(s,r,r[7],Cu);return{c(){t=it("g"),o&&o.c(),w(t,"class","a9s-annotation selected")},m(a,l){ot(a,t,l),o&&o.m(t,null),e=!0,i||(n=[Pt(t,"pointerup",r[2]),Pt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&128)&&du(o,s,a,a[7],e?uu(s,a[7],l,pv):fu(a[7]),Cu)},i(a){e||(q(o,a),e=!0)},o(a){at(o,a),e=!1},d(a){a&&st(t),o&&o.d(a),i=!1,Fe(n)}}}function gv(r,t,e){let{$$slots:i={},$$scope:n}=t;const s=Oi();let{shape:o}=t,{editor:a}=t,{transform:l}=t,{svgEl:h}=t,c,u,d;const f=y=>_=>{if(c=y,h){const{left:m,top:b}=h.getBoundingClientRect(),S=_.clientX-m,R=_.clientY-b;u=l.elementToImage(S,R)}else{const{offsetX:m,offsetY:b}=_;u=l.elementToImage(m,b)}d=o,_.target.setPointerCapture(_.pointerId),s("grab",_)},p=y=>{if(c){const[_,v]=l.elementToImage(y.offsetX,y.offsetY),m=[_-u[0],v-u[1]];e(3,o=a(d,c,m)),s("change",o)}},g=y=>{y.target.releasePointerCapture(y.pointerId),c=void 0,d=o,s("release",y)};return r.$$set=y=>{"shape"in y&&e(3,o=y.shape),"editor"in y&&e(4,a=y.editor),"transform"in y&&e(5,l=y.transform),"svgEl"in y&&e(6,h=y.svgEl),"$$scope"in y&&e(7,n=y.$$scope)},[f,p,g,o,a,l,h,n,i]}class Pa extends jt{constructor(t){super(),zt(this,t,gv,mv,Ut,{shape:3,editor:4,transform:5,svgEl:6})}}function yv(r){let t,e,i,n,s,o,a,l,h=r[3]&&Iu(r);return{c(){t=it("g"),e=it("circle"),h&&h.c(),n=it("circle"),w(e,"class","a9s-handle-buffer svelte-qtyc7s"),w(e,"cx",r[0]),w(e,"cy",r[1]),w(e,"r",i=r[5]+6/r[2]),w(e,"role","button"),w(e,"tabindex","0"),w(n,"class",s=mu(`a9s-handle-dot${r[3]?" selected":""}`)+" svelte-qtyc7s"),w(n,"cx",r[0]),w(n,"cy",r[1]),w(n,"r",r[5]),w(t,"class",o=`a9s-handle ${r[8].class||""}`.trim())},m(c,u){ot(c,t,u),Ct(t,e),h&&h.m(t,null),Ct(t,n),a||(l=[Pt(e,"dblclick",r[12]),Pt(e,"pointerenter",r[13]),Pt(e,"pointerleave",r[14]),Pt(e,"pointerdown",r[15]),Pt(e,"pointerdown",r[6]),Pt(e,"pointerup",r[16]),Pt(e,"pointerup",r[7])],a=!0)},p(c,u){u&1&&w(e,"cx",c[0]),u&2&&w(e,"cy",c[1]),u&36&&i!==(i=c[5]+6/c[2])&&w(e,"r",i),c[3]?h?h.p(c,u):(h=Iu(c),h.c(),h.m(t,n)):h&&(h.d(1),h=null),u&8&&s!==(s=mu(`a9s-handle-dot${c[3]?" selected":""}`)+" svelte-qtyc7s")&&w(n,"class",s),u&1&&w(n,"cx",c[0]),u&2&&w(n,"cy",c[1]),u&32&&w(n,"r",c[5]),u&256&&o!==(o=`a9s-handle ${c[8].class||""}`.trim())&&w(t,"class",o)},d(c){c&&st(t),h&&h.d(),a=!1,Fe(l)}}}function _v(r){let t,e,i,n,s,o,a,l,h;return{c(){t=it("g"),e=it("circle"),n=it("circle"),o=it("circle"),w(e,"cx",r[0]),w(e,"cy",r[1]),w(e,"r",i=r[5]*10),w(e,"class","a9s-touch-halo"),Lr(e,"touched",r[4]),w(n,"cx",r[0]),w(n,"cy",r[1]),w(n,"r",s=r[5]+10/r[2]),w(n,"class","a9s-handle-buffer svelte-qtyc7s"),w(n,"role","button"),w(n,"tabindex","0"),w(o,"class","a9s-handle-dot"),w(o,"cx",r[0]),w(o,"cy",r[1]),w(o,"r",a=r[5]+2/r[2]),w(t,"class","a9s-touch-handle")},m(c,u){ot(c,t,u),Ct(t,e),Ct(t,n),Ct(t,o),l||(h=[Pt(n,"dblclick",r[9]),Pt(n,"pointerdown",r[10]),Pt(n,"pointerdown",r[6]),Pt(n,"pointerup",r[11]),Pt(n,"pointerup",r[7])],l=!0)},p(c,u){u&1&&w(e,"cx",c[0]),u&2&&w(e,"cy",c[1]),u&32&&i!==(i=c[5]*10)&&w(e,"r",i),u&16&&Lr(e,"touched",c[4]),u&1&&w(n,"cx",c[0]),u&2&&w(n,"cy",c[1]),u&36&&s!==(s=c[5]+10/c[2])&&w(n,"r",s),u&1&&w(o,"cx",c[0]),u&2&&w(o,"cy",c[1]),u&36&&a!==(a=c[5]+2/c[2])&&w(o,"r",a)},d(c){c&&st(t),l=!1,Fe(h)}}}function Iu(r){let t,e;return{c(){t=it("circle"),w(t,"class","a9s-handle-selected"),w(t,"cx",r[0]),w(t,"cy",r[1]),w(t,"r",e=r[5]+8/r[2])},m(i,n){ot(i,t,n)},p(i,n){n&1&&w(t,"cx",i[0]),n&2&&w(t,"cy",i[1]),n&36&&e!==(e=i[5]+8/i[2])&&w(t,"r",e)},d(i){i&&st(t)}}}function vv(r){let t;function e(s,o){return Nr?_v:yv}let n=e()(r);return{c(){n.c(),t=Pe()},m(s,o){n.m(s,o),ot(s,t,o)},p(s,[o]){n.p(s,o)},i:Ft,o:Ft,d(s){s&&st(t),n.d(s)}}}function bv(r,t,e){let i,{x:n}=t,{y:s}=t,{scale:o}=t,{selected:a=void 0}=t,l=!1;const h=m=>{m.pointerType==="touch"&&e(4,l=!0)},c=()=>e(4,l=!1);function u(m){ae.call(this,r,m)}function d(m){ae.call(this,r,m)}function f(m){ae.call(this,r,m)}function p(m){ae.call(this,r,m)}function g(m){ae.call(this,r,m)}function y(m){ae.call(this,r,m)}function _(m){ae.call(this,r,m)}function v(m){ae.call(this,r,m)}return r.$$set=m=>{e(8,t=va(va({},t),pu(m))),"x"in m&&e(0,n=m.x),"y"in m&&e(1,s=m.y),"scale"in m&&e(2,o=m.scale),"selected"in m&&e(3,a=m.selected)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=4/o)},t=pu(t),[n,s,o,a,l,i,h,c,t,u,d,f,p,g,y,_,v]}class Gi extends jt{constructor(t){super(),zt(this,t,bv,vv,Ut,{x:0,y:1,scale:2,selected:3})}}function xv(r){let t,e,i,n,s,o,a;return{c(){t=it("g"),e=it("circle"),n=it("circle"),s=it("circle"),w(e,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),w(e,"cx",r[0]),w(e,"cy",r[1]),w(e,"r",i=1.75*r[2]),w(n,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),w(n,"cx",r[0]),w(n,"cy",r[1]),w(n,"r",r[2]),w(s,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),w(s,"cx",r[0]),w(s,"cy",r[1]),w(s,"r",r[2]),w(t,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){ot(l,t,h),Ct(t,e),Ct(t,n),Ct(t,s),o||(a=[Pt(e,"pointerdown",r[5]),Pt(e,"pointerdown",r[3])],o=!0)},p(l,h){h&1&&w(e,"cx",l[0]),h&2&&w(e,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&w(e,"r",i),h&1&&w(n,"cx",l[0]),h&2&&w(n,"cy",l[1]),h&4&&w(n,"r",l[2]),h&1&&w(s,"cx",l[0]),h&2&&w(s,"cy",l[1]),h&4&&w(s,"r",l[2])},d(l){l&&st(t),o=!1,Fe(a)}}}function wv(r){let t;return{c(){t=it("circle"),w(t,"cx",r[0]),w(t,"cy",r[1]),w(t,"r",r[2])},m(e,i){ot(e,t,i)},p(e,i){i&1&&w(t,"cx",e[0]),i&2&&w(t,"cy",e[1]),i&4&&w(t,"r",e[2])},d(e){e&&st(t)}}}function Ev(r){let t;function e(s,o){return Nr?wv:xv}let n=e()(r);return{c(){n.c(),t=Pe()},m(s,o){n.m(s,o),ot(s,t,o)},p(s,[o]){n.p(s,o)},i:Ft,o:Ft,d(s){s&&st(t),n.d(s)}}}function Tv(r,t,e){let i,{x:n}=t,{y:s}=t,{scale:o}=t;const a=h=>{h.pointerType};function l(h){ae.call(this,r,h)}return r.$$set=h=>{"x"in h&&e(0,n=h.x),"y"in h&&e(1,s=h.y),"scale"in h&&e(4,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=4/o)},[n,s,i,a,o,l]}class Pu extends jt{constructor(t){super(),zt(this,t,Tv,Ev,Ut,{x:0,y:1,scale:4})}}function Ra(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Ru(r,t,e){const i=r.slice();return i[28]=t[e],i[30]=e,i}function Ma(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Da(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Mu(r){let t,e,i,n;return{c(){t=it("circle"),w(t,"cx",e=r[28][0]),w(t,"cy",i=r[28][1]),w(t,"r",n=Pn/r[3]),w(t,"class","svelte-1h2slbm")},m(s,o){ot(s,t,o)},p(s,o){o[0]&1088&&e!==(e=s[28][0])&&w(t,"cx",e),o[0]&1088&&i!==(i=s[28][1])&&w(t,"cy",i),o[0]&8&&n!==(n=Pn/s[3])&&w(t,"r",n)},d(s){s&&st(t)}}}function Du(r){let t,e,i,n,s,o,a,l,h,c;return{c(){t=it("mask"),e=it("rect"),a=it("circle"),w(e,"x",i=r[9].x),w(e,"y",n=r[9].y),w(e,"width",s=r[9].w),w(e,"height",o=r[9].h),w(e,"class","svelte-1h2slbm"),w(a,"cx",l=r[28][0]),w(a,"cy",h=r[28][1]),w(a,"r",c=Pn/r[3]),w(a,"class","svelte-1h2slbm"),w(t,"id",`${r[19]}-inner`),w(t,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(u,d){ot(u,t,d),Ct(t,e),Ct(t,a)},p(u,d){d[0]&512&&i!==(i=u[9].x)&&w(e,"x",i),d[0]&512&&n!==(n=u[9].y)&&w(e,"y",n),d[0]&512&&s!==(s=u[9].w)&&w(e,"width",s),d[0]&512&&o!==(o=u[9].h)&&w(e,"height",o),d[0]&1088&&l!==(l=u[28][0])&&w(a,"cx",l),d[0]&1088&&h!==(h=u[28][1])&&w(a,"cy",h),d[0]&8&&c!==(c=Pn/u[3])&&w(a,"r",c)},d(u){u&&st(t)}}}function Bu(r){let t,e;return t=new Gi({props:{class:"a9s-corner-handle",x:r[28][0],y:r[28][1],scale:r[3],selected:r[8].includes(r[30])}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[15]),t.$on("pointerdown",function(){Zt(r[27](`HANDLE-${r[30]}`))&&r[27](`HANDLE-${r[30]}`).apply(this,arguments)}),t.$on("pointerup",r[16](r[30])),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&32&&(s.x=r[28][0]),n[0]&32&&(s.y=r[28][1]),n[0]&8&&(s.scale=r[3]),n[0]&256&&(s.selected=r[8].includes(r[30])),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Ou(r){let t,e;return t=new Pu({props:{x:r[28][0],y:r[28][1],scale:r[3]}}),t.$on("pointerdown",function(){Zt(r[18](r[6]))&&r[18](r[6]).apply(this,arguments)}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&1088&&(s.x=r[28][0]),n[0]&1088&&(s.y=r[28][1]),n[0]&8&&(s.scale=r[3]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Av(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v,m,b,S,R=r[6]!==void 0&&!r[7]&&Mu(Da(r)),C=r[6]!==void 0&&!r[7]&&Du(Ma(r)),I=xe(r[5].points),M=[];for(let P=0;P<I.length;P+=1)M[P]=Bu(Ru(r,I,P));const F=P=>at(M[P],1,1,()=>{M[P]=null});let U=r[6]!==void 0&&!r[7]&&Ou(Ra(r));return{c(){t=it("defs"),e=it("mask"),i=it("rect"),l=it("polygon"),R&&R.c(),C&&C.c(),c=Se(),u=it("polygon"),f=Se(),p=it("polygon"),y=Se();for(let P=0;P<M.length;P+=1)M[P].c();_=Se(),U&&U.c(),v=Pe(),w(i,"x",n=r[9].x),w(i,"y",s=r[9].y),w(i,"width",o=r[9].w),w(i,"height",a=r[9].h),w(i,"class","svelte-1h2slbm"),w(l,"points",h=r[5].points.map(Lu).join(" ")),w(l,"class","svelte-1h2slbm"),w(e,"id",`${r[19]}-outer`),w(e,"class","a9s-polygon-editor-mask svelte-1h2slbm"),w(u,"class","a9s-outer"),w(u,"mask",`url(#${r[19]}-outer)`),w(u,"points",d=r[5].points.map(Nu).join(" ")),w(p,"class","a9s-inner a9s-shape-handle"),w(p,"mask",`url(#${r[19]}-inner)`),w(p,"style",r[1]),w(p,"points",g=r[5].points.map(Fu).join(" "))},m(P,T){ot(P,t,T),Ct(t,e),Ct(e,i),Ct(e,l),R&&R.m(e,null),C&&C.m(t,null),ot(P,c,T),ot(P,u,T),ot(P,f,T),ot(P,p,T),ot(P,y,T);for(let E=0;E<M.length;E+=1)M[E]&&M[E].m(P,T);ot(P,_,T),U&&U.m(P,T),ot(P,v,T),m=!0,b||(S=[Pt(u,"pointerup",r[14]),Pt(u,"pointerdown",function(){Zt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)}),Pt(p,"pointermove",r[13]),Pt(p,"pointerup",r[14]),Pt(p,"pointerdown",function(){Zt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)})],b=!0)},p(P,T){if(r=P,(!m||T[0]&512&&n!==(n=r[9].x))&&w(i,"x",n),(!m||T[0]&512&&s!==(s=r[9].y))&&w(i,"y",s),(!m||T[0]&512&&o!==(o=r[9].w))&&w(i,"width",o),(!m||T[0]&512&&a!==(a=r[9].h))&&w(i,"height",a),(!m||T[0]&32&&h!==(h=r[5].points.map(Lu).join(" ")))&&w(l,"points",h),r[6]!==void 0&&!r[7]?R?R.p(Da(r),T):(R=Mu(Da(r)),R.c(),R.m(e,null)):R&&(R.d(1),R=null),r[6]!==void 0&&!r[7]?C?C.p(Ma(r),T):(C=Du(Ma(r)),C.c(),C.m(t,null)):C&&(C.d(1),C=null),(!m||T[0]&32&&d!==(d=r[5].points.map(Nu).join(" ")))&&w(u,"points",d),(!m||T[0]&2)&&w(p,"style",r[1]),(!m||T[0]&32&&g!==(g=r[5].points.map(Fu).join(" ")))&&w(p,"points",g),T[0]&134322472){I=xe(r[5].points);let E;for(E=0;E<I.length;E+=1){const A=Ru(r,I,E);M[E]?(M[E].p(A,T),q(M[E],1)):(M[E]=Bu(A),M[E].c(),q(M[E],1),M[E].m(_.parentNode,_))}for(le(),E=I.length;E<M.length;E+=1)F(E);he()}r[6]!==void 0&&!r[7]?U?(U.p(Ra(r),T),T[0]&192&&q(U,1)):(U=Ou(Ra(r)),U.c(),q(U,1),U.m(v.parentNode,v)):U&&(le(),at(U,1,1,()=>{U=null}),he())},i(P){if(!m){for(let T=0;T<I.length;T+=1)q(M[T]);q(U),m=!0}},o(P){M=M.filter(Boolean);for(let T=0;T<M.length;T+=1)at(M[T]);at(U),m=!1},d(P){P&&(st(t),st(c),st(u),st(f),st(p),st(y),st(_),st(v)),R&&R.d(),C&&C.d(),Or(M,P),U&&U.d(P),b=!1,Fe(S)}}}function Sv(r){let t,e;return t=new Pa({props:{shape:r[0],transform:r[2],editor:r[17],svgEl:r[4],$$slots:{default:[Av,({grab:i})=>({27:i}),({grab:i})=>[i?134217728:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n[0]&1&&(s.shape=i[0]),n[0]&4&&(s.transform=i[2]),n[0]&16&&(s.svgEl=i[4]),n[0]&134219754|n[1]&1&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}const Cv=250,Iv=1e3,Pv=12,Pn=4.5,Lu=r=>r.join(","),Nu=r=>r.join(","),Fu=r=>r.join(",");function Rv(r,t,e){let i,n,s;const o=Oi();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:c=1}=t,{svgEl:u}=t,d,f=!1,p,g=[];const y=()=>e(7,f=!0),_=()=>e(7,f=!1),v=E=>{if(g.length>0||!n.some(k=>k.visible)){e(6,d=void 0);return}const[A,L]=h.elementToImage(E.offsetX,E.offsetY),D=k=>Math.pow(k[0]-A,2)+Math.pow(k[1]-L,2),N=i.points.reduce((k,V)=>D(V)<D(k)?V:k),$=n.filter(k=>k.visible).reduce((k,V)=>D(V.point)<D(k.point)?V:k),O=Math.pow(Iv/c,2);D(N)<O||D($.point)<O?e(6,d=n.indexOf($)):e(6,d=void 0)},m=()=>{document.activeElement!==u&&u.focus()},b=()=>{e(8,g=[]),m()},S=E=>{e(7,f=!0),E.preventDefault(),E.stopPropagation(),p=performance.now()},R=E=>A=>{if(!p||Nr||performance.now()-p>Cv)return;const L=g.includes(E);A.metaKey||A.ctrlKey||A.shiftKey?L?e(8,g=g.filter(D=>D!==E)):e(8,g=[...g,E]):L&&g.length>1?e(8,g=[E]):L?e(8,g=[]):e(8,g=[E]),m()},C=(E,A,L)=>{m();let D;const N=E.geometry;g.length>1?D=N.points.map(([O,B],k)=>g.includes(k)?[O+L[0],B+L[1]]:[O,B]):A==="SHAPE"?D=N.points.map(([O,B])=>[O+L[0],B+L[1]]):D=N.points.map(([O,B],k)=>A===`HANDLE-${k}`?[O+L[0],B+L[1]]:[O,B]);const $=er(D);return{...E,geometry:{points:D,bounds:$}}},I=E=>async A=>{A.stopPropagation();const L=[...i.points.slice(0,E+1),n[E].point,...i.points.slice(E+1)],D=er(L);o("change",{...a,geometry:{points:L,bounds:D}}),await vu();const N=[...document.querySelectorAll(".a9s-handle")][E+1];if(N!=null&&N.firstChild){const $=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:A.clientX,clientY:A.clientY,pointerId:A.pointerId,pointerType:A.pointerType,isPrimary:A.isPrimary,buttons:A.buttons});N.firstChild.dispatchEvent($)}},M=()=>{if(i.points.length-g.length<3)return;const E=i.points.filter((L,D)=>!g.includes(D)),A=er(E);o("change",{...a,geometry:{points:E,bounds:A}}),e(8,g=[])};ii(()=>{if(Nr)return;const E=A=>{(A.key==="Delete"||A.key==="Backspace")&&(A.preventDefault(),M())};return u.addEventListener("pointermove",v),u.addEventListener("keydown",E),()=>{u.removeEventListener("pointermove",v),u.removeEventListener("keydown",E)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function U(E){ae.call(this,r,E)}function P(E){ae.call(this,r,E)}function T(E){ae.call(this,r,E)}return r.$$set=E=>{"shape"in E&&e(0,a=E.shape),"computedStyle"in E&&e(1,l=E.computedStyle),"transform"in E&&e(2,h=E.transform),"viewportScale"in E&&e(3,c=E.viewportScale),"svgEl"in E&&e(4,u=E.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,n=Nr?[]:i.points.map((E,A)=>{const L=A===i.points.length-1?i.points[0]:i.points[A+1],D=(E[0]+L[0])/2,N=(E[1]+L[1])/2,O=Math.sqrt(Math.pow(L[0]-D,2)+Math.pow(L[1]-N,2))>Pv/c;return{point:[D,N],visible:O}})),r.$$.dirty[0]&40&&e(9,s=Ia(i.bounds,Pn/c))},[a,l,h,c,u,i,d,f,g,s,n,y,_,v,b,S,R,C,I,F,U,P,T]}class Mv extends jt{constructor(t){super(),zt(this,t,Rv,Sv,Ut,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function Dv(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v,m,b,S,R,C,I,M,F,U,P,T,E,A,L,D,N,$,O,B,k,V,z,K,X,ft,H,mt,Q,ut,gt,Et,Dt,Yt,Vt,et,$e,es;return Q=new Gi({props:{class:"a9s-corner-handle-topleft",x:r[5].x,y:r[5].y,scale:r[3]}}),Q.$on("pointerdown",function(){Zt(r[12]("TOP_LEFT"))&&r[12]("TOP_LEFT").apply(this,arguments)}),gt=new Gi({props:{class:"a9s-corner-handle-topright",x:r[5].x+r[5].w,y:r[5].y,scale:r[3]}}),gt.$on("pointerdown",function(){Zt(r[12]("TOP_RIGHT"))&&r[12]("TOP_RIGHT").apply(this,arguments)}),Dt=new Gi({props:{class:"a9s-corner-handle-bottomright",x:r[5].x+r[5].w,y:r[5].y+r[5].h,scale:r[3]}}),Dt.$on("pointerdown",function(){Zt(r[12]("BOTTOM_RIGHT"))&&r[12]("BOTTOM_RIGHT").apply(this,arguments)}),Vt=new Gi({props:{class:"a9s-corner-handle-bottomleft",x:r[5].x,y:r[5].y+r[5].h,scale:r[3]}}),Vt.$on("pointerdown",function(){Zt(r[12]("BOTTOM_LEFT"))&&r[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=it("defs"),e=it("mask"),i=it("rect"),l=it("rect"),f=Se(),p=it("rect"),m=Se(),b=it("rect"),M=Se(),F=it("rect"),E=Se(),A=it("rect"),$=Se(),O=it("rect"),z=Se(),K=it("rect"),mt=Se(),Lt(Q.$$.fragment),ut=Se(),Lt(gt.$$.fragment),Et=Se(),Lt(Dt.$$.fragment),Yt=Se(),Lt(Vt.$$.fragment),w(i,"class","rect-mask-bg svelte-1njczvj"),w(i,"x",n=r[6].x),w(i,"y",s=r[6].y),w(i,"width",o=r[6].w),w(i,"height",a=r[6].h),w(l,"class","rect-mask-fg svelte-1njczvj"),w(l,"x",h=r[5].x),w(l,"y",c=r[5].y),w(l,"width",u=r[5].w),w(l,"height",d=r[5].h),w(e,"id",r[8]),w(e,"class","a9s-rectangle-editor-mask svelte-1njczvj"),w(p,"class","a9s-outer"),w(p,"mask",`url(#${r[8]})`),w(p,"x",g=r[5].x),w(p,"y",y=r[5].y),w(p,"width",_=r[5].w),w(p,"height",v=r[5].h),w(b,"class","a9s-inner a9s-shape-handle"),w(b,"style",r[1]),w(b,"x",S=r[5].x),w(b,"y",R=r[5].y),w(b,"width",C=r[5].w),w(b,"height",I=r[5].h),w(F,"class","a9s-edge-handle a9s-edge-handle-top"),w(F,"x",U=r[5].x),w(F,"y",P=r[5].y),w(F,"height",1),w(F,"width",T=r[5].w),w(A,"class","a9s-edge-handle a9s-edge-handle-right"),w(A,"x",L=r[5].x+r[5].w),w(A,"y",D=r[5].y),w(A,"height",N=r[5].h),w(A,"width",1),w(O,"class","a9s-edge-handle a9s-edge-handle-bottom"),w(O,"x",B=r[5].x),w(O,"y",k=r[5].y+r[5].h),w(O,"height",1),w(O,"width",V=r[5].w),w(K,"class","a9s-edge-handle a9s-edge-handle-left"),w(K,"x",X=r[5].x),w(K,"y",ft=r[5].y),w(K,"height",H=r[5].h),w(K,"width",1)},m(Y,G){ot(Y,t,G),Ct(t,e),Ct(e,i),Ct(e,l),ot(Y,f,G),ot(Y,p,G),ot(Y,m,G),ot(Y,b,G),ot(Y,M,G),ot(Y,F,G),ot(Y,E,G),ot(Y,A,G),ot(Y,$,G),ot(Y,O,G),ot(Y,z,G),ot(Y,K,G),ot(Y,mt,G),Bt(Q,Y,G),ot(Y,ut,G),Bt(gt,Y,G),ot(Y,Et,G),Bt(Dt,Y,G),ot(Y,Yt,G),Bt(Vt,Y,G),et=!0,$e||(es=[Pt(p,"pointerdown",function(){Zt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Pt(b,"pointerdown",function(){Zt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Pt(F,"pointerdown",function(){Zt(r[12]("TOP"))&&r[12]("TOP").apply(this,arguments)}),Pt(A,"pointerdown",function(){Zt(r[12]("RIGHT"))&&r[12]("RIGHT").apply(this,arguments)}),Pt(O,"pointerdown",function(){Zt(r[12]("BOTTOM"))&&r[12]("BOTTOM").apply(this,arguments)}),Pt(K,"pointerdown",function(){Zt(r[12]("LEFT"))&&r[12]("LEFT").apply(this,arguments)})],$e=!0)},p(Y,G){r=Y,(!et||G&64&&n!==(n=r[6].x))&&w(i,"x",n),(!et||G&64&&s!==(s=r[6].y))&&w(i,"y",s),(!et||G&64&&o!==(o=r[6].w))&&w(i,"width",o),(!et||G&64&&a!==(a=r[6].h))&&w(i,"height",a),(!et||G&32&&h!==(h=r[5].x))&&w(l,"x",h),(!et||G&32&&c!==(c=r[5].y))&&w(l,"y",c),(!et||G&32&&u!==(u=r[5].w))&&w(l,"width",u),(!et||G&32&&d!==(d=r[5].h))&&w(l,"height",d),(!et||G&32&&g!==(g=r[5].x))&&w(p,"x",g),(!et||G&32&&y!==(y=r[5].y))&&w(p,"y",y),(!et||G&32&&_!==(_=r[5].w))&&w(p,"width",_),(!et||G&32&&v!==(v=r[5].h))&&w(p,"height",v),(!et||G&2)&&w(b,"style",r[1]),(!et||G&32&&S!==(S=r[5].x))&&w(b,"x",S),(!et||G&32&&R!==(R=r[5].y))&&w(b,"y",R),(!et||G&32&&C!==(C=r[5].w))&&w(b,"width",C),(!et||G&32&&I!==(I=r[5].h))&&w(b,"height",I),(!et||G&32&&U!==(U=r[5].x))&&w(F,"x",U),(!et||G&32&&P!==(P=r[5].y))&&w(F,"y",P),(!et||G&32&&T!==(T=r[5].w))&&w(F,"width",T),(!et||G&32&&L!==(L=r[5].x+r[5].w))&&w(A,"x",L),(!et||G&32&&D!==(D=r[5].y))&&w(A,"y",D),(!et||G&32&&N!==(N=r[5].h))&&w(A,"height",N),(!et||G&32&&B!==(B=r[5].x))&&w(O,"x",B),(!et||G&32&&k!==(k=r[5].y+r[5].h))&&w(O,"y",k),(!et||G&32&&V!==(V=r[5].w))&&w(O,"width",V),(!et||G&32&&X!==(X=r[5].x))&&w(K,"x",X),(!et||G&32&&ft!==(ft=r[5].y))&&w(K,"y",ft),(!et||G&32&&H!==(H=r[5].h))&&w(K,"height",H);const Sr={};G&32&&(Sr.x=r[5].x),G&32&&(Sr.y=r[5].y),G&8&&(Sr.scale=r[3]),Q.$set(Sr);const Cr={};G&32&&(Cr.x=r[5].x+r[5].w),G&32&&(Cr.y=r[5].y),G&8&&(Cr.scale=r[3]),gt.$set(Cr);const Ir={};G&32&&(Ir.x=r[5].x+r[5].w),G&32&&(Ir.y=r[5].y+r[5].h),G&8&&(Ir.scale=r[3]),Dt.$set(Ir);const Pr={};G&32&&(Pr.x=r[5].x),G&32&&(Pr.y=r[5].y+r[5].h),G&8&&(Pr.scale=r[3]),Vt.$set(Pr)},i(Y){et||(q(Q.$$.fragment,Y),q(gt.$$.fragment,Y),q(Dt.$$.fragment,Y),q(Vt.$$.fragment,Y),et=!0)},o(Y){at(Q.$$.fragment,Y),at(gt.$$.fragment,Y),at(Dt.$$.fragment,Y),at(Vt.$$.fragment,Y),et=!1},d(Y){Y&&(st(t),st(f),st(p),st(m),st(b),st(M),st(F),st(E),st(A),st($),st(O),st(z),st(K),st(mt),st(ut),st(Et),st(Yt)),Ot(Q,Y),Ot(gt,Y),Ot(Dt,Y),Ot(Vt,Y),$e=!1,Fe(es)}}}function Bv(r){let t,e;return t=new Pa({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[Dv,({grab:i})=>({12:i}),({grab:i})=>i?4096:0]},$$scope:{ctx:r}}}),t.$on("grab",r[9]),t.$on("change",r[10]),t.$on("release",r[11]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,[n]){const s={};n&1&&(s.shape=i[0]),n&4&&(s.transform=i[2]),n&16&&(s.svgEl=i[4]),n&12394&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Ov(r,t,e){let i,n,{shape:s}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const c=(g,y,_)=>{const v=g.geometry.bounds;let[m,b]=[v.minX,v.minY],[S,R]=[v.maxX,v.maxY];const[C,I]=_;if(y==="SHAPE")m+=C,S+=C,b+=I,R+=I;else{switch(y){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{b+=I;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{R+=I;break}}switch(y){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{m+=C;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{S+=C;break}}}const M=Math.min(m,S),F=Math.min(b,R),U=Math.abs(S-m),P=Math.abs(R-b);return{...g,geometry:{x:M,y:F,w:U,h:P,bounds:{minX:M,minY:F,maxX:M+U,maxY:F+P}}}},u=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(g){ae.call(this,r,g)}function f(g){ae.call(this,r,g)}function p(g){ae.call(this,r,g)}return r.$$set=g=>{"shape"in g&&e(0,s=g.shape),"computedStyle"in g&&e(1,o=g.computedStyle),"transform"in g&&e(2,a=g.transform),"viewportScale"in g&&e(3,l=g.viewportScale),"svgEl"in g&&e(4,h=g.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=s.geometry),r.$$.dirty&40&&e(6,n=Ia(i.bounds,2/l))},[s,o,a,l,h,i,n,c,u,d,f,p]}class Lv extends jt{constructor(t){super(),zt(this,t,Ov,Bv,Ut,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var ku=Object.prototype.hasOwnProperty;function Ba(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--&&Ba(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(ku.call(r,e)&&++i&&!ku.call(t,e)||!(e in t)||!Ba(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}const Nv=12,Fv=(r,t)=>r.polygons.reduce((e,i,n)=>{const s=i.rings.reduce((o,a,l)=>{const h=a.points.map((c,u)=>{const d=u===a.points.length-1?a.points[0]:a.points[u+1],f=(c[0]+d[0])/2,p=(c[1]+d[1])/2,y=Math.sqrt(Math.pow(d[0]-f,2)+Math.pow(d[1]-p,2))>Nv/t;return{point:[f,p],visible:y,elementIdx:n,ringIdx:l,pointIdx:u}});return[...o,...h]},[]);return[...e,...s]},[]);function Oa(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Uu(r,t,e){const i=r.slice();return i[30]=t[e],i[32]=e,i}function Gu(r,t,e){const i=r.slice();return i[33]=t[e],i[35]=e,i}function $u(r,t,e){const i=r.slice();return i[29]=t[e],i[37]=e,i}function La(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Na(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Hu(r){let t,e,i,n;return{c(){t=it("circle"),w(t,"cx",e=r[29][0]),w(t,"cy",i=r[29][1]),w(t,"r",n=Rn/r[3]),w(t,"class","svelte-1vxo6dc")},m(s,o){ot(s,t,o)},p(s,o){o[0]&1088&&e!==(e=s[29][0])&&w(t,"cx",e),o[0]&1088&&i!==(i=s[29][1])&&w(t,"cy",i),o[0]&8&&n!==(n=Rn/s[3])&&w(t,"r",n)},d(s){s&&st(t)}}}function Xu(r){let t,e,i,n,s,o,a,l,h,c;return{c(){t=it("mask"),e=it("rect"),a=it("circle"),w(e,"x",i=r[9].x),w(e,"y",n=r[9].y),w(e,"width",s=r[9].w),w(e,"height",o=r[9].h),w(e,"class","svelte-1vxo6dc"),w(a,"cx",l=r[29][0]),w(a,"cy",h=r[29][1]),w(a,"r",c=Rn/r[3]),w(a,"class","svelte-1vxo6dc"),w(t,"id",`${r[18]}-${r[32]}-inner`),w(t,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc")},m(u,d){ot(u,t,d),Ct(t,e),Ct(t,a)},p(u,d){d[0]&512&&i!==(i=u[9].x)&&w(e,"x",i),d[0]&512&&n!==(n=u[9].y)&&w(e,"y",n),d[0]&512&&s!==(s=u[9].w)&&w(e,"width",s),d[0]&512&&o!==(o=u[9].h)&&w(e,"height",o),d[0]&1088&&l!==(l=u[29][0])&&w(a,"cx",l),d[0]&1088&&h!==(h=u[29][1])&&w(a,"cy",h),d[0]&8&&c!==(c=Rn/u[3])&&w(a,"r",c)},d(u){u&&st(t)}}}function Vu(r){let t,e;function i(...n){return r[19](r[32],r[35],r[37],...n)}return t=new Gi({props:{class:"a9s-corner-handle",x:r[29][0],y:r[29][1],scale:r[3],selected:r[8].some(i)}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[14]),t.$on("pointerdown",function(){Zt(r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`))&&r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`).apply(this,arguments)}),t.$on("pointerup",r[15](r[32],r[35],r[37])),{c(){Lt(t.$$.fragment)},m(n,s){Bt(t,n,s),e=!0},p(n,s){r=n;const o={};s[0]&32&&(o.x=r[29][0]),s[0]&32&&(o.y=r[29][1]),s[0]&8&&(o.scale=r[3]),s[0]&256&&(o.selected=r[8].some(i)),t.$set(o)},i(n){e||(q(t.$$.fragment,n),e=!0)},o(n){at(t.$$.fragment,n),e=!1},d(n){Ot(t,n)}}}function zu(r){let t,e,i=xe(r[33].points),n=[];for(let o=0;o<i.length;o+=1)n[o]=Vu($u(r,i,o));const s=o=>at(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=Pe()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);ot(o,t,a),e=!0},p(o,a){if(a[0]&268491048){i=xe(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=$u(o,i,l);n[l]?(n[l].p(h,a),q(n[l],1)):(n[l]=Vu(h),n[l].c(),q(n[l],1),n[l].m(t.parentNode,t))}for(le(),l=i.length;l<n.length;l+=1)s(l);he()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(n[a]);e=!0}},o(o){n=n.filter(Boolean);for(let a=0;a<n.length;a+=1)at(n[a]);e=!1},d(o){o&&st(t),Or(n,o)}}}function ju(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v=r[6]!==void 0&&!r[7]&&Hu(Na(r)),m=r[6]!==void 0&&!r[7]&&Xu(La(r)),b=xe(r[30].rings),S=[];for(let C=0;C<b.length;C+=1)S[C]=zu(Gu(r,b,C));const R=C=>at(S[C],1,1,()=>{S[C]=null});return{c(){t=it("g"),e=it("defs"),i=it("mask"),n=it("rect"),h=it("path"),v&&v.c(),m&&m.c(),u=it("path"),f=it("path");for(let C=0;C<S.length;C+=1)S[C].c();w(n,"x",s=r[9].x),w(n,"y",o=r[9].y),w(n,"width",a=r[9].w),w(n,"height",l=r[9].h),w(n,"class","svelte-1vxo6dc"),w(h,"d",c=Ui(r[30])),w(h,"class","svelte-1vxo6dc"),w(i,"id",`${r[18]}-${r[32]}-outer`),w(i,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc"),w(u,"class","a9s-outer"),w(u,"mask",`url(#${r[18]}-${r[32]}-outer)`),w(u,"fill-rule","evenodd"),w(u,"d",d=Ui(r[30])),w(f,"class","a9s-inner"),w(f,"mask",`url(#${r[18]}-${r[32]}-inner)`),w(f,"style",r[1]),w(f,"fill-rule","evenodd"),w(f,"d",p=Ui(r[30]))},m(C,I){ot(C,t,I),Ct(t,e),Ct(e,i),Ct(i,n),Ct(i,h),v&&v.m(i,null),m&&m.m(e,null),Ct(t,u),Ct(t,f);for(let M=0;M<S.length;M+=1)S[M]&&S[M].m(t,null);g=!0,y||(_=[Pt(u,"pointerup",r[13]),Pt(u,"pointerdown",function(){Zt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)}),Pt(f,"pointerup",r[13]),Pt(f,"pointerdown",function(){Zt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)})],y=!0)},p(C,I){if(r=C,(!g||I[0]&512&&s!==(s=r[9].x))&&w(n,"x",s),(!g||I[0]&512&&o!==(o=r[9].y))&&w(n,"y",o),(!g||I[0]&512&&a!==(a=r[9].w))&&w(n,"width",a),(!g||I[0]&512&&l!==(l=r[9].h))&&w(n,"height",l),(!g||I[0]&32&&c!==(c=Ui(r[30])))&&w(h,"d",c),r[6]!==void 0&&!r[7]?v?v.p(Na(r),I):(v=Hu(Na(r)),v.c(),v.m(i,null)):v&&(v.d(1),v=null),r[6]!==void 0&&!r[7]?m?m.p(La(r),I):(m=Xu(La(r)),m.c(),m.m(e,null)):m&&(m.d(1),m=null),(!g||I[0]&32&&d!==(d=Ui(r[30])))&&w(u,"d",d),(!g||I[0]&2)&&w(f,"style",r[1]),(!g||I[0]&32&&p!==(p=Ui(r[30])))&&w(f,"d",p),I[0]&268491048){b=xe(r[30].rings);let M;for(M=0;M<b.length;M+=1){const F=Gu(r,b,M);S[M]?(S[M].p(F,I),q(S[M],1)):(S[M]=zu(F),S[M].c(),q(S[M],1),S[M].m(t,null))}for(le(),M=b.length;M<S.length;M+=1)R(M);he()}},i(C){if(!g){for(let I=0;I<b.length;I+=1)q(S[I]);g=!0}},o(C){S=S.filter(Boolean);for(let I=0;I<S.length;I+=1)at(S[I]);g=!1},d(C){C&&st(t),v&&v.d(),m&&m.d(),Or(S,C),y=!1,Fe(_)}}}function Wu(r){let t,e;return t=new Pu({props:{x:r[29][0],y:r[29][1],scale:r[3]}}),t.$on("pointerdown",function(){Zt(r[17](r[6]))&&r[17](r[6]).apply(this,arguments)}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&1088&&(s.x=r[29][0]),n[0]&1088&&(s.y=r[29][1]),n[0]&8&&(s.scale=r[3]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function kv(r){let t,e,i,n=xe(r[5].polygons),s=[];for(let l=0;l<n.length;l+=1)s[l]=ju(Uu(r,n,l));const o=l=>at(s[l],1,1,()=>{s[l]=null});let a=r[6]!==void 0&&!r[7]&&Wu(Oa(r));return{c(){for(let l=0;l<s.length;l+=1)s[l].c();t=Se(),a&&a.c(),e=Pe()},m(l,h){for(let c=0;c<s.length;c+=1)s[c]&&s[c].m(l,h);ot(l,t,h),a&&a.m(l,h),ot(l,e,h),i=!0},p(l,h){if(h[0]&268763114){n=xe(l[5].polygons);let c;for(c=0;c<n.length;c+=1){const u=Uu(l,n,c);s[c]?(s[c].p(u,h),q(s[c],1)):(s[c]=ju(u),s[c].c(),q(s[c],1),s[c].m(t.parentNode,t))}for(le(),c=n.length;c<s.length;c+=1)o(c);he()}l[6]!==void 0&&!l[7]?a?(a.p(Oa(l),h),h[0]&192&&q(a,1)):(a=Wu(Oa(l)),a.c(),q(a,1),a.m(e.parentNode,e)):a&&(le(),at(a,1,1,()=>{a=null}),he())},i(l){if(!i){for(let h=0;h<n.length;h+=1)q(s[h]);q(a),i=!0}},o(l){s=s.filter(Boolean);for(let h=0;h<s.length;h+=1)at(s[h]);at(a),i=!1},d(l){l&&(st(t),st(e)),Or(s,l),a&&a.d(l)}}}function Uv(r){let t,e;return t=new Pa({props:{shape:r[0],transform:r[2],editor:r[16],svgEl:r[4],$$slots:{default:[kv,({grab:i})=>({28:i}),({grab:i})=>[i?268435456:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n[0]&1&&(s.shape=i[0]),n[0]&4&&(s.transform=i[2]),n[0]&16&&(s.svgEl=i[4]),n[0]&268437482|n[1]&128&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}const Gv=250,$v=1e3,Rn=4.5;function Hv(r,t,e){let i,n,s;const o=Oi();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:c=1}=t,{svgEl:u}=t,d,f=!1,p,g=[];const y=()=>e(7,f=!0),_=()=>e(7,f=!1),v=A=>{if(g.length>0||!n.some(V=>V.visible)){e(6,d=void 0);return}const[L,D]=h.elementToImage(A.offsetX,A.offsetY),N=V=>Math.pow(V[0]-L,2)+Math.pow(V[1]-D,2),$=ev(i).reduce((V,z)=>N(z)<N(V)?z:V),O=n.filter(V=>V.visible).reduce((V,z)=>N(z.point)<N(V.point)?z:V),B=Math.pow($v/c,2);N($)<B||N(O.point)<B?e(6,d=n.indexOf(O)):e(6,d=void 0)},m=()=>{document.activeElement!==u&&u.focus()},b=()=>{e(8,g=[]),m()},S=A=>{e(7,f=!0),A.preventDefault(),A.stopPropagation(),p=performance.now()},R=(A,L,D)=>N=>{if(!p||Nr||performance.now()-p>Gv)return;const $=B=>B.polygon===A&&B.ring===L&&B.point===D,O=g.some($);N.metaKey||N.ctrlKey||N.shiftKey?O?e(8,g=g.filter(B=>!$(B))):e(8,g=[...g,{polygon:A,ring:L,point:D}]):O&&g.length>1?e(8,g=[{polygon:A,ring:L,point:D}]):O?e(8,g=[]):e(8,g=[{polygon:A,ring:L,point:D}]),m()},C=(A,L,D)=>{m();const N=A.geometry.polygons;let $;if(L==="SHAPE")$=N.map(O=>{const B=O.rings.map((V,z)=>({points:V.points.map((X,ft)=>[X[0]+D[0],X[1]+D[1]])})),k=er(B[0].points);return{rings:B,bounds:k}});else{const[O,B,k,V]=L.split("-").map(z=>parseInt(z));$=N.map((z,K)=>{if(K===B){const X=z.rings.map((H,mt)=>mt===k?{points:H.points.map((ut,gt)=>gt===V?[ut[0]+D[0],ut[1]+D[1]]:ut)}:H),ft=er(X[0].points);return{rings:X,bounds:ft}}else return z})}return{...A,geometry:{polygons:$,bounds:As($)}}},I=A=>async L=>{L.stopPropagation();const D=n[A],N=i.polygons.map((O,B)=>{if(B===D.elementIdx){const k=O.rings.map((z,K)=>K===D.ringIdx?{points:[...z.points.slice(0,D.pointIdx+1),D.point,...z.points.slice(D.pointIdx+1)]}:z),V=er(k[0].points);return{rings:k,bounds:V}}else return O});o("change",{...a,geometry:{polygons:N,bounds:As(N)}}),await vu();const $=[...document.querySelectorAll(".a9s-handle")][A+1];if($!=null&&$.firstChild){const O=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:L.clientX,clientY:L.clientY,pointerId:L.pointerId,pointerType:L.pointerType,isPrimary:L.isPrimary,buttons:L.buttons});$.firstChild.dispatchEvent(O)}},M=()=>{const A=i.polygons.map((D,N)=>{if(g.some(O=>O.polygon===N)){const O=D.rings.map((k,V)=>{const z=g.filter(K=>K.polygon===N&&K.ring===V);return z.length&&k.points.length-z.length>=3?{points:k.points.filter((X,ft)=>!z.some(H=>H.point===ft))}:k}),B=er(O[0].points);return{rings:O,bounds:B}}else return D});!Ba(i.polygons,A)&&(o("change",{...a,geometry:{polygons:A,bounds:As(A)}}),e(8,g=[]))};ii(()=>{if(Nr)return;const A=L=>{(L.key==="Delete"||L.key==="Backspace")&&(L.preventDefault(),M())};return u.addEventListener("pointermove",v),u.addEventListener("keydown",A),()=>{u.removeEventListener("pointermove",v),u.removeEventListener("keydown",A)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,U=(A,L,D,{polygon:N,ring:$,point:O})=>N===A&&$===L&&O===D;function P(A){ae.call(this,r,A)}function T(A){ae.call(this,r,A)}function E(A){ae.call(this,r,A)}return r.$$set=A=>{"shape"in A&&e(0,a=A.shape),"computedStyle"in A&&e(1,l=A.computedStyle),"transform"in A&&e(2,h=A.transform),"viewportScale"in A&&e(3,c=A.viewportScale),"svgEl"in A&&e(4,u=A.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,n=Nr?[]:Fv(i,c)),r.$$.dirty[0]&40&&e(9,s=Ia(i.bounds,Rn/c))},[a,l,h,c,u,i,d,f,g,s,n,y,_,b,S,R,C,I,F,U,P,T,E]}class Xv extends jt{constructor(t){super(),zt(this,t,Hv,Uv,Ut,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}tr.RECTANGLE,tr.POLYGON,tr.MULTIPOLYGON;function Vv(r,t,e){let i;const n=Oi();let{annotation:s}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return ii(()=>(e(6,u=new o({target:l,props:{shape:s.target.selector,computedStyle:i,transform:h,viewportScale:c,svgEl:l.closest("svg")}})),u.$on("change",d=>{u.$$set({shape:d.detail}),n("change",d.detail)}),u.$on("grab",d=>n("grab",d.detail)),u.$on("release",d=>n("release",d.detail)),()=>{u.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,s=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,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=fv(s,a)),r.$$.dirty&65&&s&&(u==null||u.$set({shape:s.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c}),r.$$.dirty&192&&u&&i&&u.$set({computedStyle:i})},[s,o,a,l,h,c,u,i]}class zv extends jt{constructor(t){super(),zt(this,t,Vv,null,Ut,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;var si=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(si||{}),Yu=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Yu||{}),Fa=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(Fa||{}),vt=(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))(vt||{}),rr=(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))(rr||{}),j=(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))(j||{}),$i=(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))($i||{}),pt=(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))(pt||{}),J=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(J||{}),gr=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(gr||{}),Fr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Fr||{}),ir=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(ir||{}),Re=(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))(Re||{}),nr=(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))(nr||{}),ka=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(ka||{}),ke=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(ke||{}),ie=(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))(ie||{}),ee=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(ee||{}),sr=(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))(sr||{});const tt={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 Ua=/iPhone/i,qu=/iPod/i,Ku=/iPad/i,Zu=/\biOS-universal(?:.+)Mac\b/i,Ga=/\bAndroid(?:.+)Mobile\b/i,Qu=/Android/i,Hi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ss=/Silk/i,yr=/Windows Phone/i,Ju=/\bWindows(?:.+)ARM\b/i,td=/BlackBerry/i,ed=/BB10/i,rd=/Opera Mini/i,id=/\b(CriOS|Chrome)(?:.+)Mobile/i,nd=/Mobile(?:.+)Firefox\b/i,sd=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function jv(r){return function(t){return t.test(r)}}function od(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 n=jv(e),s={apple:{phone:n(Ua)&&!n(yr),ipod:n(qu),tablet:!n(Ua)&&(n(Ku)||sd(t))&&!n(yr),universal:n(Zu),device:(n(Ua)||n(qu)||n(Ku)||n(Zu)||sd(t))&&!n(yr)},amazon:{phone:n(Hi),tablet:!n(Hi)&&n(Ss),device:n(Hi)||n(Ss)},android:{phone:!n(yr)&&n(Hi)||!n(yr)&&n(Ga),tablet:!n(yr)&&!n(Hi)&&!n(Ga)&&(n(Ss)||n(Qu)),device:!n(yr)&&(n(Hi)||n(Ss)||n(Ga)||n(Qu))||n(/\bokhttp\b/i)},windows:{phone:n(yr),tablet:n(Ju),device:n(yr)||n(Ju)},other:{blackberry:n(td),blackberry10:n(ed),opera:n(rd),firefox:n(nd),chrome:n(id),device:n(td)||n(ed)||n(rd)||n(nd)||n(id)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}const Wv=od.default??od,_r=Wv(globalThis.navigator);tt.RETINA_PREFIX=/@([0-9\.]+)x/,tt.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var ad={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function n(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function s(l,h,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new n(c,u||l,d),p=e?e+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,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=[],c,u;if(this._eventsCount===0)return h;for(u in c=this._events)t.call(c,u)&&h.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=e?e+h:h,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(h){var c=e?e+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,f,p){var g=e?e+h:h;if(!this._events[g])return!1;var y=this._events[g],_=arguments.length,v,m;if(y.fn){switch(y.once&&this.removeListener(h,y.fn,void 0,!0),_){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,c),!0;case 3:return y.fn.call(y.context,c,u),!0;case 4:return y.fn.call(y.context,c,u,d),!0;case 5:return y.fn.call(y.context,c,u,d,f),!0;case 6:return y.fn.call(y.context,c,u,d,f,p),!0}for(m=1,v=new Array(_-1);m<_;m++)v[m-1]=arguments[m];y.fn.apply(y.context,v)}else{var b=y.length,S;for(m=0;m<b;m++)switch(y[m].once&&this.removeListener(h,y[m].fn,void 0,!0),_){case 1:y[m].fn.call(y[m].context);break;case 2:y[m].fn.call(y[m].context,c);break;case 3:y[m].fn.call(y[m].context,c,u);break;case 4:y[m].fn.call(y[m].context,c,u,d);break;default:if(!v)for(S=1,v=new Array(_-1);S<_;S++)v[S-1]=arguments[S];y[m].fn.apply(y[m].context,v)}}return!0},a.prototype.on=function(h,c,u){return s(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return s(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var f=e?e+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var g=0,y=[],_=p.length;g<_;g++)(p[g].fn!==c||d&&!p[g].once||u&&p[g].context!==u)&&y.push(p[g]);y.length?this._events[f]=y.length===1?y[0]:y:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=e?e+h:h,this._events[c]&&o(this,c)):(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})(ad);var Yv=ad.exports;const Mn=Sa(Yv);var $a={exports:{}};$a.exports=Cs,$a.exports.default=Cs;function Cs(r,t,e){e=e||2;var i=t&&t.length,n=i?t[0]*e:r.length,s=ld(r,0,n,e,!0),o=[];if(!s||s.next===s.prev)return o;var a,l,h,c,u,d,f;if(i&&(s=Jv(r,t,s,e)),r.length>80*e){a=h=r[0],l=c=r[1];for(var p=e;p<n;p+=e)u=r[p],d=r[p+1],u<a&&(a=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);f=Math.max(h-a,c-l),f=f!==0?32767/f:0}return Dn(s,o,e,a,l,f,0),o}function ld(r,t,e,i,n){var s,o;if(n===Va(r,t,e,i)>0)for(s=t;s<e;s+=i)o=ud(s,r[s],r[s+1],o);else for(s=e-i;s>=t;s-=i)o=ud(s,r[s],r[s+1],o);return o&&Is(o,o.next)&&(On(o),o=o.next),o}function oi(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Is(e,e.next)||$t(e.prev,e,e.next)===0)){if(On(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Dn(r,t,e,i,n,s,o){if(r){!o&&s&&n1(r,i,n,s);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,s?Kv(r,i,n,s):qv(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),On(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=Zv(oi(r),t,e),Dn(r,t,e,i,n,s,2)):o===2&&Qv(r,t,e,i,n,s):Dn(oi(r),t,e,i,n,s,1);break}}}}function qv(r){var t=r.prev,e=r,i=r.next;if($t(t,e,i)>=0)return!1;for(var n=t.x,s=e.x,o=i.x,a=t.y,l=e.y,h=i.y,c=n<s?n<o?n:o:s<o?s:o,u=a<l?a<h?a:h:l<h?l:h,d=n>s?n>o?n:o:s>o?s:o,f=a>l?a>h?a:h:l>h?l:h,p=i.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&Xi(n,a,s,l,o,h,p.x,p.y)&&$t(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Kv(r,t,e,i){var n=r.prev,s=r,o=r.next;if($t(n,s,o)>=0)return!1;for(var a=n.x,l=s.x,h=o.x,c=n.y,u=s.y,d=o.y,f=a<l?a<h?a:h:l<h?l:h,p=c<u?c<d?c:d:u<d?u:d,g=a>l?a>h?a:h:l>h?l:h,y=c>u?c>d?c:d:u>d?u:d,_=Ha(f,p,t,e,i),v=Ha(g,y,t,e,i),m=r.prevZ,b=r.nextZ;m&&m.z>=_&&b&&b.z<=v;){if(m.x>=f&&m.x<=g&&m.y>=p&&m.y<=y&&m!==n&&m!==o&&Xi(a,c,l,u,h,d,m.x,m.y)&&$t(m.prev,m,m.next)>=0||(m=m.prevZ,b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==n&&b!==o&&Xi(a,c,l,u,h,d,b.x,b.y)&&$t(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;m&&m.z>=_;){if(m.x>=f&&m.x<=g&&m.y>=p&&m.y<=y&&m!==n&&m!==o&&Xi(a,c,l,u,h,d,m.x,m.y)&&$t(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==n&&b!==o&&Xi(a,c,l,u,h,d,b.x,b.y)&&$t(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Zv(r,t,e){var i=r;do{var n=i.prev,s=i.next.next;!Is(n,s)&&hd(n,i,i.next,s)&&Bn(n,s)&&Bn(s,n)&&(t.push(n.i/e|0),t.push(i.i/e|0),t.push(s.i/e|0),On(i),On(i.next),i=r=s),i=i.next}while(i!==r);return oi(i)}function Qv(r,t,e,i,n,s){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&a1(o,a)){var l=cd(o,a);o=oi(o,o.next),l=oi(l,l.next),Dn(o,t,e,i,n,s,0),Dn(l,t,e,i,n,s,0);return}a=a.next}o=o.next}while(o!==r)}function Jv(r,t,e,i){var n=[],s,o,a,l,h;for(s=0,o=t.length;s<o;s++)a=t[s]*i,l=s<o-1?t[s+1]*i:r.length,h=ld(r,a,l,i,!1),h===h.next&&(h.steiner=!0),n.push(o1(h));for(n.sort(t1),s=0;s<n.length;s++)e=e1(n[s],e);return e}function t1(r,t){return r.x-t.x}function e1(r,t){var e=r1(r,t);if(!e)return t;var i=cd(e,r);return oi(i,i.next),oi(e,e.next)}function r1(r,t){var e=t,i=r.x,n=r.y,s=-1/0,o;do{if(n<=e.y&&n>=e.next.y&&e.next.y!==e.y){var a=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>s&&(s=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,c=o.y,u=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&Xi(n<c?i:s,n,h,c,n<c?s:i,n,e.x,e.y)&&(d=Math.abs(n-e.y)/(i-e.x),Bn(e,r)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&i1(o,e)))&&(o=e,u=d)),e=e.next;while(e!==l);return o}function i1(r,t){return $t(r.prev,r,t.prev)<0&&$t(t.next,r,r.next)<0}function n1(r,t,e,i){var n=r;do n.z===0&&(n.z=Ha(n.x,n.y,t,e,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==r);n.prevZ.nextZ=null,n.prevZ=null,s1(n)}function s1(r){var t,e,i,n,s,o,a,l,h=1;do{for(e=r,r=null,s=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)?(n=e,e=e.nextZ,a--):(n=i,i=i.nextZ,l--),s?s.nextZ=n:r=n,n.prevZ=s,s=n;e=i}s.nextZ=null,h*=2}while(o>1);return r}function Ha(r,t,e,i,n){return r=(r-e)*n|0,t=(t-i)*n|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 o1(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 Xi(r,t,e,i,n,s,o,a){return(n-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(n-o)*(i-a)}function a1(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!l1(r,t)&&(Bn(r,t)&&Bn(t,r)&&h1(r,t)&&($t(r.prev,r,t.prev)||$t(r,t.prev,t))||Is(r,t)&&$t(r.prev,r,r.next)>0&&$t(t.prev,t,t.next)>0)}function $t(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Is(r,t){return r.x===t.x&&r.y===t.y}function hd(r,t,e,i){var n=Rs($t(r,t,e)),s=Rs($t(r,t,i)),o=Rs($t(e,i,r)),a=Rs($t(e,i,t));return!!(n!==s&&o!==a||n===0&&Ps(r,e,t)||s===0&&Ps(r,i,t)||o===0&&Ps(e,r,i)||a===0&&Ps(e,t,i))}function Ps(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 Rs(r){return r>0?1:r<0?-1:0}function l1(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&&hd(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Bn(r,t){return $t(r.prev,r,r.next)<0?$t(r,t,r.next)>=0&&$t(r,r.prev,t)>=0:$t(r,t,r.prev)<0||$t(r,r.next,t)<0}function h1(r,t){var e=r,i=!1,n=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&n<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function cd(r,t){var e=new Xa(r.i,r.x,r.y),i=new Xa(t.i,t.x,t.y),n=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=n,n.prev=e,i.next=e,e.prev=i,s.next=i,i.prev=s,i}function ud(r,t,e,i){var n=new Xa(r,t,e);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function On(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 Xa(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}Cs.deviation=function(r,t,e,i){var n=t&&t.length,s=n?t[0]*e:r.length,o=Math.abs(Va(r,0,s,e));if(n)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,c=a<l-1?t[a+1]*e:r.length;o-=Math.abs(Va(r,h,c,e))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,f=i[a+1]*e,p=i[a+2]*e;u+=Math.abs((r[d]-r[p])*(r[f+1]-r[d+1])-(r[d]-r[f])*(r[p+1]-r[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function Va(r,t,e,i){for(var n=0,s=t,o=e-i;s<e;s+=i)n+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return n}Cs.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,n=0;n<r.length;n++){for(var s=0;s<r[n].length;s++)for(var o=0;o<t;o++)e.vertices.push(r[n][s][o]);n>0&&(i+=r[n-1].length,e.holes.push(i))}return e};var c1=$a.exports;const u1=Sa(c1);var Ms={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */Ms.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,n=r&&!r.nodeType&&r,s=typeof In=="object"&&In;(s.global===s||s.window===s||s.self===s)&&(e=s);var o,a=2147483647,l=36,h=1,c=26,u=38,d=700,f=72,p=128,g="-",y=/^xn--/,_=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,m={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},b=l-h,S=Math.floor,R=String.fromCharCode,C;function I(O){throw new RangeError(m[O])}function M(O,B){for(var k=O.length,V=[];k--;)V[k]=B(O[k]);return V}function F(O,B){var k=O.split("@"),V="";k.length>1&&(V=k[0]+"@",O=k[1]),O=O.replace(v,".");var z=O.split("."),K=M(z,B).join(".");return V+K}function U(O){for(var B=[],k=0,V=O.length,z,K;k<V;)z=O.charCodeAt(k++),z>=55296&&z<=56319&&k<V?(K=O.charCodeAt(k++),(K&64512)==56320?B.push(((z&1023)<<10)+(K&1023)+65536):(B.push(z),k--)):B.push(z);return B}function P(O){return M(O,function(B){var k="";return B>65535&&(B-=65536,k+=R(B>>>10&1023|55296),B=56320|B&1023),k+=R(B),k}).join("")}function T(O){return O-48<10?O-22:O-65<26?O-65:O-97<26?O-97:l}function E(O,B){return O+22+75*(O<26)-((B!=0)<<5)}function A(O,B,k){var V=0;for(O=k?S(O/d):O>>1,O+=S(O/B);O>b*c>>1;V+=l)O=S(O/b);return S(V+(b+1)*O/(O+u))}function L(O){var B=[],k=O.length,V,z=0,K=p,X=f,ft,H,mt,Q,ut,gt,Et,Dt,Yt;for(ft=O.lastIndexOf(g),ft<0&&(ft=0),H=0;H<ft;++H)O.charCodeAt(H)>=128&&I("not-basic"),B.push(O.charCodeAt(H));for(mt=ft>0?ft+1:0;mt<k;){for(Q=z,ut=1,gt=l;mt>=k&&I("invalid-input"),Et=T(O.charCodeAt(mt++)),(Et>=l||Et>S((a-z)/ut))&&I("overflow"),z+=Et*ut,Dt=gt<=X?h:gt>=X+c?c:gt-X,!(Et<Dt);gt+=l)Yt=l-Dt,ut>S(a/Yt)&&I("overflow"),ut*=Yt;V=B.length+1,X=A(z-Q,V,Q==0),S(z/V)>a-K&&I("overflow"),K+=S(z/V),z%=V,B.splice(z++,0,K)}return P(B)}function D(O){var B,k,V,z,K,X,ft,H,mt,Q,ut,gt=[],Et,Dt,Yt,Vt;for(O=U(O),Et=O.length,B=p,k=0,K=f,X=0;X<Et;++X)ut=O[X],ut<128&&gt.push(R(ut));for(V=z=gt.length,z&&gt.push(g);V<Et;){for(ft=a,X=0;X<Et;++X)ut=O[X],ut>=B&&ut<ft&&(ft=ut);for(Dt=V+1,ft-B>S((a-k)/Dt)&&I("overflow"),k+=(ft-B)*Dt,B=ft,X=0;X<Et;++X)if(ut=O[X],ut<B&&++k>a&&I("overflow"),ut==B){for(H=k,mt=l;Q=mt<=K?h:mt>=K+c?c:mt-K,!(H<Q);mt+=l)Vt=H-Q,Yt=l-Q,gt.push(R(E(Q+Vt%Yt,0))),H=S(Vt/Yt);gt.push(R(E(H,0))),K=A(k,Dt,V==z),k=0,++V}++k,++B}return gt.join("")}function N(O){return F(O,function(B){return y.test(B)?L(B.slice(4).toLowerCase()):B})}function $(O){return F(O,function(B){return _.test(B)?"xn--"+D(B):B})}if(o={version:"1.4.1",ucs2:{decode:U,encode:P},decode:L,encode:D,toASCII:$,toUnicode:N},i&&n)if(r.exports==i)n.exports=o;else for(C in o)o.hasOwnProperty(C)&&(i[C]=o[C]);else e.punycode=o})(In)}(Ms,Ms.exports);var d1=Ms.exports,Vi=TypeError;const f1=W_(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var za=typeof Map=="function"&&Map.prototype,ja=Object.getOwnPropertyDescriptor&&za?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Ds=za&&ja&&typeof ja.get=="function"?ja.get:null,dd=za&&Map.prototype.forEach,Wa=typeof Set=="function"&&Set.prototype,Ya=Object.getOwnPropertyDescriptor&&Wa?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Bs=Wa&&Ya&&typeof Ya.get=="function"?Ya.get:null,fd=Wa&&Set.prototype.forEach,p1=typeof WeakMap=="function"&&WeakMap.prototype,Ln=p1?WeakMap.prototype.has:null,m1=typeof WeakSet=="function"&&WeakSet.prototype,Nn=m1?WeakSet.prototype.has:null,g1=typeof WeakRef=="function"&&WeakRef.prototype,pd=g1?WeakRef.prototype.deref:null,y1=Boolean.prototype.valueOf,_1=Object.prototype.toString,v1=Function.prototype.toString,b1=String.prototype.match,qa=String.prototype.slice,kr=String.prototype.replace,x1=String.prototype.toUpperCase,md=String.prototype.toLowerCase,gd=RegExp.prototype.test,yd=Array.prototype.concat,or=Array.prototype.join,w1=Array.prototype.slice,_d=Math.floor,Ka=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Za=Object.getOwnPropertySymbols,Qa=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,zi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Fn=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===zi||!0)?Symbol.toStringTag:null,vd=Object.prototype.propertyIsEnumerable,bd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function xd(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||gd.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-_d(-r):_d(r);if(i!==r){var n=String(i),s=qa.call(t,n.length+1);return kr.call(n,e,"$&_")+"."+kr.call(kr.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return kr.call(t,e,"$&_")}var Ja=f1,wd=Ja.custom,Ed=Cd(wd)?wd:null,Td={__proto__:null,double:'"',single:"'"},E1={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Os=function r(t,e,i,n){var s=e||{};if(vr(s,"quoteStyle")&&!vr(Td,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(vr(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=vr(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(vr(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(vr(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.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 Pd(t,s);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?xd(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?xd(t,h):h}var c=typeof s.depth>"u"?5:s.depth;if(typeof i>"u"&&(i=0),i>=c&&c>0&&typeof t=="object")return tl(t)?"[Array]":"[Object]";var u=$1(s,i);if(typeof n>"u")n=[];else if(Id(n,t)>=0)return"[Circular]";function d(T,E,A){if(E&&(n=w1.call(n),n.push(E)),A){var L={depth:s.depth};return vr(s,"quoteStyle")&&(L.quoteStyle=s.quoteStyle),r(T,L,i+1,n)}return r(T,s,i+1,n)}if(typeof t=="function"&&!Sd(t)){var f=D1(t),p=Ls(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+or.call(p,", ")+" }":"")}if(Cd(t)){var g=zi?kr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Qa.call(t);return typeof t=="object"&&!zi?kn(g):g}if(k1(t)){for(var y="<"+md.call(String(t.nodeName)),_=t.attributes||[],v=0;v<_.length;v++)y+=" "+_[v].name+"="+Ad(T1(_[v].value),"double",s);return y+=">",t.childNodes&&t.childNodes.length&&(y+="..."),y+="</"+md.call(String(t.nodeName))+">",y}if(tl(t)){if(t.length===0)return"[]";var m=Ls(t,d);return u&&!G1(m)?"["+rl(m,u)+"]":"[ "+or.call(m,", ")+" ]"}if(S1(t)){var b=Ls(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!vd.call(t,"cause")?"{ ["+String(t)+"] "+or.call(yd.call("[cause]: "+d(t.cause),b),", ")+" }":b.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+or.call(b,", ")+" }"}if(typeof t=="object"&&o){if(Ed&&typeof t[Ed]=="function"&&Ja)return Ja(t,{depth:c-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(B1(t)){var S=[];return dd&&dd.call(t,function(T,E){S.push(d(E,t,!0)+" => "+d(T,t))}),Rd("Map",Ds.call(t),S,u)}if(N1(t)){var R=[];return fd&&fd.call(t,function(T){R.push(d(T,t))}),Rd("Set",Bs.call(t),R,u)}if(O1(t))return el("WeakMap");if(F1(t))return el("WeakSet");if(L1(t))return el("WeakRef");if(I1(t))return kn(d(Number(t)));if(R1(t))return kn(d(Ka.call(t)));if(P1(t))return kn(y1.call(t));if(C1(t))return kn(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof In<"u"&&t===In)return"{ [object globalThis] }";if(!A1(t)&&!Sd(t)){var C=Ls(t,d),I=bd?bd(t)===Object.prototype:t instanceof Object||t.constructor===Object,M=t instanceof Object?"":"null prototype",F=!I&&Fn&&Object(t)===t&&Fn in t?qa.call(Ur(t),8,-1):M?"Object":"",U=I||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",P=U+(F||M?"["+or.call(yd.call([],F||[],M||[]),": ")+"] ":"");return C.length===0?P+"{}":u?P+"{"+rl(C,u)+"}":P+"{ "+or.call(C,", ")+" }"}return String(t)};function Ad(r,t,e){var i=e.quoteStyle||t,n=Td[i];return n+r+n}function T1(r){return kr.call(String(r),/"/g,"&quot;")}function ai(r){return!Fn||!(typeof r=="object"&&(Fn in r||typeof r[Fn]<"u"))}function tl(r){return Ur(r)==="[object Array]"&&ai(r)}function A1(r){return Ur(r)==="[object Date]"&&ai(r)}function Sd(r){return Ur(r)==="[object RegExp]"&&ai(r)}function S1(r){return Ur(r)==="[object Error]"&&ai(r)}function C1(r){return Ur(r)==="[object String]"&&ai(r)}function I1(r){return Ur(r)==="[object Number]"&&ai(r)}function P1(r){return Ur(r)==="[object Boolean]"&&ai(r)}function Cd(r){if(zi)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Qa)return!1;try{return Qa.call(r),!0}catch{}return!1}function R1(r){if(!r||typeof r!="object"||!Ka)return!1;try{return Ka.call(r),!0}catch{}return!1}var M1=Object.prototype.hasOwnProperty||function(r){return r in this};function vr(r,t){return M1.call(r,t)}function Ur(r){return _1.call(r)}function D1(r){if(r.name)return r.name;var t=b1.call(v1.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Id(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 B1(r){if(!Ds||!r||typeof r!="object")return!1;try{Ds.call(r);try{Bs.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function O1(r){if(!Ln||!r||typeof r!="object")return!1;try{Ln.call(r,Ln);try{Nn.call(r,Nn)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function L1(r){if(!pd||!r||typeof r!="object")return!1;try{return pd.call(r),!0}catch{}return!1}function N1(r){if(!Bs||!r||typeof r!="object")return!1;try{Bs.call(r);try{Ds.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function F1(r){if(!Nn||!r||typeof r!="object")return!1;try{Nn.call(r,Nn);try{Ln.call(r,Ln)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function k1(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Pd(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return Pd(qa.call(r,0,t.maxStringLength),t)+i}var n=E1[t.quoteStyle||"single"];n.lastIndex=0;var s=kr.call(kr.call(r,n,"\\$1"),/[\x00-\x1f]/g,U1);return Ad(s,"single",t)}function U1(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":"")+x1.call(t.toString(16))}function kn(r){return"Object("+r+")"}function el(r){return r+" { ? }"}function Rd(r,t,e,i){var n=i?rl(e,i):or.call(e,", ");return r+" ("+t+") {"+n+"}"}function G1(r){for(var t=0;t<r.length;t++)if(Id(r[t],`
2
+ `)>=0)return!1;return!0}function $1(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=or.call(Array(r.indent+1)," ");else return null;return{base:e,prev:or.call(Array(t+1),e)}}function rl(r,t){if(r.length===0)return"";var e=`
3
+ `+t.prev+t.base;return e+or.call(r,","+e)+`
4
+ `+t.prev}function Ls(r,t){var e=tl(r),i=[];if(e){i.length=r.length;for(var n=0;n<r.length;n++)i[n]=vr(r,n)?t(r[n],r):""}var s=typeof Za=="function"?Za(r):[],o;if(zi){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var l in r)vr(r,l)&&(e&&String(Number(l))===l&&l<r.length||zi&&o["$"+l]instanceof Symbol||(gd.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof Za=="function")for(var h=0;h<s.length;h++)vd.call(r,s[h])&&i.push("["+t(s[h])+"]: "+t(r[s[h]],r));return i}var H1=Os,X1=Vi,Ns=function(r,t,e){for(var i=r,n;(n=i.next)!=null;i=n)if(n.key===t)return i.next=n.next,e||(n.next=r.next,r.next=n),n},V1=function(r,t){if(r){var e=Ns(r,t);return e&&e.value}},z1=function(r,t,e){var i=Ns(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},j1=function(r,t){return r?!!Ns(r,t):!1},W1=function(r,t){if(r)return Ns(r,t,!0)},Y1=function(){var t,e={assert:function(i){if(!e.has(i))throw new X1("Side channel does not contain "+H1(i))},delete:function(i){var n=t&&t.next,s=W1(t,i);return s&&n&&n===s&&(t=void 0),!!s},get:function(i){return V1(t,i)},has:function(i){return j1(t,i)},set:function(i,n){t||(t={next:void 0}),z1(t,i,n)}};return e},Md=Object,q1=Error,K1=EvalError,Z1=RangeError,Q1=ReferenceError,J1=SyntaxError,tb=URIError,eb=Math.abs,rb=Math.floor,ib=Math.max,nb=Math.min,sb=Math.pow,ob=Math.round,ab=Number.isNaN||function(t){return t!==t},lb=ab,hb=function(t){return lb(t)||t===0?t:t<0?-1:1},cb=Object.getOwnPropertyDescriptor,Fs=cb;if(Fs)try{Fs([],"length")}catch{Fs=null}var Dd=Fs,ks=Object.defineProperty||!1;if(ks)try{ks({},"a",{value:1})}catch{ks=!1}var ub=ks,il,Bd;function db(){return Bd||(Bd=1,il=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 n=42;t[e]=n;for(var s 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!==n||a.enumerable!==!0)return!1}return!0}),il}var nl,Od;function fb(){if(Od)return nl;Od=1;var r=typeof Symbol<"u"&&Symbol,t=db();return nl=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},nl}var sl,Ld;function Nd(){return Ld||(Ld=1,sl=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),sl}var ol,Fd;function kd(){if(Fd)return ol;Fd=1;var r=Md;return ol=r.getPrototypeOf||null,ol}var pb="Function.prototype.bind called on incompatible ",mb=Object.prototype.toString,gb=Math.max,yb="[object Function]",Ud=function(t,e){for(var i=[],n=0;n<t.length;n+=1)i[n]=t[n];for(var s=0;s<e.length;s+=1)i[s+t.length]=e[s];return i},_b=function(t,e){for(var i=[],n=e,s=0;n<t.length;n+=1,s+=1)i[s]=t[n];return i},vb=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},bb=function(t){var e=this;if(typeof e!="function"||mb.apply(e)!==yb)throw new TypeError(pb+e);for(var i=_b(arguments,1),n,s=function(){if(this instanceof n){var c=e.apply(this,Ud(i,arguments));return Object(c)===c?c:this}return e.apply(t,Ud(i,arguments))},o=gb(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(n=Function("binder","return function ("+vb(a,",")+"){ return binder.apply(this,arguments); }")(s),e.prototype){var h=function(){};h.prototype=e.prototype,n.prototype=new h,h.prototype=null}return n},xb=bb,Us=Function.prototype.bind||xb,al=Function.prototype.call,ll,Gd;function $d(){return Gd||(Gd=1,ll=Function.prototype.apply),ll}var wb=typeof Reflect<"u"&&Reflect&&Reflect.apply,Eb=Us,Tb=$d(),Ab=al,Sb=wb,Cb=Sb||Eb.call(Ab,Tb),Ib=Us,Pb=Vi,Rb=al,Mb=Cb,Hd=function(t){if(t.length<1||typeof t[0]!="function")throw new Pb("a function is required");return Mb(Ib,Rb,t)},hl,Xd;function Db(){if(Xd)return hl;Xd=1;var r=Hd,t=Dd,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__"),n=Object,s=n.getPrototypeOf;return hl=i&&typeof i.get=="function"?r([i.get]):typeof s=="function"?function(a){return s(a==null?a:n(a))}:!1,hl}var cl,Vd;function Bb(){if(Vd)return cl;Vd=1;var r=Nd(),t=kd(),e=Db();return cl=r?function(n){return r(n)}:t?function(n){if(!n||typeof n!="object"&&typeof n!="function")throw new TypeError("getProto: not an object");return t(n)}:e?function(n){return e(n)}:null,cl}var ul,zd;function Ob(){if(zd)return ul;zd=1;var r=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=Us;return ul=e.call(r,t),ul}var Tt,Lb=Md,Nb=q1,Fb=K1,kb=Z1,Ub=Q1,ji=J1,Wi=Vi,Gb=tb,$b=eb,Hb=rb,Xb=ib,Vb=nb,zb=sb,jb=ob,Wb=hb,jd=Function,dl=function(r){try{return jd('"use strict"; return ('+r+").constructor;")()}catch{}},Un=Dd,Yb=ub,fl=function(){throw new Wi},qb=Un?function(){try{return arguments.callee,fl}catch{try{return Un(arguments,"callee").get}catch{return fl}}}():fl,Yi=fb()(),ce=Bb(),Kb=kd(),Zb=Nd(),Wd=$d(),Gn=al,qi={},Qb=typeof Uint8Array>"u"||!ce?Tt:ce(Uint8Array),li={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?Tt:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Tt:ArrayBuffer,"%ArrayIteratorPrototype%":Yi&&ce?ce([][Symbol.iterator]()):Tt,"%AsyncFromSyncIteratorPrototype%":Tt,"%AsyncFunction%":qi,"%AsyncGenerator%":qi,"%AsyncGeneratorFunction%":qi,"%AsyncIteratorPrototype%":qi,"%Atomics%":typeof Atomics>"u"?Tt:Atomics,"%BigInt%":typeof BigInt>"u"?Tt:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Tt:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Tt:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Tt:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Nb,"%eval%":eval,"%EvalError%":Fb,"%Float16Array%":typeof Float16Array>"u"?Tt:Float16Array,"%Float32Array%":typeof Float32Array>"u"?Tt:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Tt:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Tt:FinalizationRegistry,"%Function%":jd,"%GeneratorFunction%":qi,"%Int8Array%":typeof Int8Array>"u"?Tt:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Tt:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Tt:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Yi&&ce?ce(ce([][Symbol.iterator]())):Tt,"%JSON%":typeof JSON=="object"?JSON:Tt,"%Map%":typeof Map>"u"?Tt:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Yi||!ce?Tt:ce(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Lb,"%Object.getOwnPropertyDescriptor%":Un,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Tt:Promise,"%Proxy%":typeof Proxy>"u"?Tt:Proxy,"%RangeError%":kb,"%ReferenceError%":Ub,"%Reflect%":typeof Reflect>"u"?Tt:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Tt:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Yi||!ce?Tt:ce(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Tt:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Yi&&ce?ce(""[Symbol.iterator]()):Tt,"%Symbol%":Yi?Symbol:Tt,"%SyntaxError%":ji,"%ThrowTypeError%":qb,"%TypedArray%":Qb,"%TypeError%":Wi,"%Uint8Array%":typeof Uint8Array>"u"?Tt:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Tt:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Tt:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Tt:Uint32Array,"%URIError%":Gb,"%WeakMap%":typeof WeakMap>"u"?Tt:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Tt:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Tt:WeakSet,"%Function.prototype.call%":Gn,"%Function.prototype.apply%":Wd,"%Object.defineProperty%":Yb,"%Object.getPrototypeOf%":Kb,"%Math.abs%":$b,"%Math.floor%":Hb,"%Math.max%":Xb,"%Math.min%":Vb,"%Math.pow%":zb,"%Math.round%":jb,"%Math.sign%":Wb,"%Reflect.getPrototypeOf%":Zb};if(ce)try{null.error}catch(r){var Jb=ce(ce(r));li["%Error.prototype%"]=Jb}var tx=function r(t){var e;if(t==="%AsyncFunction%")e=dl("async function () {}");else if(t==="%GeneratorFunction%")e=dl("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=dl("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var n=r("%AsyncGenerator%");n&&ce&&(e=ce(n.prototype))}return li[t]=e,e},Yd={__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"]},$n=Us,Gs=Ob(),ex=$n.call(Gn,Array.prototype.concat),rx=$n.call(Wd,Array.prototype.splice),qd=$n.call(Gn,String.prototype.replace),$s=$n.call(Gn,String.prototype.slice),ix=$n.call(Gn,RegExp.prototype.exec),nx=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,sx=/\\(\\)?/g,ox=function(t){var e=$s(t,0,1),i=$s(t,-1);if(e==="%"&&i!=="%")throw new ji("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new ji("invalid intrinsic syntax, expected opening `%`");var n=[];return qd(t,nx,function(s,o,a,l){n[n.length]=a?qd(l,sx,"$1"):o||s}),n},ax=function(t,e){var i=t,n;if(Gs(Yd,i)&&(n=Yd[i],i="%"+n[0]+"%"),Gs(li,i)){var s=li[i];if(s===qi&&(s=tx(i)),typeof s>"u"&&!e)throw new Wi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:n,name:i,value:s}}throw new ji("intrinsic "+t+" does not exist!")},pl=function(t,e){if(typeof t!="string"||t.length===0)throw new Wi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new Wi('"allowMissing" argument must be a boolean');if(ix(/^%?[^%]*%?$/,t)===null)throw new ji("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=ox(t),n=i.length>0?i[0]:"",s=ax("%"+n+"%",e),o=s.name,a=s.value,l=!1,h=s.alias;h&&(n=h[0],rx(i,ex([0,1],h)));for(var c=1,u=!0;c<i.length;c+=1){var d=i[c],f=$s(d,0,1),p=$s(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new ji("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(l=!0),n+="."+d,o="%"+n+"%",Gs(li,o))a=li[o];else if(a!=null){if(!(d in a)){if(!e)throw new Wi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Un&&c+1>=i.length){var g=Un(a,d);u=!!g,u&&"get"in g&&!("originalValue"in g.get)?a=g.get:a=a[d]}else u=Gs(a,d),a=a[d];u&&!l&&(li[o]=a)}}return a},Kd=pl,Zd=Hd,lx=Zd([Kd("%String.prototype.indexOf%")]),Qd=function(t,e){var i=Kd(t,!!e);return typeof i=="function"&&lx(t,".prototype.")>-1?Zd([i]):i},hx=pl,Hn=Qd,cx=Os,ux=Vi,Jd=hx("%Map%",!0),dx=Hn("Map.prototype.get",!0),fx=Hn("Map.prototype.set",!0),px=Hn("Map.prototype.has",!0),mx=Hn("Map.prototype.delete",!0),gx=Hn("Map.prototype.size",!0),tf=!!Jd&&function(){var t,e={assert:function(i){if(!e.has(i))throw new ux("Side channel does not contain "+cx(i))},delete:function(i){if(t){var n=mx(t,i);return gx(t)===0&&(t=void 0),n}return!1},get:function(i){if(t)return dx(t,i)},has:function(i){return t?px(t,i):!1},set:function(i,n){t||(t=new Jd),fx(t,i,n)}};return e},yx=pl,Hs=Qd,_x=Os,Xs=tf,vx=Vi,Ki=yx("%WeakMap%",!0),bx=Hs("WeakMap.prototype.get",!0),xx=Hs("WeakMap.prototype.set",!0),wx=Hs("WeakMap.prototype.has",!0),Ex=Hs("WeakMap.prototype.delete",!0),Tx=Ki?function(){var t,e,i={assert:function(n){if(!i.has(n))throw new vx("Side channel does not contain "+_x(n))},delete:function(n){if(Ki&&n&&(typeof n=="object"||typeof n=="function")){if(t)return Ex(t,n)}else if(Xs&&e)return e.delete(n);return!1},get:function(n){return Ki&&n&&(typeof n=="object"||typeof n=="function")&&t?bx(t,n):e&&e.get(n)},has:function(n){return Ki&&n&&(typeof n=="object"||typeof n=="function")&&t?wx(t,n):!!e&&e.has(n)},set:function(n,s){Ki&&n&&(typeof n=="object"||typeof n=="function")?(t||(t=new Ki),xx(t,n,s)):Xs&&(e||(e=Xs()),e.set(n,s))}};return i}:Xs,Ax=Vi,Sx=Os,Cx=Y1,Ix=tf,Px=Tx,Rx=Px||Ix||Cx,Mx=function(){var t,e={assert:function(i){if(!e.has(i))throw new Ax("Side channel does not contain "+Sx(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,n){t||(t=Rx()),t.set(i,n)}};return e},Dx=String.prototype.replace,Bx=/%20/g,ml={RFC1738:"RFC1738",RFC3986:"RFC3986"},gl={default:ml.RFC3986,formatters:{RFC1738:function(r){return Dx.call(r,Bx,"+")},RFC3986:function(r){return String(r)}},RFC1738:ml.RFC1738,RFC3986:ml.RFC3986},Ox=gl,yl=Object.prototype.hasOwnProperty,hi=Array.isArray,ar=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),Lx=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(hi(i)){for(var n=[],s=0;s<i.length;++s)typeof i[s]<"u"&&n.push(i[s]);e.obj[e.prop]=n}}},ef=function(t,e){for(var i=e&&e.plainObjects?{__proto__:null}:{},n=0;n<t.length;++n)typeof t[n]<"u"&&(i[n]=t[n]);return i},Nx=function r(t,e,i){if(!e)return t;if(typeof e!="object"&&typeof e!="function"){if(hi(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!yl.call(Object.prototype,e))&&(t[e]=!0);else return[t,e];return t}if(!t||typeof t!="object")return[t].concat(e);var n=t;return hi(t)&&!hi(e)&&(n=ef(t,i)),hi(t)&&hi(e)?(e.forEach(function(s,o){if(yl.call(t,o)){var a=t[o];a&&typeof a=="object"&&s&&typeof s=="object"?t[o]=r(a,s,i):t.push(s)}else t[o]=s}),t):Object.keys(e).reduce(function(s,o){var a=e[o];return yl.call(s,o)?s[o]=r(s[o],a,i):s[o]=a,s},n)},Fx=function(t,e){return Object.keys(e).reduce(function(i,n){return i[n]=e[n],i},t)},kx=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}},_l=1024,Ux=function(t,e,i,n,s){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(f){return"%26%23"+parseInt(f.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;l+=_l){for(var h=o.length>=_l?o.slice(l,l+_l):o,c=[],u=0;u<h.length;++u){var d=h.charCodeAt(u);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||s===Ox.RFC1738&&(d===40||d===41)){c[c.length]=h.charAt(u);continue}if(d<128){c[c.length]=ar[d];continue}if(d<2048){c[c.length]=ar[192|d>>6]+ar[128|d&63];continue}if(d<55296||d>=57344){c[c.length]=ar[224|d>>12]+ar[128|d>>6&63]+ar[128|d&63];continue}u+=1,d=65536+((d&1023)<<10|h.charCodeAt(u)&1023),c[c.length]=ar[240|d>>18]+ar[128|d>>12&63]+ar[128|d>>6&63]+ar[128|d&63]}a+=c.join("")}return a},Gx=function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],n=0;n<e.length;++n)for(var s=e[n],o=s.obj[s.prop],a=Object.keys(o),l=0;l<a.length;++l){var h=a[l],c=o[h];typeof c=="object"&&c!==null&&i.indexOf(c)===-1&&(e.push({obj:o,prop:h}),i.push(c))}return Lx(e),t},$x=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},Hx=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},Xx=function(t,e){return[].concat(t,e)},Vx=function(t,e){if(hi(t)){for(var i=[],n=0;n<t.length;n+=1)i.push(e(t[n]));return i}return e(t)},rf={arrayToObject:ef,assign:Fx,combine:Xx,compact:Gx,decode:kx,encode:Ux,isBuffer:Hx,isRegExp:$x,maybeMap:Vx,merge:Nx},nf=Mx,Vs=rf,Xn=gl,zx=Object.prototype.hasOwnProperty,sf={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},lr=Array.isArray,jx=Array.prototype.push,of=function(r,t){jx.apply(r,lr(t)?t:[t])},Wx=Date.prototype.toISOString,af=Xn.default,ne={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Vs.encode,encodeValuesOnly:!1,filter:void 0,format:af,formatter:Xn.formatters[af],indices:!1,serializeDate:function(t){return Wx.call(t)},skipNulls:!1,strictNullHandling:!1},Yx=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},vl={},qx=function r(t,e,i,n,s,o,a,l,h,c,u,d,f,p,g,y,_,v){for(var m=t,b=v,S=0,R=!1;(b=b.get(vl))!==void 0&&!R;){var C=b.get(t);if(S+=1,typeof C<"u"){if(C===S)throw new RangeError("Cyclic object value");R=!0}typeof b.get(vl)>"u"&&(S=0)}if(typeof c=="function"?m=c(e,m):m instanceof Date?m=f(m):i==="comma"&&lr(m)&&(m=Vs.maybeMap(m,function(O){return O instanceof Date?f(O):O})),m===null){if(o)return h&&!y?h(e,ne.encoder,_,"key",p):e;m=""}if(Yx(m)||Vs.isBuffer(m)){if(h){var I=y?e:h(e,ne.encoder,_,"key",p);return[g(I)+"="+g(h(m,ne.encoder,_,"value",p))]}return[g(e)+"="+g(String(m))]}var M=[];if(typeof m>"u")return M;var F;if(i==="comma"&&lr(m))y&&h&&(m=Vs.maybeMap(m,h)),F=[{value:m.length>0?m.join(",")||null:void 0}];else if(lr(c))F=c;else{var U=Object.keys(m);F=u?U.sort(u):U}var P=l?String(e).replace(/\./g,"%2E"):String(e),T=n&&lr(m)&&m.length===1?P+"[]":P;if(s&&lr(m)&&m.length===0)return T+"[]";for(var E=0;E<F.length;++E){var A=F[E],L=typeof A=="object"&&A&&typeof A.value<"u"?A.value:m[A];if(!(a&&L===null)){var D=d&&l?String(A).replace(/\./g,"%2E"):String(A),N=lr(m)?typeof i=="function"?i(T,D):T:T+(d?"."+D:"["+D+"]");v.set(t,S);var $=nf();$.set(vl,v),of(M,r(L,N,i,n,s,o,a,l,i==="comma"&&y&&lr(m)?null:h,c,u,d,f,p,g,y,_,$))}}return M},Kx=function(t){if(!t)return ne;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||ne.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=Xn.default;if(typeof t.format<"u"){if(!zx.call(Xn.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var n=Xn.formatters[i],s=ne.filter;(typeof t.filter=="function"||lr(t.filter))&&(s=t.filter);var o;if(t.arrayFormat in sf?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=ne.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:ne.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:ne.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:ne.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:ne.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?ne.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:ne.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:ne.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:ne.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:ne.encodeValuesOnly,filter:s,format:i,formatter:n,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:ne.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:ne.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:ne.strictNullHandling}},Zx=function(r,t){var e=r,i=Kx(t),n,s;typeof i.filter=="function"?(s=i.filter,e=s("",e)):lr(i.filter)&&(s=i.filter,n=s);var o=[];if(typeof e!="object"||e===null)return"";var a=sf[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;n||(n=Object.keys(e)),i.sort&&n.sort(i.sort);for(var h=nf(),c=0;c<n.length;++c){var u=n[c],d=e[u];i.skipNulls&&d===null||of(o,qx(d,u,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 f=o.join(i.delimiter),p=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?p+="utf8=%26%2310003%3B&":p+="utf8=%E2%9C%93&"),f.length>0?p+f:""},ci=rf,bl=Object.prototype.hasOwnProperty,lf=Array.isArray,Wt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:ci.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},Qx=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},hf=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},Jx="utf8=%26%2310003%3B",tw="utf8=%E2%9C%93",ew=function(t,e){var i={__proto__:null},n=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;n=n.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var s=e.parameterLimit===1/0?void 0:e.parameterLimit,o=n.split(e.delimiter,e.throwOnLimitExceeded?s+1:s);if(e.throwOnLimitExceeded&&o.length>s)throw new RangeError("Parameter limit exceeded. Only "+s+" parameter"+(s===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]===tw?h="utf-8":o[l]===Jx&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var c=o[l],u=c.indexOf("]="),d=u===-1?c.indexOf("="):u+1,f,p;d===-1?(f=e.decoder(c,Wt.decoder,h,"key"),p=e.strictNullHandling?null:""):(f=e.decoder(c.slice(0,d),Wt.decoder,h,"key"),p=ci.maybeMap(hf(c.slice(d+1),e,lf(i[f])?i[f].length:0),function(y){return e.decoder(y,Wt.decoder,h,"value")})),p&&e.interpretNumericEntities&&h==="iso-8859-1"&&(p=Qx(String(p))),c.indexOf("[]=")>-1&&(p=lf(p)?[p]:p);var g=bl.call(i,f);g&&e.duplicates==="combine"?i[f]=ci.combine(i[f],p):(!g||e.duplicates==="last")&&(i[f]=p)}return i},rw=function(r,t,e,i){var n=0;if(r.length>0&&r[r.length-1]==="[]"){var s=r.slice(0,-1).join("");n=Array.isArray(t)&&t[s]?t[s].length:0}for(var o=i?t:hf(t,e,n),a=r.length-1;a>=0;--a){var l,h=r[a];if(h==="[]"&&e.parseArrays)l=e.allowEmptyArrays&&(o===""||e.strictNullHandling&&o===null)?[]:ci.combine([],o);else{l=e.plainObjects?{__proto__:null}:{};var c=h.charAt(0)==="["&&h.charAt(h.length-1)==="]"?h.slice(1,-1):h,u=e.decodeDotInKeys?c.replace(/%2E/g,"."):c,d=parseInt(u,10);!e.parseArrays&&u===""?l={0:o}:!isNaN(d)&&h!==u&&String(d)===u&&d>=0&&e.parseArrays&&d<=e.arrayLimit?(l=[],l[d]=o):u!=="__proto__"&&(l[u]=o)}o=l}return o},iw=function(t,e,i,n){if(t){var s=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=i.depth>0&&o.exec(s),h=l?s.slice(0,l.index):s,c=[];if(h){if(!i.plainObjects&&bl.call(Object.prototype,h)&&!i.allowPrototypes)return;c.push(h)}for(var u=0;i.depth>0&&(l=a.exec(s))!==null&&u<i.depth;){if(u+=1,!i.plainObjects&&bl.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;c.push(l[1])}if(l){if(i.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+i.depth+" and strictDepth is true");c.push("["+s.slice(l.index)+"]")}return rw(c,e,i,n)}},nw=function(t){if(!t)return Wt;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"?Wt.charset:t.charset,i=typeof t.duplicates>"u"?Wt.duplicates:t.duplicates;if(i!=="combine"&&i!=="first"&&i!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var n=typeof t.allowDots>"u"?t.decodeDotInKeys===!0?!0:Wt.allowDots:!!t.allowDots;return{allowDots:n,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Wt.allowEmptyArrays,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Wt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Wt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Wt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Wt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Wt.comma,decodeDotInKeys:typeof t.decodeDotInKeys=="boolean"?t.decodeDotInKeys:Wt.decodeDotInKeys,decoder:typeof t.decoder=="function"?t.decoder:Wt.decoder,delimiter:typeof t.delimiter=="string"||ci.isRegExp(t.delimiter)?t.delimiter:Wt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Wt.depth,duplicates:i,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Wt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Wt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Wt.plainObjects,strictDepth:typeof t.strictDepth=="boolean"?!!t.strictDepth:Wt.strictDepth,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Wt.strictNullHandling,throwOnLimitExceeded:typeof t.throwOnLimitExceeded=="boolean"?t.throwOnLimitExceeded:!1}},sw=function(r,t){var e=nw(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?{__proto__:null}:{};for(var i=typeof r=="string"?ew(r,e):r,n=e.plainObjects?{__proto__:null}:{},s=Object.keys(i),o=0;o<s.length;++o){var a=s[o],l=iw(a,i[a],e,typeof r=="string");n=ci.merge(n,l,e)}return e.allowSparse===!0?n:ci.compact(n)},ow=Zx,aw=sw,lw=gl,hw={formats:lw,parse:aw,stringify:ow},cw=d1;function br(){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 uw=/^([a-z0-9.+-]+:)/i,dw=/:[0-9]*$/,fw=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,pw=["<",">",'"',"`"," ","\r",`
5
+ `," "],mw=["{","}","|","\\","^","`"].concat(pw),xl=["'"].concat(mw),cf=["%","/","?",";","#"].concat(xl),uf=["/","?","#"],gw=255,df=/^[+a-z0-9A-Z_-]{0,63}$/,yw=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,_w={javascript:!0,"javascript:":!0},wl={javascript:!0,"javascript:":!0},Zi={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},El=hw;function vw(r,t,e){if(r&&typeof r=="object"&&r instanceof br)return r;var i=new br;return i.parse(r,t,e),i}br.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("?"),n=i!==-1&&i<r.indexOf("#")?"?":"#",s=r.split(n),o=/\\/g;s[0]=s[0].replace(o,"/"),r=s.join(n);var a=r;if(a=a.trim(),!e&&r.split("#").length===1){var l=fw.exec(a);if(l)return this.path=a,this.href=a,this.pathname=l[1],l[2]?(this.search=l[2],t?this.query=El.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=uw.exec(a);if(h){h=h[0];var c=h.toLowerCase();this.protocol=c,a=a.substr(h.length)}if(e||h||a.match(/^\/\/[^@/]+@[^@/]+/)){var u=a.substr(0,2)==="//";u&&!(h&&wl[h])&&(a=a.substr(2),this.slashes=!0)}if(!wl[h]&&(u||h&&!Zi[h])){for(var d=-1,f=0;f<uf.length;f++){var p=a.indexOf(uf[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var g,y;d===-1?y=a.lastIndexOf("@"):y=a.lastIndexOf("@",d),y!==-1&&(g=a.slice(0,y),a=a.slice(y+1),this.auth=decodeURIComponent(g)),d=-1;for(var f=0;f<cf.length;f++){var p=a.indexOf(cf[f]);p!==-1&&(d===-1||p<d)&&(d=p)}d===-1&&(d=a.length),this.host=a.slice(0,d),a=a.slice(d),this.parseHost(),this.hostname=this.hostname||"";var _=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!_)for(var v=this.hostname.split(/\./),f=0,m=v.length;f<m;f++){var b=v[f];if(b&&!b.match(df)){for(var S="",R=0,C=b.length;R<C;R++)b.charCodeAt(R)>127?S+="x":S+=b[R];if(!S.match(df)){var I=v.slice(0,f),M=v.slice(f+1),F=b.match(yw);F&&(I.push(F[1]),M.unshift(F[2])),M.length&&(a="/"+M.join(".")+a),this.hostname=I.join(".");break}}}this.hostname.length>gw?this.hostname="":this.hostname=this.hostname.toLowerCase(),_||(this.hostname=cw.toASCII(this.hostname));var U=this.port?":"+this.port:"",P=this.hostname||"";this.host=P+U,this.href+=this.host,_&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!_w[c])for(var f=0,m=xl.length;f<m;f++){var T=xl[f];if(a.indexOf(T)!==-1){var E=encodeURIComponent(T);E===T&&(E=escape(T)),a=a.split(T).join(E)}}var A=a.indexOf("#");A!==-1&&(this.hash=a.substr(A),a=a.slice(0,A));var L=a.indexOf("?");if(L!==-1?(this.search=a.substr(L),this.query=a.substr(L+1),t&&(this.query=El.parse(this.query)),a=a.slice(0,L)):t&&(this.search="",this.query={}),a&&(this.pathname=a),Zi[c]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var U=this.pathname||"",D=this.search||"";this.path=U+D}return this.href=this.format(),this},br.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||"",n=!1,s="";this.host?n=r+this.host:this.hostname&&(n=r+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(n+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(s=El.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||s&&"?"+s||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||Zi[t])&&n!==!1?(n="//"+(n||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):n||(n=""),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+n+e+o+i},br.prototype.resolve=function(r){return this.resolveObject(vw(r,!1,!0)).format()},br.prototype.resolveObject=function(r){if(typeof r=="string"){var t=new br;t.parse(r,!1,!0),r=t}for(var e=new br,i=Object.keys(this),n=0;n<i.length;n++){var s=i[n];e[s]=this[s]}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 Zi[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(!Zi[r.protocol]){for(var h=Object.keys(r),c=0;c<h.length;c++){var u=h[c];e[u]=r[u]}return e.href=e.format(),e}if(e.protocol=r.protocol,!r.host&&!wl[r.protocol]){for(var m=(r.pathname||"").split("/");m.length&&!(r.host=m.shift()););r.host||(r.host=""),r.hostname||(r.hostname=""),m[0]!==""&&m.unshift(""),m.length<2&&m.unshift(""),e.pathname=m.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||"",f=e.search||"";e.path=d+f}return e.slashes=e.slashes||r.slashes,e.href=e.format(),e}var p=e.pathname&&e.pathname.charAt(0)==="/",g=r.host||r.pathname&&r.pathname.charAt(0)==="/",y=g||p||e.host&&r.pathname,_=y,v=e.pathname&&e.pathname.split("/")||[],m=r.pathname&&r.pathname.split("/")||[],b=e.protocol&&!Zi[e.protocol];if(b&&(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&&(m[0]===""?m[0]=r.host:m.unshift(r.host)),r.host=null),y=y&&(m[0]===""||v[0]==="")),g)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=m;else if(m.length)v||(v=[]),v.pop(),v=v.concat(m),e.search=r.search,e.query=r.query;else if(r.search!=null){if(b){e.host=v.shift(),e.hostname=e.host;var S=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;S&&(e.auth=S.shift(),e.hostname=S.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 R=v.slice(-1)[0],C=(e.host||r.host||v.length>1)&&(R==="."||R==="..")||R==="",I=0,M=v.length;M>=0;M--)R=v[M],R==="."?v.splice(M,1):R===".."?(v.splice(M,1),I++):I&&(v.splice(M,1),I--);if(!y&&!_)for(;I--;I)v.unshift("..");y&&v[0]!==""&&(!v[0]||v[0].charAt(0)!=="/")&&v.unshift(""),C&&v.join("/").substr(-1)!=="/"&&v.push("");var F=v[0]===""||v[0]&&v[0].charAt(0)==="/";if(b){e.hostname=F?"":v.length?v.shift():"",e.host=e.hostname;var S=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;S&&(e.auth=S.shift(),e.hostname=S.shift(),e.host=e.hostname)}return y=y||e.host&&v.length,y&&!F&&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},br.prototype.parseHost=function(){var r=this.host,t=dw.exec(r);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),r=r.substr(0,r.length-t.length)),r&&(this.hostname=r)};const ff={};function At(r,t,e=3){if(ff[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))),df[t]=!0}function Xe(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function Xn(r){return r.split("?")[0].split("#")[0]}function vw(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bw(r,t,e){return r.replace(new RegExp(vw(t),"g"),e)}function xw(r,t){let e="",i=0,n=-1,s=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(!(n===a-1||s===1))if(n!==a-1&&s===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("/")),n=a,s=0;continue}}else if(e.length===2||e.length===1){e="",i=0,n=a,s=0;continue}}}else e.length>0?e+=`/${r.slice(n+1,a)}`:e=r.slice(n+1,a),i=a-n-1;n=a,s=0}else o===46&&s!==-1?++s:s=-1}return e}const ue={toPosix(r){return bw(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){Xe(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(Xe(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=Xn(this.toPosix(t??tt.ADAPTER.getBaseUrl())),n=Xn(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?ue.join(n,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(Xe(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=xw(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Xe(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(Xe(i),i.length>0)if(t===void 0)t=i;else{const n=r[e-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(Xe(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,n=!0;const s=this.getProtocol(r),o=r;r=r.slice(s.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!n){i=a;break}}else n=!1;return i===-1?e?"/":this.isUrl(o)?s+r:s:e&&i===1?"//":s+r.slice(0,i)},rootname(r){Xe(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){Xe(r),t&&Xe(t),r=Xn(this.toPosix(r));let e=0,i=-1,n=!0,s;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(s=r.length-1;s>=0;--s){const l=r.charCodeAt(s);if(l===47){if(!n){e=s+1;break}}else a===-1&&(n=!1,a=s+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(i=s):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(s=r.length-1;s>=0;--s)if(r.charCodeAt(s)===47){if(!n){e=s+1;break}}else i===-1&&(n=!1,i=s+1);return i===-1?"":r.slice(e,i)},extname(r){Xe(r),r=Xn(this.toPosix(r));let t=-1,e=0,i=-1,n=!0,s=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!n){e=o+1;break}continue}i===-1&&(n=!1,i=o+1),a===46?t===-1?t=o:s!==1&&(s=1):t!==-1&&(s=-1)}return t===-1||i===-1||s===0||s===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){Xe(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=Xn(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let n;t.root=this.rootname(r),i||this.hasProtocol(r)?n=1:n=0;let s=-1,o=0,a=-1,l=!0,h=r.length-1,c=0;for(;h>=n;--h){if(e=r.charCodeAt(h),e===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),e===46?s===-1?s=h:c!==1&&(c=1):s!==-1&&(c=-1)}return s===-1||a===-1||c===0||c===1&&s===a-1&&s===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,s),t.base=r.slice(1,a)):(t.name=r.slice(o,s),t.base=r.slice(o,a)),t.ext=r.slice(s,a)),t.dir=this.dirname(r),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let El;async function ww(){return El??(El=(async()=>{var s;const r=document.createElement("canvas").getContext("webgl");if(!r)return Re.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 Re.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 n=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,n),r.deleteFramebuffer(i),r.deleteTexture(e),(s=r.getExtension("WEBGL_lose_context"))==null||s.loseContext(),n[0]<=n[3]?Re.PMA:Re.UNPACK})()),El}let Tl;function Ew(){return typeof Tl>"u"&&(Tl=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:tt.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!tt.ADAPTER.getWebGLRenderingContext())return!1;const e=tt.ADAPTER.createCanvas();let i=e.getContext("webgl",r)||e.getContext("experimental-webgl",r);const n=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const s=i.getExtension("WEBGL_lose_context");s&&s.loseContext()}return i=null,n}catch{return!1}}()),Tl}var Tw={grad:.9,turn:360,rad:360/(2*Math.PI)},br=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},de=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},Ue=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},ff=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},pf=function(r){return{r:Ue(r.r,0,255),g:Ue(r.g,0,255),b:Ue(r.b,0,255),a:Ue(r.a)}},Al=function(r){return{r:de(r.r),g:de(r.g),b:de(r.b),a:de(r.a,3)}},Aw=/^#([0-9a-f]{3,8})$/i,Vs=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},mf=function(r){var t=r.r,e=r.g,i=r.b,n=r.a,s=Math.max(t,e,i),o=s-Math.min(t,e,i),a=o?s===t?(e-i)/o:s===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:s?o/s*100:0,v:s/255*100,a:n}},gf=function(r){var t=r.h,e=r.s,i=r.v,n=r.a;t=t/360*6,e/=100,i/=100;var s=Math.floor(t),o=i*(1-e),a=i*(1-(t-s)*e),l=i*(1-(1-t+s)*e),h=s%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:n}},yf=function(r){return{h:ff(r.h),s:Ue(r.s,0,100),l:Ue(r.l,0,100),a:Ue(r.a)}},_f=function(r){return{h:de(r.h),s:de(r.s),l:de(r.l),a:de(r.a,3)}},vf=function(r){return gf((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},Vn=function(r){return{h:(t=mf(r)).h,s:(n=(200-(e=t.s))*(i=t.v)/100)>0&&n<200?e*i/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,i,n},Sw=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Cw=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Iw=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Pw=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Sl={string:[[function(r){var t=Aw.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?de(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?de(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=Iw.exec(r)||Pw.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:pf({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=Sw.exec(r)||Cw.exec(r);if(!t)return null;var e,i,n=yf({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Tw[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return vf(n)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,n=r.a,s=n===void 0?1:n;return br(t)&&br(e)&&br(i)?pf({r:Number(t),g:Number(e),b:Number(i),a:Number(s)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,n=r.a,s=n===void 0?1:n;if(!br(t)||!br(e)||!br(i))return null;var o=yf({h:Number(t),s:Number(e),l:Number(i),a:Number(s)});return vf(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,n=r.a,s=n===void 0?1:n;if(!br(t)||!br(e)||!br(i))return null;var o=function(a){return{h:ff(a.h),s:Ue(a.s,0,100),v:Ue(a.v,0,100),a:Ue(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(s)});return gf(o)},"hsv"]]},bf=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]},Rw=function(r){return typeof r=="string"?bf(r.trim(),Sl.string):typeof r=="object"&&r!==null?bf(r,Sl.object):[null,void 0]},Cl=function(r,t){var e=Vn(r);return{h:e.h,s:Ue(e.s+100*t,0,100),l:e.l,a:e.a}},Il=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},xf=function(r,t){var e=Vn(r);return{h:e.h,s:e.s,l:Ue(e.l+100*t,0,100),a:e.a}},Pl=function(){function r(t){this.parsed=Rw(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 de(Il(this.rgba),2)},r.prototype.isDark=function(){return Il(this.rgba)<.5},r.prototype.isLight=function(){return Il(this.rgba)>=.5},r.prototype.toHex=function(){return t=Al(this.rgba),e=t.r,i=t.g,n=t.b,o=(s=t.a)<1?Vs(de(255*s)):"","#"+Vs(e)+Vs(i)+Vs(n)+o;var t,e,i,n,s,o},r.prototype.toRgb=function(){return Al(this.rgba)},r.prototype.toRgbString=function(){return t=Al(this.rgba),e=t.r,i=t.g,n=t.b,(s=t.a)<1?"rgba("+e+", "+i+", "+n+", "+s+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,s},r.prototype.toHsl=function(){return _f(Vn(this.rgba))},r.prototype.toHslString=function(){return t=_f(Vn(this.rgba)),e=t.h,i=t.s,n=t.l,(s=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+s+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,s},r.prototype.toHsv=function(){return t=mf(this.rgba),{h:de(t.h),s:de(t.s),v:de(t.v),a:de(t.a,3)};var t},r.prototype.invert=function(){return lr({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),lr(Cl(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),lr(Cl(this.rgba,-t))},r.prototype.grayscale=function(){return lr(Cl(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),lr(xf(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),lr(xf(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"?lr({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):de(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=Vn(this.rgba);return typeof t=="number"?lr({h:t,s:e.s,l:e.l,a:e.a}):de(e.h)},r.prototype.isEqual=function(t){return this.toHex()===lr(t).toHex()},r}(),lr=function(r){return r instanceof Pl?r:new Pl(r)},wf=[],Mw=function(r){r.forEach(function(t){wf.indexOf(t)<0&&(t(Pl,Sl),wf.push(t))})};function Dw(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 n in e)i[e[n]]=n;var s={};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 c=this.toRgb(),u=1/0,d="black";if(!s.length)for(var f in e)s[f]=new r(e[f]).toRgb();for(var p in e){var g=(a=c,l=s[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));g<u&&(u=g,d=p)}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"])}Mw([Dw]);const Zi=class Lo{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 Lo)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((n,s)=>n===e[s]);if(t!==null&&e!==null){const n=Object.keys(t),s=Object.keys(e);return n.length!==s.length?!1:n.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,n]=this._components;return{r:t,g:e,b:i,a:n}}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,n]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(n*255),t}toRgbArray(t){t=t??[];const[e,i,n]=this._components;return t[0]=e,t[1]=i,t[2]=n,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,n,s]=Lo.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=n,this._components[3]*=s,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,n=this._int>>8&255,s=this._int&255;return e&&(i=i*t+.5|0,n=n*t+.5|0,s=s*t+.5|0),(t*255<<24)+(i<<16)+(n<<8)+s}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,n]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(n*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,n,s]=this._components;return t[0]=e,t[1]=i,t[2]=n,t[3]=s,t}normalize(t){let e,i,n,s;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,n=(o&255)/255,s=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,n,s=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,n,s=255]=t,e/=255,i/=255,n/=255,s/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Lo.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=lr(t);o.isValid()&&({r:e,g:i,b:n,a:s}=o.rgba,e/=255,i/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=n,this._components[3]=s,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((n,s)=>{t[s]=Math.min(Math.max(n,e),i)}),t)}};Zi.shared=new Zi,Zi.temp=new Zi,Zi.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Mt=Zi;function Bw(r){return At("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),Mt.shared.setValue(r).toHex()}function Ow(r){return At("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),Mt.shared.setValue(r).toNumber()}function Lw(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[vt.NORMAL_NPM]=vt.NORMAL,r[vt.ADD_NPM]=vt.ADD,r[vt.SCREEN_NPM]=vt.SCREEN,t[vt.NORMAL]=vt.NORMAL_NPM,t[vt.ADD]=vt.ADD_NPM,t[vt.SCREEN]=vt.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const Ef=Lw();function Tf(r,t){return Ef[t?1:0][r]}function Nw(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,n=0;i<e;i+=6,n+=4)t[i+0]=n+0,t[i+1]=n+1,t[i+2]=n+2,t[i+3]=n+0,t[i+4]=n+2,t[i+5]=n+3;return t}function Af(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}function zs(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 Sf(r){return!(r&r-1)&&!!r}function Cf(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 Ji(r,t,e){const i=r.length;let n;if(t>=i||e===0)return;e=t+e>i?i-t:e;const s=i-e;for(n=t;n<s;++n)r[n]=r[n+e];r.length=s}function kr(r){return r===0?0:r<0?-1:1}let Fw=0;function hi(){return++Fw}const Rl=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}};Rl.EMPTY=new Rl(0,0,0,0);let If=Rl;const Pf={},hr=Object.create(null),Ur=Object.create(null);class kw{constructor(t,e,i){this._canvas=tt.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||tt.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 Rf(r,t,e){for(let i=0,n=4*e*t;i<t;++i,n+=4)if(r[n+3]!==0)return!1;return!0}function Mf(r,t,e,i,n){const s=4*t;for(let o=i,a=i*s+4*e;o<=n;++o,a+=s)if(r[a+3]!==0)return!1;return!0}function Uw(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 n=i.getImageData(0,0,t,e).data;let s=0,o=0,a=t-1,l=e-1;for(;o<e&&Rf(n,t,o);)++o;if(o===e)return If.EMPTY;for(;Rf(n,t,l);)--l;for(;Mf(n,t,s,o,l);)++s;for(;Mf(n,t,a,o,l);)--a;return++a,++l,new If(s,o,a,l)}function Gw(r){const t=Uw(r),{width:e,height:i}=t;let n=null;if(!t.isEmpty()){const s=r.getContext("2d");if(s===null)throw new TypeError("Failed to get canvas 2D context");n=s.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:n}}function $w(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 xr(r,t=1){var i;const e=(i=tt.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}var Z=(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))(Z||{});const Ml=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},Df=(r,t)=>Ml(r).priority??t,ht={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Ml).forEach(t=>{t.type.forEach(e=>{var i,n;return(n=(i=this._removeHandlers)[e])==null?void 0:n.call(i,t)})}),this},add(...r){return r.map(Ml).forEach(t=>{t.type.forEach(e=>{var s,o;const i=this._addHandlers,n=this._queue;i[e]?(s=i[e])==null||s.call(i,t):(n[e]=n[e]||[],(o=n[e])==null||o.push(t))})}),this},handle(r,t,e){var o;const i=this._addHandlers,n=this._removeHandlers;if(i[r]||n[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=t,n[r]=e;const s=this._queue;return s[r]&&((o=s[r])==null||o.forEach(a=>t(a)),delete s[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((n,s)=>Df(s,e)-Df(n,e)))},i=>{const n=t.indexOf(i.ref);n!==-1&&t.splice(n,1)})}};class Dl{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 Hw=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
11
- `);function Xw(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 Vw(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=Hw.replace(/%forloop%/gi,Xw(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const Bl=0,Ol=1,Ll=2,Nl=3,Fl=4,kl=5;class cr{constructor(){this.data=0,this.blendMode=vt.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Bl)}set blend(t){!!(this.data&1<<Bl)!==t&&(this.data^=1<<Bl)}get offsets(){return!!(this.data&1<<Ol)}set offsets(t){!!(this.data&1<<Ol)!==t&&(this.data^=1<<Ol)}get culling(){return!!(this.data&1<<Ll)}set culling(t){!!(this.data&1<<Ll)!==t&&(this.data^=1<<Ll)}get depthTest(){return!!(this.data&1<<Nl)}set depthTest(t){!!(this.data&1<<Nl)!==t&&(this.data^=1<<Nl)}get depthMask(){return!!(this.data&1<<kl)}set depthMask(t){!!(this.data&1<<kl)!==t&&(this.data^=1<<kl)}get clockwiseFrontFace(){return!!(this.data&1<<Fl)}set clockwiseFrontFace(t){!!(this.data&1<<Fl)!==t&&(this.data^=1<<Fl)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==vt.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new cr;return t.depthTest=!1,t.blend=!0,t}}cr.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Ul=[];function Bf(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=Ul.length-1;i>=0;--i){const n=Ul[i];if(n.test&&n.test(r,e))return new n(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class Ve{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,n,s,o,a,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:c}=this;this._aliasCount++;for(let u=0,d=c.length;u<d;u++)c[u][h](t,e,i,n,s,o,a,l);return c===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(Ve.prototype,{dispatch:{value:Ve.prototype.emit},run:{value:Ve.prototype.emit}});class zn{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new Ve("setRealSize"),this.onUpdate=new Ve("update"),this.onError=new Ve("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 js extends zn{constructor(t,e){const{width:i,height:n}=e||{};if(!i||!n)throw new Error("BufferResource width or height invalid");super(i,n),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const n=t.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,this.unpackAlignment),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Re.UNPACK);const s=e.realWidth,o=e.realHeight;return i.width===s&&i.height===o?n.texSubImage2D(e.target,0,0,0,s,o,e.format,i.type,this.data):(i.width=s,i.height=o,n.texImage2D(e.target,0,i.internalFormat,s,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 zw={scaleMode:mr.NEAREST,alphaMode:Re.NPM},Gl=class fn extends Rn{constructor(t=null,e=null){super(),e=Object.assign({},fn.defaultOptions,e);const{alphaMode:i,mipmap:n,anisotropicLevel:s,scaleMode:o,width:a,height:l,wrapMode:h,format:c,type:u,target:d,resolution:f,resourceOptions:p}=e;t&&!(t instanceof zn)&&(t=Bf(t,p),t.internal=!0),this.resolution=f||tt.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=n,this.anisotropicLevel=s,this._wrapMode=h,this._scaleMode=o,this.format=c,this.type=u,this.target=d,this.alphaMode=i,this.uid=hi(),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=Sf(this.realWidth)&&Sf(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 Ur[this.cacheId],delete hr[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),fn.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=tt.STRICT_TEXTURE_CACHE){const n=typeof t=="string";let s=null;if(n)s=t;else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${hi()}`}s=t._pixiId}let o=Ur[s];if(n&&i&&!o)throw new Error(`The cacheId "${s}" does not exist in BaseTextureCache.`);return o||(o=new fn(t,e),o.cacheId=s,fn.addToCache(o,s)),o}static fromBuffer(t,e,i,n){t=t||new Float32Array(e*i*4);const s=new js(t,{width:e,height:i,...n==null?void 0:n.resourceOptions});let o,a;return t instanceof Float32Array?(o=j.RGBA,a=pt.FLOAT):t instanceof Int32Array?(o=j.RGBA_INTEGER,a=pt.INT):t instanceof Uint32Array?(o=j.RGBA_INTEGER,a=pt.UNSIGNED_INT):t instanceof Int16Array?(o=j.RGBA_INTEGER,a=pt.SHORT):t instanceof Uint16Array?(o=j.RGBA_INTEGER,a=pt.UNSIGNED_SHORT):t instanceof Int8Array?(o=j.RGBA,a=pt.BYTE):(o=j.RGBA,a=pt.UNSIGNED_BYTE),s.internal=!0,new fn(s,Object.assign({},zw,{type:a,format:o},n))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Ur[e]&&Ur[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),Ur[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Ur[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Ur[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete Ur[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};Gl.defaultOptions={mipmap:rr.POW2,anisotropicLevel:0,scaleMode:mr.LINEAR,wrapMode:Lr.CLAMP,alphaMode:Re.UNPACK,target:Gi.TEXTURE_2D,format:j.RGBA,type:pt.UNSIGNED_BYTE},Gl._globalBatch=0;let bt=Gl;class $l{constructor(){this.texArray=null,this.blend=0,this.type=er.TRIANGLES,this.start=0,this.size=0,this.data=null}}let jw=0;class Jt{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=jw++,this.disposeRunner=new Ve("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?nr.ELEMENT_ARRAY_BUFFER:nr.ARRAY_BUFFER}get index(){return this.type===nr.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Jt(t)}}class Ws{constructor(t,e=0,i=!1,n=pt.FLOAT,s,o,a,l=1){this.buffer=t,this.size=e,this.normalized=i,this.type=n,this.stride=s,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(t,e,i,n,s){return new Ws(t,e,i,n,s)}}const Ww={Float32Array,Uint32Array,Int32Array,Uint8Array};function Yw(r,t){let e=0,i=0;const n={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const s=new ArrayBuffer(e*4);let o=null,a=0;for(let l=0;l<r.length;l++){const h=t[l],c=r[l],u=Af(c);n[u]||(n[u]=new Ww[u](s)),o=n[u];for(let d=0;d<c.length;d++){const f=(d/h|0)*i+a,p=d%h;o[f+p]=c[d]}a+=h}return new Float32Array(s)}const Of={5126:4,5123:2,5121:1};let qw=0;const Kw={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class Gr{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=qw++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new Ve("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,n=!1,s,o,a,l=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Jt||(e instanceof Array&&(e=new Float32Array(e)),e=new Jt(e));const h=t.split("|");if(h.length>1){for(let u=0;u<h.length;u++)this.addAttribute(h[u],e,i,n,s);return this}let c=this.buffers.indexOf(e);return c===-1&&(this.buffers.push(e),c=this.buffers.length-1),this.attributes[t]=new Ws(c,i,n,s,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 Jt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Jt(t)),t.type=nr.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 Jt;let n;for(n in this.attributes){const s=this.attributes[n],o=this.buffers[s.buffer];t.push(o.data),e.push(s.size*Of[s.type]/4),s.buffer=0}for(i.data=Yw(t,e),n=0;n<this.buffers.length;n++)this.buffers[n]!==this.indexBuffer&&this.buffers[n].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 Gr;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new Jt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new Ws(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=nr.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Gr,i=[],n=[],s=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)n[l]=n[l]||0,n[l]+=o.buffers[l].data.length,s[l]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new Kw[Af(o.buffers[a].data)](n[a]),e.buffers[a]=new Jt(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,s[l]),s[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=nr.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,c=0;for(let u=0;u<o.buffers.length;u++)if(o.buffers[u]!==o.indexBuffer){c=u;break}for(const u in o.attributes){const d=o.attributes[u];(d.buffer|0)===c&&(l+=d.size*Of[d.type]/4)}for(let u=0;u<t.length;u++){const d=t[u].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+h]+=a;a+=t[u].buffers[c].data.length/l,h+=d.length}}return e}}class Lf extends Gr{constructor(t=!1){super(),this._buffer=new Jt(null,t,!1),this._indexBuffer=new Jt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,pt.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,pt.FLOAT).addAttribute("aColor",this._buffer,4,!0,pt.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,pt.FLOAT).addIndex(this._indexBuffer)}}const Ys=Math.PI*2,Zw=180/Math.PI,Jw=Math.PI/180;var ve=(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))(ve||{});class It{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new It(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}}It.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const qs=[new It,new It,new It,new It];class wt{constructor(t=0,e=0,i=0,n=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(n),this.type=ve.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 wt(0,0,0,0)}clone(){return new wt(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 I=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=I)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,n=this.right,s=this.top,o=this.bottom;if(n<=i||o<=s)return!1;const a=qs[0].set(t.left,t.top),l=qs[1].set(t.left,t.bottom),h=qs[2].set(t.right,t.top),c=qs[3].set(t.right,t.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(l,l),e.apply(h,h),e.apply(c,c),Math.max(a.x,l.x,h.x,c.x)<=i||Math.min(a.x,l.x,h.x,c.x)>=n||Math.max(a.y,l.y,h.y,c.y)<=s||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const d=u*(l.y-a.y),f=u*(a.x-l.x),p=d*i+f*s,g=d*n+f*s,y=d*i+f*o,_=d*n+f*o;if(Math.max(p,g,y,_)<=d*a.x+f*a.y||Math.min(p,g,y,_)>=d*c.x+f*c.y)return!1;const v=u*(a.y-h.y),m=u*(h.x-a.x),b=v*i+m*s,S=v*n+m*s,R=v*i+m*o,C=v*n+m*o;return!(Math.max(b,S,R,C)<=v*a.x+m*a.y||Math.min(b,S,R,C)>=v*c.x+m*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),s=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=n,this.height=Math.max(s-n,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,n=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=n-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),s=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=n,this.height=s-n,this}}wt.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Ks{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=ve.CIRC}clone(){return new Ks(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-t,s=this.y-e;return n*=n,s*=s,n+s<=i}getBounds(){return new wt(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}Ks.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Zs{constructor(t=0,e=0,i=0,n=0){this.x=t,this.y=e,this.width=i,this.height=n,this.type=ve.ELIP}clone(){return new Zs(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,n=(e-this.y)/this.height;return i*=i,n*=n,i+n<=1}getBounds(){return new wt(this.x-this.width,this.y-this.height,this.width,this.height)}}Zs.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class ci{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let n=0,s=e.length;n<s;n++)i.push(e[n].x,e[n].y);e=i}this.points=e,this.type=ve.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new ci(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const n=this.points.length/2;for(let s=0,o=n-1;s<n;o=s++){const a=this.points[s*2],l=this.points[s*2+1],h=this.points[o*2],c=this.points[o*2+1];l>e!=c>e&&t<(h-a)*((e-l)/(c-l))+a&&(i=!i)}return i}}ci.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class Js{constructor(t=0,e=0,i=0,n=0,s=20){this.x=t,this.y=e,this.width=i,this.height=n,this.radius=s,this.type=ve.RREC}clone(){return new Js(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 n=t-(this.x+i),s=e-(this.y+i);const o=i*i;if(n*n+s*s<=o||(n=t-(this.x+this.width-i),n*n+s*s<=o)||(s=e-(this.y+this.height-i),n*n+s*s<=o)||(n=t-(this.x+i),n*n+s*s<=o))return!0}return!1}}Js.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class kt{constructor(t=1,e=0,i=0,n=1,s=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,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,n,s,o){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,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 It;const i=t.x,n=t.y;return e.x=this.a*i+this.c*n+this.tx,e.y=this.b*i+this.d*n+this.ty,e}applyInverse(t,e){e=e||new It;const i=1/(this.a*this.d+this.c*-this.b),n=t.x,s=t.y;return e.x=this.d*i*n+-this.c*i*s+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*s+-this.b*i*n+(-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),n=this.a,s=this.c,o=this.tx;return this.a=n*e-this.b*i,this.b=n*i+this.b*e,this.c=s*e-this.d*i,this.d=s*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,n=this.c,s=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*i+t.b*s,this.c=t.c*e+t.d*n,this.d=t.c*i+t.d*s,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*s+this.ty,this}setTransform(t,e,i,n,s,o,a,l,h){return this.a=Math.cos(a+h)*s,this.b=Math.sin(a+h)*s,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(i*this.a+n*this.c),this.ty=e-(i*this.b+n*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,n=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*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,n=this.c,s=this.d,o=t.pivot,a=-Math.atan2(-n,s),l=Math.atan2(i,e),h=Math.abs(a+l);return h<1e-5||Math.abs(Ys-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(n*n+s*s),t.position.x=this.tx+(o.x*e+o.y*n),t.position.y=this.ty+(o.x*i+o.y*s),t}invert(){const t=this.a,e=this.b,i=this.c,n=this.d,s=this.tx,o=t*n-e*i;return this.a=n/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-n*s)/o,this.ty=-(t*this.ty-e*s)/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 kt;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 kt}static get TEMP_MATRIX(){return new kt}}kt.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 ui=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],di=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],fi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],pi=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Hl=[],Nf=[],Qs=Math.sign;function Qw(){for(let r=0;r<16;r++){const t=[];Hl.push(t);for(let e=0;e<16;e++){const i=Qs(ui[r]*ui[e]+fi[r]*di[e]),n=Qs(di[r]*ui[e]+pi[r]*di[e]),s=Qs(ui[r]*fi[e]+fi[r]*pi[e]),o=Qs(di[r]*fi[e]+pi[r]*pi[e]);for(let a=0;a<16;a++)if(ui[a]===i&&di[a]===n&&fi[a]===s&&pi[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new kt;t.set(ui[r],di[r],fi[r],pi[r],0,0),Nf.push(t)}}Qw();const Ht={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=>ui[r],uY:r=>di[r],vX:r=>fi[r],vY:r=>pi[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Hl[r][t],sub:(r,t)=>Hl[r][Ht.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?Ht.S:Ht.N:Math.abs(t)*2<=Math.abs(r)?r>0?Ht.E:Ht.W:t>0?r>0?Ht.SE:Ht.SW:r>0?Ht.NE:Ht.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const n=Nf[Ht.inv(t)];n.tx=e,n.ty=i,r.append(n)}};class wr{constructor(t,e,i=0,n=0){this._x=i,this._y=n,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new wr(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))}}wr.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Xl=class{constructor(){this.worldTransform=new kt,this.localTransform=new kt,this.position=new wr(this.onChange,this,0,0),this.scale=new wr(this.onChange,this,1,1),this.pivot=new wr(this.onChange,this,0,0),this.skew=new wr(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())}};Xl.IDENTITY=new Xl;let Vl=Xl;Vl.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 tE=`varying vec2 vTextureCoord;
10
+ Deprecated since v${r}`),console.warn(i))),ff[t]=!0}function Ve(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function Vn(r){return r.split("?")[0].split("#")[0]}function bw(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xw(r,t,e){return r.replace(new RegExp(bw(t),"g"),e)}function ww(r,t){let e="",i=0,n=-1,s=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(!(n===a-1||s===1))if(n!==a-1&&s===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("/")),n=a,s=0;continue}}else if(e.length===2||e.length===1){e="",i=0,n=a,s=0;continue}}}else e.length>0?e+=`/${r.slice(n+1,a)}`:e=r.slice(n+1,a),i=a-n-1;n=a,s=0}else o===46&&s!==-1?++s:s=-1}return e}const ue={toPosix(r){return xw(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){Ve(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(Ve(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=Vn(this.toPosix(t??tt.ADAPTER.getBaseUrl())),n=Vn(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?ue.join(n,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(Ve(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=ww(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Ve(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(Ve(i),i.length>0)if(t===void 0)t=i;else{const n=r[e-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(Ve(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,n=!0;const s=this.getProtocol(r),o=r;r=r.slice(s.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!n){i=a;break}}else n=!1;return i===-1?e?"/":this.isUrl(o)?s+r:s:e&&i===1?"//":s+r.slice(0,i)},rootname(r){Ve(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){Ve(r),t&&Ve(t),r=Vn(this.toPosix(r));let e=0,i=-1,n=!0,s;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(s=r.length-1;s>=0;--s){const l=r.charCodeAt(s);if(l===47){if(!n){e=s+1;break}}else a===-1&&(n=!1,a=s+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(i=s):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(s=r.length-1;s>=0;--s)if(r.charCodeAt(s)===47){if(!n){e=s+1;break}}else i===-1&&(n=!1,i=s+1);return i===-1?"":r.slice(e,i)},extname(r){Ve(r),r=Vn(this.toPosix(r));let t=-1,e=0,i=-1,n=!0,s=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!n){e=o+1;break}continue}i===-1&&(n=!1,i=o+1),a===46?t===-1?t=o:s!==1&&(s=1):t!==-1&&(s=-1)}return t===-1||i===-1||s===0||s===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){Ve(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=Vn(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let n;t.root=this.rootname(r),i||this.hasProtocol(r)?n=1:n=0;let s=-1,o=0,a=-1,l=!0,h=r.length-1,c=0;for(;h>=n;--h){if(e=r.charCodeAt(h),e===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),e===46?s===-1?s=h:c!==1&&(c=1):s!==-1&&(c=-1)}return s===-1||a===-1||c===0||c===1&&s===a-1&&s===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,s),t.base=r.slice(1,a)):(t.name=r.slice(o,s),t.base=r.slice(o,a)),t.ext=r.slice(s,a)),t.dir=this.dirname(r),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let Tl;async function Ew(){return Tl??(Tl=(async()=>{var s;const r=document.createElement("canvas").getContext("webgl");if(!r)return Re.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 Re.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 n=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,n),r.deleteFramebuffer(i),r.deleteTexture(e),(s=r.getExtension("WEBGL_lose_context"))==null||s.loseContext(),n[0]<=n[3]?Re.PMA:Re.UNPACK})()),Tl}let Al;function Tw(){return typeof Al>"u"&&(Al=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:tt.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!tt.ADAPTER.getWebGLRenderingContext())return!1;const e=tt.ADAPTER.createCanvas();let i=e.getContext("webgl",r)||e.getContext("experimental-webgl",r);const n=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const s=i.getExtension("WEBGL_lose_context");s&&s.loseContext()}return i=null,n}catch{return!1}}()),Al}var Aw={grad:.9,turn:360,rad:360/(2*Math.PI)},xr=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},de=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},Ue=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},pf=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},mf=function(r){return{r:Ue(r.r,0,255),g:Ue(r.g,0,255),b:Ue(r.b,0,255),a:Ue(r.a)}},Sl=function(r){return{r:de(r.r),g:de(r.g),b:de(r.b),a:de(r.a,3)}},Sw=/^#([0-9a-f]{3,8})$/i,zs=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},gf=function(r){var t=r.r,e=r.g,i=r.b,n=r.a,s=Math.max(t,e,i),o=s-Math.min(t,e,i),a=o?s===t?(e-i)/o:s===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:s?o/s*100:0,v:s/255*100,a:n}},yf=function(r){var t=r.h,e=r.s,i=r.v,n=r.a;t=t/360*6,e/=100,i/=100;var s=Math.floor(t),o=i*(1-e),a=i*(1-(t-s)*e),l=i*(1-(1-t+s)*e),h=s%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:n}},_f=function(r){return{h:pf(r.h),s:Ue(r.s,0,100),l:Ue(r.l,0,100),a:Ue(r.a)}},vf=function(r){return{h:de(r.h),s:de(r.s),l:de(r.l),a:de(r.a,3)}},bf=function(r){return yf((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},zn=function(r){return{h:(t=gf(r)).h,s:(n=(200-(e=t.s))*(i=t.v)/100)>0&&n<200?e*i/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,i,n},Cw=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Iw=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Pw=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Rw=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Cl={string:[[function(r){var t=Sw.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?de(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?de(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=Pw.exec(r)||Rw.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:mf({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=Cw.exec(r)||Iw.exec(r);if(!t)return null;var e,i,n=_f({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Aw[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return bf(n)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,n=r.a,s=n===void 0?1:n;return xr(t)&&xr(e)&&xr(i)?mf({r:Number(t),g:Number(e),b:Number(i),a:Number(s)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,n=r.a,s=n===void 0?1:n;if(!xr(t)||!xr(e)||!xr(i))return null;var o=_f({h:Number(t),s:Number(e),l:Number(i),a:Number(s)});return bf(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,n=r.a,s=n===void 0?1:n;if(!xr(t)||!xr(e)||!xr(i))return null;var o=function(a){return{h:pf(a.h),s:Ue(a.s,0,100),v:Ue(a.v,0,100),a:Ue(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(s)});return yf(o)},"hsv"]]},xf=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]},Mw=function(r){return typeof r=="string"?xf(r.trim(),Cl.string):typeof r=="object"&&r!==null?xf(r,Cl.object):[null,void 0]},Il=function(r,t){var e=zn(r);return{h:e.h,s:Ue(e.s+100*t,0,100),l:e.l,a:e.a}},Pl=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},wf=function(r,t){var e=zn(r);return{h:e.h,s:e.s,l:Ue(e.l+100*t,0,100),a:e.a}},Rl=function(){function r(t){this.parsed=Mw(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 de(Pl(this.rgba),2)},r.prototype.isDark=function(){return Pl(this.rgba)<.5},r.prototype.isLight=function(){return Pl(this.rgba)>=.5},r.prototype.toHex=function(){return t=Sl(this.rgba),e=t.r,i=t.g,n=t.b,o=(s=t.a)<1?zs(de(255*s)):"","#"+zs(e)+zs(i)+zs(n)+o;var t,e,i,n,s,o},r.prototype.toRgb=function(){return Sl(this.rgba)},r.prototype.toRgbString=function(){return t=Sl(this.rgba),e=t.r,i=t.g,n=t.b,(s=t.a)<1?"rgba("+e+", "+i+", "+n+", "+s+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,s},r.prototype.toHsl=function(){return vf(zn(this.rgba))},r.prototype.toHslString=function(){return t=vf(zn(this.rgba)),e=t.h,i=t.s,n=t.l,(s=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+s+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,s},r.prototype.toHsv=function(){return t=gf(this.rgba),{h:de(t.h),s:de(t.s),v:de(t.v),a:de(t.a,3)};var t},r.prototype.invert=function(){return hr({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),hr(Il(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),hr(Il(this.rgba,-t))},r.prototype.grayscale=function(){return hr(Il(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),hr(wf(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),hr(wf(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"?hr({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):de(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=zn(this.rgba);return typeof t=="number"?hr({h:t,s:e.s,l:e.l,a:e.a}):de(e.h)},r.prototype.isEqual=function(t){return this.toHex()===hr(t).toHex()},r}(),hr=function(r){return r instanceof Rl?r:new Rl(r)},Ef=[],Dw=function(r){r.forEach(function(t){Ef.indexOf(t)<0&&(t(Rl,Cl),Ef.push(t))})};function Bw(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 n in e)i[e[n]]=n;var s={};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 c=this.toRgb(),u=1/0,d="black";if(!s.length)for(var f in e)s[f]=new r(e[f]).toRgb();for(var p in e){var g=(a=c,l=s[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));g<u&&(u=g,d=p)}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"])}Dw([Bw]);const Qi=class No{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 No)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((n,s)=>n===e[s]);if(t!==null&&e!==null){const n=Object.keys(t),s=Object.keys(e);return n.length!==s.length?!1:n.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,n]=this._components;return{r:t,g:e,b:i,a:n}}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,n]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(n*255),t}toRgbArray(t){t=t??[];const[e,i,n]=this._components;return t[0]=e,t[1]=i,t[2]=n,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,n,s]=No.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=n,this._components[3]*=s,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,n=this._int>>8&255,s=this._int&255;return e&&(i=i*t+.5|0,n=n*t+.5|0,s=s*t+.5|0),(t*255<<24)+(i<<16)+(n<<8)+s}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,n]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(n*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,n,s]=this._components;return t[0]=e,t[1]=i,t[2]=n,t[3]=s,t}normalize(t){let e,i,n,s;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,n=(o&255)/255,s=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,n,s=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,n,s=255]=t,e/=255,i/=255,n/=255,s/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=No.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=hr(t);o.isValid()&&({r:e,g:i,b:n,a:s}=o.rgba,e/=255,i/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=n,this._components[3]=s,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((n,s)=>{t[s]=Math.min(Math.max(n,e),i)}),t)}};Qi.shared=new Qi,Qi.temp=new Qi,Qi.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Mt=Qi;function Ow(r){return At("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),Mt.shared.setValue(r).toHex()}function Lw(r){return At("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),Mt.shared.setValue(r).toNumber()}function Nw(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[vt.NORMAL_NPM]=vt.NORMAL,r[vt.ADD_NPM]=vt.ADD,r[vt.SCREEN_NPM]=vt.SCREEN,t[vt.NORMAL]=vt.NORMAL_NPM,t[vt.ADD]=vt.ADD_NPM,t[vt.SCREEN]=vt.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const Tf=Nw();function Af(r,t){return Tf[t?1:0][r]}function Fw(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,n=0;i<e;i+=6,n+=4)t[i+0]=n+0,t[i+1]=n+1,t[i+2]=n+2,t[i+3]=n+0,t[i+4]=n+2,t[i+5]=n+3;return t}function Sf(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}function js(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 Cf(r){return!(r&r-1)&&!!r}function If(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 Ji(r,t,e){const i=r.length;let n;if(t>=i||e===0)return;e=t+e>i?i-t:e;const s=i-e;for(n=t;n<s;++n)r[n]=r[n+e];r.length=s}function Gr(r){return r===0?0:r<0?-1:1}let kw=0;function ui(){return++kw}const Ml=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}};Ml.EMPTY=new Ml(0,0,0,0);let Pf=Ml;const Rf={},cr=Object.create(null),$r=Object.create(null);class Uw{constructor(t,e,i){this._canvas=tt.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||tt.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 Mf(r,t,e){for(let i=0,n=4*e*t;i<t;++i,n+=4)if(r[n+3]!==0)return!1;return!0}function Df(r,t,e,i,n){const s=4*t;for(let o=i,a=i*s+4*e;o<=n;++o,a+=s)if(r[a+3]!==0)return!1;return!0}function Gw(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 n=i.getImageData(0,0,t,e).data;let s=0,o=0,a=t-1,l=e-1;for(;o<e&&Mf(n,t,o);)++o;if(o===e)return Pf.EMPTY;for(;Mf(n,t,l);)--l;for(;Df(n,t,s,o,l);)++s;for(;Df(n,t,a,o,l);)--a;return++a,++l,new Pf(s,o,a,l)}function $w(r){const t=Gw(r),{width:e,height:i}=t;let n=null;if(!t.isEmpty()){const s=r.getContext("2d");if(s===null)throw new TypeError("Failed to get canvas 2D context");n=s.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:n}}function Hw(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 wr(r,t=1){var i;const e=(i=tt.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}var Z=(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))(Z||{});const Dl=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},Bf=(r,t)=>Dl(r).priority??t,ht={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Dl).forEach(t=>{t.type.forEach(e=>{var i,n;return(n=(i=this._removeHandlers)[e])==null?void 0:n.call(i,t)})}),this},add(...r){return r.map(Dl).forEach(t=>{t.type.forEach(e=>{var s,o;const i=this._addHandlers,n=this._queue;i[e]?(s=i[e])==null||s.call(i,t):(n[e]=n[e]||[],(o=n[e])==null||o.push(t))})}),this},handle(r,t,e){var o;const i=this._addHandlers,n=this._removeHandlers;if(i[r]||n[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=t,n[r]=e;const s=this._queue;return s[r]&&((o=s[r])==null||o.forEach(a=>t(a)),delete s[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((n,s)=>Bf(s,e)-Bf(n,e)))},i=>{const n=t.indexOf(i.ref);n!==-1&&t.splice(n,1)})}};class Bl{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 Xw=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
11
+ `);function Vw(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 zw(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=Xw.replace(/%forloop%/gi,Vw(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const Ol=0,Ll=1,Nl=2,Fl=3,kl=4,Ul=5;class ur{constructor(){this.data=0,this.blendMode=vt.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Ol)}set blend(t){!!(this.data&1<<Ol)!==t&&(this.data^=1<<Ol)}get offsets(){return!!(this.data&1<<Ll)}set offsets(t){!!(this.data&1<<Ll)!==t&&(this.data^=1<<Ll)}get culling(){return!!(this.data&1<<Nl)}set culling(t){!!(this.data&1<<Nl)!==t&&(this.data^=1<<Nl)}get depthTest(){return!!(this.data&1<<Fl)}set depthTest(t){!!(this.data&1<<Fl)!==t&&(this.data^=1<<Fl)}get depthMask(){return!!(this.data&1<<Ul)}set depthMask(t){!!(this.data&1<<Ul)!==t&&(this.data^=1<<Ul)}get clockwiseFrontFace(){return!!(this.data&1<<kl)}set clockwiseFrontFace(t){!!(this.data&1<<kl)!==t&&(this.data^=1<<kl)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==vt.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new ur;return t.depthTest=!1,t.blend=!0,t}}ur.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Gl=[];function Of(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=Gl.length-1;i>=0;--i){const n=Gl[i];if(n.test&&n.test(r,e))return new n(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class ze{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,n,s,o,a,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:c}=this;this._aliasCount++;for(let u=0,d=c.length;u<d;u++)c[u][h](t,e,i,n,s,o,a,l);return c===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(ze.prototype,{dispatch:{value:ze.prototype.emit},run:{value:ze.prototype.emit}});class jn{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new ze("setRealSize"),this.onUpdate=new ze("update"),this.onError=new ze("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 Ws extends jn{constructor(t,e){const{width:i,height:n}=e||{};if(!i||!n)throw new Error("BufferResource width or height invalid");super(i,n),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const n=t.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,this.unpackAlignment),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Re.UNPACK);const s=e.realWidth,o=e.realHeight;return i.width===s&&i.height===o?n.texSubImage2D(e.target,0,0,0,s,o,e.format,i.type,this.data):(i.width=s,i.height=o,n.texImage2D(e.target,0,i.internalFormat,s,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 jw={scaleMode:gr.NEAREST,alphaMode:Re.NPM},$l=class pn extends Mn{constructor(t=null,e=null){super(),e=Object.assign({},pn.defaultOptions,e);const{alphaMode:i,mipmap:n,anisotropicLevel:s,scaleMode:o,width:a,height:l,wrapMode:h,format:c,type:u,target:d,resolution:f,resourceOptions:p}=e;t&&!(t instanceof jn)&&(t=Of(t,p),t.internal=!0),this.resolution=f||tt.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=n,this.anisotropicLevel=s,this._wrapMode=h,this._scaleMode=o,this.format=c,this.type=u,this.target=d,this.alphaMode=i,this.uid=ui(),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=Cf(this.realWidth)&&Cf(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 $r[this.cacheId],delete cr[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),pn.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=tt.STRICT_TEXTURE_CACHE){const n=typeof t=="string";let s=null;if(n)s=t;else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${ui()}`}s=t._pixiId}let o=$r[s];if(n&&i&&!o)throw new Error(`The cacheId "${s}" does not exist in BaseTextureCache.`);return o||(o=new pn(t,e),o.cacheId=s,pn.addToCache(o,s)),o}static fromBuffer(t,e,i,n){t=t||new Float32Array(e*i*4);const s=new Ws(t,{width:e,height:i,...n==null?void 0:n.resourceOptions});let o,a;return t instanceof Float32Array?(o=j.RGBA,a=pt.FLOAT):t instanceof Int32Array?(o=j.RGBA_INTEGER,a=pt.INT):t instanceof Uint32Array?(o=j.RGBA_INTEGER,a=pt.UNSIGNED_INT):t instanceof Int16Array?(o=j.RGBA_INTEGER,a=pt.SHORT):t instanceof Uint16Array?(o=j.RGBA_INTEGER,a=pt.UNSIGNED_SHORT):t instanceof Int8Array?(o=j.RGBA,a=pt.BYTE):(o=j.RGBA,a=pt.UNSIGNED_BYTE),s.internal=!0,new pn(s,Object.assign({},jw,{type:a,format:o},n))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),$r[e]&&$r[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),$r[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=$r[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete $r[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete $r[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};$l.defaultOptions={mipmap:ir.POW2,anisotropicLevel:0,scaleMode:gr.LINEAR,wrapMode:Fr.CLAMP,alphaMode:Re.UNPACK,target:$i.TEXTURE_2D,format:j.RGBA,type:pt.UNSIGNED_BYTE},$l._globalBatch=0;let bt=$l;class Hl{constructor(){this.texArray=null,this.blend=0,this.type=rr.TRIANGLES,this.start=0,this.size=0,this.data=null}}let Ww=0;class Qt{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=Ww++,this.disposeRunner=new ze("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?sr.ELEMENT_ARRAY_BUFFER:sr.ARRAY_BUFFER}get index(){return this.type===sr.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Qt(t)}}class Ys{constructor(t,e=0,i=!1,n=pt.FLOAT,s,o,a,l=1){this.buffer=t,this.size=e,this.normalized=i,this.type=n,this.stride=s,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(t,e,i,n,s){return new Ys(t,e,i,n,s)}}const Yw={Float32Array,Uint32Array,Int32Array,Uint8Array};function qw(r,t){let e=0,i=0;const n={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const s=new ArrayBuffer(e*4);let o=null,a=0;for(let l=0;l<r.length;l++){const h=t[l],c=r[l],u=Sf(c);n[u]||(n[u]=new Yw[u](s)),o=n[u];for(let d=0;d<c.length;d++){const f=(d/h|0)*i+a,p=d%h;o[f+p]=c[d]}a+=h}return new Float32Array(s)}const Lf={5126:4,5123:2,5121:1};let Kw=0;const Zw={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class Hr{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=Kw++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new ze("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,n=!1,s,o,a,l=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Qt||(e instanceof Array&&(e=new Float32Array(e)),e=new Qt(e));const h=t.split("|");if(h.length>1){for(let u=0;u<h.length;u++)this.addAttribute(h[u],e,i,n,s);return this}let c=this.buffers.indexOf(e);return c===-1&&(this.buffers.push(e),c=this.buffers.length-1),this.attributes[t]=new Ys(c,i,n,s,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 Qt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Qt(t)),t.type=sr.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 Qt;let n;for(n in this.attributes){const s=this.attributes[n],o=this.buffers[s.buffer];t.push(o.data),e.push(s.size*Lf[s.type]/4),s.buffer=0}for(i.data=qw(t,e),n=0;n<this.buffers.length;n++)this.buffers[n]!==this.indexBuffer&&this.buffers[n].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 Hr;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new Qt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new Ys(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=sr.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Hr,i=[],n=[],s=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)n[l]=n[l]||0,n[l]+=o.buffers[l].data.length,s[l]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new Zw[Sf(o.buffers[a].data)](n[a]),e.buffers[a]=new Qt(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,s[l]),s[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=sr.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,c=0;for(let u=0;u<o.buffers.length;u++)if(o.buffers[u]!==o.indexBuffer){c=u;break}for(const u in o.attributes){const d=o.attributes[u];(d.buffer|0)===c&&(l+=d.size*Lf[d.type]/4)}for(let u=0;u<t.length;u++){const d=t[u].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+h]+=a;a+=t[u].buffers[c].data.length/l,h+=d.length}}return e}}class Nf extends Hr{constructor(t=!1){super(),this._buffer=new Qt(null,t,!1),this._indexBuffer=new Qt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,pt.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,pt.FLOAT).addAttribute("aColor",this._buffer,4,!0,pt.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,pt.FLOAT).addIndex(this._indexBuffer)}}const qs=Math.PI*2,Qw=180/Math.PI,Jw=Math.PI/180;var ve=(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))(ve||{});class It{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new It(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}}It.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Ks=[new It,new It,new It,new It];class wt{constructor(t=0,e=0,i=0,n=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(n),this.type=ve.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 wt(0,0,0,0)}clone(){return new wt(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 I=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=I)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,n=this.right,s=this.top,o=this.bottom;if(n<=i||o<=s)return!1;const a=Ks[0].set(t.left,t.top),l=Ks[1].set(t.left,t.bottom),h=Ks[2].set(t.right,t.top),c=Ks[3].set(t.right,t.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(l,l),e.apply(h,h),e.apply(c,c),Math.max(a.x,l.x,h.x,c.x)<=i||Math.min(a.x,l.x,h.x,c.x)>=n||Math.max(a.y,l.y,h.y,c.y)<=s||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const d=u*(l.y-a.y),f=u*(a.x-l.x),p=d*i+f*s,g=d*n+f*s,y=d*i+f*o,_=d*n+f*o;if(Math.max(p,g,y,_)<=d*a.x+f*a.y||Math.min(p,g,y,_)>=d*c.x+f*c.y)return!1;const v=u*(a.y-h.y),m=u*(h.x-a.x),b=v*i+m*s,S=v*n+m*s,R=v*i+m*o,C=v*n+m*o;return!(Math.max(b,S,R,C)<=v*a.x+m*a.y||Math.min(b,S,R,C)>=v*c.x+m*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),s=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=n,this.height=Math.max(s-n,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,n=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=n-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),s=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=n,this.height=s-n,this}}wt.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Zs{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=ve.CIRC}clone(){return new Zs(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-t,s=this.y-e;return n*=n,s*=s,n+s<=i}getBounds(){return new wt(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}Zs.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Qs{constructor(t=0,e=0,i=0,n=0){this.x=t,this.y=e,this.width=i,this.height=n,this.type=ve.ELIP}clone(){return new Qs(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,n=(e-this.y)/this.height;return i*=i,n*=n,i+n<=1}getBounds(){return new wt(this.x-this.width,this.y-this.height,this.width,this.height)}}Qs.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class di{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let n=0,s=e.length;n<s;n++)i.push(e[n].x,e[n].y);e=i}this.points=e,this.type=ve.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new di(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const n=this.points.length/2;for(let s=0,o=n-1;s<n;o=s++){const a=this.points[s*2],l=this.points[s*2+1],h=this.points[o*2],c=this.points[o*2+1];l>e!=c>e&&t<(h-a)*((e-l)/(c-l))+a&&(i=!i)}return i}}di.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class Js{constructor(t=0,e=0,i=0,n=0,s=20){this.x=t,this.y=e,this.width=i,this.height=n,this.radius=s,this.type=ve.RREC}clone(){return new Js(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 n=t-(this.x+i),s=e-(this.y+i);const o=i*i;if(n*n+s*s<=o||(n=t-(this.x+this.width-i),n*n+s*s<=o)||(s=e-(this.y+this.height-i),n*n+s*s<=o)||(n=t-(this.x+i),n*n+s*s<=o))return!0}return!1}}Js.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class kt{constructor(t=1,e=0,i=0,n=1,s=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,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,n,s,o){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,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 It;const i=t.x,n=t.y;return e.x=this.a*i+this.c*n+this.tx,e.y=this.b*i+this.d*n+this.ty,e}applyInverse(t,e){e=e||new It;const i=1/(this.a*this.d+this.c*-this.b),n=t.x,s=t.y;return e.x=this.d*i*n+-this.c*i*s+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*s+-this.b*i*n+(-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),n=this.a,s=this.c,o=this.tx;return this.a=n*e-this.b*i,this.b=n*i+this.b*e,this.c=s*e-this.d*i,this.d=s*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,n=this.c,s=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*i+t.b*s,this.c=t.c*e+t.d*n,this.d=t.c*i+t.d*s,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*s+this.ty,this}setTransform(t,e,i,n,s,o,a,l,h){return this.a=Math.cos(a+h)*s,this.b=Math.sin(a+h)*s,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(i*this.a+n*this.c),this.ty=e-(i*this.b+n*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,n=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*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,n=this.c,s=this.d,o=t.pivot,a=-Math.atan2(-n,s),l=Math.atan2(i,e),h=Math.abs(a+l);return h<1e-5||Math.abs(qs-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(n*n+s*s),t.position.x=this.tx+(o.x*e+o.y*n),t.position.y=this.ty+(o.x*i+o.y*s),t}invert(){const t=this.a,e=this.b,i=this.c,n=this.d,s=this.tx,o=t*n-e*i;return this.a=n/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-n*s)/o,this.ty=-(t*this.ty-e*s)/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 kt;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 kt}static get TEMP_MATRIX(){return new kt}}kt.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 fi=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],pi=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],mi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],gi=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Xl=[],Ff=[],to=Math.sign;function tE(){for(let r=0;r<16;r++){const t=[];Xl.push(t);for(let e=0;e<16;e++){const i=to(fi[r]*fi[e]+mi[r]*pi[e]),n=to(pi[r]*fi[e]+gi[r]*pi[e]),s=to(fi[r]*mi[e]+mi[r]*gi[e]),o=to(pi[r]*mi[e]+gi[r]*gi[e]);for(let a=0;a<16;a++)if(fi[a]===i&&pi[a]===n&&mi[a]===s&&gi[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new kt;t.set(fi[r],pi[r],mi[r],gi[r],0,0),Ff.push(t)}}tE();const Ht={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=>fi[r],uY:r=>pi[r],vX:r=>mi[r],vY:r=>gi[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Xl[r][t],sub:(r,t)=>Xl[r][Ht.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?Ht.S:Ht.N:Math.abs(t)*2<=Math.abs(r)?r>0?Ht.E:Ht.W:t>0?r>0?Ht.SE:Ht.SW:r>0?Ht.NE:Ht.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const n=Ff[Ht.inv(t)];n.tx=e,n.ty=i,r.append(n)}};class Er{constructor(t,e,i=0,n=0){this._x=i,this._y=n,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new Er(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))}}Er.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Vl=class{constructor(){this.worldTransform=new kt,this.localTransform=new kt,this.position=new Er(this.onChange,this,0,0),this.scale=new Er(this.onChange,this,1,1),this.pivot=new Er(this.onChange,this,0,0),this.skew=new Er(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())}};Vl.IDENTITY=new Vl;let zl=Vl;zl.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 eE=`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
- }`,eE=`attribute vec2 aVertexPosition;
18
+ }`,rE=`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 Ff(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function zl(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function kf(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 zl(2*t);case"bvec3":return zl(3*t);case"bvec4":return zl(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 Qi=[{test:r=>r.type==="float"&&r.size===1&&!r.isArray,code:r=>`
29
+ `;function kf(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function jl(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Uf(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 jl(2*t);case"bvec3":return jl(3*t);case"bvec4":return jl(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 tn=[{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
- }`}],rE={float:`
149
+ }`}],iE={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
- }`},iE={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 nE(r,t){var i;const e=[`
285
+ }`},nE={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 sE(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.${n}, '${n}');
293
293
  `):e.push(`
294
294
  renderer.shader.syncUniformGroup(uv.${n}, syncData);
295
- `));continue}const o=r.uniforms[n];let a=!1;for(let l=0;l<Qi.length;l++)if(Qi[l].test(s,o)){e.push(Qi[l].code(n,o)),a=!0;break}if(!a){const l=(s.size===1&&!s.isArray?rE:iE)[s.type].replace("location",`ud["${n}"].location`);e.push(`
295
+ `));continue}const o=r.uniforms[n];let a=!1;for(let l=0;l<tn.length;l++)if(tn[l].test(s,o)){e.push(tn[l].code(n,o)),a=!0;break}if(!a){const l=(s.size===1&&!s.isArray?iE:nE)[s.type].replace("location",`ud["${n}"].location`);e.push(`
296
296
  cu = ud["${n}"];
297
297
  cv = cu.value;
298
298
  v = uv["${n}"];
299
299
  ${l};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
300
- `))}const Uf={};let tn=Uf;function sE(){if(tn===Uf||tn!=null&&tn.isContextLost()){const r=tt.ADAPTER.createCanvas();let t;tt.PREFER_ENV>=ii.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),tn=t}return tn}let to;function oE(){if(!to){to=ke.MEDIUM;const r=sE();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(to=t.precision?ke.HIGH:ke.MEDIUM)}}return to}function Gf(r,t){const e=r.getShaderSource(t).split(`
300
+ `))}const Gf={};let en=Gf;function oE(){if(en===Gf||en!=null&&en.isContextLost()){const r=tt.ADAPTER.createCanvas();let t;tt.PREFER_ENV>=si.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),en=t}return en}let eo;function aE(){if(!eo){eo=ke.MEDIUM;const r=oE();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(eo=t.precision?ke.HIGH:ke.MEDIUM)}}return eo}function $f(r,t){const e=r.getShaderSource(t).split(`
301
301
  `).map((h,c)=>`${c}: ${h}`),i=r.getShaderInfoLog(t),n=i.split(`
302
302
  `),s={},o=n.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!s[h]?(s[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 aE(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Gf(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Gf(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const lE={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 $f(r){return lE[r]}let eo=null;const Hf={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 Xf(r,t){if(!eo){const e=Object.keys(Hf);eo={};for(let i=0;i<e.length;++i){const n=e[i];eo[r[n]]=Hf[n]}}return eo[t]}function Vf(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===ke.HIGH&&e!==ke.HIGH&&(i=ke.MEDIUM),`precision ${i} float;
304
- ${r}`}else if(e!==ke.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let jn;function hE(){if(typeof jn=="boolean")return jn;try{jn=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{jn=!1}return jn}let cE=0;const ro={},jl=class pn{constructor(t,e,i="pixi-shader",n={}){this.extra={},this.id=cE++,this.vertexSrc=t||pn.defaultVertexSrc,this.fragmentSrc=e||pn.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=n,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),ro[i]?(ro[i]++,i+=`-${ro[i]}`):ro[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
303
+ `);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function lE(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||$f(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||$f(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const hE={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 Hf(r){return hE[r]}let ro=null;const Xf={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 Vf(r,t){if(!ro){const e=Object.keys(Xf);ro={};for(let i=0;i<e.length;++i){const n=e[i];ro[r[n]]=Xf[n]}}return ro[t]}function zf(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===ke.HIGH&&e!==ke.HIGH&&(i=ke.MEDIUM),`precision ${i} float;
304
+ ${r}`}else if(e!==ke.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let Wn;function cE(){if(typeof Wn=="boolean")return Wn;try{Wn=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Wn=!1}return Wn}let uE=0;const io={},Wl=class mn{constructor(t,e,i="pixi-shader",n={}){this.extra={},this.id=uE++,this.vertexSrc=t||mn.defaultVertexSrc,this.fragmentSrc=e||mn.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=n,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),io[i]?(io[i]++,i+=`-${io[i]}`):io[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
305
305
  ${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
306
- ${this.fragmentSrc}`,this.vertexSrc=Vf(this.vertexSrc,pn.defaultVertexPrecision,ke.HIGH),this.fragmentSrc=Vf(this.fragmentSrc,pn.defaultFragmentPrecision,oE())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return eE}static get defaultFragmentSrc(){return tE}static from(t,e,i){const n=t+e;let s=Pf[n];return s||(Pf[n]=s=new pn(t,e,i)),s}};jl.defaultVertexPrecision=ke.HIGH,jl.defaultFragmentPrecision=yr.apple.device?ke.HIGH:ke.MEDIUM;let Er=jl,uE=0;class ze{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=uE++,this.static=!!e,this.ubo=!!i,t instanceof Jt?(this.buffer=t,this.buffer.type=nr.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Jt(new Float32Array(1)),this.buffer.type=nr.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 ze(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 ze(t,e,i)}static uboFrom(t,e){return new ze(t,e??!0,!0)}}class ur{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof ze?this.uniformGroup=e:this.uniformGroup=new ze(e):this.uniformGroup=new ze({}),this.disposeRunner=new Ve("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const n=e.uniforms[i];if(n.group===!0&&this.checkUniformExists(t,n))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 n=Er.from(t,e);return new ur(n,i)}}class dE{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 s=0;s<t;s++)i[s]=s;this.defaultGroupCache[t]=ze.from({uSamplers:i},!0);let n=this.fragTemplate;n=n.replace(/%count%/gi,`${t}`),n=n.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new Er(this.vertexSrc,n)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new kt,default:this.defaultGroupCache[t]};return new ur(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
306
+ ${this.fragmentSrc}`,this.vertexSrc=zf(this.vertexSrc,mn.defaultVertexPrecision,ke.HIGH),this.fragmentSrc=zf(this.fragmentSrc,mn.defaultFragmentPrecision,aE())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return rE}static get defaultFragmentSrc(){return eE}static from(t,e,i){const n=t+e;let s=Rf[n];return s||(Rf[n]=s=new mn(t,e,i)),s}};Wl.defaultVertexPrecision=ke.HIGH,Wl.defaultFragmentPrecision=_r.apple.device?ke.HIGH:ke.MEDIUM;let Tr=Wl,dE=0;class je{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=dE++,this.static=!!e,this.ubo=!!i,t instanceof Qt?(this.buffer=t,this.buffer.type=sr.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Qt(new Float32Array(1)),this.buffer.type=sr.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 je(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 je(t,e,i)}static uboFrom(t,e){return new je(t,e??!0,!0)}}class dr{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof je?this.uniformGroup=e:this.uniformGroup=new je(e):this.uniformGroup=new je({}),this.disposeRunner=new ze("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const n=e.uniforms[i];if(n.group===!0&&this.checkUniformExists(t,n))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 n=Tr.from(t,e);return new dr(n,i)}}class fE{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 s=0;s<t;s++)i[s]=s;this.defaultGroupCache[t]=je.from({uSamplers:i},!0);let n=this.fragTemplate;n=n.replace(/%count%/gi,`${t}`),n=n.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new Tr(this.vertexSrc,n)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new kt,default:this.defaultGroupCache[t]};return new dr(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 Wl{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 fE(){return!yr.apple.device}function pE(r){let t=!0;const e=tt.ADAPTER.getNavigator();if(yr.tablet||yr.phone){if(yr.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(yr.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class io{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var mE=`varying vec2 vTextureCoord;
314
+ `,e}}class Yl{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 pE(){return!_r.apple.device}function mE(r){let t=!0;const e=tt.ADAPTER.getNavigator();if(_r.tablet||_r.phone){if(_r.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(_r.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class no{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var gE=`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
- `,gE=`precision highp float;
324
+ `,yE=`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 Wn=class Ze extends io{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Lf,this.vertexSize=6,this.state=cr.for2d(),this.size=Ze.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??pE(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??fE(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return At("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return gE}static get defaultFragmentTemplate(){return mE}setShaderGenerator({vertex:t=Ze.defaultVertexSrc,fragment:e=Ze.defaultFragmentTemplate}={}){this.shaderGenerator=new dE(t,e)}contextChange(){const t=this.renderer.gl;tt.PREFER_ENV===ii.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Ze.defaultMaxTextures),this.maxTextures=Vw(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}=Ze,i=this.size/4,n=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new $l);for(;e.length<n;)e.push(new Wl);for(let s=0;s<this.maxTextures;s++)this._tempBoundTextures[s]=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=Ze._textureArrayPool,n=this.renderer.batch,s=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++bt._globalBatch,l=0,h=i[0],c=0;n.copyBoundTextures(s,e);for(let u=0;u<this._bufferSize;++u){const d=t[u];t[u]=null,d._batchEnabled!==a&&(h.count>=e&&(n.boundArray(h,s,a,e),this.buildDrawCalls(h,c,u),c=u,h=i[++l],++a),d._batchEnabled=a,d.touched=o,h.elements[h.count++]=d)}h.count>0&&(n.boundArray(h,s,a,e),this.buildDrawCalls(h,c,this._bufferSize),++l,++a);for(let u=0;u<s.length;u++)s[u]=null;bt._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:n,_attributeBuffer:s,_indexBuffer:o,vertexSize:a}=this,l=Ze._drawCallPool;let h=this._dcIndex,c=this._aIndex,u=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=t;for(let f=e;f<i;++f){const p=n[f],g=p._texture.baseTexture,y=Ef[g.alphaMode?1:0][p.blendMode];n[f]=null,e<f&&d.blend!==y&&(d.size=u-d.start,e=f,d=l[++h],d.texArray=t,d.start=u),this.packInterleavedGeometry(p,s,o,c,u),c+=p.vertexData.length/2*a,u+=p.indices.length,d.blend=y}e<i&&(d.size=u-d.start,++h),this._dcIndex=h,this._aIndex=c,this._iIndex=u}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;Ze.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,n=Ze._drawCallPool;let s=null;for(let o=0;o<t;o++){const{texArray:a,type:l,size:h,start:c,blend:u}=n[o];s!==a&&(s=a,this.bindAndClearTexArray(a)),this.state.blendMode=u,i.set(this.state),e.drawElements(l,h,e.UNSIGNED_SHORT,c*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),Ze.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=zs(Math.ceil(t/8)),i=Cf(e),n=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._aBuffers[n];return s||(this._aBuffers[n]=s=new Dl(n*this.vertexSize*4)),s}getIndexBuffer(t){const e=zs(Math.ceil(t/12)),i=Cf(e),n=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._iBuffers[i];return s||(this._iBuffers[i]=s=new Uint16Array(n)),s}packInterleavedGeometry(t,e,i,n,s){const{uint32View:o,float32View:a}=e,l=n/this.vertexSize,h=t.uvs,c=t.indices,u=t.vertexData,d=t._texture.baseTexture._batchLocation,f=Math.min(t.worldAlpha,1),p=Mt.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let g=0;g<u.length;g+=2)a[n++]=u[g],a[n++]=u[g+1],a[n++]=h[g],a[n++]=h[g+1],o[n++]=p,a[n++]=d;for(let g=0;g<c.length;g++)i[s++]=l+c[g]}};Wn.defaultBatchSize=4096,Wn.extension={name:"batch",type:Z.RendererPlugin},Wn._drawCallPool=[],Wn._textureArrayPool=[];let mi=Wn;ht.add(mi);var yE=`varying vec2 vTextureCoord;
345
+ `;const Yn=class Qe extends no{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Nf,this.vertexSize=6,this.state=ur.for2d(),this.size=Qe.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??mE(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??pE(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return At("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return yE}static get defaultFragmentTemplate(){return gE}setShaderGenerator({vertex:t=Qe.defaultVertexSrc,fragment:e=Qe.defaultFragmentTemplate}={}){this.shaderGenerator=new fE(t,e)}contextChange(){const t=this.renderer.gl;tt.PREFER_ENV===si.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Qe.defaultMaxTextures),this.maxTextures=zw(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}=Qe,i=this.size/4,n=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new Hl);for(;e.length<n;)e.push(new Yl);for(let s=0;s<this.maxTextures;s++)this._tempBoundTextures[s]=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=Qe._textureArrayPool,n=this.renderer.batch,s=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++bt._globalBatch,l=0,h=i[0],c=0;n.copyBoundTextures(s,e);for(let u=0;u<this._bufferSize;++u){const d=t[u];t[u]=null,d._batchEnabled!==a&&(h.count>=e&&(n.boundArray(h,s,a,e),this.buildDrawCalls(h,c,u),c=u,h=i[++l],++a),d._batchEnabled=a,d.touched=o,h.elements[h.count++]=d)}h.count>0&&(n.boundArray(h,s,a,e),this.buildDrawCalls(h,c,this._bufferSize),++l,++a);for(let u=0;u<s.length;u++)s[u]=null;bt._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:n,_attributeBuffer:s,_indexBuffer:o,vertexSize:a}=this,l=Qe._drawCallPool;let h=this._dcIndex,c=this._aIndex,u=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=t;for(let f=e;f<i;++f){const p=n[f],g=p._texture.baseTexture,y=Tf[g.alphaMode?1:0][p.blendMode];n[f]=null,e<f&&d.blend!==y&&(d.size=u-d.start,e=f,d=l[++h],d.texArray=t,d.start=u),this.packInterleavedGeometry(p,s,o,c,u),c+=p.vertexData.length/2*a,u+=p.indices.length,d.blend=y}e<i&&(d.size=u-d.start,++h),this._dcIndex=h,this._aIndex=c,this._iIndex=u}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;Qe.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,n=Qe._drawCallPool;let s=null;for(let o=0;o<t;o++){const{texArray:a,type:l,size:h,start:c,blend:u}=n[o];s!==a&&(s=a,this.bindAndClearTexArray(a)),this.state.blendMode=u,i.set(this.state),e.drawElements(l,h,e.UNSIGNED_SHORT,c*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),Qe.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=js(Math.ceil(t/8)),i=If(e),n=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._aBuffers[n];return s||(this._aBuffers[n]=s=new Bl(n*this.vertexSize*4)),s}getIndexBuffer(t){const e=js(Math.ceil(t/12)),i=If(e),n=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._iBuffers[i];return s||(this._iBuffers[i]=s=new Uint16Array(n)),s}packInterleavedGeometry(t,e,i,n,s){const{uint32View:o,float32View:a}=e,l=n/this.vertexSize,h=t.uvs,c=t.indices,u=t.vertexData,d=t._texture.baseTexture._batchLocation,f=Math.min(t.worldAlpha,1),p=Mt.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let g=0;g<u.length;g+=2)a[n++]=u[g],a[n++]=u[g+1],a[n++]=h[g],a[n++]=h[g+1],o[n++]=p,a[n++]=d;for(let g=0;g<c.length;g++)i[s++]=l+c[g]}};Yn.defaultBatchSize=4096,Yn.extension={name:"batch",type:Z.RendererPlugin},Yn._drawCallPool=[],Yn._textureArrayPool=[];let yi=Yn;ht.add(yi);var _E=`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
- `,_E=`attribute vec2 aVertexPosition;
352
+ `,vE=`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 Yl=class es extends ur{constructor(t,e,i){const n=Er.from(t||es.defaultVertexSrc,e||es.defaultFragmentSrc);super(n,i),this.padding=0,this.resolution=es.defaultResolution,this.multisample=es.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new cr}apply(t,e,i,n,s){t.applyFilter(this,e,i,n)}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 _E}static get defaultFragmentSrc(){return yE}};Yl.defaultResolution=1,Yl.defaultMultisample=ee.NONE;let Ce=Yl;class no{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Mt(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:n}=t,s=i??e;s!==void 0&&(this.color=s),this.alpha=n}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(){}}no.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},no.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"background"},ht.add(no);class zf{constructor(t){this.renderer=t,this.emptyRenderer=new io(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 n=e-1;n>=0;--n)t[n]=i[n]||null,t[n]&&(t[n]._batchLocation=n)}boundArray(t,e,i,n){const{elements:s,ids:o,count:a}=t;let l=0;for(let h=0;h<a;h++){const c=s[h],u=c._batchLocation;if(u>=0&&u<n&&e[u]===c){o[h]=u;continue}for(;l<n;){const d=e[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,c._batchLocation=l,e[l]=c;break}}}destroy(){this.renderer=null}}zf.extension={type:Z.RendererSystem,name:"batch"},ht.add(zf);let jf=0;class so{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=jf++}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=jf++,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(tt.PREFER_ENV>=ii.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 n=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=n,n||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}so.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},so.extension={type:Z.RendererSystem,name:"context"},ht.add(so);class ql{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 Ve("disposeFramebuffer"),this.multisample=ee.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new bt(null,{scaleMode:mr.NEAREST,resolution:1,mipmap:rr.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new bt(null,{scaleMode:mr.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:rr.OFF,format:j.DEPTH_COMPONENT,type:pt.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 n=this.colorTextures[i],s=n.resolution;n.setSize(t/s,e/s)}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 Wf extends bt{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],n=arguments[2],s=arguments[3];t={width:e,height:i,scaleMode:n,resolution:s}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=ee.NONE),super(null,t),this.mipmap=rr.OFF,this.valid=!0,this._clear=new Mt([0,0,0,0]),this.framebuffer=new ql(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 Tr extends zn{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.displayWidth||e.width,n=e.naturalHeight||e.videoHeight||e.displayHeight||e.height;super(i,n),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=$w(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,n){const s=t.gl,o=e.realWidth,a=e.realHeight;if(n=n||this.source,typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement){if(!n.complete||n.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement&&n.readyState<=1)return!1;return s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Re.UNPACK),!this.noSubImage&&e.target===s.TEXTURE_2D&&i.width===o&&i.height===a?s.texSubImage2D(s.TEXTURE_2D,0,0,0,e.format,i.type,n):(i.width=o,i.height=a,s.texImage2D(e.target,0,i.internalFormat,e.format,i.type,n)),!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 Yf extends Tr{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;Tr.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??tt.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 n=this.source;this.url=n.src;const s=()=>{this.destroyed||(n.onload=null,n.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};n.complete&&n.src?s():(n.onload=s,n.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(n=>n.blob()).then(n=>e(n,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Re.UNPACK?"premultiply":"none"})).then(n=>this.destroyed?Promise.reject():(this.bitmap=n,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 n=!0;const s=e._glTextures;for(const o in s){const a=s[o];if(a!==i&&a.dirtyId!==e.dirtyId){n=!1;break}}n&&(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 Kl{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 n=e.width,s=e.height;if(i){const o=t.width/2/n,a=t.height/2/s,l=t.x/n+o,h=t.y/s+a;i=Ht.add(i,Ht.NW),this.x0=l+o*Ht.uX(i),this.y0=h+a*Ht.uY(i),i=Ht.add(i,2),this.x1=l+o*Ht.uX(i),this.y1=h+a*Ht.uY(i),i=Ht.add(i,2),this.x2=l+o*Ht.uX(i),this.y2=h+a*Ht.uY(i),i=Ht.add(i,2),this.x3=l+o*Ht.uX(i),this.y3=h+a*Ht.uY(i)}else this.x0=t.x/n,this.y0=t.y/s,this.x1=(t.x+t.width)/n,this.y1=t.y/s,this.x2=(t.x+t.width)/n,this.y2=(t.y+t.height)/s,this.x3=t.x/n,this.y3=(t.y+t.height)/s;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}}Kl.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 qf=new Kl;function oo(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class ct extends Rn{constructor(t,e,i,n,s,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new wt(0,0,1,1)),t instanceof ct&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=n,this.valid=!1,this.destroyed=!1,this._uvs=qf,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(s||0),s===!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 It(o.x,o.y):new It(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&&hr[e.url]&&ct.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,ct.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var n;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),i=new ct(this.baseTexture,!this.noFrame&&t,e,(n=this.trim)==null?void 0:n.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===qf&&(this._uvs=new Kl),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=tt.STRICT_TEXTURE_CACHE){const n=typeof t=="string";let s=null;if(n)s=t;else if(t instanceof bt){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${hi()}`,bt.addToCache(t,t.cacheId)}s=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${hi()}`}s=t._pixiId}let o=hr[s];if(n&&i&&!o)throw new Error(`The cacheId "${s}" does not exist in TextureCache.`);return!o&&!(t instanceof bt)?(e.resolution||(e.resolution=xr(t)),o=new ct(new bt(t,e)),o.baseTexture.cacheId=s,bt.addToCache(o.baseTexture,s),ct.addToCache(o,s)):!o&&t instanceof bt&&(o=new ct(t),ct.addToCache(o,s)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),n=ct.from(t,Object.assign({resourceOptions:i},e),!1),s=n.baseTexture.resource;return n.baseTexture.valid?Promise.resolve(n):s.load().then(()=>Promise.resolve(n))}static fromBuffer(t,e,i,n){return new ct(bt.fromBuffer(t,e,i,n))}static fromLoader(t,e,i,n){const s=new bt(t,Object.assign({scaleMode:bt.defaultOptions.scaleMode,resolution:xr(e)},n)),{resource:o}=s;o instanceof Yf&&(o.url=e);const a=new ct(s);return i||(i=e),bt.addToCache(a.baseTexture,i),ct.addToCache(a,i),i!==e&&(bt.addToCache(a.baseTexture,e),ct.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),hr[e]&&hr[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),hr[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=hr[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete hr[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)hr[t.textureCacheIds[e]]===t&&delete hr[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:n,height:s}=t,o=e+n>this.baseTexture.width,a=i+s>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${e} + ${n} = ${e+n} > ${this.baseTexture.width}`,c=`Y: ${i} + ${s} = ${i+s} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${c}`)}this.valid=n&&s&&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 ct._EMPTY||(ct._EMPTY=new ct(new bt),oo(ct._EMPTY),oo(ct._EMPTY.baseTexture)),ct._EMPTY}static get WHITE(){if(!ct._WHITE){const t=tt.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),ct._WHITE=new ct(bt.from(t)),oo(ct._WHITE),oo(ct._WHITE.baseTexture)}return ct._WHITE}}class gi extends ct{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 n=this.baseTexture.resolution,s=Math.round(t*n)/n,o=Math.round(e*n)/n;this.valid=s>0&&o>0,this._frame.width=this.orig.width=s,this._frame.height=this.orig.height=o,i&&this.baseTexture.resize(s,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 gi(new Wf(t))}}class Kf{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=ee.NONE){const n=new Wf(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new gi(n)}getOptimalTexture(t,e,i=1,n=ee.NONE){let s;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=zs(t),e=zs(e),s=((t&65535)<<16|e&65535)>>>0,n>1&&(s+=n*4294967296)):s=n>1?-n:-1,this.texturePool[s]||(this.texturePool[s]=[]);let o=this.texturePool[s].pop();return o||(o=this.createTexture(t,e,n)),o.filterPoolKey=s,o.setResolution(i),o}getFilterTexture(t,e,i){const n=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||ee.NONE);return n.filterFrame=t.filterFrame,n}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 n=0;n<i.length;n++)i[n].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 n=0;n<i.length;n++)i[n].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Kf.SCREEN_KEY=-1;class vE extends Gr{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Zf extends Gr{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 Jt(this.vertices),this.uvBuffer=new Jt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,n=0;return this.uvs[0]=i,this.uvs[1]=n,this.uvs[2]=i+e.width/t.width,this.uvs[3]=n,this.uvs[4]=i+e.width/t.width,this.uvs[5]=n+e.height/t.height,this.uvs[6]=i,this.uvs[7]=n+e.height/t.height,i=e.x,n=e.y,this.vertices[0]=i,this.vertices[1]=n,this.vertices[2]=i+e.width,this.vertices[3]=n,this.vertices[4]=i+e.width,this.vertices[5]=n+e.height,this.vertices[6]=i,this.vertices[7]=n+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class bE{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=ee.NONE,this.sourceFrame=new wt,this.destinationFrame=new wt,this.bindingSourceFrame=new wt,this.bindingDestinationFrame=new wt,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const ao=[new It,new It,new It,new It],Zl=new kt;class Jf{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Kf,this.statePool=[],this.quad=new vE,this.quadUv=new Zf,this.tempRect=new wt,this.activeState={},this.globalUniforms=new ze({outputFrame:new wt,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,n=this.defaultFilterStack,s=this.statePool.pop()||new bE,o=i.renderTexture;let a,l;if(o.current){const y=o.current;a=y.resolution,l=y.multisample}else a=i.resolution,l=i.multisample;let h=e[0].resolution||a,c=e[0].multisample??l,u=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let y=1;y<e.length;y++){const _=e[y];h=Math.min(h,_.resolution||a),c=Math.min(c,_.multisample??l),u=this.useMaxPadding?Math.max(u,_.padding):u+_.padding,d=d&&_.autoFit,f=f||(_.legacy??!0)}n.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),n.push(s),s.resolution=h,s.multisample=c,s.legacy=f,s.target=t,s.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),s.sourceFrame.pad(u);const p=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(Zl.copyFrom(i.projection.transform).invert(),p),d?(s.sourceFrame.fit(p),(s.sourceFrame.width<=0||s.sourceFrame.height<=0)&&(s.sourceFrame.width=0,s.sourceFrame.height=0)):s.sourceFrame.intersects(p)||(s.sourceFrame.width=0,s.sourceFrame.height=0),this.roundFrame(s.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),s.renderTexture=this.getOptimalFilterTexture(s.sourceFrame.width,s.sourceFrame.height,h,c),s.filters=e,s.destinationFrame.width=s.renderTexture.width,s.destinationFrame.height=s.renderTexture.height;const g=this.tempRect;g.x=0,g.y=0,g.width=s.sourceFrame.width,g.height=s.sourceFrame.height,s.renderTexture.filterFrame=s.sourceFrame,s.bindingSourceFrame.copyFrom(o.sourceFrame),s.bindingDestinationFrame.copyFrom(o.destinationFrame),s.transform=i.projection.transform,i.projection.transform=null,o.bind(s.renderTexture,s.sourceFrame,g),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const n=this.globalUniforms.uniforms;n.outputFrame=e.sourceFrame,n.resolution=e.resolution;const s=n.inputSize,o=n.inputPixel,a=n.inputClamp;if(s[0]=e.destinationFrame.width,s[1]=e.destinationFrame.height,s[2]=1/s[0],s[3]=1/s[1],o[0]=Math.round(s[0]*e.resolution),o[1]=Math.round(s[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*s[2]-.5*o[2],a[3]=e.sourceFrame.height*s[3]-.5*o[3],e.legacy){const h=n.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,n.filterClamp=n.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,ir.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,c=this.getOptimalFilterTexture(h.width,h.height,e.resolution);c.filterFrame=h.filterFrame;let u=0;for(u=0;u<i.length-1;++u){u===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(h.width,h.height,e.resolution),c.filterFrame=h.filterFrame),i[u].apply(this,h,c,ir.CLEAR,e);const d=h;h=c,c=d}i[u].apply(this,h,l.renderTexture,ir.BLEND,e),u>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(c)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=ir.CLEAR){const{renderTexture:i,state:n}=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 s=n.stateId&1||this.forceClear;(e===ir.CLEAR||e===ir.BLIT&&s)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,n){const s=this.renderer;s.state.set(t.state),this.bindAndClear(i,n),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,s.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),s.geometry.bind(this.quadUv),s.geometry.draw(er.TRIANGLES)):(s.geometry.bind(this.quad),s.geometry.draw(er.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:n}=this.activeState,{orig:s}=e._texture,o=t.set(n.width,0,0,n.height,i.x,i.y),a=e.worldTransform.copyTo(kt.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/s.width,1/s.height),o.translate(e.anchor.x,e.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,n=ee.NONE){return this.texturePool.getOptimalTexture(t,e,i,n)}getFilterTexture(t,e,i){if(typeof t=="number"){const s=t;t=e,e=s}t=t||this.activeState.renderTexture;const n=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||ee.NONE);return n.filterFrame=t.filterFrame,n}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=ao[0],n=ao[1],s=ao[2],o=ao[3];i.set(e.left,e.top),n.set(e.left,e.bottom),s.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(i,i),t.apply(n,n),t.apply(s,s),t.apply(o,o);const a=Math.min(i.x,n.x,s.x,o.x),l=Math.min(i.y,n.y,s.y,o.y),h=Math.max(i.x,n.x,s.x,o.x),c=Math.max(i.y,n.y,s.y,o.y);e.x=a,e.y=l,e.width=h-a,e.height=c-l}roundFrame(t,e,i,n,s){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(s){const{a:o,b:a,c:l,d:h}=s;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(h)>1e-4))return}s=s?Zl.copyFrom(s):Zl.identity(),s.translate(-i.x,-i.y).scale(n.width/i.width,n.height/i.height).translate(n.x,n.y),this.transformAABB(s,t),t.ceil(e),this.transformAABB(s.invert(),t)}}}Jf.extension={type:Z.RendererSystem,name:"filter"},ht.add(Jf);class xE{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=ee.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const wE=new wt;class Qf{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new ql(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 wt,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;tt.PREFER_ENV===ii.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=n=>e.drawBuffersWEBGL(n):(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:n}=this;if(t){const s=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,n.bindFramebuffer(n.FRAMEBUFFER,s.framebuffer)),s.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,s.mipLevel=i),s.dirtyId!==t.dirtyId&&(s.dirtyId=t.dirtyId,s.dirtyFormat!==t.dirtyFormat?(s.dirtyFormat=t.dirtyFormat,s.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):s.dirtySize!==t.dirtySize&&(s.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,n.bindFramebuffer(n.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,n){const s=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),n=Math.round(n),(s.width!==i||s.height!==n||s.x!==t||s.y!==e)&&(s.x=t,s.y=e,s.width=i,s.height=n,this.gl.viewport(t,e,i,n))}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,n,s=Na.COLOR|Na.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,n),o.clear(s)}initFramebuffer(t){const{gl:e}=this,i=new xE(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 n=t.colorTextures;let s=n.length;e.drawBuffers||(s=Math.min(s,1));for(let o=0;o<s;o++){const a=n[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,n=t.glFramebuffers[this.CONTEXT_UID],s=t.colorTextures;let o=s.length;i.drawBuffers||(o=Math.min(o,1)),n.multisample>1&&this.canMultisampleFramebuffer(t)?n.msaaBuffer=n.msaaBuffer||i.createRenderbuffer():n.msaaBuffer&&(i.deleteRenderbuffer(n.msaaBuffer),n.msaaBuffer=null,n.blitFramebuffer&&(n.blitFramebuffer.dispose(),n.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=s[l],c=h.parentTextureArray||h;this.renderer.texture.bind(c,0),l===0&&n.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,n.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,c._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,c._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)){n.stencil=n.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,n.stencil),n.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,h,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,h,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,n.stencil)}else n.stencil&&(i.deleteRenderbuffer(n.stencil),n.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=ee.NONE;if(t<=1||e===null)return i;for(let n=0;n<e.length;n++)if(e[n]<=t){i=e[n];break}return i===1&&(i=ee.NONE),i}blit(t,e,i){const{current:n,renderer:s,gl:o,CONTEXT_UID:a}=this;if(s.context.webGLVersion!==2||!n)return;const l=n.glFramebuffers[a];if(!l)return;if(!t){if(!l.msaaBuffer)return;const c=n.colorTextures[0];if(!c)return;l.blitFramebuffer||(l.blitFramebuffer=new ql(n.width,n.height),l.blitFramebuffer.addColorTexture(0,c)),t=l.blitFramebuffer,t.colorTextures[0]!==c&&(t.colorTextures[0]=c,t.dirtyId++,t.dirtyFormat++),(t.width!==n.width||t.height!==n.height)&&(t.width=n.width,t.height=n.height,t.dirtyId++,t.dirtySize++)}e||(e=wE,e.width=n.width,e.height=n.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],n=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const s=this.managedFramebuffers.indexOf(t);s>=0&&this.managedFramebuffers.splice(s,1),t.disposeRunner.remove(this),e||(n.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&n.deleteRenderbuffer(i.msaaBuffer),i.stencil&&n.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,n=t.height,s=this.gl,o=e.stencil=s.createRenderbuffer();s.bindRenderbuffer(s.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=s.DEPTH_STENCIL_ATTACHMENT,l=s.DEPTH_STENCIL):t.depth?(a=s.DEPTH_STENCIL_ATTACHMENT,l=s.DEPTH24_STENCIL8):(a=s.STENCIL_ATTACHMENT,l=s.STENCIL_INDEX8),e.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,e.multisample,l,i,n):s.renderbufferStorage(s.RENDERBUFFER,l,i,n),s.framebufferRenderbuffer(s.FRAMEBUFFER,a,s.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new wt}destroy(){this.renderer=null}}Qf.extension={type:Z.RendererSystem,name:"framebuffer"},ht.add(Qf);const Jl={5126:4,5123:2,5121:1};class tp{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;tt.PREFER_ENV===ii.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=n=>i.bindVertexArrayOES(n),t.deleteVertexArray=n=>i.deleteVertexArrayOES(n)):(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=(n,s)=>i.vertexAttribDivisorANGLE(n,s),t.drawElementsInstanced=(n,s,o,a,l)=>i.drawElementsInstancedANGLE(n,s,o,a,l),t.drawArraysInstanced=(n,s,o,a)=>i.drawArraysInstancedANGLE(n,s,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 n=t.glVertexArrayObjects[this.CONTEXT_UID],s=!1;n||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=n={},s=!0);const o=n[e.program.id]||this.initGeometryVao(t,e,s);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 n=t.buffers[i];e.update(n)}}checkCompatibility(t,e){const i=t.attributes,n=e.attributeData;for(const s in n)if(!i[s])throw new Error(`shader and geometry incompatible, geometry missing the "${s}" attribute`)}getSignature(t,e){const i=t.attributes,n=e.attributeData,s=["g",t.id];for(const o in i)n[o]&&s.push(o,n[o].location);return s.join("-")}initGeometryVao(t,e,i=!0){const n=this.gl,s=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[s]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const l=this.getSignature(t,a),h=t.glVertexArrayObjects[this.CONTEXT_UID];let c=h[l];if(c)return h[a.id]=c,c;const u=t.buffers,d=t.attributes,f={},p={};for(const g in u)f[g]=0,p[g]=0;for(const g in d)!d[g].size&&a.attributeData[g]?d[g].size=a.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)`),f[d[g].buffer]+=d[g].size*Jl[d[g].type];for(const g in d){const y=d[g],_=y.size;y.stride===void 0&&(f[y.buffer]===_*Jl[y.type]?y.stride=0:y.stride=f[y.buffer]),y.start===void 0&&(y.start=p[y.buffer],p[y.buffer]+=_*Jl[y.type])}c=n.createVertexArray(),n.bindVertexArray(c);for(let g=0;g<u.length;g++){const y=u[g];o.bind(y),i&&y._glBuffers[s].refCount++}return this.activateVao(t,a),h[a.id]=c,h[l]=c,n.bindVertexArray(null),o.unbind(nr.ARRAY_BUFFER),c}disposeGeometry(t,e){var a;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],n=this.gl,s=t.buffers,o=(a=this.renderer)==null?void 0:a.buffer;if(t.disposeRunner.remove(this),!!i){if(o)for(let l=0;l<s.length;l++){const h=s[l]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&o.dispose(s[l],e))}if(!e){for(const l in i)if(l[0]==="g"){const h=i[l];this._activeVao===h&&this.unbind(),n.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,n=this.CONTEXT_UID,s=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&s.bind(t.indexBuffer);let l=null;for(const h in a){const c=a[h],u=o[c.buffer],d=u._glBuffers[n];if(e.attributeData[h]){l!==d&&(s.bind(u),l=d);const f=e.attributeData[h].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,c.size,c.type||i.FLOAT,c.normalized,c.stride,c.start),c.instance)if(this.hasInstance)i.vertexAttribDivisor(f,c.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,n){const{gl:s}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?s.UNSIGNED_SHORT:s.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?s.drawElementsInstanced(t,e||o.indexBuffer.data.length,l,(i||0)*a,n||1):s.drawElements(t,e||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?s.drawArraysInstanced(t,i,e||o.getSize(),n||1):s.drawArrays(t,i,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}tp.extension={type:Z.RendererSystem,name:"geometry"},ht.add(tp);const ep=new kt;class rp{constructor(t,e){this._texture=t,this.mapCoord=new kt,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 n=0;n<t.length;n+=2){const s=t[n],o=t[n+1];e[n]=s*i.a+o*i.c+i.tx,e[n+1]=s*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 n=e.orig,s=e.trim;s&&(ep.set(n.width/s.width,0,0,n.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(ep));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 EE=`varying vec2 vMaskCoord;
378
+ `;const ql=class rs extends dr{constructor(t,e,i){const n=Tr.from(t||rs.defaultVertexSrc,e||rs.defaultFragmentSrc);super(n,i),this.padding=0,this.resolution=rs.defaultResolution,this.multisample=rs.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new ur}apply(t,e,i,n,s){t.applyFilter(this,e,i,n)}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 vE}static get defaultFragmentSrc(){return _E}};ql.defaultResolution=1,ql.defaultMultisample=ee.NONE;let Ce=ql;class so{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Mt(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:n}=t,s=i??e;s!==void 0&&(this.color=s),this.alpha=n}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(){}}so.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},so.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"background"},ht.add(so);class jf{constructor(t){this.renderer=t,this.emptyRenderer=new no(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 n=e-1;n>=0;--n)t[n]=i[n]||null,t[n]&&(t[n]._batchLocation=n)}boundArray(t,e,i,n){const{elements:s,ids:o,count:a}=t;let l=0;for(let h=0;h<a;h++){const c=s[h],u=c._batchLocation;if(u>=0&&u<n&&e[u]===c){o[h]=u;continue}for(;l<n;){const d=e[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,c._batchLocation=l,e[l]=c;break}}}destroy(){this.renderer=null}}jf.extension={type:Z.RendererSystem,name:"batch"},ht.add(jf);let Wf=0;class oo{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=Wf++}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=Wf++,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(tt.PREFER_ENV>=si.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 n=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=n,n||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}oo.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},oo.extension={type:Z.RendererSystem,name:"context"},ht.add(oo);class Kl{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 ze("disposeFramebuffer"),this.multisample=ee.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new bt(null,{scaleMode:gr.NEAREST,resolution:1,mipmap:ir.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new bt(null,{scaleMode:gr.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:ir.OFF,format:j.DEPTH_COMPONENT,type:pt.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 n=this.colorTextures[i],s=n.resolution;n.setSize(t/s,e/s)}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 Yf extends bt{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],n=arguments[2],s=arguments[3];t={width:e,height:i,scaleMode:n,resolution:s}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=ee.NONE),super(null,t),this.mipmap=ir.OFF,this.valid=!0,this._clear=new Mt([0,0,0,0]),this.framebuffer=new Kl(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 Ar extends jn{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.displayWidth||e.width,n=e.naturalHeight||e.videoHeight||e.displayHeight||e.height;super(i,n),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=Hw(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,n){const s=t.gl,o=e.realWidth,a=e.realHeight;if(n=n||this.source,typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement){if(!n.complete||n.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement&&n.readyState<=1)return!1;return s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Re.UNPACK),!this.noSubImage&&e.target===s.TEXTURE_2D&&i.width===o&&i.height===a?s.texSubImage2D(s.TEXTURE_2D,0,0,0,e.format,i.type,n):(i.width=o,i.height=a,s.texImage2D(e.target,0,i.internalFormat,e.format,i.type,n)),!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 qf extends Ar{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;Ar.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??tt.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 n=this.source;this.url=n.src;const s=()=>{this.destroyed||(n.onload=null,n.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};n.complete&&n.src?s():(n.onload=s,n.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(n=>n.blob()).then(n=>e(n,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Re.UNPACK?"premultiply":"none"})).then(n=>this.destroyed?Promise.reject():(this.bitmap=n,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 n=!0;const s=e._glTextures;for(const o in s){const a=s[o];if(a!==i&&a.dirtyId!==e.dirtyId){n=!1;break}}n&&(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 Zl{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 n=e.width,s=e.height;if(i){const o=t.width/2/n,a=t.height/2/s,l=t.x/n+o,h=t.y/s+a;i=Ht.add(i,Ht.NW),this.x0=l+o*Ht.uX(i),this.y0=h+a*Ht.uY(i),i=Ht.add(i,2),this.x1=l+o*Ht.uX(i),this.y1=h+a*Ht.uY(i),i=Ht.add(i,2),this.x2=l+o*Ht.uX(i),this.y2=h+a*Ht.uY(i),i=Ht.add(i,2),this.x3=l+o*Ht.uX(i),this.y3=h+a*Ht.uY(i)}else this.x0=t.x/n,this.y0=t.y/s,this.x1=(t.x+t.width)/n,this.y1=t.y/s,this.x2=(t.x+t.width)/n,this.y2=(t.y+t.height)/s,this.x3=t.x/n,this.y3=(t.y+t.height)/s;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}}Zl.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 Kf=new Zl;function ao(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class ct extends Mn{constructor(t,e,i,n,s,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new wt(0,0,1,1)),t instanceof ct&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=n,this.valid=!1,this.destroyed=!1,this._uvs=Kf,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(s||0),s===!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 It(o.x,o.y):new It(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&&cr[e.url]&&ct.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,ct.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var n;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),i=new ct(this.baseTexture,!this.noFrame&&t,e,(n=this.trim)==null?void 0:n.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===Kf&&(this._uvs=new Zl),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=tt.STRICT_TEXTURE_CACHE){const n=typeof t=="string";let s=null;if(n)s=t;else if(t instanceof bt){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${ui()}`,bt.addToCache(t,t.cacheId)}s=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${ui()}`}s=t._pixiId}let o=cr[s];if(n&&i&&!o)throw new Error(`The cacheId "${s}" does not exist in TextureCache.`);return!o&&!(t instanceof bt)?(e.resolution||(e.resolution=wr(t)),o=new ct(new bt(t,e)),o.baseTexture.cacheId=s,bt.addToCache(o.baseTexture,s),ct.addToCache(o,s)):!o&&t instanceof bt&&(o=new ct(t),ct.addToCache(o,s)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),n=ct.from(t,Object.assign({resourceOptions:i},e),!1),s=n.baseTexture.resource;return n.baseTexture.valid?Promise.resolve(n):s.load().then(()=>Promise.resolve(n))}static fromBuffer(t,e,i,n){return new ct(bt.fromBuffer(t,e,i,n))}static fromLoader(t,e,i,n){const s=new bt(t,Object.assign({scaleMode:bt.defaultOptions.scaleMode,resolution:wr(e)},n)),{resource:o}=s;o instanceof qf&&(o.url=e);const a=new ct(s);return i||(i=e),bt.addToCache(a.baseTexture,i),ct.addToCache(a,i),i!==e&&(bt.addToCache(a.baseTexture,e),ct.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),cr[e]&&cr[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),cr[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=cr[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete cr[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)cr[t.textureCacheIds[e]]===t&&delete cr[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:n,height:s}=t,o=e+n>this.baseTexture.width,a=i+s>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${e} + ${n} = ${e+n} > ${this.baseTexture.width}`,c=`Y: ${i} + ${s} = ${i+s} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${c}`)}this.valid=n&&s&&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 ct._EMPTY||(ct._EMPTY=new ct(new bt),ao(ct._EMPTY),ao(ct._EMPTY.baseTexture)),ct._EMPTY}static get WHITE(){if(!ct._WHITE){const t=tt.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),ct._WHITE=new ct(bt.from(t)),ao(ct._WHITE),ao(ct._WHITE.baseTexture)}return ct._WHITE}}class _i extends ct{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 n=this.baseTexture.resolution,s=Math.round(t*n)/n,o=Math.round(e*n)/n;this.valid=s>0&&o>0,this._frame.width=this.orig.width=s,this._frame.height=this.orig.height=o,i&&this.baseTexture.resize(s,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 _i(new Yf(t))}}class Zf{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=ee.NONE){const n=new Yf(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new _i(n)}getOptimalTexture(t,e,i=1,n=ee.NONE){let s;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=js(t),e=js(e),s=((t&65535)<<16|e&65535)>>>0,n>1&&(s+=n*4294967296)):s=n>1?-n:-1,this.texturePool[s]||(this.texturePool[s]=[]);let o=this.texturePool[s].pop();return o||(o=this.createTexture(t,e,n)),o.filterPoolKey=s,o.setResolution(i),o}getFilterTexture(t,e,i){const n=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||ee.NONE);return n.filterFrame=t.filterFrame,n}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 n=0;n<i.length;n++)i[n].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 n=0;n<i.length;n++)i[n].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Zf.SCREEN_KEY=-1;class bE extends Hr{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Qf extends Hr{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 Qt(this.vertices),this.uvBuffer=new Qt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,n=0;return this.uvs[0]=i,this.uvs[1]=n,this.uvs[2]=i+e.width/t.width,this.uvs[3]=n,this.uvs[4]=i+e.width/t.width,this.uvs[5]=n+e.height/t.height,this.uvs[6]=i,this.uvs[7]=n+e.height/t.height,i=e.x,n=e.y,this.vertices[0]=i,this.vertices[1]=n,this.vertices[2]=i+e.width,this.vertices[3]=n,this.vertices[4]=i+e.width,this.vertices[5]=n+e.height,this.vertices[6]=i,this.vertices[7]=n+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class xE{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=ee.NONE,this.sourceFrame=new wt,this.destinationFrame=new wt,this.bindingSourceFrame=new wt,this.bindingDestinationFrame=new wt,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const lo=[new It,new It,new It,new It],Ql=new kt;class Jf{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Zf,this.statePool=[],this.quad=new bE,this.quadUv=new Qf,this.tempRect=new wt,this.activeState={},this.globalUniforms=new je({outputFrame:new wt,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,n=this.defaultFilterStack,s=this.statePool.pop()||new xE,o=i.renderTexture;let a,l;if(o.current){const y=o.current;a=y.resolution,l=y.multisample}else a=i.resolution,l=i.multisample;let h=e[0].resolution||a,c=e[0].multisample??l,u=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let y=1;y<e.length;y++){const _=e[y];h=Math.min(h,_.resolution||a),c=Math.min(c,_.multisample??l),u=this.useMaxPadding?Math.max(u,_.padding):u+_.padding,d=d&&_.autoFit,f=f||(_.legacy??!0)}n.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),n.push(s),s.resolution=h,s.multisample=c,s.legacy=f,s.target=t,s.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),s.sourceFrame.pad(u);const p=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(Ql.copyFrom(i.projection.transform).invert(),p),d?(s.sourceFrame.fit(p),(s.sourceFrame.width<=0||s.sourceFrame.height<=0)&&(s.sourceFrame.width=0,s.sourceFrame.height=0)):s.sourceFrame.intersects(p)||(s.sourceFrame.width=0,s.sourceFrame.height=0),this.roundFrame(s.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),s.renderTexture=this.getOptimalFilterTexture(s.sourceFrame.width,s.sourceFrame.height,h,c),s.filters=e,s.destinationFrame.width=s.renderTexture.width,s.destinationFrame.height=s.renderTexture.height;const g=this.tempRect;g.x=0,g.y=0,g.width=s.sourceFrame.width,g.height=s.sourceFrame.height,s.renderTexture.filterFrame=s.sourceFrame,s.bindingSourceFrame.copyFrom(o.sourceFrame),s.bindingDestinationFrame.copyFrom(o.destinationFrame),s.transform=i.projection.transform,i.projection.transform=null,o.bind(s.renderTexture,s.sourceFrame,g),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const n=this.globalUniforms.uniforms;n.outputFrame=e.sourceFrame,n.resolution=e.resolution;const s=n.inputSize,o=n.inputPixel,a=n.inputClamp;if(s[0]=e.destinationFrame.width,s[1]=e.destinationFrame.height,s[2]=1/s[0],s[3]=1/s[1],o[0]=Math.round(s[0]*e.resolution),o[1]=Math.round(s[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*s[2]-.5*o[2],a[3]=e.sourceFrame.height*s[3]-.5*o[3],e.legacy){const h=n.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,n.filterClamp=n.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,nr.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,c=this.getOptimalFilterTexture(h.width,h.height,e.resolution);c.filterFrame=h.filterFrame;let u=0;for(u=0;u<i.length-1;++u){u===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(h.width,h.height,e.resolution),c.filterFrame=h.filterFrame),i[u].apply(this,h,c,nr.CLEAR,e);const d=h;h=c,c=d}i[u].apply(this,h,l.renderTexture,nr.BLEND,e),u>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(c)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=nr.CLEAR){const{renderTexture:i,state:n}=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 s=n.stateId&1||this.forceClear;(e===nr.CLEAR||e===nr.BLIT&&s)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,n){const s=this.renderer;s.state.set(t.state),this.bindAndClear(i,n),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,s.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),s.geometry.bind(this.quadUv),s.geometry.draw(rr.TRIANGLES)):(s.geometry.bind(this.quad),s.geometry.draw(rr.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:n}=this.activeState,{orig:s}=e._texture,o=t.set(n.width,0,0,n.height,i.x,i.y),a=e.worldTransform.copyTo(kt.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/s.width,1/s.height),o.translate(e.anchor.x,e.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,n=ee.NONE){return this.texturePool.getOptimalTexture(t,e,i,n)}getFilterTexture(t,e,i){if(typeof t=="number"){const s=t;t=e,e=s}t=t||this.activeState.renderTexture;const n=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||ee.NONE);return n.filterFrame=t.filterFrame,n}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=lo[0],n=lo[1],s=lo[2],o=lo[3];i.set(e.left,e.top),n.set(e.left,e.bottom),s.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(i,i),t.apply(n,n),t.apply(s,s),t.apply(o,o);const a=Math.min(i.x,n.x,s.x,o.x),l=Math.min(i.y,n.y,s.y,o.y),h=Math.max(i.x,n.x,s.x,o.x),c=Math.max(i.y,n.y,s.y,o.y);e.x=a,e.y=l,e.width=h-a,e.height=c-l}roundFrame(t,e,i,n,s){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(s){const{a:o,b:a,c:l,d:h}=s;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(h)>1e-4))return}s=s?Ql.copyFrom(s):Ql.identity(),s.translate(-i.x,-i.y).scale(n.width/i.width,n.height/i.height).translate(n.x,n.y),this.transformAABB(s,t),t.ceil(e),this.transformAABB(s.invert(),t)}}}Jf.extension={type:Z.RendererSystem,name:"filter"},ht.add(Jf);class wE{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=ee.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const EE=new wt;class tp{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Kl(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 wt,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;tt.PREFER_ENV===si.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=n=>e.drawBuffersWEBGL(n):(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:n}=this;if(t){const s=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,n.bindFramebuffer(n.FRAMEBUFFER,s.framebuffer)),s.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,s.mipLevel=i),s.dirtyId!==t.dirtyId&&(s.dirtyId=t.dirtyId,s.dirtyFormat!==t.dirtyFormat?(s.dirtyFormat=t.dirtyFormat,s.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):s.dirtySize!==t.dirtySize&&(s.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,n.bindFramebuffer(n.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,n){const s=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),n=Math.round(n),(s.width!==i||s.height!==n||s.x!==t||s.y!==e)&&(s.x=t,s.y=e,s.width=i,s.height=n,this.gl.viewport(t,e,i,n))}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,n,s=Fa.COLOR|Fa.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,n),o.clear(s)}initFramebuffer(t){const{gl:e}=this,i=new wE(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 n=t.colorTextures;let s=n.length;e.drawBuffers||(s=Math.min(s,1));for(let o=0;o<s;o++){const a=n[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,n=t.glFramebuffers[this.CONTEXT_UID],s=t.colorTextures;let o=s.length;i.drawBuffers||(o=Math.min(o,1)),n.multisample>1&&this.canMultisampleFramebuffer(t)?n.msaaBuffer=n.msaaBuffer||i.createRenderbuffer():n.msaaBuffer&&(i.deleteRenderbuffer(n.msaaBuffer),n.msaaBuffer=null,n.blitFramebuffer&&(n.blitFramebuffer.dispose(),n.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=s[l],c=h.parentTextureArray||h;this.renderer.texture.bind(c,0),l===0&&n.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,n.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,c._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,c._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)){n.stencil=n.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,n.stencil),n.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,h,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,h,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,n.stencil)}else n.stencil&&(i.deleteRenderbuffer(n.stencil),n.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=ee.NONE;if(t<=1||e===null)return i;for(let n=0;n<e.length;n++)if(e[n]<=t){i=e[n];break}return i===1&&(i=ee.NONE),i}blit(t,e,i){const{current:n,renderer:s,gl:o,CONTEXT_UID:a}=this;if(s.context.webGLVersion!==2||!n)return;const l=n.glFramebuffers[a];if(!l)return;if(!t){if(!l.msaaBuffer)return;const c=n.colorTextures[0];if(!c)return;l.blitFramebuffer||(l.blitFramebuffer=new Kl(n.width,n.height),l.blitFramebuffer.addColorTexture(0,c)),t=l.blitFramebuffer,t.colorTextures[0]!==c&&(t.colorTextures[0]=c,t.dirtyId++,t.dirtyFormat++),(t.width!==n.width||t.height!==n.height)&&(t.width=n.width,t.height=n.height,t.dirtyId++,t.dirtySize++)}e||(e=EE,e.width=n.width,e.height=n.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],n=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const s=this.managedFramebuffers.indexOf(t);s>=0&&this.managedFramebuffers.splice(s,1),t.disposeRunner.remove(this),e||(n.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&n.deleteRenderbuffer(i.msaaBuffer),i.stencil&&n.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,n=t.height,s=this.gl,o=e.stencil=s.createRenderbuffer();s.bindRenderbuffer(s.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=s.DEPTH_STENCIL_ATTACHMENT,l=s.DEPTH_STENCIL):t.depth?(a=s.DEPTH_STENCIL_ATTACHMENT,l=s.DEPTH24_STENCIL8):(a=s.STENCIL_ATTACHMENT,l=s.STENCIL_INDEX8),e.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,e.multisample,l,i,n):s.renderbufferStorage(s.RENDERBUFFER,l,i,n),s.framebufferRenderbuffer(s.FRAMEBUFFER,a,s.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new wt}destroy(){this.renderer=null}}tp.extension={type:Z.RendererSystem,name:"framebuffer"},ht.add(tp);const Jl={5126:4,5123:2,5121:1};class ep{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;tt.PREFER_ENV===si.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=n=>i.bindVertexArrayOES(n),t.deleteVertexArray=n=>i.deleteVertexArrayOES(n)):(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=(n,s)=>i.vertexAttribDivisorANGLE(n,s),t.drawElementsInstanced=(n,s,o,a,l)=>i.drawElementsInstancedANGLE(n,s,o,a,l),t.drawArraysInstanced=(n,s,o,a)=>i.drawArraysInstancedANGLE(n,s,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 n=t.glVertexArrayObjects[this.CONTEXT_UID],s=!1;n||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=n={},s=!0);const o=n[e.program.id]||this.initGeometryVao(t,e,s);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 n=t.buffers[i];e.update(n)}}checkCompatibility(t,e){const i=t.attributes,n=e.attributeData;for(const s in n)if(!i[s])throw new Error(`shader and geometry incompatible, geometry missing the "${s}" attribute`)}getSignature(t,e){const i=t.attributes,n=e.attributeData,s=["g",t.id];for(const o in i)n[o]&&s.push(o,n[o].location);return s.join("-")}initGeometryVao(t,e,i=!0){const n=this.gl,s=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[s]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const l=this.getSignature(t,a),h=t.glVertexArrayObjects[this.CONTEXT_UID];let c=h[l];if(c)return h[a.id]=c,c;const u=t.buffers,d=t.attributes,f={},p={};for(const g in u)f[g]=0,p[g]=0;for(const g in d)!d[g].size&&a.attributeData[g]?d[g].size=a.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)`),f[d[g].buffer]+=d[g].size*Jl[d[g].type];for(const g in d){const y=d[g],_=y.size;y.stride===void 0&&(f[y.buffer]===_*Jl[y.type]?y.stride=0:y.stride=f[y.buffer]),y.start===void 0&&(y.start=p[y.buffer],p[y.buffer]+=_*Jl[y.type])}c=n.createVertexArray(),n.bindVertexArray(c);for(let g=0;g<u.length;g++){const y=u[g];o.bind(y),i&&y._glBuffers[s].refCount++}return this.activateVao(t,a),h[a.id]=c,h[l]=c,n.bindVertexArray(null),o.unbind(sr.ARRAY_BUFFER),c}disposeGeometry(t,e){var a;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],n=this.gl,s=t.buffers,o=(a=this.renderer)==null?void 0:a.buffer;if(t.disposeRunner.remove(this),!!i){if(o)for(let l=0;l<s.length;l++){const h=s[l]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&o.dispose(s[l],e))}if(!e){for(const l in i)if(l[0]==="g"){const h=i[l];this._activeVao===h&&this.unbind(),n.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,n=this.CONTEXT_UID,s=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&s.bind(t.indexBuffer);let l=null;for(const h in a){const c=a[h],u=o[c.buffer],d=u._glBuffers[n];if(e.attributeData[h]){l!==d&&(s.bind(u),l=d);const f=e.attributeData[h].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,c.size,c.type||i.FLOAT,c.normalized,c.stride,c.start),c.instance)if(this.hasInstance)i.vertexAttribDivisor(f,c.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,n){const{gl:s}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?s.UNSIGNED_SHORT:s.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?s.drawElementsInstanced(t,e||o.indexBuffer.data.length,l,(i||0)*a,n||1):s.drawElements(t,e||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?s.drawArraysInstanced(t,i,e||o.getSize(),n||1):s.drawArrays(t,i,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}ep.extension={type:Z.RendererSystem,name:"geometry"},ht.add(ep);const rp=new kt;class ip{constructor(t,e){this._texture=t,this.mapCoord=new kt,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 n=0;n<t.length;n+=2){const s=t[n],o=t[n+1];e[n]=s*i.a+o*i.c+i.tx,e[n+1]=s*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 n=e.orig,s=e.trim;s&&(rp.set(n.width/s.width,0,0,n.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(rp));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 TE=`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
- `,TE=`attribute vec2 aVertexPosition;
403
+ `,AE=`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 AE extends Ce{constructor(t,e,i){let n=null;typeof t!="string"&&e===void 0&&i===void 0&&(n=t,t=void 0,e=void 0,i=void 0),super(t||TE,e||EE,i),this.maskSprite=n,this.maskMatrix=new kt}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,n){const s=this._maskSprite,o=s._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new rp(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,s).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=s.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,t.applyFilter(this,e,i,n))}}class SE{constructor(t=null){this.type=ie.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Ce.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=ie.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 ip{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 s=this.maskDataPool.pop()||new SE;s.pooled=!0,s.maskObject=e,i=s}const n=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(n),i._colorMask=n?n._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==ie.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case ie.SCISSOR:this.renderer.scissor.push(i);break;case ie.STENCIL:this.renderer.stencil.push(i);break;case ie.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case ie.COLOR:this.pushColorMask(i);break}i.type===ie.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case ie.SCISSOR:this.renderer.scissor.pop(e);break;case ie.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case ie.SPRITE:this.popSpriteMask(e);break;case ie.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===ie.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=ie.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=ie.SCISSOR:t.type=ie.STENCIL:t.type=ie.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let n=t._filters;n||(n=this.alphaMaskPool[this.alphaMaskIndex],n||(n=this.alphaMaskPool[this.alphaMaskIndex]=[new AE])),n[0].resolution=t.resolution,n[0].multisample=t.multisample,n[0].maskSprite=e;const s=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,n),i.filterArea=s,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}}ip.extension={type:Z.RendererSystem,name:"mask"},ht.add(ip);class np{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 n=this.getStackLength();n!==i&&(n===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const sp=new kt,op=[],ap=class No extends np{constructor(t){super(t),this.glConst=tt.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:n}=this,s=n.renderTexture,o=i.getBounds(!0,op.pop()??new wt);this.roundFrameToPixels(o,s.current?s.current.resolution:n.resolution,s.sourceFrame,s.destinationFrame,n.projection.transform),e&&o.fit(e),t._scissorRectLocal=o}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:n,d:s}=t;return(Math.abs(i)>1e-4||Math.abs(n)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(s)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||No.isMatrixRotated(e.worldTransform)||No.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,n,s){No.isMatrixRotated(s)||(s=s?sp.copyFrom(s):sp.identity(),s.translate(-i.x,-i.y).scale(n.width/i.width,n.height/i.height).translate(n.x,n.y),this.renderer.filter.transformAABB(s,t),t.fit(n),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&&op.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)}};ap.extension={type:Z.RendererSystem,name:"scissor"};let CE=ap;ht.add(CE);class lp extends np{constructor(t){super(t),this.glConst=tt.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,n=t._stencilCounter;n===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const s=t._colorMask;s!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,n,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,s!==0&&(t._colorMask=s,i.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&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,n=i?i._colorMask:15;n!==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,n!==0&&(i._colorMask=n,e.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&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)}}lp.extension={type:Z.RendererSystem,name:"stencil"},ht.add(lp);class hp{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return At("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return At("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return At("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}}hp.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"_plugin"},ht.add(hp);class cp{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new kt,this.transform=null}update(t,e,i,n){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,n),this.transform&&this.projectionMatrix.append(this.transform);const s=this.renderer;s.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,s.globalUniforms.update(),s.shader.shader&&s.shader.syncUniformGroup(s.shader.shader.uniforms.globals)}calculateProjection(t,e,i,n){const s=this.projectionMatrix,o=n?-1:1;s.identity(),s.a=1/e.width*2,s.d=o*(1/e.height*2),s.tx=-1-e.x*s.a,s.ty=-o-e.y*s.d}setTransform(t){}destroy(){this.renderer=null}}cp.extension={type:Z.RendererSystem,name:"projection"},ht.add(cp);const IE=new Vl,up=new wt;class dp{constructor(t){this.renderer=t,this._tempMatrix=new kt}generateTexture(t,e){const{region:i,...n}=e||{},s=(i==null?void 0:i.copyTo(up))||t.getLocalBounds(up,!0),o=n.resolution||this.renderer.resolution;s.width=Math.max(s.width,1/o),s.height=Math.max(s.height,1/o),n.width=s.width,n.height=s.height,n.resolution=o,n.multisample??(n.multisample=this.renderer.multisample);const a=gi.create(n);this._tempMatrix.tx=-s.x,this._tempMatrix.ty=-s.y;const l=t.transform;return t.transform=IE,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}dp.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"textureGenerator"},ht.add(dp);const yi=new wt,Yn=new wt;class fp{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new wt,this.destinationFrame=new wt,this.viewportFrame=new wt}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 n=this.renderer;this.current=t;let s,o,a;t?(s=t.baseTexture,a=s.resolution,e||(yi.width=t.frame.width,yi.height=t.frame.height,e=yi),i||(Yn.x=t.frame.x,Yn.y=t.frame.y,Yn.width=e.width,Yn.height=e.height,i=Yn),o=s.framebuffer):(a=n.resolution,e||(yi.width=n._view.screen.width,yi.height=n._view.screen.height,e=yi),i||(i=yi,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=n.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(s.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,n=Mt.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&n.premultiply(n.alpha);const s=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=s.width!==o.width||s.height!==o.height;if(a){let{x:l,y:h,width:c,height:u}=this.viewportFrame;l=Math.round(l),h=Math.round(h),c=Math.round(c),u=Math.round(u),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,c,u)}this.renderer.framebuffer.clear(n.red,n.green,n.blue,n.alpha,e),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}fp.extension={type:Z.RendererSystem,name:"renderTexture"},ht.add(fp);class PE{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 RE(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){const s=t.getActiveAttrib(r,n);if(s.name.startsWith("gl_"))continue;const o=Xf(t,s.type),a={type:o,name:s.name,size:$f(o),location:t.getAttribLocation(r,s.name)};e[s.name]=a}return e}function ME(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let n=0;n<i;n++){const s=t.getActiveUniform(r,n),o=s.name.replace(/\[.*?\]$/,""),a=!!s.name.match(/\[.*?\]$/),l=Xf(t,s.type);e[o]={name:o,index:n,type:l,size:s.size,isArray:a,value:kf(l,s.size)}}return e}function DE(r,t){var a;const e=Ff(r,r.VERTEX_SHADER,t.vertexSrc),i=Ff(r,r.FRAGMENT_SHADER,t.fragmentSrc),n=r.createProgram();r.attachShader(n,e),r.attachShader(n,i);const s=(a=t.extra)==null?void 0:a.transformFeedbackVaryings;if(s&&(typeof r.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(n,s.names,s.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(n),r.getProgramParameter(n,r.LINK_STATUS)||aE(r,n,e,i),t.attributeData=RE(n,r),t.uniformData=ME(n,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((h,c)=>h>c?1:-1);for(let h=0;h<l.length;h++)t.attributeData[l[h]].location=h,r.bindAttribLocation(n,h,l[h]);r.linkProgram(n)}r.deleteShader(e),r.deleteShader(i);const o={};for(const l in t.uniformData){const h=t.uniformData[l];o[l]={location:r.getUniformLocation(n,l),value:kf(h.type,h.size)}}return new PE(n,o)}function BE(r,t,e,i,n){e.buffer.update(n)}const OE={float:`
419
+ `;class SE extends Ce{constructor(t,e,i){let n=null;typeof t!="string"&&e===void 0&&i===void 0&&(n=t,t=void 0,e=void 0,i=void 0),super(t||AE,e||TE,i),this.maskSprite=n,this.maskMatrix=new kt}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,n){const s=this._maskSprite,o=s._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new ip(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,s).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=s.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,t.applyFilter(this,e,i,n))}}class CE{constructor(t=null){this.type=ie.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Ce.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=ie.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 np{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 s=this.maskDataPool.pop()||new CE;s.pooled=!0,s.maskObject=e,i=s}const n=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(n),i._colorMask=n?n._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==ie.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case ie.SCISSOR:this.renderer.scissor.push(i);break;case ie.STENCIL:this.renderer.stencil.push(i);break;case ie.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case ie.COLOR:this.pushColorMask(i);break}i.type===ie.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case ie.SCISSOR:this.renderer.scissor.pop(e);break;case ie.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case ie.SPRITE:this.popSpriteMask(e);break;case ie.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===ie.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=ie.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=ie.SCISSOR:t.type=ie.STENCIL:t.type=ie.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let n=t._filters;n||(n=this.alphaMaskPool[this.alphaMaskIndex],n||(n=this.alphaMaskPool[this.alphaMaskIndex]=[new SE])),n[0].resolution=t.resolution,n[0].multisample=t.multisample,n[0].maskSprite=e;const s=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,n),i.filterArea=s,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}}np.extension={type:Z.RendererSystem,name:"mask"},ht.add(np);class sp{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 n=this.getStackLength();n!==i&&(n===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const op=new kt,ap=[],lp=class Fo extends sp{constructor(t){super(t),this.glConst=tt.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:n}=this,s=n.renderTexture,o=i.getBounds(!0,ap.pop()??new wt);this.roundFrameToPixels(o,s.current?s.current.resolution:n.resolution,s.sourceFrame,s.destinationFrame,n.projection.transform),e&&o.fit(e),t._scissorRectLocal=o}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:n,d:s}=t;return(Math.abs(i)>1e-4||Math.abs(n)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(s)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||Fo.isMatrixRotated(e.worldTransform)||Fo.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,n,s){Fo.isMatrixRotated(s)||(s=s?op.copyFrom(s):op.identity(),s.translate(-i.x,-i.y).scale(n.width/i.width,n.height/i.height).translate(n.x,n.y),this.renderer.filter.transformAABB(s,t),t.fit(n),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&&ap.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)}};lp.extension={type:Z.RendererSystem,name:"scissor"};let IE=lp;ht.add(IE);class hp extends sp{constructor(t){super(t),this.glConst=tt.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,n=t._stencilCounter;n===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const s=t._colorMask;s!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,n,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,s!==0&&(t._colorMask=s,i.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&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,n=i?i._colorMask:15;n!==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,n!==0&&(i._colorMask=n,e.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&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)}}hp.extension={type:Z.RendererSystem,name:"stencil"},ht.add(hp);class cp{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return At("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return At("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return At("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}}cp.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"_plugin"},ht.add(cp);class up{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new kt,this.transform=null}update(t,e,i,n){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,n),this.transform&&this.projectionMatrix.append(this.transform);const s=this.renderer;s.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,s.globalUniforms.update(),s.shader.shader&&s.shader.syncUniformGroup(s.shader.shader.uniforms.globals)}calculateProjection(t,e,i,n){const s=this.projectionMatrix,o=n?-1:1;s.identity(),s.a=1/e.width*2,s.d=o*(1/e.height*2),s.tx=-1-e.x*s.a,s.ty=-o-e.y*s.d}setTransform(t){}destroy(){this.renderer=null}}up.extension={type:Z.RendererSystem,name:"projection"},ht.add(up);const PE=new zl,dp=new wt;class fp{constructor(t){this.renderer=t,this._tempMatrix=new kt}generateTexture(t,e){const{region:i,...n}=e||{},s=(i==null?void 0:i.copyTo(dp))||t.getLocalBounds(dp,!0),o=n.resolution||this.renderer.resolution;s.width=Math.max(s.width,1/o),s.height=Math.max(s.height,1/o),n.width=s.width,n.height=s.height,n.resolution=o,n.multisample??(n.multisample=this.renderer.multisample);const a=_i.create(n);this._tempMatrix.tx=-s.x,this._tempMatrix.ty=-s.y;const l=t.transform;return t.transform=PE,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}fp.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"textureGenerator"},ht.add(fp);const vi=new wt,qn=new wt;class pp{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new wt,this.destinationFrame=new wt,this.viewportFrame=new wt}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 n=this.renderer;this.current=t;let s,o,a;t?(s=t.baseTexture,a=s.resolution,e||(vi.width=t.frame.width,vi.height=t.frame.height,e=vi),i||(qn.x=t.frame.x,qn.y=t.frame.y,qn.width=e.width,qn.height=e.height,i=qn),o=s.framebuffer):(a=n.resolution,e||(vi.width=n._view.screen.width,vi.height=n._view.screen.height,e=vi),i||(i=vi,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=n.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(s.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,n=Mt.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&n.premultiply(n.alpha);const s=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=s.width!==o.width||s.height!==o.height;if(a){let{x:l,y:h,width:c,height:u}=this.viewportFrame;l=Math.round(l),h=Math.round(h),c=Math.round(c),u=Math.round(u),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,c,u)}this.renderer.framebuffer.clear(n.red,n.green,n.blue,n.alpha,e),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}pp.extension={type:Z.RendererSystem,name:"renderTexture"},ht.add(pp);class RE{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 ME(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){const s=t.getActiveAttrib(r,n);if(s.name.startsWith("gl_"))continue;const o=Vf(t,s.type),a={type:o,name:s.name,size:Hf(o),location:t.getAttribLocation(r,s.name)};e[s.name]=a}return e}function DE(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let n=0;n<i;n++){const s=t.getActiveUniform(r,n),o=s.name.replace(/\[.*?\]$/,""),a=!!s.name.match(/\[.*?\]$/),l=Vf(t,s.type);e[o]={name:o,index:n,type:l,size:s.size,isArray:a,value:Uf(l,s.size)}}return e}function BE(r,t){var a;const e=kf(r,r.VERTEX_SHADER,t.vertexSrc),i=kf(r,r.FRAGMENT_SHADER,t.fragmentSrc),n=r.createProgram();r.attachShader(n,e),r.attachShader(n,i);const s=(a=t.extra)==null?void 0:a.transformFeedbackVaryings;if(s&&(typeof r.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(n,s.names,s.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(n),r.getProgramParameter(n,r.LINK_STATUS)||lE(r,n,e,i),t.attributeData=ME(n,r),t.uniformData=DE(n,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((h,c)=>h>c?1:-1);for(let h=0;h<l.length;h++)t.attributeData[l[h]].location=h,r.bindAttribLocation(n,h,l[h]);r.linkProgram(n)}r.deleteShader(e),r.deleteShader(i);const o={};for(const l in t.uniformData){const h=t.uniformData[l];o[l]={location:r.getUniformLocation(n,l),value:Uf(h.type,h.size)}}return new RE(n,o)}function OE(r,t,e,i,n){e.buffer.update(n)}const LE={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
- `},pp={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 LE(r){const t=r.map(s=>({data:s,offset:0,dataLen:0,dirty:0}));let e=0,i=0,n=0;for(let s=0;s<t.length;s++){const o=t[s];if(e=pp[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,n+=a}i+e>16?(n=Math.ceil(n/16)*16,o.offset=n,n+=e,i=e):(o.offset=n,i+=e,n+=e)}return n=Math.ceil(n/16)*16,{uboElements:t,size:n}}function NE(r,t){const e=[];for(const i in r)t[i]&&e.push(t[i]);return e.sort((i,n)=>i.index-n.index),e}function FE(r,t){if(!r.autoManage)return{size:0,syncFunc:BE};const e=NE(r.uniforms,t),{uboElements:i,size:n}=LE(e),s=[`
457
+ `},mp={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 NE(r){const t=r.map(s=>({data:s,offset:0,dataLen:0,dirty:0}));let e=0,i=0,n=0;for(let s=0;s<t.length;s++){const o=t[s];if(e=mp[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,n+=a}i+e>16?(n=Math.ceil(n/16)*16,o.offset=n,n+=e,i=e):(o.offset=n,i+=e,n+=e)}return n=Math.ceil(n/16)*16,{uboElements:t,size:n}}function FE(r,t){const e=[];for(const i in r)t[i]&&e.push(t[i]);return e.sort((i,n)=>i.index-n.index),e}function kE(r,t){if(!r.autoManage)return{size:0,syncFunc:OE};const e=FE(r.uniforms,t),{uboElements:i,size:n}=NE(e),s=[`
458
458
  var v = null;
459
459
  var v2 = null;
460
460
  var cv = null;
@@ -462,7 +462,7 @@ 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 c=!1;for(let u=0;u<Qi.length;u++){const d=Qi[u];if(d.codeUbo&&d.test(a.data,l)){s.push(`offset = ${a.offset/4};`,Qi[u].codeUbo(a.data.name,l)),c=!0;break}}if(!c)if(a.data.size>1){const u=$f(a.data.type),d=Math.max(pp[a.data.type]/16,1),f=u/d,p=(4-f%4)%4;s.push(`
465
+ `];for(let o=0;o<i.length;o++){const a=i[o],l=r.uniforms[a.data.name],h=a.data.name;let c=!1;for(let u=0;u<tn.length;u++){const d=tn[u];if(d.codeUbo&&d.test(a.data,l)){s.push(`offset = ${a.offset/4};`,tn[u].codeUbo(a.data.name,l)),c=!0;break}}if(!c)if(a.data.size>1){const u=Hf(a.data.type),d=Math.max(mp[a.data.type]/16,1),f=u/d,p=(4-f%4)%4;s.push(`
466
466
  cv = ud.${h}.value;
467
467
  v = uv.${h};
468
468
  offset = ${a.offset/4};
@@ -478,7 +478,7 @@ void main(void)
478
478
  offset += ${p};
479
479
  }
480
480
 
481
- `)}else{const u=OE[a.data.type];s.push(`
481
+ `)}else{const u=LE[a.data.type];s.push(`
482
482
  cv = ud.${h}.value;
483
483
  v = uv.${h};
484
484
  offset = ${a.offset/4};
@@ -486,7 +486,7 @@ void main(void)
486
486
  `)}}return s.push(`
487
487
  renderer.buffer.update(buffer);
488
488
  `),{size:n,syncFunc:new Function("ud","uv","renderer","syncData","buffer",s.join(`
489
- `))}}let kE=0;const lo={textureCount:0,uboCount:0};class mp{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=kE++}systemCheck(){if(!hE())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,n=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(n.program)),e||(lo.textureCount=0,lo.uboCount=0,this.syncUniformGroup(t.uniformGroup,lo)),n}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]=nE(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 n=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),n(i.uniformData,t.uniforms,this.renderer,lo,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:n}=this.renderer;this.renderer.buffer.bind(t.buffer);const s=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,n.uniformBlockBinding(e.program,s,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]=FE(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 n=t.uniforms,s=[`${i}-`];for(const o in n)s.push(o),e[o]&&s.push(e[o].type);return s.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,n=DE(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=n,n}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}mp.extension={type:Z.RendererSystem,name:"shader"},ht.add(mp);class ho{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.3 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}ho.defaultOptions={hello:!1},ho.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"startup"},ht.add(ho);function UE(r,t=[]){return t[vt.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.ADD]=[r.ONE,r.ONE],t[vt.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.NONE]=[0,0],t[vt.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[vt.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[vt.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[vt.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[vt.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[vt.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[vt.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[vt.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[vt.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[vt.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const GE=0,$E=1,HE=2,XE=3,VE=4,zE=5,gp=class Oh{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=vt.NONE,this._blendEq=!1,this.map=[],this.map[GE]=this.setBlend,this.map[$E]=this.setOffset,this.map[HE]=this.setCullFace,this.map[XE]=this.setDepthTest,this.map[VE]=this.setFrontFace,this.map[zE]=this.setDepthMask,this.checks=[],this.defaultState=new cr,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=UE(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(Oh.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Oh.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}};gp.extension={type:Z.RendererSystem,name:"state"};let jE=gp;ht.add(jE);class WE extends Rn{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(n=>t.systems[n]),i=[...e,...Object.keys(t.systems).filter(n=>!e.includes(n))];for(const n of i)this.addSystem(t.systems[n],n)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Ve(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 n in this.runners)this.runners[n].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(n=>{const s=i.find(o=>this._systemsHash[o]===n);n[t.name](e[s])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const qn=class Fo{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Fo.defaultMaxIdle,this.checkCountMax=Fo.defaultCheckCountMax,this.mode=Fo.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Fa.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 n=0;n<e.length;n++){const s=e[n];s.resource&&this.count-s.touched>this.maxIdle&&(t.destroyTexture(s,!0),e[n]=null,i=!0)}if(i){let n=0;for(let s=0;s<e.length;s++)e[s]!==null&&(e[n++]=e[s]);e.length=n}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let n=t.children.length-1;n>=0;n--)this.unload(t.children[n])}destroy(){this.renderer=null}};qn.defaultMode=Fa.AUTO,qn.defaultMaxIdle=60*60,qn.defaultCheckCountMax=60*10,qn.extension={type:Z.RendererSystem,name:"textureGC"};let _i=qn;ht.add(_i);class Ql{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=pt.UNSIGNED_BYTE,this.internalFormat=j.RGBA,this.samplerType=0}}function YE(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 qE(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[pt.UNSIGNED_BYTE]:{[j.RGBA]:r.RGBA8,[j.RGB]:r.RGB8,[j.RG]:r.RG8,[j.RED]:r.R8,[j.RGBA_INTEGER]:r.RGBA8UI,[j.RGB_INTEGER]:r.RGB8UI,[j.RG_INTEGER]:r.RG8UI,[j.RED_INTEGER]:r.R8UI,[j.ALPHA]:r.ALPHA,[j.LUMINANCE]:r.LUMINANCE,[j.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[pt.BYTE]:{[j.RGBA]:r.RGBA8_SNORM,[j.RGB]:r.RGB8_SNORM,[j.RG]:r.RG8_SNORM,[j.RED]:r.R8_SNORM,[j.RGBA_INTEGER]:r.RGBA8I,[j.RGB_INTEGER]:r.RGB8I,[j.RG_INTEGER]:r.RG8I,[j.RED_INTEGER]:r.R8I},[pt.UNSIGNED_SHORT]:{[j.RGBA_INTEGER]:r.RGBA16UI,[j.RGB_INTEGER]:r.RGB16UI,[j.RG_INTEGER]:r.RG16UI,[j.RED_INTEGER]:r.R16UI,[j.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[pt.SHORT]:{[j.RGBA_INTEGER]:r.RGBA16I,[j.RGB_INTEGER]:r.RGB16I,[j.RG_INTEGER]:r.RG16I,[j.RED_INTEGER]:r.R16I},[pt.UNSIGNED_INT]:{[j.RGBA_INTEGER]:r.RGBA32UI,[j.RGB_INTEGER]:r.RGB32UI,[j.RG_INTEGER]:r.RG32UI,[j.RED_INTEGER]:r.R32UI,[j.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[pt.INT]:{[j.RGBA_INTEGER]:r.RGBA32I,[j.RGB_INTEGER]:r.RGB32I,[j.RG_INTEGER]:r.RG32I,[j.RED_INTEGER]:r.R32I},[pt.FLOAT]:{[j.RGBA]:r.RGBA32F,[j.RGB]:r.RGB32F,[j.RG]:r.RG32F,[j.RED]:r.R32F,[j.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[pt.HALF_FLOAT]:{[j.RGBA]:r.RGBA16F,[j.RGB]:r.RGB16F,[j.RG]:r.RG16F,[j.RED]:r.R16F},[pt.UNSIGNED_SHORT_5_6_5]:{[j.RGB]:r.RGB565},[pt.UNSIGNED_SHORT_4_4_4_4]:{[j.RGBA]:r.RGBA4},[pt.UNSIGNED_SHORT_5_5_5_1]:{[j.RGBA]:r.RGB5_A1},[pt.UNSIGNED_INT_2_10_10_10_REV]:{[j.RGBA]:r.RGB10_A2,[j.RGBA_INTEGER]:r.RGB10_A2UI},[pt.UNSIGNED_INT_10F_11F_11F_REV]:{[j.RGB]:r.R11F_G11F_B10F},[pt.UNSIGNED_INT_5_9_9_9_REV]:{[j.RGB]:r.RGB9_E5},[pt.UNSIGNED_INT_24_8]:{[j.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[pt.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[j.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[pt.UNSIGNED_BYTE]:{[j.RGBA]:r.RGBA,[j.RGB]:r.RGB,[j.ALPHA]:r.ALPHA,[j.LUMINANCE]:r.LUMINANCE,[j.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[pt.UNSIGNED_SHORT_5_6_5]:{[j.RGB]:r.RGB},[pt.UNSIGNED_SHORT_4_4_4_4]:{[j.RGBA]:r.RGBA},[pt.UNSIGNED_SHORT_5_5_5_1]:{[j.RGBA]:r.RGBA}},t}class yp{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new bt,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=qE(t),this.samplerTypes=YE(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let n=0;n<e;n++)this.boundTextures[n]=null;this.emptyTextures={};const i=new Ql(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 Ql(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let n=0;n<6;n++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+n,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 n=0;n<this.boundTextures.length;n++)this.bind(null,n)}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 n=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,n.texture)),n.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):n.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 n=0;n<i.length;n++)i[n]===this.unknownTexture&&this.bind(null,n)}for(let n=0;n<i.length;n++)i[n]===t&&(this.currentLocation!==n&&(e.activeTexture(e.TEXTURE0+n),this.currentLocation=n),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[n]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:n}=this;if(i)for(let s=t-1;s>=0;--s){const o=e[s];o&&o._glTextures[n].samplerType!==Q.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Ql(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===pt.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var n;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const i=this.renderer;if(this.initTextureType(t,e),(n=t.resource)==null?void 0:n.upload(i,t,e))e.samplerType!==Q.FLOAT&&(this.hasIntegerTextures=!0);else{const s=t.realWidth,o=t.realHeight,a=i.gl;(e.width!==s||e.height!==o||e.dirtyId<0)&&(e.width=s,e.height=o,a.texImage2D(t.target,0,e.internalFormat,s,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 n=this.managedTextures.indexOf(t);n!==-1&&Ji(this.managedTextures,n,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===rr.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Lr.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!==rr.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===mr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const n=this.renderer.context.extensions.anisotropicFiltering;if(n&&t.anisotropicLevel>0&&t.scaleMode===mr.LINEAR){const s=Math.min(t.anisotropicLevel,i.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,n.TEXTURE_MAX_ANISOTROPY_EXT,s)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===mr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===mr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}yp.extension={type:Z.RendererSystem,name:"texture"},ht.add(yp);class _p{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,n=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:n}=this;e&&n.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:n}=this,s=e.createTransformFeedback();t._glTransformFeedbacks[n]=s,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];a&&(i.buffer.update(a),a._glBuffers[n].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[n].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),s}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],n=this.gl;t.disposeRunner.remove(this);const s=this.renderer.buffer;if(s)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&&s.dispose(a,e))}i&&(e||n.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}_p.extension={type:Z.RendererSystem,name:"transformFeedback"},ht.add(_p);class co{constructor(t){this.renderer=t}init(t){this.screen=new wt(0,0,t.width,t.height),this.element=t.view||tt.ADAPTER.createCanvas(),this.resolution=t.resolution||tt.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,n=this.element.height/this.resolution;this.screen.width=i,this.screen.height=n,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${n}px`),this.renderer.emit("resize",i,n),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}}co.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},co.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"_view"},ht.add(co),tt.PREFER_ENV=ii.WEBGL2,tt.STRICT_TEXTURE_CACHE=!1,tt.RENDER_OPTIONS={...so.defaultOptions,...no.defaultOptions,...co.defaultOptions,...ho.defaultOptions},Object.defineProperties(tt,{WRAP_MODE:{get(){return bt.defaultOptions.wrapMode},set(r){At("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),bt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return bt.defaultOptions.scaleMode},set(r){At("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),bt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return bt.defaultOptions.mipmap},set(r){At("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),bt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return bt.defaultOptions.anisotropicLevel},set(r){At("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),bt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return At("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Ce.defaultResolution},set(r){Ce.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return At("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Ce.defaultMultisample},set(r){Ce.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return mi.defaultMaxTextures},set(r){At("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),mi.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return mi.defaultBatchSize},set(r){At("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),mi.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return mi.canUploadSameBuffer},set(r){At("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),mi.canUploadSameBuffer=r}},GC_MODE:{get(){return _i.defaultMode},set(r){At("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),_i.defaultMode=r}},GC_MAX_IDLE:{get(){return _i.defaultMaxIdle},set(r){At("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),_i.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return _i.defaultCheckCountMax},set(r){At("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),_i.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return Er.defaultVertexPrecision},set(r){At("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Er.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return Er.defaultFragmentPrecision},set(r){At("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Er.defaultFragmentPrecision=r}}});var vi=(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))(vi||{});class th{constructor(t,e=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=n}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 vp=class Oe{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 th(null,null,1/0),this.deltaMS=1/Oe.targetFPMS,this.elapsedMS=1/Oe.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=vi.NORMAL){return this._addListener(new th(t,e,i))}addOnce(t,e,i=vi.NORMAL){return this._addListener(new th(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 s=t-this._lastFrame|0;if(s<this._minElapsedMS)return;this._lastFrame=t-s%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Oe.targetFPMS;const i=this._head;let n=i.next;for(;n;)n=n.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,Oe.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(!Oe._shared){const t=Oe._shared=new Oe;t.autoStart=!0,t._protected=!0}return Oe._shared}static get system(){if(!Oe._system){const t=Oe._system=new Oe;t.autoStart=!0,t._protected=!0}return Oe._system}};vp.targetFPMS=.06;let Be=vp;Object.defineProperties(tt,{TARGET_FPMS:{get(){return Be.targetFPMS},set(r){At("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),Be.targetFPMS=r}}});class bp{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,vi.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Be.shared:new Be,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}bp.extension=Z.Application,ht.add(bp);const xp=[];ht.handleByList(Z.Renderer,xp);function wp(r){for(const t of xp)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var KE=`attribute vec2 aVertexPosition;
489
+ `))}}let UE=0;const ho={textureCount:0,uboCount:0};class gp{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=UE++}systemCheck(){if(!cE())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,n=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(n.program)),e||(ho.textureCount=0,ho.uboCount=0,this.syncUniformGroup(t.uniformGroup,ho)),n}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]=sE(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 n=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),n(i.uniformData,t.uniforms,this.renderer,ho,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:n}=this.renderer;this.renderer.buffer.bind(t.buffer);const s=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,n.uniformBlockBinding(e.program,s,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]=kE(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 n=t.uniforms,s=[`${i}-`];for(const o in n)s.push(o),e[o]&&s.push(e[o].type);return s.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,n=BE(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=n,n}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}gp.extension={type:Z.RendererSystem,name:"shader"},ht.add(gp);class co{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.3 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}co.defaultOptions={hello:!1},co.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"startup"},ht.add(co);function GE(r,t=[]){return t[vt.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.ADD]=[r.ONE,r.ONE],t[vt.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.NONE]=[0,0],t[vt.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[vt.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[vt.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[vt.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[vt.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[vt.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[vt.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[vt.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[vt.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[vt.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[vt.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const $E=0,HE=1,XE=2,VE=3,zE=4,jE=5,yp=class Lh{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=vt.NONE,this._blendEq=!1,this.map=[],this.map[$E]=this.setBlend,this.map[HE]=this.setOffset,this.map[XE]=this.setCullFace,this.map[VE]=this.setDepthTest,this.map[zE]=this.setFrontFace,this.map[jE]=this.setDepthMask,this.checks=[],this.defaultState=new ur,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=GE(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(Lh.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Lh.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}};yp.extension={type:Z.RendererSystem,name:"state"};let WE=yp;ht.add(WE);class YE extends Mn{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(n=>t.systems[n]),i=[...e,...Object.keys(t.systems).filter(n=>!e.includes(n))];for(const n of i)this.addSystem(t.systems[n],n)}addRunners(...t){t.forEach(e=>{this.runners[e]=new ze(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 n in this.runners)this.runners[n].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(n=>{const s=i.find(o=>this._systemsHash[o]===n);n[t.name](e[s])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const Kn=class ko{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=ko.defaultMaxIdle,this.checkCountMax=ko.defaultCheckCountMax,this.mode=ko.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==ka.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 n=0;n<e.length;n++){const s=e[n];s.resource&&this.count-s.touched>this.maxIdle&&(t.destroyTexture(s,!0),e[n]=null,i=!0)}if(i){let n=0;for(let s=0;s<e.length;s++)e[s]!==null&&(e[n++]=e[s]);e.length=n}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let n=t.children.length-1;n>=0;n--)this.unload(t.children[n])}destroy(){this.renderer=null}};Kn.defaultMode=ka.AUTO,Kn.defaultMaxIdle=60*60,Kn.defaultCheckCountMax=60*10,Kn.extension={type:Z.RendererSystem,name:"textureGC"};let bi=Kn;ht.add(bi);class th{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=pt.UNSIGNED_BYTE,this.internalFormat=j.RGBA,this.samplerType=0}}function qE(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:J.FLOAT,[r.RGBA]:J.FLOAT,[r.ALPHA]:J.FLOAT,[r.LUMINANCE]:J.FLOAT,[r.LUMINANCE_ALPHA]:J.FLOAT,[r.R8]:J.FLOAT,[r.R8_SNORM]:J.FLOAT,[r.RG8]:J.FLOAT,[r.RG8_SNORM]:J.FLOAT,[r.RGB8]:J.FLOAT,[r.RGB8_SNORM]:J.FLOAT,[r.RGB565]:J.FLOAT,[r.RGBA4]:J.FLOAT,[r.RGB5_A1]:J.FLOAT,[r.RGBA8]:J.FLOAT,[r.RGBA8_SNORM]:J.FLOAT,[r.RGB10_A2]:J.FLOAT,[r.RGB10_A2UI]:J.FLOAT,[r.SRGB8]:J.FLOAT,[r.SRGB8_ALPHA8]:J.FLOAT,[r.R16F]:J.FLOAT,[r.RG16F]:J.FLOAT,[r.RGB16F]:J.FLOAT,[r.RGBA16F]:J.FLOAT,[r.R32F]:J.FLOAT,[r.RG32F]:J.FLOAT,[r.RGB32F]:J.FLOAT,[r.RGBA32F]:J.FLOAT,[r.R11F_G11F_B10F]:J.FLOAT,[r.RGB9_E5]:J.FLOAT,[r.R8I]:J.INT,[r.R8UI]:J.UINT,[r.R16I]:J.INT,[r.R16UI]:J.UINT,[r.R32I]:J.INT,[r.R32UI]:J.UINT,[r.RG8I]:J.INT,[r.RG8UI]:J.UINT,[r.RG16I]:J.INT,[r.RG16UI]:J.UINT,[r.RG32I]:J.INT,[r.RG32UI]:J.UINT,[r.RGB8I]:J.INT,[r.RGB8UI]:J.UINT,[r.RGB16I]:J.INT,[r.RGB16UI]:J.UINT,[r.RGB32I]:J.INT,[r.RGB32UI]:J.UINT,[r.RGBA8I]:J.INT,[r.RGBA8UI]:J.UINT,[r.RGBA16I]:J.INT,[r.RGBA16UI]:J.UINT,[r.RGBA32I]:J.INT,[r.RGBA32UI]:J.UINT,[r.DEPTH_COMPONENT16]:J.FLOAT,[r.DEPTH_COMPONENT24]:J.FLOAT,[r.DEPTH_COMPONENT32F]:J.FLOAT,[r.DEPTH_STENCIL]:J.FLOAT,[r.DEPTH24_STENCIL8]:J.FLOAT,[r.DEPTH32F_STENCIL8]:J.FLOAT}:t={[r.RGB]:J.FLOAT,[r.RGBA]:J.FLOAT,[r.ALPHA]:J.FLOAT,[r.LUMINANCE]:J.FLOAT,[r.LUMINANCE_ALPHA]:J.FLOAT,[r.DEPTH_STENCIL]:J.FLOAT},t}function KE(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[pt.UNSIGNED_BYTE]:{[j.RGBA]:r.RGBA8,[j.RGB]:r.RGB8,[j.RG]:r.RG8,[j.RED]:r.R8,[j.RGBA_INTEGER]:r.RGBA8UI,[j.RGB_INTEGER]:r.RGB8UI,[j.RG_INTEGER]:r.RG8UI,[j.RED_INTEGER]:r.R8UI,[j.ALPHA]:r.ALPHA,[j.LUMINANCE]:r.LUMINANCE,[j.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[pt.BYTE]:{[j.RGBA]:r.RGBA8_SNORM,[j.RGB]:r.RGB8_SNORM,[j.RG]:r.RG8_SNORM,[j.RED]:r.R8_SNORM,[j.RGBA_INTEGER]:r.RGBA8I,[j.RGB_INTEGER]:r.RGB8I,[j.RG_INTEGER]:r.RG8I,[j.RED_INTEGER]:r.R8I},[pt.UNSIGNED_SHORT]:{[j.RGBA_INTEGER]:r.RGBA16UI,[j.RGB_INTEGER]:r.RGB16UI,[j.RG_INTEGER]:r.RG16UI,[j.RED_INTEGER]:r.R16UI,[j.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[pt.SHORT]:{[j.RGBA_INTEGER]:r.RGBA16I,[j.RGB_INTEGER]:r.RGB16I,[j.RG_INTEGER]:r.RG16I,[j.RED_INTEGER]:r.R16I},[pt.UNSIGNED_INT]:{[j.RGBA_INTEGER]:r.RGBA32UI,[j.RGB_INTEGER]:r.RGB32UI,[j.RG_INTEGER]:r.RG32UI,[j.RED_INTEGER]:r.R32UI,[j.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[pt.INT]:{[j.RGBA_INTEGER]:r.RGBA32I,[j.RGB_INTEGER]:r.RGB32I,[j.RG_INTEGER]:r.RG32I,[j.RED_INTEGER]:r.R32I},[pt.FLOAT]:{[j.RGBA]:r.RGBA32F,[j.RGB]:r.RGB32F,[j.RG]:r.RG32F,[j.RED]:r.R32F,[j.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[pt.HALF_FLOAT]:{[j.RGBA]:r.RGBA16F,[j.RGB]:r.RGB16F,[j.RG]:r.RG16F,[j.RED]:r.R16F},[pt.UNSIGNED_SHORT_5_6_5]:{[j.RGB]:r.RGB565},[pt.UNSIGNED_SHORT_4_4_4_4]:{[j.RGBA]:r.RGBA4},[pt.UNSIGNED_SHORT_5_5_5_1]:{[j.RGBA]:r.RGB5_A1},[pt.UNSIGNED_INT_2_10_10_10_REV]:{[j.RGBA]:r.RGB10_A2,[j.RGBA_INTEGER]:r.RGB10_A2UI},[pt.UNSIGNED_INT_10F_11F_11F_REV]:{[j.RGB]:r.R11F_G11F_B10F},[pt.UNSIGNED_INT_5_9_9_9_REV]:{[j.RGB]:r.RGB9_E5},[pt.UNSIGNED_INT_24_8]:{[j.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[pt.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[j.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[pt.UNSIGNED_BYTE]:{[j.RGBA]:r.RGBA,[j.RGB]:r.RGB,[j.ALPHA]:r.ALPHA,[j.LUMINANCE]:r.LUMINANCE,[j.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[pt.UNSIGNED_SHORT_5_6_5]:{[j.RGB]:r.RGB},[pt.UNSIGNED_SHORT_4_4_4_4]:{[j.RGBA]:r.RGBA},[pt.UNSIGNED_SHORT_5_5_5_1]:{[j.RGBA]:r.RGBA}},t}class _p{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new bt,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=KE(t),this.samplerTypes=qE(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let n=0;n<e;n++)this.boundTextures[n]=null;this.emptyTextures={};const i=new th(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 th(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let n=0;n<6;n++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+n,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 n=0;n<this.boundTextures.length;n++)this.bind(null,n)}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 n=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,n.texture)),n.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):n.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 n=0;n<i.length;n++)i[n]===this.unknownTexture&&this.bind(null,n)}for(let n=0;n<i.length;n++)i[n]===t&&(this.currentLocation!==n&&(e.activeTexture(e.TEXTURE0+n),this.currentLocation=n),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[n]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:n}=this;if(i)for(let s=t-1;s>=0;--s){const o=e[s];o&&o._glTextures[n].samplerType!==J.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new th(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]??J.FLOAT,this.webGLVersion===2&&t.type===pt.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var n;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const i=this.renderer;if(this.initTextureType(t,e),(n=t.resource)==null?void 0:n.upload(i,t,e))e.samplerType!==J.FLOAT&&(this.hasIntegerTextures=!0);else{const s=t.realWidth,o=t.realHeight,a=i.gl;(e.width!==s||e.height!==o||e.dirtyId<0)&&(e.width=s,e.height=o,a.texImage2D(t.target,0,e.internalFormat,s,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 n=this.managedTextures.indexOf(t);n!==-1&&Ji(this.managedTextures,n,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===ir.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Fr.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!==ir.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===gr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const n=this.renderer.context.extensions.anisotropicFiltering;if(n&&t.anisotropicLevel>0&&t.scaleMode===gr.LINEAR){const s=Math.min(t.anisotropicLevel,i.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,n.TEXTURE_MAX_ANISOTROPY_EXT,s)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===gr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===gr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}_p.extension={type:Z.RendererSystem,name:"texture"},ht.add(_p);class vp{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,n=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:n}=this;e&&n.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:n}=this,s=e.createTransformFeedback();t._glTransformFeedbacks[n]=s,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];a&&(i.buffer.update(a),a._glBuffers[n].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[n].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),s}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],n=this.gl;t.disposeRunner.remove(this);const s=this.renderer.buffer;if(s)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&&s.dispose(a,e))}i&&(e||n.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}vp.extension={type:Z.RendererSystem,name:"transformFeedback"},ht.add(vp);class uo{constructor(t){this.renderer=t}init(t){this.screen=new wt(0,0,t.width,t.height),this.element=t.view||tt.ADAPTER.createCanvas(),this.resolution=t.resolution||tt.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,n=this.element.height/this.resolution;this.screen.width=i,this.screen.height=n,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${n}px`),this.renderer.emit("resize",i,n),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}}uo.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},uo.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"_view"},ht.add(uo),tt.PREFER_ENV=si.WEBGL2,tt.STRICT_TEXTURE_CACHE=!1,tt.RENDER_OPTIONS={...oo.defaultOptions,...so.defaultOptions,...uo.defaultOptions,...co.defaultOptions},Object.defineProperties(tt,{WRAP_MODE:{get(){return bt.defaultOptions.wrapMode},set(r){At("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),bt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return bt.defaultOptions.scaleMode},set(r){At("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),bt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return bt.defaultOptions.mipmap},set(r){At("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),bt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return bt.defaultOptions.anisotropicLevel},set(r){At("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),bt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return At("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Ce.defaultResolution},set(r){Ce.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return At("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Ce.defaultMultisample},set(r){Ce.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return yi.defaultMaxTextures},set(r){At("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),yi.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return yi.defaultBatchSize},set(r){At("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),yi.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return yi.canUploadSameBuffer},set(r){At("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),yi.canUploadSameBuffer=r}},GC_MODE:{get(){return bi.defaultMode},set(r){At("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),bi.defaultMode=r}},GC_MAX_IDLE:{get(){return bi.defaultMaxIdle},set(r){At("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),bi.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return bi.defaultCheckCountMax},set(r){At("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),bi.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return Tr.defaultVertexPrecision},set(r){At("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Tr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return Tr.defaultFragmentPrecision},set(r){At("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Tr.defaultFragmentPrecision=r}}});var xi=(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))(xi||{});class eh{constructor(t,e=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=n}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 bp=class Oe{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 eh(null,null,1/0),this.deltaMS=1/Oe.targetFPMS,this.elapsedMS=1/Oe.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=xi.NORMAL){return this._addListener(new eh(t,e,i))}addOnce(t,e,i=xi.NORMAL){return this._addListener(new eh(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 s=t-this._lastFrame|0;if(s<this._minElapsedMS)return;this._lastFrame=t-s%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Oe.targetFPMS;const i=this._head;let n=i.next;for(;n;)n=n.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,Oe.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(!Oe._shared){const t=Oe._shared=new Oe;t.autoStart=!0,t._protected=!0}return Oe._shared}static get system(){if(!Oe._system){const t=Oe._system=new Oe;t.autoStart=!0,t._protected=!0}return Oe._system}};bp.targetFPMS=.06;let Be=bp;Object.defineProperties(tt,{TARGET_FPMS:{get(){return Be.targetFPMS},set(r){At("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),Be.targetFPMS=r}}});class xp{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,xi.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Be.shared:new Be,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}xp.extension=Z.Application,ht.add(xp);const wp=[];ht.handleByList(Z.Renderer,wp);function Ep(r){for(const t of wp)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var ZE=`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
- }`,ZE=`attribute vec2 aVertexPosition;
500
+ }`,QE=`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 JE=KE,Ep=ZE;class Tp{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>=ee.HIGH?this.multisample=ee.HIGH:e>=ee.MEDIUM?this.multisample=ee.MEDIUM:e>=ee.LOW?this.multisample=ee.LOW:this.multisample=ee.NONE}destroy(){}}Tp.extension={type:Z.RendererSystem,name:"_multisample"},ht.add(Tp);class QE{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Ap{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,n=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,n.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:n}=this;if(this.boundBufferBases[e]!==t){const s=t._glBuffers[n]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,s.buffer)}}bindBufferRange(t,e,i){const{gl:n,CONTEXT_UID:s}=this;i=i||0;const o=t._glBuffers[s]||this.createGLBuffer(t);n.bindBufferRange(n.UNIFORM_BUFFER,e||0,o.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,n=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==n.updateID)if(n.updateID=t._updateID,e.bindBuffer(t.type,n.buffer),n.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const s=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;n.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,s)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],n=this.gl;t.disposeRunner.remove(this),i&&(e||n.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 QE(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Ap.extension={type:Z.RendererSystem,name:"buffer"},ht.add(Ap);class Sp{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let n,s,o,a;if(e&&(n=e.renderTexture,s=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!n,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(n||(this.lastObjectRendered=t),!a){const l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(n),i.batch.currentRenderer.start(),(s??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),n&&(e.blit&&i.framebuffer.blit(),n.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Sp.extension={type:Z.RendererSystem,name:"objectRenderer"},ht.add(Sp);const uo=class Lh extends WE{constructor(t){super(),this.type=Wu.WEBGL,t=Object.assign({},tt.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new ze({projectionMatrix:new kt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Lh.__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&&(At("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=Lh.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:Ew()}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 At("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return At("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return At("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return At("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){At("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return At("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){At("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return At("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)}};uo.extension={type:Z.Renderer,priority:1},uo.__plugins={},uo.__systems={};let eh=uo;ht.handleByMap(Z.RendererPlugin,eh.__plugins),ht.handleByMap(Z.RendererSystem,eh.__systems),ht.add(eh);class Cp extends zn{constructor(t,e){const{width:i,height:n}=e||{};super(i,n),this.items=[],this.itemDirtyIds=[];for(let s=0;s<t;s++){const o=new bt;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 zn?this.addResourceAt(t[i],i):this.addResourceAt(Bf(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 tT extends Cp{constructor(t,e){const{width:i,height:n}=e||{};let s,o;Array.isArray(t)?(s=t,o=t.length):o=t,super(o,{width:i,height:n}),s&&this.initFromArray(s,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=Gi.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:n,itemDirtyIds:s,items:o}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,n,0,e.format,i.type,null);for(let l=0;l<n;l++){const h=o[l];s[l]<h.dirtyId&&(s[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 eT extends Tr{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Ip=class rs extends Cp{constructor(t,e){const{width:i,height:n,autoLoad:s,linkBaseTexture:o}=e||{};if(t&&t.length!==rs.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:n});for(let a=0;a<rs.SIDES;a++)this.items[a].target=Gi.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,t&&this.initFromArray(t,e),s!==!1&&this.load()}bind(t){super.bind(t),t.target=Gi.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=Gi.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 n=this.itemDirtyIds;for(let s=0;s<rs.SIDES;s++){const o=this.items[s];(n[s]<o.dirtyId||i.dirtyId<e.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(t,o,i),n[s]=o.dirtyId):n[s]<-1&&(t.gl.texImage2D(o.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),n[s]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===rs.SIDES}};Ip.SIDES=6;let rT=Ip;class en extends Tr{constructor(t,e){e=e||{};let i,n,s;typeof t=="string"?(i=en.EMPTY,n=t,s=!0):(i=t,n=null,s=!1),super(i),this.url=n,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??s,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 tt.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const n=await i.blob();if(this.destroyed)return;const s=await createImageBitmap(n,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Re.UNPACK?"premultiply":"none"});if(this.destroyed){s.close();return}this.source=s,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 en._EMPTY=en._EMPTY??tt.ADAPTER.createCanvas(0,0),en._EMPTY}}const rh=class ko extends Tr{constructor(t,e){e=e||{},super(tt.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)},ko.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;Tr.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 n=e*this.scale,s=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(n=this._overrideWidth||this._overrideHeight/i*e,s=this._overrideHeight||this._overrideWidth/e*i),n=Math.round(n),s=Math.round(s);const o=this.source;o.width=n,o.height=s,o._pixiId=`canvas_${hi()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,n,s),this._resolve(),this._resolve=null}}static getSize(t){const e=ko.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"&&ko.SVG_XML.test(t)}};rh.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,rh.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let ih=rh;class iT extends Tr{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const nh=class Nh extends Tr{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 n=t[0].src||t[0];Tr.crossOrigin(i,n,e.crossorigin);for(let s=0;s<t.length;++s){const o=document.createElement("source");let{src:a,mime:l}=t[s];if(a=a||t[s],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),c=h.slice(h.lastIndexOf(".")+1);l=l||Nh.MIME_TYPES[c]||`video/${c}`}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=Be.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&&(Be.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||(Be.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Be.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Nh.TYPES.includes(e)}};nh.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],nh.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Pp=nh;Ul.push(en,Yf,eT,Pp,iT,ih,js,rT,tT);class fo{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?wt.EMPTY:(t=t||new wt(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:n,c:s,d:o,tx:a,ty:l}=t,h=i*e.x+s*e.y+a,c=n*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,c),this.maxY=Math.max(this.maxY,c)}addQuad(t){let e=this.minX,i=this.minY,n=this.maxX,s=this.maxY,o=t[0],a=t[1];e=o<e?o:e,i=a<i?a:i,n=o>n?o:n,s=a>s?a:s,o=t[2],a=t[3],e=o<e?o:e,i=a<i?a:i,n=o>n?o:n,s=a>s?a:s,o=t[4],a=t[5],e=o<e?o:e,i=a<i?a:i,n=o>n?o:n,s=a>s?a:s,o=t[6],a=t[7],e=o<e?o:e,i=a<i?a:i,n=o>n?o:n,s=a>s?a:s,this.minX=e,this.minY=i,this.maxX=n,this.maxY=s}addFrame(t,e,i,n,s){this.addFrameMatrix(t.worldTransform,e,i,n,s)}addFrameMatrix(t,e,i,n,s){const o=t.a,a=t.b,l=t.c,h=t.d,c=t.tx,u=t.ty;let d=this.minX,f=this.minY,p=this.maxX,g=this.maxY,y=o*e+l*i+c,_=a*e+h*i+u;d=y<d?y:d,f=_<f?_:f,p=y>p?y:p,g=_>g?_:g,y=o*n+l*i+c,_=a*n+h*i+u,d=y<d?y:d,f=_<f?_:f,p=y>p?y:p,g=_>g?_:g,y=o*e+l*s+c,_=a*e+h*s+u,d=y<d?y:d,f=_<f?_:f,p=y>p?y:p,g=_>g?_:g,y=o*n+l*s+c,_=a*n+h*s+u,d=y<d?y:d,f=_<f?_:f,p=y>p?y:p,g=_>g?_:g,this.minX=d,this.minY=f,this.maxX=p,this.maxY=g}addVertexData(t,e,i){let n=this.minX,s=this.minY,o=this.maxX,a=this.maxY;for(let l=e;l<i;l+=2){const h=t[l],c=t[l+1];n=h<n?h:n,s=c<s?c:s,o=h>o?h:o,a=c>a?c:a}this.minX=n,this.minY=s,this.maxX=o,this.maxY=a}addVertices(t,e,i,n){this.addVerticesMatrix(t.worldTransform,e,i,n)}addVerticesMatrix(t,e,i,n,s=0,o=s){const a=t.a,l=t.b,h=t.c,c=t.d,u=t.tx,d=t.ty;let f=this.minX,p=this.minY,g=this.maxX,y=this.maxY;for(let _=i;_<n;_+=2){const v=e[_],m=e[_+1],b=a*v+h*m+u,S=c*m+l*v+d;f=Math.min(f,b-s),g=Math.max(g,b+s),p=Math.min(p,S-o),y=Math.max(y,S+o)}this.minX=f,this.minY=p,this.maxX=g,this.maxY=y}addBounds(t){const e=this.minX,i=this.minY,n=this.maxX,s=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>n?t.maxX:n,this.maxY=t.maxY>s?t.maxY:s}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,n=t.minY>e.minY?t.minY:e.minY,s=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=s&&n<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=n<l?n:l,this.maxX=s>h?s:h,this.maxY=o>c?o:c}}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,n=t.minY>e.y?t.minY:e.y,s=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<=s&&n<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=n<l?n:l,this.maxX=s>h?s:h,this.maxY=o>c?o:c}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,n,s,o){t-=s,e-=o,i+=s,n+=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>n?this.maxY:n}}class Xt extends Rn{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Vl,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 fo,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 n=e[i];Object.defineProperty(Xt.prototype,n,Object.getOwnPropertyDescriptor(t,n))}}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 wt),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new wt),t=this._localBoundsRect),this._localBounds||(this._localBounds=new fo);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 n=this._bounds,s=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=n,this._bounds.updateID+=this._boundsID-s,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,n){return e&&(t=e.toGlobal(t,i,n)),n||(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,n=1,s=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=n||1,this.rotation=s,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 nT),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*Zw}set angle(t){this.transform.rotation=t*Jw}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 nT extends Xt{constructor(){super(...arguments),this.sortDirty=null}}Xt.prototype.displayObjectUpdateTransform=Xt.prototype.updateTransform;const sT=new kt;function oT(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const Rp=class Fh extends Xt{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),n=this.getChildIndex(e);this.children[i]=e,this.children[n]=t,this.onChildrenChange(i<n?i:n)}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);Ji(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,Ji(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,Ji(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,n=e,s=n-i;let o;if(s>0&&s<=n){o=this.children.splice(i,s);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(s===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 n=this.children[e];n._lastSortedIndex=e,!t&&n.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(oT),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 n=0,s=this.children.length;n<s;++n){const o=this.children[n];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,n;this.cullArea?(i=this.cullArea,n=this.worldTransform):this._render!==Fh.prototype._render&&(i=this.getBounds(!0));const s=t.projection.transform;if(s&&(n?(n=sT.copyFrom(n),n.prepend(s)):n=s),i&&e.intersects(i,n))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,n=this.children.length;i<n;++i)this.children[i].render(t)}}renderAdvanced(t){var s,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 n=e&&((s=this._enabledFilters)==null?void 0:s.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==ie.NONE));if(n&&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)}n&&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 n=0;n<i.length;++n)i[n].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}};Rp.defaultSortableChildren=!1;let je=Rp;je.prototype.containerUpdateTransform=je.prototype.updateTransform,Object.defineProperties(tt,{SORTABLE_CHILDREN:{get(){return je.defaultSortableChildren},set(r){At("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),je.defaultSortableChildren=r}}});const Kn=new It,aT=new Uint16Array([0,1,2,0,2,3]);class rn extends je{constructor(t){super(),this._anchor=new wr(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 Mt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=vt.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||ct.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=aT,this.pluginName="batch",this.isSprite=!0,this._roundPixels=tt.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=kr(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=kr(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,n=e.b,s=e.c,o=e.d,a=e.tx,l=e.ty,h=this.vertexData,c=t.trim,u=t.orig,d=this._anchor;let f=0,p=0,g=0,y=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,y=c.y-d._y*u.height,g=y+c.height):(p=-d._x*u.width,f=p+u.width,y=-d._y*u.height,g=y+u.height),h[0]=i*p+s*y+a,h[1]=o*y+n*p+l,h[2]=i*f+s*y+a,h[3]=o*y+n*f+l,h[4]=i*f+s*g+a,h[5]=o*g+n*f+l,h[6]=i*p+s*g+a,h[7]=o*g+n*p+l,this._roundPixels){const _=tt.RESOLUTION;for(let v=0;v<h.length;++v)h[v]=Math.round(h[v]*_)/_}}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,n=this._anchor,s=this.transform.worldTransform,o=s.a,a=s.b,l=s.c,h=s.d,c=s.tx,u=s.ty,d=-n._x*i.width,f=d+i.width,p=-n._y*i.height,g=p+i.height;if(e[0]=o*d+l*p+c,e[1]=h*p+a*d+u,e[2]=o*f+l*p+c,e[3]=h*p+a*f+u,e[4]=o*f+l*g+c,e[5]=h*g+a*f+u,e[6]=o*d+l*g+c,e[7]=h*g+a*d+u,this._roundPixels){const y=tt.RESOLUTION;for(let _=0;_<e.length;++_)e[_]=Math.round(e[_]*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 fo),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 wt),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Kn);const e=this._texture.orig.width,i=this._texture.orig.height,n=-e*this.anchor.x;let s=0;return Kn.x>=n&&Kn.x<n+e&&(s=-i*this.anchor.y,Kn.y>=s&&Kn.y<s+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 ct?t:ct.from(t,e);return new rn(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=kr(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=kr(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||ct.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Mp=new kt;Xt.prototype._cacheAsBitmap=!1,Xt.prototype._cacheData=null,Xt.prototype._cacheAsBitmapResolution=null,Xt.prototype._cacheAsBitmapMultisample=null;class lT{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(Xt.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 lT),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)}}}),Xt.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))},Xt.prototype._initCachedDisplayObject=function(r){var d,f;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new wt,!0);if((f=this.filters)!=null&&f.length){const p=this.filters[0].padding;e.pad(p)}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 n=r.renderTexture.current,s=r.renderTexture.sourceFrame.clone(),o=r.renderTexture.destinationFrame.clone(),a=r.projection.transform,l=gi.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${hi()}`;this._cacheData.textureCacheId=h,bt.addToCache(l.baseTexture,h),ct.addToCache(l,h);const c=this.transform.localTransform.copyTo(Mp).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:c,skipUpdateTransform:!1}),r.framebuffer.blit(),r.projection.transform=a,r.renderTexture.bind(n,s,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 u=new rn(l);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(e.x/e.width),u.anchor.y=-(e.y/e.height),u.alpha=t,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=u.containsPoint.bind(u)},Xt.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))},Xt.prototype._initCachedDisplayObjectCanvas=function(r){var c;if((c=this._cacheData)!=null&&c.sprite)return;const t=this.getLocalBounds(new wt,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,n=r._projTransform,s=this.cacheAsBitmapResolution||r.resolution;t.ceil(s),t.width=Math.max(t.width,1/s),t.height=Math.max(t.height,1/s);const o=gi.create({width:t.width,height:t.height,resolution:s}),a=`cacheAsBitmap_${hi()}`;this._cacheData.textureCacheId=a,bt.addToCache(o.baseTexture,a),ct.addToCache(o,a);const l=Mp;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=n,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 rn(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)},Xt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Xt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Xt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,bt.removeFromCache(this._cacheData.textureCacheId),ct.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Xt.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Xt.prototype.name=null,je.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 n=this.children[e];if(!n.getChildByName)continue;const s=n.getChildByName(r,!0);if(s)return s}return null},Xt.prototype.getGlobalPosition=function(r=new It,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var hT=`varying vec2 vTextureCoord;
526
+ `;const JE=ZE,Tp=QE;class Ap{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>=ee.HIGH?this.multisample=ee.HIGH:e>=ee.MEDIUM?this.multisample=ee.MEDIUM:e>=ee.LOW?this.multisample=ee.LOW:this.multisample=ee.NONE}destroy(){}}Ap.extension={type:Z.RendererSystem,name:"_multisample"},ht.add(Ap);class tT{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Sp{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,n=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,n.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:n}=this;if(this.boundBufferBases[e]!==t){const s=t._glBuffers[n]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,s.buffer)}}bindBufferRange(t,e,i){const{gl:n,CONTEXT_UID:s}=this;i=i||0;const o=t._glBuffers[s]||this.createGLBuffer(t);n.bindBufferRange(n.UNIFORM_BUFFER,e||0,o.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,n=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==n.updateID)if(n.updateID=t._updateID,e.bindBuffer(t.type,n.buffer),n.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const s=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;n.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,s)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],n=this.gl;t.disposeRunner.remove(this),i&&(e||n.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 tT(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Sp.extension={type:Z.RendererSystem,name:"buffer"},ht.add(Sp);class Cp{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let n,s,o,a;if(e&&(n=e.renderTexture,s=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!n,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(n||(this.lastObjectRendered=t),!a){const l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(n),i.batch.currentRenderer.start(),(s??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),n&&(e.blit&&i.framebuffer.blit(),n.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Cp.extension={type:Z.RendererSystem,name:"objectRenderer"},ht.add(Cp);const fo=class Nh extends YE{constructor(t){super(),this.type=Yu.WEBGL,t=Object.assign({},tt.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new je({projectionMatrix:new kt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Nh.__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&&(At("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=Nh.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:Tw()}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 At("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return At("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return At("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return At("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){At("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return At("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){At("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return At("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)}};fo.extension={type:Z.Renderer,priority:1},fo.__plugins={},fo.__systems={};let rh=fo;ht.handleByMap(Z.RendererPlugin,rh.__plugins),ht.handleByMap(Z.RendererSystem,rh.__systems),ht.add(rh);class Ip extends jn{constructor(t,e){const{width:i,height:n}=e||{};super(i,n),this.items=[],this.itemDirtyIds=[];for(let s=0;s<t;s++){const o=new bt;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 jn?this.addResourceAt(t[i],i):this.addResourceAt(Of(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 eT extends Ip{constructor(t,e){const{width:i,height:n}=e||{};let s,o;Array.isArray(t)?(s=t,o=t.length):o=t,super(o,{width:i,height:n}),s&&this.initFromArray(s,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=$i.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:n,itemDirtyIds:s,items:o}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,n,0,e.format,i.type,null);for(let l=0;l<n;l++){const h=o[l];s[l]<h.dirtyId&&(s[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 rT extends Ar{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Pp=class is extends Ip{constructor(t,e){const{width:i,height:n,autoLoad:s,linkBaseTexture:o}=e||{};if(t&&t.length!==is.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:n});for(let a=0;a<is.SIDES;a++)this.items[a].target=$i.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,t&&this.initFromArray(t,e),s!==!1&&this.load()}bind(t){super.bind(t),t.target=$i.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=$i.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 n=this.itemDirtyIds;for(let s=0;s<is.SIDES;s++){const o=this.items[s];(n[s]<o.dirtyId||i.dirtyId<e.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(t,o,i),n[s]=o.dirtyId):n[s]<-1&&(t.gl.texImage2D(o.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),n[s]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===is.SIDES}};Pp.SIDES=6;let iT=Pp;class rn extends Ar{constructor(t,e){e=e||{};let i,n,s;typeof t=="string"?(i=rn.EMPTY,n=t,s=!0):(i=t,n=null,s=!1),super(i),this.url=n,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??s,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 tt.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const n=await i.blob();if(this.destroyed)return;const s=await createImageBitmap(n,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Re.UNPACK?"premultiply":"none"});if(this.destroyed){s.close();return}this.source=s,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 rn._EMPTY=rn._EMPTY??tt.ADAPTER.createCanvas(0,0),rn._EMPTY}}const ih=class Uo extends Ar{constructor(t,e){e=e||{},super(tt.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)},Uo.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;Ar.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 n=e*this.scale,s=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(n=this._overrideWidth||this._overrideHeight/i*e,s=this._overrideHeight||this._overrideWidth/e*i),n=Math.round(n),s=Math.round(s);const o=this.source;o.width=n,o.height=s,o._pixiId=`canvas_${ui()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,n,s),this._resolve(),this._resolve=null}}static getSize(t){const e=Uo.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"&&Uo.SVG_XML.test(t)}};ih.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,ih.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let nh=ih;class nT extends Ar{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const sh=class Fh extends Ar{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 n=t[0].src||t[0];Ar.crossOrigin(i,n,e.crossorigin);for(let s=0;s<t.length;++s){const o=document.createElement("source");let{src:a,mime:l}=t[s];if(a=a||t[s],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),c=h.slice(h.lastIndexOf(".")+1);l=l||Fh.MIME_TYPES[c]||`video/${c}`}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=Be.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&&(Be.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||(Be.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Be.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Fh.TYPES.includes(e)}};sh.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],sh.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Rp=sh;Gl.push(rn,qf,rT,Rp,nT,nh,Ws,iT,eT);class po{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?wt.EMPTY:(t=t||new wt(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:n,c:s,d:o,tx:a,ty:l}=t,h=i*e.x+s*e.y+a,c=n*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,c),this.maxY=Math.max(this.maxY,c)}addQuad(t){let e=this.minX,i=this.minY,n=this.maxX,s=this.maxY,o=t[0],a=t[1];e=o<e?o:e,i=a<i?a:i,n=o>n?o:n,s=a>s?a:s,o=t[2],a=t[3],e=o<e?o:e,i=a<i?a:i,n=o>n?o:n,s=a>s?a:s,o=t[4],a=t[5],e=o<e?o:e,i=a<i?a:i,n=o>n?o:n,s=a>s?a:s,o=t[6],a=t[7],e=o<e?o:e,i=a<i?a:i,n=o>n?o:n,s=a>s?a:s,this.minX=e,this.minY=i,this.maxX=n,this.maxY=s}addFrame(t,e,i,n,s){this.addFrameMatrix(t.worldTransform,e,i,n,s)}addFrameMatrix(t,e,i,n,s){const o=t.a,a=t.b,l=t.c,h=t.d,c=t.tx,u=t.ty;let d=this.minX,f=this.minY,p=this.maxX,g=this.maxY,y=o*e+l*i+c,_=a*e+h*i+u;d=y<d?y:d,f=_<f?_:f,p=y>p?y:p,g=_>g?_:g,y=o*n+l*i+c,_=a*n+h*i+u,d=y<d?y:d,f=_<f?_:f,p=y>p?y:p,g=_>g?_:g,y=o*e+l*s+c,_=a*e+h*s+u,d=y<d?y:d,f=_<f?_:f,p=y>p?y:p,g=_>g?_:g,y=o*n+l*s+c,_=a*n+h*s+u,d=y<d?y:d,f=_<f?_:f,p=y>p?y:p,g=_>g?_:g,this.minX=d,this.minY=f,this.maxX=p,this.maxY=g}addVertexData(t,e,i){let n=this.minX,s=this.minY,o=this.maxX,a=this.maxY;for(let l=e;l<i;l+=2){const h=t[l],c=t[l+1];n=h<n?h:n,s=c<s?c:s,o=h>o?h:o,a=c>a?c:a}this.minX=n,this.minY=s,this.maxX=o,this.maxY=a}addVertices(t,e,i,n){this.addVerticesMatrix(t.worldTransform,e,i,n)}addVerticesMatrix(t,e,i,n,s=0,o=s){const a=t.a,l=t.b,h=t.c,c=t.d,u=t.tx,d=t.ty;let f=this.minX,p=this.minY,g=this.maxX,y=this.maxY;for(let _=i;_<n;_+=2){const v=e[_],m=e[_+1],b=a*v+h*m+u,S=c*m+l*v+d;f=Math.min(f,b-s),g=Math.max(g,b+s),p=Math.min(p,S-o),y=Math.max(y,S+o)}this.minX=f,this.minY=p,this.maxX=g,this.maxY=y}addBounds(t){const e=this.minX,i=this.minY,n=this.maxX,s=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>n?t.maxX:n,this.maxY=t.maxY>s?t.maxY:s}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,n=t.minY>e.minY?t.minY:e.minY,s=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=s&&n<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=n<l?n:l,this.maxX=s>h?s:h,this.maxY=o>c?o:c}}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,n=t.minY>e.y?t.minY:e.y,s=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<=s&&n<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=n<l?n:l,this.maxX=s>h?s:h,this.maxY=o>c?o:c}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,n,s,o){t-=s,e-=o,i+=s,n+=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>n?this.maxY:n}}class Xt extends Mn{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new zl,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 po,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 n=e[i];Object.defineProperty(Xt.prototype,n,Object.getOwnPropertyDescriptor(t,n))}}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 wt),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new wt),t=this._localBoundsRect),this._localBounds||(this._localBounds=new po);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 n=this._bounds,s=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=n,this._bounds.updateID+=this._boundsID-s,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,n){return e&&(t=e.toGlobal(t,i,n)),n||(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,n=1,s=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=n||1,this.rotation=s,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 sT),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*Qw}set angle(t){this.transform.rotation=t*Jw}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 sT extends Xt{constructor(){super(...arguments),this.sortDirty=null}}Xt.prototype.displayObjectUpdateTransform=Xt.prototype.updateTransform;const oT=new kt;function aT(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const Mp=class kh extends Xt{constructor(){super(),this.children=[],this.sortableChildren=kh.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),n=this.getChildIndex(e);this.children[i]=e,this.children[n]=t,this.onChildrenChange(i<n?i:n)}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);Ji(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,Ji(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,Ji(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,n=e,s=n-i;let o;if(s>0&&s<=n){o=this.children.splice(i,s);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(s===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 n=this.children[e];n._lastSortedIndex=e,!t&&n.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(aT),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 n=0,s=this.children.length;n<s;++n){const o=this.children[n];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,n;this.cullArea?(i=this.cullArea,n=this.worldTransform):this._render!==kh.prototype._render&&(i=this.getBounds(!0));const s=t.projection.transform;if(s&&(n?(n=oT.copyFrom(n),n.prepend(s)):n=s),i&&e.intersects(i,n))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,n=this.children.length;i<n;++i)this.children[i].render(t)}}renderAdvanced(t){var s,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 n=e&&((s=this._enabledFilters)==null?void 0:s.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==ie.NONE));if(n&&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)}n&&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 n=0;n<i.length;++n)i[n].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}};Mp.defaultSortableChildren=!1;let We=Mp;We.prototype.containerUpdateTransform=We.prototype.updateTransform,Object.defineProperties(tt,{SORTABLE_CHILDREN:{get(){return We.defaultSortableChildren},set(r){At("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),We.defaultSortableChildren=r}}});const Zn=new It,lT=new Uint16Array([0,1,2,0,2,3]);class nn extends We{constructor(t){super(),this._anchor=new Er(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 Mt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=vt.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||ct.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=lT,this.pluginName="batch",this.isSprite=!0,this._roundPixels=tt.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=Gr(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=Gr(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,n=e.b,s=e.c,o=e.d,a=e.tx,l=e.ty,h=this.vertexData,c=t.trim,u=t.orig,d=this._anchor;let f=0,p=0,g=0,y=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,y=c.y-d._y*u.height,g=y+c.height):(p=-d._x*u.width,f=p+u.width,y=-d._y*u.height,g=y+u.height),h[0]=i*p+s*y+a,h[1]=o*y+n*p+l,h[2]=i*f+s*y+a,h[3]=o*y+n*f+l,h[4]=i*f+s*g+a,h[5]=o*g+n*f+l,h[6]=i*p+s*g+a,h[7]=o*g+n*p+l,this._roundPixels){const _=tt.RESOLUTION;for(let v=0;v<h.length;++v)h[v]=Math.round(h[v]*_)/_}}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,n=this._anchor,s=this.transform.worldTransform,o=s.a,a=s.b,l=s.c,h=s.d,c=s.tx,u=s.ty,d=-n._x*i.width,f=d+i.width,p=-n._y*i.height,g=p+i.height;if(e[0]=o*d+l*p+c,e[1]=h*p+a*d+u,e[2]=o*f+l*p+c,e[3]=h*p+a*f+u,e[4]=o*f+l*g+c,e[5]=h*g+a*f+u,e[6]=o*d+l*g+c,e[7]=h*g+a*d+u,this._roundPixels){const y=tt.RESOLUTION;for(let _=0;_<e.length;++_)e[_]=Math.round(e[_]*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 po),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 wt),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Zn);const e=this._texture.orig.width,i=this._texture.orig.height,n=-e*this.anchor.x;let s=0;return Zn.x>=n&&Zn.x<n+e&&(s=-i*this.anchor.y,Zn.y>=s&&Zn.y<s+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 ct?t:ct.from(t,e);return new nn(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=Gr(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=Gr(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||ct.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Dp=new kt;Xt.prototype._cacheAsBitmap=!1,Xt.prototype._cacheData=null,Xt.prototype._cacheAsBitmapResolution=null,Xt.prototype._cacheAsBitmapMultisample=null;class hT{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(Xt.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 hT),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)}}}),Xt.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))},Xt.prototype._initCachedDisplayObject=function(r){var d,f;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new wt,!0);if((f=this.filters)!=null&&f.length){const p=this.filters[0].padding;e.pad(p)}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 n=r.renderTexture.current,s=r.renderTexture.sourceFrame.clone(),o=r.renderTexture.destinationFrame.clone(),a=r.projection.transform,l=_i.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${ui()}`;this._cacheData.textureCacheId=h,bt.addToCache(l.baseTexture,h),ct.addToCache(l,h);const c=this.transform.localTransform.copyTo(Dp).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:c,skipUpdateTransform:!1}),r.framebuffer.blit(),r.projection.transform=a,r.renderTexture.bind(n,s,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 u=new nn(l);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(e.x/e.width),u.anchor.y=-(e.y/e.height),u.alpha=t,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=u.containsPoint.bind(u)},Xt.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))},Xt.prototype._initCachedDisplayObjectCanvas=function(r){var c;if((c=this._cacheData)!=null&&c.sprite)return;const t=this.getLocalBounds(new wt,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,n=r._projTransform,s=this.cacheAsBitmapResolution||r.resolution;t.ceil(s),t.width=Math.max(t.width,1/s),t.height=Math.max(t.height,1/s);const o=_i.create({width:t.width,height:t.height,resolution:s}),a=`cacheAsBitmap_${ui()}`;this._cacheData.textureCacheId=a,bt.addToCache(o.baseTexture,a),ct.addToCache(o,a);const l=Dp;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=n,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 nn(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)},Xt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Xt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Xt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,bt.removeFromCache(this._cacheData.textureCacheId),ct.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Xt.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Xt.prototype.name=null,We.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 n=this.children[e];if(!n.getChildByName)continue;const s=n.getChildByName(r,!0);if(s)return s}return null},Xt.prototype.getGlobalPosition=function(r=new It,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var cT=`varying vec2 vTextureCoord;
527
527
 
528
528
  uniform sampler2D uSampler;
529
529
  uniform float uAlpha;
@@ -532,9 +532,9 @@ void main(void)
532
532
  {
533
533
  gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
534
534
  }
535
- `;class cT extends Ce{constructor(t=1){super(JE,hT,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const uT={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]},dT=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
536
- `);function fT(r){const t=uT[r],e=t.length;let i=dT,n="";const s="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=s.replace("%index%",a.toString());o=a,a>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),n+=l,n+=`
537
- `}return i=i.replace("%blur%",n),i=i.replace("%size%",r.toString()),i}const pT=`
535
+ `;class uT extends Ce{constructor(t=1){super(JE,cT,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const dT={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]},fT=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
536
+ `);function pT(r){const t=dT[r],e=t.length;let i=fT,n="";const s="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=s.replace("%index%",a.toString());o=a,a>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),n+=l,n+=`
537
+ `}return i=i.replace("%blur%",n),i=i.replace("%size%",r.toString()),i}const mT=`
538
538
  attribute vec2 aVertexPosition;
539
539
 
540
540
  uniform mat3 projectionMatrix;
@@ -564,8 +564,8 @@ void main(void)
564
564
 
565
565
  vec2 textureCoord = filterTextureCoord();
566
566
  %blur%
567
- }`;function mT(r,t){const e=Math.ceil(r/2);let i=pT,n="",s;t?s="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":s="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<r;o++){let a=s.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),n+=a,n+=`
568
- `}return i=i.replace("%blur%",n),i=i.replace("%size%",r.toString()),i}class sh extends Ce{constructor(t,e=8,i=4,n=Ce.defaultResolution,s=5){const o=mT(s,t),a=fT(s);super(o,a),this.horizontal=t,this.resolution=n,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,n){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,n);else{const s=t.getFilterTexture(),o=t.renderer;let a=e,l=s;this.state.blend=!1,t.applyFilter(this,a,l,ir.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(a,ir.BLIT),this.uniforms.uSampler=l;const c=l;l=a,a=c,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,l,i,n),t.returnFilterTexture(s)}}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 gT extends Ce{constructor(t=8,e=4,i=Ce.defaultResolution,n=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new sh(!0,t,e,i,n),this.blurYFilter=new sh(!1,t,e,i,n),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,n){const s=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(s&&o){const a=t.getFilterTexture();this.blurXFilter.apply(t,e,a,ir.CLEAR),this.blurYFilter.apply(t,a,i,n),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,i,n):this.blurXFilter.apply(t,e,i,n)}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 yT=`varying vec2 vTextureCoord;
567
+ }`;function gT(r,t){const e=Math.ceil(r/2);let i=mT,n="",s;t?s="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":s="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<r;o++){let a=s.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),n+=a,n+=`
568
+ `}return i=i.replace("%blur%",n),i=i.replace("%size%",r.toString()),i}class oh extends Ce{constructor(t,e=8,i=4,n=Ce.defaultResolution,s=5){const o=gT(s,t),a=pT(s);super(o,a),this.horizontal=t,this.resolution=n,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,n){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,n);else{const s=t.getFilterTexture(),o=t.renderer;let a=e,l=s;this.state.blend=!1,t.applyFilter(this,a,l,nr.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(a,nr.BLIT),this.uniforms.uSampler=l;const c=l;l=a,a=c,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,l,i,n),t.returnFilterTexture(s)}}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 yT extends Ce{constructor(t=8,e=4,i=Ce.defaultResolution,n=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new oh(!0,t,e,i,n),this.blurYFilter=new oh(!1,t,e,i,n),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,n){const s=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(s&&o){const a=t.getFilterTexture();this.blurXFilter.apply(t,e,a,nr.CLEAR),this.blurYFilter.apply(t,a,i,n),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,i,n):this.blurXFilter.apply(t,e,i,n)}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 _T=`varying vec2 vTextureCoord;
569
569
  uniform sampler2D uSampler;
570
570
  uniform float m[20];
571
571
  uniform float uAlpha;
@@ -617,7 +617,7 @@ void main(void)
617
617
 
618
618
  gl_FragColor = vec4(rgb, result.a);
619
619
  }
620
- `;class oh extends Ce{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(Ep,yT,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,n,s]=Mt.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,n,0,0,0,0,0,s,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),n=Math.sin(t),s=Math.sqrt,o=1/3,a=s(o),l=i+(1-i)*o,h=o*(1-i)-a*n,c=o*(1-i)+a*n,u=o*(1-i)+a*n,d=i+o*(1-i),f=o*(1-i)-a*n,p=o*(1-i)-a*n,g=o*(1-i)+a*n,y=i+o*(1-i),_=[l,h,c,0,0,u,d,f,0,0,p,g,y,0,0,0,0,0,1,0];this._loadMatrix(_,e)}contrast(t,e){const i=(t||0)+1,n=-.5*(i-1),s=[i,0,0,0,n,0,i,0,0,n,0,0,i,0,n,0,0,0,1,0];this._loadMatrix(s,e)}saturate(t=0,e){const i=t*2/3+1,n=(i-1)*-.5,s=[i,n,n,0,0,n,i,n,0,0,n,n,i,0,0,0,0,0,1,0];this._loadMatrix(s,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,n,s){t=t||.2,e=e||.15,i=i||16770432,n=n||3375104;const o=Mt.shared,[a,l,h]=o.setValue(i).toArray(),[c,u,d]=o.setValue(n).toArray(),f=[.3,.59,.11,0,0,a,l,h,t,0,c,u,d,e,0,a-c,l-u,h-d,0,0];this._loadMatrix(f,s)}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}}oh.prototype.grayscale=oh.prototype.greyscale;var _T=`varying vec2 vFilterCoord;
620
+ `;class ah extends Ce{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(Tp,_T,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,n,s]=Mt.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,n,0,0,0,0,0,s,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),n=Math.sin(t),s=Math.sqrt,o=1/3,a=s(o),l=i+(1-i)*o,h=o*(1-i)-a*n,c=o*(1-i)+a*n,u=o*(1-i)+a*n,d=i+o*(1-i),f=o*(1-i)-a*n,p=o*(1-i)-a*n,g=o*(1-i)+a*n,y=i+o*(1-i),_=[l,h,c,0,0,u,d,f,0,0,p,g,y,0,0,0,0,0,1,0];this._loadMatrix(_,e)}contrast(t,e){const i=(t||0)+1,n=-.5*(i-1),s=[i,0,0,0,n,0,i,0,0,n,0,0,i,0,n,0,0,0,1,0];this._loadMatrix(s,e)}saturate(t=0,e){const i=t*2/3+1,n=(i-1)*-.5,s=[i,n,n,0,0,n,i,n,0,0,n,n,i,0,0,0,0,0,1,0];this._loadMatrix(s,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,n,s){t=t||.2,e=e||.15,i=i||16770432,n=n||3375104;const o=Mt.shared,[a,l,h]=o.setValue(i).toArray(),[c,u,d]=o.setValue(n).toArray(),f=[.3,.59,.11,0,0,a,l,h,t,0,c,u,d,e,0,a-c,l-u,h-d,0,0];this._loadMatrix(f,s)}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}}ah.prototype.grayscale=ah.prototype.greyscale;var vT=`varying vec2 vFilterCoord;
621
621
  varying vec2 vTextureCoord;
622
622
 
623
623
  uniform vec2 scale;
@@ -637,7 +637,7 @@ void main(void)
637
637
 
638
638
  gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));
639
639
  }
640
- `,vT=`attribute vec2 aVertexPosition;
640
+ `,bT=`attribute vec2 aVertexPosition;
641
641
 
642
642
  uniform mat3 projectionMatrix;
643
643
  uniform mat3 filterMatrix;
@@ -666,7 +666,7 @@ void main(void)
666
666
  vTextureCoord = filterTextureCoord();
667
667
  vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;
668
668
  }
669
- `;class bT extends Ce{constructor(t,e){const i=new kt;t.renderable=!1,super(vT,_T,{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 It(e,e)}apply(t,e,i,n){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const s=this.maskSprite.worldTransform,o=Math.sqrt(s.a*s.a+s.b*s.b),a=Math.sqrt(s.c*s.c+s.d*s.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=s.a/o,this.uniforms.rotation[1]=s.b/o,this.uniforms.rotation[2]=s.c/a,this.uniforms.rotation[3]=s.d/a),t.applyFilter(this,e,i,n)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var xT=`varying vec2 v_rgbNW;
669
+ `;class xT extends Ce{constructor(t,e){const i=new kt;t.renderable=!1,super(bT,vT,{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 It(e,e)}apply(t,e,i,n){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const s=this.maskSprite.worldTransform,o=Math.sqrt(s.a*s.a+s.b*s.b),a=Math.sqrt(s.c*s.c+s.d*s.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=s.a/o,this.uniforms.rotation[1]=s.b/o,this.uniforms.rotation[2]=s.c/a,this.uniforms.rotation[3]=s.d/a),t.applyFilter(this,e,i,n)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var wT=`varying vec2 v_rgbNW;
670
670
  varying vec2 v_rgbNE;
671
671
  varying vec2 v_rgbSW;
672
672
  varying vec2 v_rgbSE;
@@ -787,7 +787,7 @@ void main() {
787
787
 
788
788
  gl_FragColor = color;
789
789
  }
790
- `,wT=`
790
+ `,ET=`
791
791
  attribute vec2 aVertexPosition;
792
792
 
793
793
  uniform mat3 projectionMatrix;
@@ -829,7 +829,7 @@ void main(void) {
829
829
 
830
830
  texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
831
831
  }
832
- `;class ET extends Ce{constructor(){super(wT,xT)}}var TT=`precision highp float;
832
+ `;class TT extends Ce{constructor(){super(ET,wT)}}var AT=`precision highp float;
833
833
 
834
834
  varying vec2 vTextureCoord;
835
835
  varying vec4 vColor;
@@ -863,8 +863,8 @@ void main()
863
863
 
864
864
  gl_FragColor = color;
865
865
  }
866
- `;class AT extends Ce{constructor(t=.5,e=Math.random()){super(Ep,TT,{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 Dp={AlphaFilter:cT,BlurFilter:gT,BlurFilterPass:sh,ColorMatrixFilter:oh,DisplacementFilter:bT,FXAAFilter:ET,NoiseFilter:AT};Object.entries(Dp).forEach(([r,t])=>{Object.defineProperty(Dp,r,{get(){return At("7.1.0",`filters.${r} has moved to ${r}`),t}})});class ST{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||(Be.system.add(this.tickerUpdate,this,vi.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Be.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 $r=new ST;class Zn{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Zn.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new It,this.page=new It,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,n,s){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 po extends Zn{constructor(){super(...arguments),this.client=new It,this.movement=new It,this.offset=new It,this.global=new It,this.screen=new It}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,n,s,o,a,l,h,c,u,d,f,p,g){throw new Error("Method not implemented.")}}class We extends po{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 nn extends po{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}nn.DOM_DELTA_PIXEL=0,nn.DOM_DELTA_LINE=1,nn.DOM_DELTA_PAGE=2;const CT=2048,IT=new It,ah=new It;class PT{constructor(t){this.dispatch=new Rn,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,n)=>i.priority-n.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,n=e.length;i<n;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){$r.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[i](this.rootTarget,this.rootTarget.eventMode,IT.set(t,e),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let n=0,s=i.length-1;n<s;n++)if(t.currentTarget=i[n],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 n=i.length-2;n>=0;n--)if(t.currentTarget=i[n],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 n=Array.isArray(e)?e:[e];for(let s=i.length-1;s>=0;s--)n.forEach(o=>{t.currentTarget=i[s],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<CT&&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,n,s,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&($r.pauseUpdate=!1),t.interactiveChildren&&t.children){const c=t.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,n,s,o||s(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),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&&!s(t,i)&&n(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,n,s){if(this._interactivePrune(t)||s(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&($r.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let h=l.length-1;h>=0;h--){const c=l[h],u=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,i,n,s);if(u){if(u.length>0&&!u[u.length-1].parent)continue;const d=t.isInteractive();return(u.length>0||d)&&u.push(t),u}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&n(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,ah),!t.hitArea.contains(ah.x,ah.y)))return!0;if(t._mask){const n=t._mask.isMaskData?t._mask.maskObject:t._mask;if(n&&!((i=n.containsPoint)!=null&&i.call(n,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 s,o;e=e??t.type;const i=`on${e}`;(o=(s=t.currentTarget)[i])==null||o.call(s,t);const n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof We)){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 n=e.button===2;this.dispatchEvent(e,n?"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 We)){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",n=this.trackingData(t.pointerId),s=this.findMountedTarget(n.overTargets);if(((l=n.overTargets)==null?void 0:l.length)>0&&s!==e.target){const c=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,c,s);if(this.dispatchEvent(u,"pointerout"),i&&this.dispatchEvent(u,"mouseout"),!e.composedPath().includes(s)){const d=this.createPointerEvent(t,"pointerleave",s);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(u)}if(s!==e.target){const c=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(e,c);this.dispatchEvent(u,"pointerover"),i&&this.dispatchEvent(u,"mouseover");let d=s==null?void 0:s.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(e,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==s&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),i&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}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,n.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var o;if(!(t instanceof We)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),n=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(o=i.target)==null?void 0:o.cursor);const s=this.clonePointerEvent(i,"pointerenter");for(s.eventPhase=s.AT_TARGET;s.target&&s.target!==this.rootTarget.parent;)s.currentTarget=s.target,this.notifyTarget(s),n&&this.notifyTarget(s,"mouseenter"),s.target=s.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(s)}mapPointerOut(t){if(!(t instanceof We)){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",n=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(t,"pointerleave",n);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(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof We)){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 n=this.trackingData(t.pointerId),s=this.findMountedTarget(n.pressTargetsByButton[t.button]);let o=s;if(s&&!i.composedPath().includes(s)){let a=s;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 n.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=n.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 We)){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]),n=this.createPointerEvent(t);if(i){let s=i;for(;s;)n.currentTarget=s,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch"?this.notifyTarget(n,"touchendoutside"):(n.pointerType==="mouse"||n.pointerType==="pen")&&this.notifyTarget(n,n.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof nn)){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 n=this.allocateEvent(We);return this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.nativeEvent=t.nativeEvent,n.originalEvent=t,n.target=i??this.hitTest(n.global.x,n.global.y)??this._hitElements[0],typeof e=="string"&&(n.type=e),n}createWheelEvent(t){const e=this.allocateEvent(nn);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(We);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 We&&e instanceof We&&(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 po&&e instanceof po&&(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 n=0,s=i.length;n<s&&!t.propagationImmediatelyStopped;n++)i[n].once&&t.currentTarget.removeListener(e,i[n].fn,void 0,!0),i[n].fn.call(i[n].context,t)}}const RT=1,MT={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},lh=class kh{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new PT(null),$r.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new We(null),this.rootWheelEvent=new nn(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...kh.defaultEventFeatures},{set:(e,i,n)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=n),e[i]=n,!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,kh._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,n=e.length;i<n;i++){const s=e[i],o=this.bootstrapEvent(this.rootPointerEvent,s);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,$r.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,n=e.length;i<n;i++){const s=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(s)}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":"",n=this.normalizeToPointerData(t);for(let s=0,o=n.length;s<o;s++){const a=this.bootstrapEvent(this.rootPointerEvent,n[s]);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,n=e.length;i<n;i++){const s=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(s)}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,$r.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;$r.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;$r.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 n=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},s=1/this.resolution;t.x=(e-n.left)*(this.domElement.width/n.width)*s,t.y=(i-n.top)*(this.domElement.height/n.height)*s}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,n=t.changedTouches.length;i<n;i++){const s=t.changedTouches[i];typeof s.button>"u"&&(s.button=0),typeof s.buttons>"u"&&(s.buttons=1),typeof s.isPrimary>"u"&&(s.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof s.width>"u"&&(s.width=s.radiusX||1),typeof s.height>"u"&&(s.height=s.radiusY||1),typeof s.tiltX>"u"&&(s.tiltX=0),typeof s.tiltY>"u"&&(s.tiltY=0),typeof s.pointerType>"u"&&(s.pointerType="touch"),typeof s.pointerId>"u"&&(s.pointerId=s.identifier||0),typeof s.pressure>"u"&&(s.pressure=s.force||.5),typeof s.twist>"u"&&(s.twist=0),typeof s.tangentialPressure>"u"&&(s.tangentialPressure=0),typeof s.layerX>"u"&&(s.layerX=s.offsetX=s.clientX),typeof s.layerY>"u"&&(s.layerY=s.offsetY=s.clientY),s.isNormalized=!0,s.type=t.type,e.push(s)}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=RT),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=MT[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}};lh.extension={name:"events",type:[Z.RendererSystem,Z.CanvasRendererSystem]},lh.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let hh=lh;ht.add(hh);function Bp(r){return r==="dynamic"||r==="static"}const DT={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??Bp(hh.defaultEventMode)},set interactive(r){At("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??hh.defaultEventMode},set eventMode(r){this._internalInteractive=Bp(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,n=typeof e=="object"?e.signal:void 0,s=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;n&&n.addEventListener("abort",()=>{l.off(r,a,o)}),s?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,n=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,n)},dispatchEvent(r){if(!(r instanceof Zn))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}};Xt.mixin(DT);const BT={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Xt.mixin(BT);const OT=9,mo=100,LT=0,NT=0,Op=2,Lp=1,FT=-1e3,kT=-1e3,UT=2;class Np{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,(yr.tablet||yr.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${mo}px`,e.style.height=`${mo}px`,e.style.position="absolute",e.style.top=`${LT}px`,e.style.left=`${NT}px`,e.style.zIndex=Op.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=`${Lp}px`,t.style.height=`${Lp}px`,t.style.position="absolute",t.style.top=`${FT}px`,t.style.left=`${kT}px`,t.style.zIndex=UT.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(yr.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:n,height:s}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=n/o*l,c=s/a*l;let u=this.div;u.style.left=`${e}px`,u.style.top=`${i}px`,u.style.width=`${o}px`,u.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,Ji(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let p=f.hitArea;const g=f.worldTransform;f.hitArea?(u.style.left=`${(g.tx+p.x*g.a)*h}px`,u.style.top=`${(g.ty+p.y*g.d)*c}px`,u.style.width=`${p.width*g.a*h}px`,u.style.height=`${p.height*g.d*c}px`):(p=f.getBounds(),this.capHitArea(p),u.style.left=`${p.x*h}px`,u.style.top=`${p.y*c}px`,u.style.width=`${p.width*h}px`,u.style.height=`${p.height*c}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle,u.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(u))}}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=`${mo}px`,e.style.height=`${mo}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Op.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,n=this.renderer.events.rootBoundary,s=Object.assign(new Zn(n),{target:i});n.rootTarget=this.renderer.lastObjectRendered,e.forEach(o=>n.dispatchEvent(s,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===OT&&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}}Np.extension={name:"accessibility",type:[Z.RendererPlugin,Z.CanvasRendererPlugin]},ht.add(Np);const Fp=class Uh{constructor(t){this.stage=new je,t=Object.assign({forceCanvas:!1},t),this.renderer=wp(t),Uh._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=Uh._plugins.slice(0);i.reverse(),i.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Fp._plugins=[];let GT=Fp;ht.handleByList(Z.Application,GT._plugins);class kp{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:n,clientHeight:s}=this._resizeTo;e=n,i=s}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}}kp.extension=Z.Application,ht.add(kp);const Up={loader:Z.LoadParser,resolver:Z.ResolveParser,cache:Z.CacheParser,detection:Z.DetectionParser};ht.handle(Z.Asset,r=>{const t=r.ref;Object.entries(Up).filter(([e])=>!!t[e]).forEach(([e,i])=>ht.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(Up).filter(e=>!!t[e]).forEach(e=>ht.remove(t[e]))});class $T{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 sn(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 Hr(r,t){const e=r.split("?")[0],i=ue.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const Ye=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),ch=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Gp(r,t,e,i,n){const s=t[e];for(let o=0;o<s.length;o++){const a=s[o];e<t.length-1?Gp(r.replace(i[e],a),t,e+1,i,n):n.push(r.replace(i[e],a))}}function HT(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const n=[];e.forEach(s=>{const o=s.substring(1,s.length-1).split(",");n.push(o)}),Gp(r,n,0,e,i)}else i.push(r);return i}const go=r=>!Array.isArray(r);class XT{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=Ye(t);let n;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(e)){n=l.getCacheableAssets(i,e);break}}n||(n={},i.forEach(a=>{n[a]=e}));const s=Object.keys(n),o={cacheKeys:s,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),s.forEach(a=>{const l=n?n[a]:e;this._cache.has(a)&&this._cache.get(a)!==l&&console.warn("[Cache] already has key:",a),this._cache.set(a,n[a])}),e instanceof ct){const a=e;i.forEach(l=>{a.baseTexture!==ct.EMPTY.baseTexture&&bt.addToCache(a.baseTexture,l),ct.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 bi=new XT;class VT{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 n=null,s=null;if(e.loadParser&&(s=this._parserHash[e.loadParser],s||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!s){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))){s=h;break}}if(!s)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}n=await s.load(t,e,this),i.parser=s;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,n,e,this))&&(n=await h.parse(n,e,this)||n,i.parser=h)}return n})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const n={},s=go(t),o=Ye(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const c=ue.toAbsolute(h.src);if(!n[h.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,h)),n[h.src]=await this.promiseCache[c].promise,e&&e(++i/a)}catch(u){throw delete this.promiseCache[c],delete n[h.src],new Error(`[Loader.load] Failed to load ${c}.
867
- ${u}`)}});return await Promise.all(l),s?n[o[0].src]:n}async unload(t){const e=Ye(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const n=ue.toAbsolute(i.src),s=this.promiseCache[n];if(s){const l=await s.promise;delete this.promiseCache[n],(a=(o=s.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 qe=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(qe||{});const zT=".json",jT="application/json",WT={extension:{type:Z.LoadParser,priority:qe.Low},name:"loadJson",test(r){return sn(r,jT)||Hr(r,zT)},async load(r){return await(await tt.ADAPTER.fetch(r)).json()}};ht.add(WT);const YT=".txt",qT="text/plain",KT={name:"loadTxt",extension:{type:Z.LoadParser,priority:qe.Low},test(r){return sn(r,qT)||Hr(r,YT)},async load(r){return await(await tt.ADAPTER.fetch(r)).text()}};ht.add(KT);const ZT=["normal","bold","100","200","300","400","500","600","700","800","900"],JT=[".ttf",".otf",".woff",".woff2"],QT=["font/ttf","font/otf","font/woff","font/woff2"],tA=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function eA(r){const t=ue.extname(r),e=ue.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(s=>s.charAt(0).toUpperCase()+s.slice(1));let i=e.length>0;for(const s of e)if(!s.match(tA)){i=!1;break}let n=e.join(" ");return i||(n=`"${n.replace(/[\\"]/g,"\\$&")}"`),n}const rA=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function iA(r){return rA.test(r)?r:encodeURI(r)}const nA={extension:{type:Z.LoadParser,priority:qe.Low},name:"loadWebFont",test(r){return sn(r,QT)||Hr(r,JT)},async load(r,t){var i,n,s;const e=tt.ADAPTER.getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??eA(r),l=((s=(n=t.data)==null?void 0:n.weights)==null?void 0:s.filter(c=>ZT.includes(c)))??["normal"],h=t.data??{};for(let c=0;c<l.length;c++){const u=l[c],d=new FontFace(a,`url(${iA(r)})`,{...h,weight:u});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=>tt.ADAPTER.getFontFaceSet().delete(t))}};ht.add(nA);const sA=`(function() {
866
+ `;class ST extends Ce{constructor(t=.5,e=Math.random()){super(Tp,AT,{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 Bp={AlphaFilter:uT,BlurFilter:yT,BlurFilterPass:oh,ColorMatrixFilter:ah,DisplacementFilter:xT,FXAAFilter:TT,NoiseFilter:ST};Object.entries(Bp).forEach(([r,t])=>{Object.defineProperty(Bp,r,{get(){return At("7.1.0",`filters.${r} has moved to ${r}`),t}})});class CT{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||(Be.system.add(this.tickerUpdate,this,xi.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Be.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 Xr=new CT;class Qn{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Qn.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new It,this.page=new It,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,n,s){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 mo extends Qn{constructor(){super(...arguments),this.client=new It,this.movement=new It,this.offset=new It,this.global=new It,this.screen=new It}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,n,s,o,a,l,h,c,u,d,f,p,g){throw new Error("Method not implemented.")}}class Ye extends mo{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 sn extends mo{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}sn.DOM_DELTA_PIXEL=0,sn.DOM_DELTA_LINE=1,sn.DOM_DELTA_PAGE=2;const IT=2048,PT=new It,lh=new It;class RT{constructor(t){this.dispatch=new Mn,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,n)=>i.priority-n.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,n=e.length;i<n;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){Xr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[i](this.rootTarget,this.rootTarget.eventMode,PT.set(t,e),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let n=0,s=i.length-1;n<s;n++)if(t.currentTarget=i[n],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 n=i.length-2;n>=0;n--)if(t.currentTarget=i[n],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 n=Array.isArray(e)?e:[e];for(let s=i.length-1;s>=0;s--)n.forEach(o=>{t.currentTarget=i[s],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<IT&&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,n,s,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Xr.pauseUpdate=!1),t.interactiveChildren&&t.children){const c=t.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,n,s,o||s(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),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&&!s(t,i)&&n(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,n,s){if(this._interactivePrune(t)||s(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Xr.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let h=l.length-1;h>=0;h--){const c=l[h],u=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,i,n,s);if(u){if(u.length>0&&!u[u.length-1].parent)continue;const d=t.isInteractive();return(u.length>0||d)&&u.push(t),u}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&n(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,lh),!t.hitArea.contains(lh.x,lh.y)))return!0;if(t._mask){const n=t._mask.isMaskData?t._mask.maskObject:t._mask;if(n&&!((i=n.containsPoint)!=null&&i.call(n,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 s,o;e=e??t.type;const i=`on${e}`;(o=(s=t.currentTarget)[i])==null||o.call(s,t);const n=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,n),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof Ye)){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 n=e.button===2;this.dispatchEvent(e,n?"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 Ye)){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",n=this.trackingData(t.pointerId),s=this.findMountedTarget(n.overTargets);if(((l=n.overTargets)==null?void 0:l.length)>0&&s!==e.target){const c=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,c,s);if(this.dispatchEvent(u,"pointerout"),i&&this.dispatchEvent(u,"mouseout"),!e.composedPath().includes(s)){const d=this.createPointerEvent(t,"pointerleave",s);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(u)}if(s!==e.target){const c=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(e,c);this.dispatchEvent(u,"pointerover"),i&&this.dispatchEvent(u,"mouseover");let d=s==null?void 0:s.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(e,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==s&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),i&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}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,n.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var o;if(!(t instanceof Ye)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),n=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(o=i.target)==null?void 0:o.cursor);const s=this.clonePointerEvent(i,"pointerenter");for(s.eventPhase=s.AT_TARGET;s.target&&s.target!==this.rootTarget.parent;)s.currentTarget=s.target,this.notifyTarget(s),n&&this.notifyTarget(s,"mouseenter"),s.target=s.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(s)}mapPointerOut(t){if(!(t instanceof Ye)){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",n=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(t,"pointerleave",n);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(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof Ye)){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 n=this.trackingData(t.pointerId),s=this.findMountedTarget(n.pressTargetsByButton[t.button]);let o=s;if(s&&!i.composedPath().includes(s)){let a=s;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 n.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=n.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 Ye)){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]),n=this.createPointerEvent(t);if(i){let s=i;for(;s;)n.currentTarget=s,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch"?this.notifyTarget(n,"touchendoutside"):(n.pointerType==="mouse"||n.pointerType==="pen")&&this.notifyTarget(n,n.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof sn)){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 n=this.allocateEvent(Ye);return this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.nativeEvent=t.nativeEvent,n.originalEvent=t,n.target=i??this.hitTest(n.global.x,n.global.y)??this._hitElements[0],typeof e=="string"&&(n.type=e),n}createWheelEvent(t){const e=this.allocateEvent(sn);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(Ye);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 Ye&&e instanceof Ye&&(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 mo&&e instanceof mo&&(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 n=0,s=i.length;n<s&&!t.propagationImmediatelyStopped;n++)i[n].once&&t.currentTarget.removeListener(e,i[n].fn,void 0,!0),i[n].fn.call(i[n].context,t)}}const MT=1,DT={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},hh=class Uh{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new RT(null),Xr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new Ye(null),this.rootWheelEvent=new sn(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Uh.defaultEventFeatures},{set:(e,i,n)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=n),e[i]=n,!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,Uh._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,n=e.length;i<n;i++){const s=e[i],o=this.bootstrapEvent(this.rootPointerEvent,s);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Xr.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,n=e.length;i<n;i++){const s=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(s)}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":"",n=this.normalizeToPointerData(t);for(let s=0,o=n.length;s<o;s++){const a=this.bootstrapEvent(this.rootPointerEvent,n[s]);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,n=e.length;i<n;i++){const s=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(s)}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,Xr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Xr.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;Xr.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 n=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},s=1/this.resolution;t.x=(e-n.left)*(this.domElement.width/n.width)*s,t.y=(i-n.top)*(this.domElement.height/n.height)*s}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,n=t.changedTouches.length;i<n;i++){const s=t.changedTouches[i];typeof s.button>"u"&&(s.button=0),typeof s.buttons>"u"&&(s.buttons=1),typeof s.isPrimary>"u"&&(s.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof s.width>"u"&&(s.width=s.radiusX||1),typeof s.height>"u"&&(s.height=s.radiusY||1),typeof s.tiltX>"u"&&(s.tiltX=0),typeof s.tiltY>"u"&&(s.tiltY=0),typeof s.pointerType>"u"&&(s.pointerType="touch"),typeof s.pointerId>"u"&&(s.pointerId=s.identifier||0),typeof s.pressure>"u"&&(s.pressure=s.force||.5),typeof s.twist>"u"&&(s.twist=0),typeof s.tangentialPressure>"u"&&(s.tangentialPressure=0),typeof s.layerX>"u"&&(s.layerX=s.offsetX=s.clientX),typeof s.layerY>"u"&&(s.layerY=s.offsetY=s.clientY),s.isNormalized=!0,s.type=t.type,e.push(s)}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=MT),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=DT[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}};hh.extension={name:"events",type:[Z.RendererSystem,Z.CanvasRendererSystem]},hh.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let ch=hh;ht.add(ch);function Op(r){return r==="dynamic"||r==="static"}const BT={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??Op(ch.defaultEventMode)},set interactive(r){At("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??ch.defaultEventMode},set eventMode(r){this._internalInteractive=Op(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,n=typeof e=="object"?e.signal:void 0,s=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;n&&n.addEventListener("abort",()=>{l.off(r,a,o)}),s?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,n=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,n)},dispatchEvent(r){if(!(r instanceof Qn))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}};Xt.mixin(BT);const OT={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Xt.mixin(OT);const LT=9,go=100,NT=0,FT=0,Lp=2,Np=1,kT=-1e3,UT=-1e3,GT=2;class Fp{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,(_r.tablet||_r.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${go}px`,e.style.height=`${go}px`,e.style.position="absolute",e.style.top=`${NT}px`,e.style.left=`${FT}px`,e.style.zIndex=Lp.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=`${Np}px`,t.style.height=`${Np}px`,t.style.position="absolute",t.style.top=`${kT}px`,t.style.left=`${UT}px`,t.style.zIndex=GT.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(_r.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:n,height:s}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=n/o*l,c=s/a*l;let u=this.div;u.style.left=`${e}px`,u.style.top=`${i}px`,u.style.width=`${o}px`,u.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,Ji(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let p=f.hitArea;const g=f.worldTransform;f.hitArea?(u.style.left=`${(g.tx+p.x*g.a)*h}px`,u.style.top=`${(g.ty+p.y*g.d)*c}px`,u.style.width=`${p.width*g.a*h}px`,u.style.height=`${p.height*g.d*c}px`):(p=f.getBounds(),this.capHitArea(p),u.style.left=`${p.x*h}px`,u.style.top=`${p.y*c}px`,u.style.width=`${p.width*h}px`,u.style.height=`${p.height*c}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle,u.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(u))}}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=`${go}px`,e.style.height=`${go}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Lp.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,n=this.renderer.events.rootBoundary,s=Object.assign(new Qn(n),{target:i});n.rootTarget=this.renderer.lastObjectRendered,e.forEach(o=>n.dispatchEvent(s,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===LT&&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}}Fp.extension={name:"accessibility",type:[Z.RendererPlugin,Z.CanvasRendererPlugin]},ht.add(Fp);const kp=class Gh{constructor(t){this.stage=new We,t=Object.assign({forceCanvas:!1},t),this.renderer=Ep(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(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};kp._plugins=[];let $T=kp;ht.handleByList(Z.Application,$T._plugins);class Up{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:n,clientHeight:s}=this._resizeTo;e=n,i=s}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}}Up.extension=Z.Application,ht.add(Up);const Gp={loader:Z.LoadParser,resolver:Z.ResolveParser,cache:Z.CacheParser,detection:Z.DetectionParser};ht.handle(Z.Asset,r=>{const t=r.ref;Object.entries(Gp).filter(([e])=>!!t[e]).forEach(([e,i])=>ht.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(Gp).filter(e=>!!t[e]).forEach(e=>ht.remove(t[e]))});class HT{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 on(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 Vr(r,t){const e=r.split("?")[0],i=ue.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const qe=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),uh=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function $p(r,t,e,i,n){const s=t[e];for(let o=0;o<s.length;o++){const a=s[o];e<t.length-1?$p(r.replace(i[e],a),t,e+1,i,n):n.push(r.replace(i[e],a))}}function XT(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const n=[];e.forEach(s=>{const o=s.substring(1,s.length-1).split(",");n.push(o)}),$p(r,n,0,e,i)}else i.push(r);return i}const yo=r=>!Array.isArray(r);class VT{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=qe(t);let n;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(e)){n=l.getCacheableAssets(i,e);break}}n||(n={},i.forEach(a=>{n[a]=e}));const s=Object.keys(n),o={cacheKeys:s,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),s.forEach(a=>{const l=n?n[a]:e;this._cache.has(a)&&this._cache.get(a)!==l&&console.warn("[Cache] already has key:",a),this._cache.set(a,n[a])}),e instanceof ct){const a=e;i.forEach(l=>{a.baseTexture!==ct.EMPTY.baseTexture&&bt.addToCache(a.baseTexture,l),ct.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 wi=new VT;class zT{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 n=null,s=null;if(e.loadParser&&(s=this._parserHash[e.loadParser],s||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!s){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))){s=h;break}}if(!s)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}n=await s.load(t,e,this),i.parser=s;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,n,e,this))&&(n=await h.parse(n,e,this)||n,i.parser=h)}return n})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const n={},s=yo(t),o=qe(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const c=ue.toAbsolute(h.src);if(!n[h.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,h)),n[h.src]=await this.promiseCache[c].promise,e&&e(++i/a)}catch(u){throw delete this.promiseCache[c],delete n[h.src],new Error(`[Loader.load] Failed to load ${c}.
867
+ ${u}`)}});return await Promise.all(l),s?n[o[0].src]:n}async unload(t){const e=qe(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const n=ue.toAbsolute(i.src),s=this.promiseCache[n];if(s){const l=await s.promise;delete this.promiseCache[n],(a=(o=s.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 Ke=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Ke||{});const jT=".json",WT="application/json",YT={extension:{type:Z.LoadParser,priority:Ke.Low},name:"loadJson",test(r){return on(r,WT)||Vr(r,jT)},async load(r){return await(await tt.ADAPTER.fetch(r)).json()}};ht.add(YT);const qT=".txt",KT="text/plain",ZT={name:"loadTxt",extension:{type:Z.LoadParser,priority:Ke.Low},test(r){return on(r,KT)||Vr(r,qT)},async load(r){return await(await tt.ADAPTER.fetch(r)).text()}};ht.add(ZT);const QT=["normal","bold","100","200","300","400","500","600","700","800","900"],JT=[".ttf",".otf",".woff",".woff2"],tA=["font/ttf","font/otf","font/woff","font/woff2"],eA=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function rA(r){const t=ue.extname(r),e=ue.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(s=>s.charAt(0).toUpperCase()+s.slice(1));let i=e.length>0;for(const s of e)if(!s.match(eA)){i=!1;break}let n=e.join(" ");return i||(n=`"${n.replace(/[\\"]/g,"\\$&")}"`),n}const iA=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function nA(r){return iA.test(r)?r:encodeURI(r)}const sA={extension:{type:Z.LoadParser,priority:Ke.Low},name:"loadWebFont",test(r){return on(r,tA)||Vr(r,JT)},async load(r,t){var i,n,s;const e=tt.ADAPTER.getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??rA(r),l=((s=(n=t.data)==null?void 0:n.weights)==null?void 0:s.filter(c=>QT.includes(c)))??["normal"],h=t.data??{};for(let c=0;c<l.length;c++){const u=l[c],d=new FontFace(a,`url(${nA(r)})`,{...h,weight:u});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=>tt.ADAPTER.getFontFaceSet().delete(t))}};ht.add(sA);const oA=`(function() {
868
868
  "use strict";
869
869
  const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
870
870
  async function checkImageBitmap() {
@@ -881,7 +881,7 @@ ${u}`)}});return await Promise.all(l),s?n[o[0].src]:n}async unload(t){const e=Ye
881
881
  self.postMessage(result);
882
882
  });
883
883
  })();
884
- `;let on=null,uh=class{constructor(){on||(on=URL.createObjectURL(new Blob([sA],{type:"application/javascript"}))),this.worker=new Worker(on)}};uh.revokeObjectURL=function(){on&&(URL.revokeObjectURL(on),on=null)};const oA=`(function() {
884
+ `;let an=null,dh=class{constructor(){an||(an=URL.createObjectURL(new Blob([oA],{type:"application/javascript"}))),this.worker=new Worker(an)}};dh.revokeObjectURL=function(){an&&(URL.revokeObjectURL(an),an=null)};const aA=`(function() {
885
885
  "use strict";
886
886
  async function loadImageBitmap(url) {
887
887
  const response = await fetch(url);
@@ -907,8 +907,8 @@ ${u}`)}});return await Promise.all(l),s?n[o[0].src]:n}async unload(t){const e=Ye
907
907
  }
908
908
  };
909
909
  })();
910
- `;let an=null;class $p{constructor(){an||(an=URL.createObjectURL(new Blob([oA],{type:"application/javascript"}))),this.worker=new Worker(an)}}$p.revokeObjectURL=function(){an&&(URL.revokeObjectURL(an),an=null)};let Hp=0,dh;class aA{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 uh;e.addEventListener("message",i=>{e.terminate(),uh.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){dh===void 0&&(dh=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<dh&&(this._createdWorkers++,t=new $p().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((n,s)=>{this.queue.push({id:t,arguments:e,resolve:n,reject:s})});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[Hp]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Hp++,id:i})}}const Xp=new aA;function Jn(r,t,e){r.resource.internal=!0;const i=new ct(r),n=()=>{delete t.promiseCache[e],bi.has(e)&&bi.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."),n())}),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."),n())}),i}const lA=[".jpeg",".jpg",".png",".webp",".avif"],hA=["image/jpeg","image/png","image/webp","image/avif"];async function cA(r){const t=await tt.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 yo={name:"loadTextures",extension:{type:Z.LoadParser,priority:qe.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return sn(r,hA)||Hr(r,lA)},async load(r,t,e){var a;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let n;i?this.config.preferWorkers&&await Xp.isImageBitmapSupported()?n=await Xp.loadImageBitmap(r):n=await cA(r):n=await new Promise((l,h)=>{const c=new Image;c.crossOrigin=this.config.crossOrigin,c.src=r,c.complete?l(c):(c.onload=()=>l(c),c.onerror=u=>h(u))});const s={...t.data};s.resolution??(s.resolution=xr(r)),i&&((a=s.resourceOptions)==null?void 0:a.ownsImageBitmap)===void 0&&(s.resourceOptions={...s.resourceOptions},s.resourceOptions.ownsImageBitmap=!0);const o=new bt(n,s);return o.resource.src=r,Jn(o,e,r)},unload(r){r.destroy(!0)}};ht.add(yo);const uA=".svg",dA="image/svg+xml",fA={extension:{type:Z.LoadParser,priority:qe.High},name:"loadSVG",test(r){return sn(r,dA)||Hr(r,uA)},async testParse(r){return ih.test(r)},async parse(r,t,e){var s;const i=new ih(r,(s=t==null?void 0:t.data)==null?void 0:s.resourceOptions);await i.load();const n=new bt(i,{resolution:xr(r),...t==null?void 0:t.data});return n.resource.src=t.src,Jn(n,e,t.src)},async load(r,t){return(await tt.ADAPTER.fetch(r)).text()},unload:yo.unload};ht.add(fA);const pA=[".mp4",".m4v",".webm",".ogv"],mA=["video/mp4","video/webm","video/ogg"],gA={name:"loadVideo",extension:{type:Z.LoadParser,priority:qe.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(r){return sn(r,mA)||Hr(r,pA)},async load(r,t,e){var o;let i;const n=await(await tt.ADAPTER.fetch(r)).blob(),s=URL.createObjectURL(n);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 Pp(s,a);await l.load();const h=new bt(l,{alphaMode:await ww(),resolution:xr(r),...t==null?void 0:t.data});h.resource.src=r,i=Jn(h,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(s)})}catch(a){throw URL.revokeObjectURL(s),a}return i},unload(r){r.destroy(!0)}};ht.add(gA);class yA{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:n,srcs:s}=t;return Ye(e||i||n||s,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(n=>{const s=n.src??n.srcs,o=n.alias??n.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({...n,alias:a,src:s})}):Object.keys(e).forEach(n=>{const s=[n,this._createBundleAssetId(t,n)];if(typeof e[n]=="string")this.add({alias:s,src:e[n]});else if(Array.isArray(e[n]))this.add({alias:s,src:e[n]});else{const o=e[n],a=o.src??o.srcs;this.add({...o,alias:s,src:Array.isArray(a)?a:[a]})}i.push(...s)}),this._bundles[t]=i}add(t,e,i,n,s){const o=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(At("7.2.0",`Assets.add now uses an object instead of individual parameters.
911
- Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:t,src:e,data:i,format:n,loadParser:s})):Array.isArray(t)?o.push(...t):o.push(t);let a;a=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},Ye(o).forEach(l=>{const{src:h,srcs:c}=l;let{data:u,format:d,loadParser:f}=l;const p=Ye(h||c).map(_=>typeof _=="string"?HT(_):Array.isArray(_)?_:[_]),g=this.getAlias(l);Array.isArray(g)?g.forEach(a):a(g);const y=[];p.forEach(_=>{_.forEach(v=>{let m={};if(typeof v!="object"){m.src=v;for(let b=0;b<this._parsers.length;b++){const S=this._parsers[b];if(S.test(v)){m=S.parse(v);break}}}else u=v.data??u,d=v.format??d,f=v.loadParser??f,m={...m,...v};if(!g)throw new Error(`[Resolver] alias is undefined for this asset: ${m.src}`);m=this.buildResolvedAsset(m,{aliases:g,data:u,format:d,loadParser:f}),y.push(m)})}),g.forEach(_=>{this._assetMap[_]=y})})}resolveBundle(t){const e=go(t);t=Ye(t);const i={};return t.forEach(n=>{const s=this._bundles[n];if(s){const o=this.resolve(s),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(n,l)]=h}i[n]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const n in e)i[n]=e[n].src;return i}return e.src}resolve(t){const e=go(t);t=Ye(t);const i={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let s=this._assetMap[n];const o=s[0],a=this._getPreferredOrder(s);a==null||a.priority.forEach(l=>{a.params[l].forEach(h=>{const c=s.filter(u=>u[l]?u[l]===h:!1);c.length&&(s=c)})}),this._resolverHash[n]=s[0]??o}else this._resolverHash[n]=this.buildResolvedAsset({alias:[n],src:n},{});i[n]=this._resolverHash[n]}),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],n=this._preferredOrder.find(s=>s.params.format.includes(i.format));if(n)return n}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:n,loadParser:s,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=ue.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=s??t.loadParser,t.format=o??t.format??ue.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class _A{constructor(){this._detections=[],this._initialized=!1,this.resolver=new yA,this.loader=new VT,this.cache=bi,this._backgroundLoader=new $T(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var s,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=((s=t.texturePreference)==null?void 0:s.resolution)??1,i=typeof e=="number"?[e]:e,n=await this._detectFormats({preferredFormats:(o=t.texturePreference)==null?void 0:o.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,n,s){this.resolver.add(t,e,i,n,s)}async load(t,e){this._initialized||await this.init();const i=go(t),n=Ye(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}),s=this.resolver.resolve(n),o=await this._mapLoadToResolve(s,e);return i?o[n[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 n=this.resolver.resolveBundle(t),s={},o=Object.keys(n);let a=0,l=0;const h=()=>{e==null||e(++a/l)},c=o.map(u=>{const d=n[u];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(f=>{s[u]=f})});return await Promise.all(c),i?s[t[0]]:s}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 bi.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=bi.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),n=Object.keys(t);this._backgroundLoader.active=!1;const s=await this.loader.load(i,e);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=s[a.src],c=[a.src];a.alias&&c.push(...a.alias),o[n[l]]=h,bi.set(c,h)}),o}async unload(t){this._initialized||await this.init();const e=Ye(t).map(n=>typeof n!="string"?n.src:n),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=Ye(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(n=>this._unloadFromResolved(e[n]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{bi.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,n)=>e.indexOf(i)===n),e}get detections(){return this._detections}get preferWorkers(){return yo.config.preferWorkers}set preferWorkers(t){At("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 _o=new _A;ht.handleByList(Z.LoadParser,_o.loader.parsers).handleByList(Z.ResolveParser,_o.resolver.parsers).handleByList(Z.CacheParser,_o.cache.parsers).handleByList(Z.DetectionParser,_o.detections);const vA={extension:Z.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof ct),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((n,s)=>{e[i+(s===0?"":s+1)]=n})}),e}};ht.add(vA);async function Vp(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 bA={extension:{type:Z.DetectionParser,priority:1},test:async()=>Vp("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};ht.add(bA);const xA={extension:{type:Z.DetectionParser,priority:0},test:async()=>Vp("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};ht.add(xA);const zp=["png","jpg","jpeg"],wA={extension:{type:Z.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...zp],remove:async r=>r.filter(t=>!zp.includes(t))};ht.add(wA);const EA="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function fh(r){return EA?!1:document.createElement("video").canPlayType(r)!==""}const TA={extension:{type:Z.DetectionParser,priority:0},test:async()=>fh("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};ht.add(TA);const AA={extension:{type:Z.DetectionParser,priority:0},test:async()=>fh("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};ht.add(AA);const SA={extension:{type:Z.DetectionParser,priority:0},test:async()=>fh("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};ht.add(SA);const CA={extension:Z.ResolveParser,test:yo.test,parse:r=>{var t;return{resolution:parseFloat(((t=tt.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:ue.extname(r).slice(1),src:r}}};ht.add(CA);var be=(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))(be||{});const vo={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 dr,ln;function jp(){ln={bptc:dr.getExtension("EXT_texture_compression_bptc"),astc:dr.getExtension("WEBGL_compressed_texture_astc"),etc:dr.getExtension("WEBGL_compressed_texture_etc"),s3tc:dr.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:dr.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:dr.getExtension("WEBGL_compressed_texture_pvrtc")||dr.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:dr.getExtension("WEBGL_compressed_texture_etc1"),atc:dr.getExtension("WEBGL_compressed_texture_atc")}}const IA={extension:{type:Z.DetectionParser,priority:2},test:async()=>{const r=tt.ADAPTER.createCanvas().getContext("webgl");return r?(dr=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{ln||jp();const t=[];for(const e in ln)ln[e]&&t.push(e);return[...t,...r]},remove:async r=>(ln||jp(),r.filter(t=>!(t in ln)))};ht.add(IA);class PA extends js{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,n;typeof t=="string"?(i=t,n=new Uint8Array):(i=null,n=t),super(n,e),this.origin=i,this.buffer=n?new Dl(n):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 Dl(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class xi extends PA{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=xi._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||xi._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const n=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;n.pixelStorei(n.UNPACK_ALIGNMENT,4);for(let s=0,o=this.levels;s<o;s++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:c}=this._levelBuffers[s];n.compressedTexImage2D(n.TEXTURE_2D,a,this.format,l,h,0,c)}return!0}onBlobLoaded(){this._levelBuffers=xi._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,n,s,o,a){const l=new Array(i);let h=t.byteOffset,c=o,u=a,d=c+n-1&~(n-1),f=u+s-1&~(s-1),p=d*f*vo[e];for(let g=0;g<i;g++)l[g]={levelID:g,levelWidth:i>1?c:d,levelHeight:i>1?u:f,levelBuffer:new Uint8Array(t.buffer,h,p)},h+=p,c=c>>1||1,u=u>>1||1,d=c+n-1&~(n-1),f=u+s-1&~(s-1),p=d*f*vo[e];return l}}const ph=4,bo=124,RA=32,Wp=20,MA=542327876,xo={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},DA={FOURCC:2},wo={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},BA=1,OA=2,LA=4,NA=64,FA=512,kA=131072,UA=827611204,GA=861165636,$A=894720068,HA=808540228,XA=4,VA={[UA]:be.COMPRESSED_RGBA_S3TC_DXT1_EXT,[GA]:be.COMPRESSED_RGBA_S3TC_DXT3_EXT,[$A]:be.COMPRESSED_RGBA_S3TC_DXT5_EXT},zA={70:be.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:be.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:be.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:be.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:be.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:be.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:be.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:be.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:be.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:be.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:be.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:be.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:be.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function jA(r){const t=new Uint32Array(r);if(t[0]!==MA)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,bo/Uint32Array.BYTES_PER_ELEMENT),i=e[xo.HEIGHT],n=e[xo.WIDTH],s=e[xo.MIPMAP_COUNT],o=new Uint32Array(r,xo.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,RA/Uint32Array.BYTES_PER_ELEMENT),a=o[BA];if(a&LA){const l=o[DA.FOURCC];if(l!==HA){const v=VA[l],m=ph+bo,b=new Uint8Array(r,m);return[new xi(b,{format:v,width:n,height:i,levels:s})]}const h=ph+bo,c=new Uint32Array(t.buffer,h,Wp/Uint32Array.BYTES_PER_ELEMENT),u=c[wo.DXGI_FORMAT],d=c[wo.RESOURCE_DIMENSION],f=c[wo.MISC_FLAG],p=c[wo.ARRAY_SIZE],g=zA[u];if(g===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${u}`);if(f===XA)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,_=ph+bo+Wp;if(p===1)y.push(new Uint8Array(r,_));else{const v=vo[g];let m=0,b=n,S=i;for(let C=0;C<s;C++){const I=Math.max(1,b+3&-4),M=Math.max(1,S+3&-4),F=I*M*v;m+=F,b=b>>>1,S=S>>>1}let R=_;for(let C=0;C<p;C++)y.push(new Uint8Array(r,R,m)),R+=m}return y.map(v=>new xi(v,{format:g,width:n,height:i,levels:s}))}throw a&NA?new Error("DDSParser does not support uncompressed texture data."):a&FA?new Error("DDSParser does not supported YUV uncompressed texture data."):a&kA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&OA?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 Yp=[171,75,84,88,32,49,49,187,13,10,26,10],WA=67305985,Ke={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,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},mh=64,qp={[pt.UNSIGNED_BYTE]:1,[pt.UNSIGNED_SHORT]:2,[pt.INT]:4,[pt.UNSIGNED_INT]:4,[pt.FLOAT]:4,[pt.HALF_FLOAT]:8},YA={[j.RGBA]:4,[j.RGB]:3,[j.RG]:2,[j.RED]:1,[j.LUMINANCE]:1,[j.LUMINANCE_ALPHA]:2,[j.ALPHA]:1},qA={[pt.UNSIGNED_SHORT_4_4_4_4]:2,[pt.UNSIGNED_SHORT_5_5_5_1]:2,[pt.UNSIGNED_SHORT_5_6_5]:2};function KA(r,t,e=!1){const i=new DataView(t);if(!ZA(r,i))return null;const n=i.getUint32(Ke.ENDIANNESS,!0)===WA,s=i.getUint32(Ke.GL_TYPE,n),o=i.getUint32(Ke.GL_FORMAT,n),a=i.getUint32(Ke.GL_INTERNAL_FORMAT,n),l=i.getUint32(Ke.PIXEL_WIDTH,n),h=i.getUint32(Ke.PIXEL_HEIGHT,n)||1,c=i.getUint32(Ke.PIXEL_DEPTH,n)||1,u=i.getUint32(Ke.NUMBER_OF_ARRAY_ELEMENTS,n)||1,d=i.getUint32(Ke.NUMBER_OF_FACES,n),f=i.getUint32(Ke.NUMBER_OF_MIPMAP_LEVELS,n),p=i.getUint32(Ke.BYTES_OF_KEY_VALUE_DATA,n);if(h===0||c!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==1)throw new Error("WebGL does not support array textures");const g=4,y=4,_=l+3&-4,v=h+3&-4,m=new Array(u);let b=l*h;s===0&&(b=_*v);let S;if(s!==0?qp[s]?S=qp[s]*YA[o]:S=qA[s]:S=vo[a],S===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const R=e?QA(i,p,n):null;let C=b*S,I=l,M=h,F=_,U=v,P=mh+p;for(let T=0;T<f;T++){const E=i.getUint32(P,n);let A=P+4;for(let L=0;L<u;L++){let D=m[L];D||(D=m[L]=new Array(f)),D[T]={levelID:T,levelWidth:f>1||s!==0?I:F,levelHeight:f>1||s!==0?M:U,levelBuffer:new Uint8Array(t,A,C)},A+=C}P+=E+4,P=P%4!==0?P+4-P%4:P,I=I>>1||1,M=M>>1||1,F=I+g-1&-4,U=M+y-1&-4,C=F*U*S}return s!==0?{uncompressed:m.map(T=>{let E=T[0].levelBuffer,A=!1;return s===pt.FLOAT?E=new Float32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4):s===pt.UNSIGNED_INT?(A=!0,E=new Uint32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4)):s===pt.INT&&(A=!0,E=new Int32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4)),{resource:new js(E,{width:T[0].levelWidth,height:T[0].levelHeight}),type:s,format:A?JA(o):o}}),kvData:R}:{compressed:m.map(T=>new xi(null,{format:a,width:l,height:h,levels:f,levelBuffers:T})),kvData:R}}function ZA(r,t){for(let e=0;e<Yp.length;e++)if(t.getUint8(e)!==Yp[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function JA(r){switch(r){case j.RGBA:return j.RGBA_INTEGER;case j.RGB:return j.RGB_INTEGER;case j.RG:return j.RG_INTEGER;case j.RED:return j.RED_INTEGER;default:return r}}function QA(r,t,e){const i=new Map;let n=0;for(;n<t;){const s=r.getUint32(mh+n,e),o=mh+n+4,a=3-(s+3)%4;if(s===0||s>t-n){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<s&&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)),c=new DataView(r.buffer,o+l+1,s-l-1);i.set(h,c),n+=4+s+a}return i}const tS={extension:{type:Z.LoadParser,priority:qe.High},name:"loadDDS",test(r){return Hr(r,".dds")},async load(r,t,e){const i=await(await tt.ADAPTER.fetch(r)).arrayBuffer(),n=jA(i).map(s=>{const o=new bt(s,{mipmap:rr.OFF,alphaMode:Re.NO_PREMULTIPLIED_ALPHA,resolution:xr(r),...t.data});return Jn(o,e,r)});return n.length===1?n[0]:n},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};ht.add(tS);const eS={extension:{type:Z.LoadParser,priority:qe.High},name:"loadKTX",test(r){return Hr(r,".ktx")},async load(r,t,e){const i=await(await tt.ADAPTER.fetch(r)).arrayBuffer(),{compressed:n,uncompressed:s,kvData:o}=KA(r,i),a=n??s,l={mipmap:rr.OFF,alphaMode:Re.NO_PREMULTIPLIED_ALPHA,resolution:xr(r),...t.data},h=a.map(c=>{a===s&&Object.assign(l,{type:c.type,format:c.format});const u=c.resource??c,d=new bt(u,l);return d.ktxKeyValueData=o,Jn(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};ht.add(eS);const rS=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],iS={extension:Z.ResolveParser,test:r=>{const t=ue.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{var i,n;const t=r.split("."),e=t.pop();if(["ktx","dds"].includes(e)){const s=t.pop();if(rS.includes(s))return{resolution:parseFloat(((i=tt.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:s,src:r}}return{resolution:parseFloat(((n=tt.RETINA_PREFIX.exec(r))==null?void 0:n[1])??"1"),format:e,src:r}}};ht.add(iS);const Eo=new wt,nS=4,Kp=class is{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,n){const s=new Image;return s.src=await this.base64(t,e,i,n),s}async base64(t,e,i,n){const s=this.canvas(t,n);if(s.toBlob!==void 0)return new Promise((o,a)=>{s.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(s.toDataURL!==void 0)return s.toDataURL(e,i);if(s.convertToBlob!==void 0){const o=await s.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:n,height:s,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);o&&is._flipY(i,n,s),a&&is._unpremultiplyAlpha(i);const l=new kw(n,s,1),h=new ImageData(new Uint8ClampedArray(i.buffer),n,s);return l.context.putImageData(h,0,0),l.canvas}pixels(t,e){const{pixels:i,width:n,height:s,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&is._flipY(i,n,s),a&&is._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let n,s=!1,o=!1,a,l=!1;t&&(t instanceof gi?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(Eo.width=e.width,Eo.height=e.height,e=Eo)));const h=i.gl;if(a){if(n=a.baseTexture.resolution,e=e??a.frame,s=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===j.RGBA,!l){i.renderTexture.bind(a);const f=a.framebuffer.glFramebuffers[i.CONTEXT_UID];f.blitFramebuffer&&i.framebuffer.bind(f.blitFramebuffer)}}else n=i.resolution,e||(e=Eo,e.width=i.width/n,e.height=i.height/n),s=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const c=Math.max(Math.round(e.width*n),1),u=Math.max(Math.round(e.height*n),1),d=new Uint8Array(nS*c*u);return h.readPixels(Math.round(e.x*n),Math.round(e.y*n),c,u,h.RGBA,h.UNSIGNED_BYTE,d),l&&(a==null||a.destroy(!0)),{pixels:d,width:c,height:u,flipY:s,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(t,e,i){const n=e<<2,s=i>>1,o=new Uint8Array(n);for(let a=0;a<s;a++){const l=a*n,h=(i-a-1)*n;o.set(t.subarray(l,l+n)),t.copyWithin(l,h,h+n),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 n=t[i+3];if(n!==0){const s=255.001/n;t[i]=t[i]*s+.5,t[i+1]=t[i+1]*s+.5,t[i+2]=t[i+2]*s+.5}}}};Kp.extension={name:"extract",type:Z.RendererSystem};let sS=Kp;ht.add(sS);const To={build(r){const t=r.points;let e,i,n,s,o,a;if(r.type===ve.CIRC){const p=r.shape;e=p.x,i=p.y,o=a=p.radius,n=s=0}else if(r.type===ve.ELIP){const p=r.shape;e=p.x,i=p.y,o=p.width,a=p.height,n=s=0}else{const p=r.shape,g=p.width/2,y=p.height/2;e=p.x+g,i=p.y+y,o=a=Math.max(0,Math.min(p.radius,Math.min(g,y))),n=g-o,s=y-a}if(!(o>=0&&a>=0&&n>=0&&s>=0)){t.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(n?4:0)+(s?4:0);if(t.length=h,h===0)return;if(l===0){t.length=8,t[0]=t[6]=e+n,t[1]=t[3]=i+s,t[2]=t[4]=e-n,t[5]=t[7]=i-s;return}let c=0,u=l*4+(n?2:0)+2,d=u,f=h;{const p=n+o,g=s,y=e+p,_=e-p,v=i+g;if(t[c++]=y,t[c++]=v,t[--u]=v,t[--u]=_,s){const m=i-g;t[d++]=_,t[d++]=m,t[--f]=m,t[--f]=y}}for(let p=1;p<l;p++){const g=Math.PI/2*(p/l),y=n+Math.cos(g)*o,_=s+Math.sin(g)*a,v=e+y,m=e-y,b=i+_,S=i-_;t[c++]=v,t[c++]=b,t[--u]=b,t[--u]=m,t[d++]=m,t[d++]=S,t[--f]=S,t[--f]=v}{const p=n,g=s+a,y=e+p,_=e-p,v=i+g,m=i-g;t[c++]=y,t[c++]=v,t[--f]=m,t[--f]=y,n&&(t[c++]=_,t[c++]=v,t[--f]=m,t[--f]=_)}},triangulate(r,t){const e=r.points,i=t.points,n=t.indices;if(e.length===0)return;let s=i.length/2;const o=s;let a,l;if(r.type!==ve.RREC){const c=r.shape;a=c.x,l=c.y}else{const c=r.shape;a=c.x+c.width/2,l=c.y+c.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),s++,i.push(e[0],e[1]);for(let c=2;c<e.length;c+=2)i.push(e[c],e[c+1]),n.push(s++,o,s);n.push(o+1,o,s)}};function Zp(r,t=!1){const e=r.length;if(e<6)return;let i=0;for(let n=0,s=r[e-2],o=r[e-1];n<e;n+=2){const a=r[n],l=r[n+1];i+=(a-s)*(l+o),s=a,o=l}if(!t&&i>0||t&&i<=0){const n=e/2;for(let s=n+n%2;s<e;s+=2){const o=e-s-2,a=e-s-1,l=s,h=s+1;[r[o],r[l]]=[r[l],r[o]],[r[a],r[h]]=[r[h],r[a]]}}}const Jp={build(r){r.points=r.shape.points.slice()},triangulate(r,t){let e=r.points;const i=r.holes,n=t.points,s=t.indices;if(e.length>=6){Zp(e,!1);const o=[];for(let h=0;h<i.length;h++){const c=i[h];Zp(c.points,!0),o.push(e.length/2),e=e.concat(c.points)}const a=c1(e,o,2);if(!a)return;const l=n.length/2;for(let h=0;h<a.length;h+=3)s.push(a[h]+l),s.push(a[h+1]+l),s.push(a[h+2]+l);for(let h=0;h<e.length;h++)n.push(e[h])}}},oS={build(r){const t=r.shape,e=t.x,i=t.y,n=t.width,s=t.height,o=r.points;o.length=0,n>=0&&s>=0&&o.push(e,i,e+n,i,e+n,i+s,e,i+s)},triangulate(r,t){const e=r.points,i=t.points;if(e.length===0)return;const n=i.length/2;i.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(n,n+1,n+2,n+1,n+2,n+3)}},aS={build(r){To.build(r)},triangulate(r,t){To.triangulate(r,t)}};var Ge=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(Ge||{}),Xr=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(Xr||{});const hn={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 Qp{static curveTo(t,e,i,n,s,o){const a=o[o.length-2],l=o[o.length-1]-e,h=a-t,c=n-e,u=i-t,d=Math.abs(l*u-h*c);if(d<1e-8||s===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const f=l*l+h*h,p=c*c+u*u,g=l*c+h*u,y=s*Math.sqrt(f)/d,_=s*Math.sqrt(p)/d,v=y*g/f,m=_*g/p,b=y*u+_*h,S=y*c+_*l,R=h*(_+v),C=l*(_+v),I=u*(y+m),M=c*(y+m),F=Math.atan2(C-S,R-b),U=Math.atan2(M-S,I-b);return{cx:b+t,cy:S+e,radius:s,startAngle:F,endAngle:U,anticlockwise:h*c>u*l}}static arc(t,e,i,n,s,o,a,l,h){const c=a-o,u=hn._segmentsCount(Math.abs(c)*s,Math.ceil(Math.abs(c)/Ys)*40),d=c/(u*2),f=d*2,p=Math.cos(d),g=Math.sin(d),y=u-1,_=y%1/y;for(let v=0;v<=y;++v){const m=v+_*v,b=d+o+f*m,S=Math.cos(b),R=-Math.sin(b);h.push((p*S+g*R)*s+i,(p*-R+g*S)*s+n)}}}class lS{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 gh{static curveLength(t,e,i,n,s,o,a,l){let h=0,c=0,u=0,d=0,f=0,p=0,g=0,y=0,_=0,v=0,m=0,b=t,S=e;for(let R=1;R<=10;++R)c=R/10,u=c*c,d=u*c,f=1-c,p=f*f,g=p*f,y=g*t+3*p*c*i+3*f*u*s+d*a,_=g*e+3*p*c*n+3*f*u*o+d*l,v=b-y,m=S-_,b=y,S=_,h+=Math.sqrt(v*v+m*m);return h}static curveTo(t,e,i,n,s,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const c=hn._segmentsCount(gh.curveLength(l,h,t,e,i,n,s,o));let u=0,d=0,f=0,p=0,g=0;a.push(l,h);for(let y=1,_=0;y<=c;++y)_=y/c,u=1-_,d=u*u,f=d*u,p=_*_,g=p*_,a.push(f*l+3*d*_*t+3*u*p*i+g*s,f*h+3*d*_*e+3*u*p*n+g*o)}}function tm(r,t,e,i,n,s,o,a){const l=r-e*n,h=t-i*n,c=r+e*s,u=t+i*s;let d,f;o?(d=i,f=-e):(d=-i,f=e);const p=l+d,g=h+f,y=c+d,_=u+f;return a.push(p,g,y,_),2}function wi(r,t,e,i,n,s,o,a){const l=e-r,h=i-t;let c=Math.atan2(l,h),u=Math.atan2(n-r,s-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),g=Math.sqrt(l*l+h*h),y=(15*p*Math.sqrt(g)/Math.PI>>0)+1,_=f/y;if(d+=_,a){o.push(r,t,e,i);for(let v=1,m=d;v<y;v++,m+=_)o.push(r,t,r+Math.sin(m)*g,t+Math.cos(m)*g);o.push(r,t,n,s)}else{o.push(e,i,r,t);for(let v=1,m=d;v<y;v++,m+=_)o.push(r+Math.sin(m)*g,t+Math.cos(m)*g,r,t);o.push(n,s,r,t)}return y*2}function hS(r,t){const e=r.shape;let i=r.points||e.points.slice();const n=t.closePointEps;if(i.length===0)return;const s=r.lineStyle,o=new It(i[0],i[1]),a=new It(i[i.length-2],i[i.length-1]),l=e.type!==ve.POLY||e.closeStroke,h=Math.abs(o.x-a.x)<n&&Math.abs(o.y-a.y)<n;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const D=(o.x+a.x)*.5,N=(a.y+o.y)*.5;i.unshift(D,N),i.push(D,N)}const c=t.points,u=i.length/2;let d=i.length;const f=c.length/2,p=s.width/2,g=p*p,y=s.miterLimit*s.miterLimit;let _=i[0],v=i[1],m=i[2],b=i[3],S=0,R=0,C=-(v-b),I=_-m,M=0,F=0,U=Math.sqrt(C*C+I*I);C/=U,I/=U,C*=p,I*=p;const P=s.alignment,T=(1-P)*2,E=P*2;l||(s.cap===Xr.ROUND?d+=wi(_-C*(T-E)*.5,v-I*(T-E)*.5,_-C*T,v-I*T,_+C*E,v+I*E,c,!0)+2:s.cap===Xr.SQUARE&&(d+=tm(_,v,C,I,T,E,!0,c))),c.push(_-C*T,v-I*T,_+C*E,v+I*E);for(let D=1;D<u-1;++D){_=i[(D-1)*2],v=i[(D-1)*2+1],m=i[D*2],b=i[D*2+1],S=i[(D+1)*2],R=i[(D+1)*2+1],C=-(v-b),I=_-m,U=Math.sqrt(C*C+I*I),C/=U,I/=U,C*=p,I*=p,M=-(b-R),F=m-S,U=Math.sqrt(M*M+F*F),M/=U,F/=U,M*=p,F*=p;const N=m-_,$=v-b,O=m-S,B=R-b,k=N*O+$*B,V=$*O-B*N,z=V<0;if(Math.abs(V)<.001*Math.abs(k)){c.push(m-C*T,b-I*T,m+C*E,b+I*E),k>=0&&(s.join===Ge.ROUND?d+=wi(m,b,m-C*T,b-I*T,m-M*T,b-F*T,c,!1)+4:d+=2,c.push(m-M*E,b-F*E,m+M*T,b+F*T));continue}const K=(-C+_)*(-I+b)-(-C+m)*(-I+v),X=(-M+S)*(-F+b)-(-M+m)*(-F+R),ft=(N*X-O*K)/V,H=(B*K-$*X)/V,mt=(ft-m)*(ft-m)+(H-b)*(H-b),J=m+(ft-m)*T,ut=b+(H-b)*T,gt=m-(ft-m)*E,Et=b-(H-b)*E,Dt=Math.min(N*N+$*$,O*O+B*B),Yt=z?T:E,Vt=Dt+Yt*Yt*g,et=mt<=Vt;let $e=s.join;if($e===Ge.MITER&&mt/g>y&&($e=Ge.BEVEL),et)switch($e){case Ge.MITER:{c.push(J,ut,gt,Et);break}case Ge.BEVEL:{z?c.push(J,ut,m+C*E,b+I*E,J,ut,m+M*E,b+F*E):c.push(m-C*T,b-I*T,gt,Et,m-M*T,b-F*T,gt,Et),d+=2;break}case Ge.ROUND:{z?(c.push(J,ut,m+C*E,b+I*E),d+=wi(m,b,m+C*E,b+I*E,m+M*E,b+F*E,c,!0)+4,c.push(J,ut,m+M*E,b+F*E)):(c.push(m-C*T,b-I*T,gt,Et),d+=wi(m,b,m-C*T,b-I*T,m-M*T,b-F*T,c,!1)+4,c.push(m-M*T,b-F*T,gt,Et));break}}else{switch(c.push(m-C*T,b-I*T,m+C*E,b+I*E),$e){case Ge.MITER:{z?c.push(gt,Et,gt,Et):c.push(J,ut,J,ut),d+=2;break}case Ge.ROUND:{z?d+=wi(m,b,m+C*E,b+I*E,m+M*E,b+F*E,c,!0)+2:d+=wi(m,b,m-C*T,b-I*T,m-M*T,b-F*T,c,!1)+2;break}}c.push(m-M*T,b-F*T,m+M*E,b+F*E),d+=2}}_=i[(u-2)*2],v=i[(u-2)*2+1],m=i[(u-1)*2],b=i[(u-1)*2+1],C=-(v-b),I=_-m,U=Math.sqrt(C*C+I*I),C/=U,I/=U,C*=p,I*=p,c.push(m-C*T,b-I*T,m+C*E,b+I*E),l||(s.cap===Xr.ROUND?d+=wi(m-C*(T-E)*.5,b-I*(T-E)*.5,m-C*T,b-I*T,m+C*E,b+I*E,c,!1)+2:s.cap===Xr.SQUARE&&(d+=tm(m,b,C,I,T,E,!1,c)));const A=t.indices,L=hn.epsilon*hn.epsilon;for(let D=f;D<d+f-2;++D)_=c[D*2],v=c[D*2+1],m=c[(D+1)*2],b=c[(D+1)*2+1],S=c[(D+2)*2],R=c[(D+2)*2+1],!(Math.abs(_*(b-R)+m*(R-v)+S*(v-b))<L)&&A.push(D,D+1,D+2)}function cS(r,t){let e=0;const i=r.shape,n=r.points||i.points,s=i.type!==ve.POLY||i.closeStroke;if(n.length===0)return;const o=t.points,a=t.indices,l=n.length/2,h=o.length/2;let c=h;for(o.push(n[0],n[1]),e=1;e<l;e++)o.push(n[e*2],n[e*2+1]),a.push(c,c+1),c++;s&&a.push(c,h)}function em(r,t){r.lineStyle.native?cS(r,t):hS(r,t)}class yh{static curveLength(t,e,i,n,s,o){const a=t-2*i+s,l=e-2*n+o,h=2*i-2*t,c=2*n-2*e,u=4*(a*a+l*l),d=4*(a*h+l*c),f=h*h+c*c,p=2*Math.sqrt(u+d+f),g=Math.sqrt(u),y=2*u*g,_=2*Math.sqrt(f),v=d/g;return(y*p+g*d*(p-_)+(4*f*u-d*d)*Math.log((2*g+v+p)/(v+_)))/(4*y)}static curveTo(t,e,i,n,s){const o=s[s.length-2],a=s[s.length-1],l=hn._segmentsCount(yh.curveLength(o,a,t,e,i,n));let h=0,c=0;for(let u=1;u<=l;++u){const d=u/l;h=o+(t-o)*d,c=a+(e-a)*d,s.push(h+(t+(i-t)*d-h)*d,c+(e+(n-e)*d-c)*d)}}}const _h={[ve.POLY]:Jp,[ve.CIRC]:To,[ve.ELIP]:To,[ve.RECT]:oS,[ve.RREC]:aS},rm=[],Ao=[];class So{constructor(t,e=null,i=null,n=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=n,this.type=t.type}clone(){return new So(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 cn=new It,im=class Ym extends Lf{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 fo,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(),Ao.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),rm.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,n=null){const s=new So(t,e,i,n);return this.graphicsData.push(s),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new So(t,null,null,e),n=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=n.lineStyle,n.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 n=e[i];if(n.fillStyle.visible&&n.shape&&(n.matrix?n.matrix.applyInverse(t,cn):cn.copyFrom(t),n.shape.contains(cn.x,cn.y))){let s=!1;if(n.holes){for(let o=0;o<n.holes.length;o++)if(n.holes[o].shape.contains(cn.x,cn.y)){s=!0;break}}if(!s)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,n=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],n=i.style);for(let l=this.shapeIndex;l<e.length;l++){this.shapeIndex++;const h=e[l],c=h.fillStyle,u=h.lineStyle;_h[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(c.visible||u.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?c:u;if(!f.visible)continue;const p=f.texture.baseTexture,g=this.indices.length,y=this.points.length/2;p.wrapMode=Lr.REPEAT,d===0?this.processFill(h):this.processLine(h);const _=this.points.length/2-y;_!==0&&(i&&!this._compareStyles(n,f)&&(i.end(g,y),i=null),i||(i=rm.pop()||new lS,i.begin(f,g,y),this.batches.push(i),n=f),this.addUvs(this.points,t,f.texture,y,_,f.matrix))}}const s=this.indices.length,o=this.points.length/2;if(i&&i.end(s,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],n=i.fillStyle,s=i.lineStyle;if(n&&!n.texture.baseTexture.valid||s&&!s.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 n=t[e];for(let s=0;s<n.size;s++){const o=n.start+s;this.indicesUint16[o]=this.indicesUint16[o]-n.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<Ym.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++bt._globalBatch;for(let u=0;u<this.drawCalls.length;u++)this.drawCalls[u].texArray.clear(),Ao.push(this.drawCalls[u]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let n=Ao.pop();n||(n=new $l,n.texArray=new Wl),n.texArray.count=0,n.start=0,n.size=0,n.type=er.TRIANGLES;let s=0,o=null,a=0,l=!1,h=er.TRIANGLES,c=0;this.drawCalls.push(n);for(let u=0;u<this.batches.length;u++){const d=this.batches[u],f=8,p=d.style,g=p.texture.baseTexture;l!==!!p.native&&(l=!!p.native,h=l?er.LINES:er.TRIANGLES,o=null,s=f,t++),o!==g&&(o=g,g._batchEnabled!==t&&(s===f&&(t++,s=0,n.size>0&&(n=Ao.pop(),n||(n=new $l,n.texArray=new Wl),this.drawCalls.push(n)),n.start=c,n.size=0,n.texArray.count=0,n.type=h),g.touched=1,g._batchEnabled=t,g._batchLocation=s,g.wrapMode=Lr.REPEAT,n.texArray.elements[n.texArray.count++]=g,s++)),n.size+=d.size,c+=d.size,a=g._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}bt._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,n=this.textureIds,s=new ArrayBuffer(t.length*3*4),o=new Float32Array(s),a=new Uint32Array(s);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++]=n[h];this._buffer.update(s),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Jp.triangulate(t,this):_h[t.type].triangulate(t,this)}processLine(t){em(t,this);for(let e=0;e<t.holes.length;e++)em(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];_h[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 n=t[i*2],s=t[i*2+1];t[i*2]=e.a*n+e.c*s+e.tx,t[i*2+1]=e.b*n+e.d*s+e.ty}}addColors(t,e,i,n,s=0){const o=Mt.shared.setValue(e).toLittleEndianNumber(),a=Mt.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,s+n);for(let l=0;l<n;l++)t[s+l]=a}addTextureIds(t,e,i,n=0){t.length=Math.max(t.length,n+i);for(let s=0;s<i;s++)t[n+s]=e}addUvs(t,e,i,n,s,o=null){let a=0;const l=e.length,h=i.frame;for(;a<s;){let u=t[(n+a)*2],d=t[(n+a)*2+1];if(o){const f=o.a*u+o.c*d+o.tx;d=o.b*u+o.d*d+o.ty,u=f}a++,e.push(u/h.width,d/h.height)}const c=i.baseTexture;(h.width<c.width||h.height<c.height)&&this.adjustUvs(e,i,l,s)}adjustUvs(t,e,i,n){const s=e.baseTexture,o=1e-6,a=i+n*2,l=e.frame,h=l.width/s.width,c=l.height/s.height;let u=l.x/l.width,d=l.y/l.height,f=Math.floor(t[i]+o),p=Math.floor(t[i+1]+o);for(let g=i+2;g<a;g+=2)f=Math.min(f,Math.floor(t[g]+o)),p=Math.min(p,Math.floor(t[g+1]+o));u-=f,d-=p;for(let g=i;g<a;g+=2)t[g]=(t[g]+u)*h,t[g+1]=(t[g+1]+d)*c}};im.BATCHABLE_SIZE=100;let uS=im;class Co{constructor(){this.color=16777215,this.alpha=1,this.texture=ct.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Co;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=ct.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class vh extends Co{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Xr.BUTT,this.join=Ge.MITER,this.miterLimit=10}clone(){const t=new vh;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=Xr.BUTT,this.join=Ge.MITER,this.miterLimit=10}}const bh={},xh=class Uo extends je{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 Co,this._lineStyle=new vh,this._matrix=null,this._holeMode=!1,this.state=cr.for2d(),this._geometry=t||new uS,this._geometry.refCount++,this._transformID=-1,this._tintColor=new Mt(16777215),this.blendMode=vt.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new Uo(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,n=.5,s=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:n,native:s}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:ct.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:Xr.BUTT,join:Ge.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 ci,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new ci,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,n=i[i.length-2],s=i[i.length-1];return(n!==t||s!==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,n){this._initCurve();const s=this.currentPath.points;return s.length===0&&this.moveTo(0,0),yh.curveTo(t,e,i,n,s),this}bezierCurveTo(t,e,i,n,s,o){return this._initCurve(),gh.curveTo(t,e,i,n,s,o,this.currentPath.points),this}arcTo(t,e,i,n,s){this._initCurve(t,e);const o=this.currentPath.points,a=Qp.curveTo(t,e,i,n,s,o);if(a){const{cx:l,cy:h,radius:c,startAngle:u,endAngle:d,anticlockwise:f}=a;this.arc(l,h,c,u,d,f)}return this}arc(t,e,i,n,s,o=!1){if(n===s)return this;if(!o&&s<=n?s+=Ys:o&&n<=s&&(n+=Ys),s-n===0)return this;const a=t+Math.cos(n)*i,l=e+Math.sin(n)*i,h=this._geometry.closePointEps;let c=this.currentPath?this.currentPath.points:null;if(c){const u=Math.abs(c[c.length-2]-a),d=Math.abs(c[c.length-1]-l);u<h&&d<h||c.push(a,l)}else this.moveTo(a,l),c=this.currentPath.points;return Qp.arc(a,l,t,e,i,n,s,o,c),this}beginFill(t=0,e){return this.beginTextureFill({texture:ct.WHITE,color:t,alpha:e})}normalizeColor(t){const e=Mt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:ct.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,n){return this.drawShape(new wt(t,e,i,n))}drawRoundedRect(t,e,i,n,s){return this.drawShape(new Js(t,e,i,n,s))}drawCircle(t,e,i){return this.drawShape(new Ks(t,e,i))}drawEllipse(t,e,i,n){return this.drawShape(new Zs(t,e,i,n))}drawPolygon(...t){let e,i=!0;const n=t[0];n.points?(i=n.closeStroke,e=n.points):Array.isArray(t[0])?e=t[0]:e=t;const s=new ci(e);return s.closeStroke=i,this.drawShape(s),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===ve.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 n=0;n<i;n++){const s=t.batches[n],o=s.style.color,a=new Float32Array(this.vertexData.buffer,s.attribStart*4*2,s.attribSize*2),l=new Float32Array(t.uvsFloat32.buffer,s.attribStart*4*2,s.attribSize*2),h=new Uint16Array(t.indicesUint16.buffer,s.start*2,s.size),c={vertexData:a,blendMode:e,indices:h,uvs:l,_batchRGB:Mt.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:s.style.texture,alpha:s.style.alpha,worldAlpha:1};this.batches[n]=c}}_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 n=this.batches[e];n.worldAlpha=this.worldAlpha*n.alpha,t.plugins[this.pluginName].render(n)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,n=this.worldAlpha,s=e.uniforms,o=i.drawCalls;s.translationMatrix=this.transform.worldTransform,Mt.shared.setValue(this._tintColor).premultiply(n).toArray(s.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:n,size:s,start:o}=e,a=i.count;for(let l=0;l<a;l++)t.texture.bind(i.elements[l],l);t.geometry.draw(n,s,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!bh[i]){const{maxTextures:n}=t.plugins[i],s=new Int32Array(n);for(let l=0;l<n;l++)s[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new kt,default:ze.from({uSamplers:s},!0)},a=t.plugins[i]._shader.program;bh[i]=new ur(a,o)}e=bh[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:n,maxY:s}=t.bounds;this._bounds.addFrame(this.transform,e,i,n,s)}containsPoint(t){return this.worldTransform.applyInverse(t,Uo._TEMP_POINT),this._geometry.containsPoint(Uo._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=Mt.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,n=e.b,s=e.c,o=e.d,a=e.tx,l=e.ty,h=this._geometry.points,c=this.vertexData;let u=0;for(let d=0;d<h.length;d+=2){const f=h[d],p=h[d+1];c[u++]=i*f+s*p+a,c[u++]=o*p+n*f+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)}};xh.curves=hn,xh._TEMP_POINT=new It;let Qn=xh;class dS{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 wh=new It,nm=new ci,sm=class qm extends je{constructor(t,e,i,n=er.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||cr.for2d(),this.drawMode=n,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=tt.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===er.TRIANGLES&&e.length<qm.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 n=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[n]),t.plugins[n].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 n=this.transform.worldTransform,s=n.a,o=n.b,a=n.c,l=n.d,h=n.tx,c=n.ty,u=this.vertexData;for(let d=0;d<u.length/2;d++){const f=e[d*2],p=e[d*2+1];u[d*2]=s*f+a*p+h,u[d*2+1]=o*f+l*p+c}if(this._roundPixels){const d=tt.RESOLUTION;for(let f=0;f<u.length;++f)u[f]=Math.round(u[f]*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 dS(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,wh);const e=this.geometry.getBuffer("aVertexPosition").data,i=nm.points,n=this.geometry.getIndex().data,s=n.length,o=this.drawMode===4?3:1;for(let a=0;a+2<s;a+=o){const l=n[a]*2,h=n[a+1]*2,c=n[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[c],i[5]=e[c+1],nm.contains(wh.x,wh.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}};sm.BATCHABLE_SIZE=100;let om=sm;class fS extends Gr{constructor(t,e,i){super();const n=new Jt(t),s=new Jt(e,!0),o=new Jt(i,!0,!0);this.addAttribute("aVertexPosition",n,2,!1,pt.FLOAT).addAttribute("aTextureCoord",s,2,!1,pt.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var pS=`varying vec2 vTextureCoord;
910
+ `;let ln=null;class Hp{constructor(){ln||(ln=URL.createObjectURL(new Blob([aA],{type:"application/javascript"}))),this.worker=new Worker(ln)}}Hp.revokeObjectURL=function(){ln&&(URL.revokeObjectURL(ln),ln=null)};let Xp=0,fh;class lA{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 dh;e.addEventListener("message",i=>{e.terminate(),dh.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){fh===void 0&&(fh=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<fh&&(this._createdWorkers++,t=new Hp().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((n,s)=>{this.queue.push({id:t,arguments:e,resolve:n,reject:s})});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[Xp]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Xp++,id:i})}}const Vp=new lA;function Jn(r,t,e){r.resource.internal=!0;const i=new ct(r),n=()=>{delete t.promiseCache[e],wi.has(e)&&wi.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."),n())}),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."),n())}),i}const hA=[".jpeg",".jpg",".png",".webp",".avif"],cA=["image/jpeg","image/png","image/webp","image/avif"];async function uA(r){const t=await tt.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 _o={name:"loadTextures",extension:{type:Z.LoadParser,priority:Ke.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return on(r,cA)||Vr(r,hA)},async load(r,t,e){var a;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let n;i?this.config.preferWorkers&&await Vp.isImageBitmapSupported()?n=await Vp.loadImageBitmap(r):n=await uA(r):n=await new Promise((l,h)=>{const c=new Image;c.crossOrigin=this.config.crossOrigin,c.src=r,c.complete?l(c):(c.onload=()=>l(c),c.onerror=u=>h(u))});const s={...t.data};s.resolution??(s.resolution=wr(r)),i&&((a=s.resourceOptions)==null?void 0:a.ownsImageBitmap)===void 0&&(s.resourceOptions={...s.resourceOptions},s.resourceOptions.ownsImageBitmap=!0);const o=new bt(n,s);return o.resource.src=r,Jn(o,e,r)},unload(r){r.destroy(!0)}};ht.add(_o);const dA=".svg",fA="image/svg+xml",pA={extension:{type:Z.LoadParser,priority:Ke.High},name:"loadSVG",test(r){return on(r,fA)||Vr(r,dA)},async testParse(r){return nh.test(r)},async parse(r,t,e){var s;const i=new nh(r,(s=t==null?void 0:t.data)==null?void 0:s.resourceOptions);await i.load();const n=new bt(i,{resolution:wr(r),...t==null?void 0:t.data});return n.resource.src=t.src,Jn(n,e,t.src)},async load(r,t){return(await tt.ADAPTER.fetch(r)).text()},unload:_o.unload};ht.add(pA);const mA=[".mp4",".m4v",".webm",".ogv"],gA=["video/mp4","video/webm","video/ogg"],yA={name:"loadVideo",extension:{type:Z.LoadParser,priority:Ke.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(r){return on(r,gA)||Vr(r,mA)},async load(r,t,e){var o;let i;const n=await(await tt.ADAPTER.fetch(r)).blob(),s=URL.createObjectURL(n);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 Rp(s,a);await l.load();const h=new bt(l,{alphaMode:await Ew(),resolution:wr(r),...t==null?void 0:t.data});h.resource.src=r,i=Jn(h,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(s)})}catch(a){throw URL.revokeObjectURL(s),a}return i},unload(r){r.destroy(!0)}};ht.add(yA);class _A{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:n,srcs:s}=t;return qe(e||i||n||s,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(n=>{const s=n.src??n.srcs,o=n.alias??n.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({...n,alias:a,src:s})}):Object.keys(e).forEach(n=>{const s=[n,this._createBundleAssetId(t,n)];if(typeof e[n]=="string")this.add({alias:s,src:e[n]});else if(Array.isArray(e[n]))this.add({alias:s,src:e[n]});else{const o=e[n],a=o.src??o.srcs;this.add({...o,alias:s,src:Array.isArray(a)?a:[a]})}i.push(...s)}),this._bundles[t]=i}add(t,e,i,n,s){const o=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(At("7.2.0",`Assets.add now uses an object instead of individual parameters.
911
+ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:t,src:e,data:i,format:n,loadParser:s})):Array.isArray(t)?o.push(...t):o.push(t);let a;a=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},qe(o).forEach(l=>{const{src:h,srcs:c}=l;let{data:u,format:d,loadParser:f}=l;const p=qe(h||c).map(_=>typeof _=="string"?XT(_):Array.isArray(_)?_:[_]),g=this.getAlias(l);Array.isArray(g)?g.forEach(a):a(g);const y=[];p.forEach(_=>{_.forEach(v=>{let m={};if(typeof v!="object"){m.src=v;for(let b=0;b<this._parsers.length;b++){const S=this._parsers[b];if(S.test(v)){m=S.parse(v);break}}}else u=v.data??u,d=v.format??d,f=v.loadParser??f,m={...m,...v};if(!g)throw new Error(`[Resolver] alias is undefined for this asset: ${m.src}`);m=this.buildResolvedAsset(m,{aliases:g,data:u,format:d,loadParser:f}),y.push(m)})}),g.forEach(_=>{this._assetMap[_]=y})})}resolveBundle(t){const e=yo(t);t=qe(t);const i={};return t.forEach(n=>{const s=this._bundles[n];if(s){const o=this.resolve(s),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(n,l)]=h}i[n]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const n in e)i[n]=e[n].src;return i}return e.src}resolve(t){const e=yo(t);t=qe(t);const i={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let s=this._assetMap[n];const o=s[0],a=this._getPreferredOrder(s);a==null||a.priority.forEach(l=>{a.params[l].forEach(h=>{const c=s.filter(u=>u[l]?u[l]===h:!1);c.length&&(s=c)})}),this._resolverHash[n]=s[0]??o}else this._resolverHash[n]=this.buildResolvedAsset({alias:[n],src:n},{});i[n]=this._resolverHash[n]}),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],n=this._preferredOrder.find(s=>s.params.format.includes(i.format));if(n)return n}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:n,loadParser:s,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=ue.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=s??t.loadParser,t.format=o??t.format??ue.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class vA{constructor(){this._detections=[],this._initialized=!1,this.resolver=new _A,this.loader=new zT,this.cache=wi,this._backgroundLoader=new HT(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var s,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=((s=t.texturePreference)==null?void 0:s.resolution)??1,i=typeof e=="number"?[e]:e,n=await this._detectFormats({preferredFormats:(o=t.texturePreference)==null?void 0:o.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,n,s){this.resolver.add(t,e,i,n,s)}async load(t,e){this._initialized||await this.init();const i=yo(t),n=qe(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}),s=this.resolver.resolve(n),o=await this._mapLoadToResolve(s,e);return i?o[n[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 n=this.resolver.resolveBundle(t),s={},o=Object.keys(n);let a=0,l=0;const h=()=>{e==null||e(++a/l)},c=o.map(u=>{const d=n[u];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(f=>{s[u]=f})});return await Promise.all(c),i?s[t[0]]:s}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 wi.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=wi.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),n=Object.keys(t);this._backgroundLoader.active=!1;const s=await this.loader.load(i,e);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=s[a.src],c=[a.src];a.alias&&c.push(...a.alias),o[n[l]]=h,wi.set(c,h)}),o}async unload(t){this._initialized||await this.init();const e=qe(t).map(n=>typeof n!="string"?n.src:n),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=qe(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(n=>this._unloadFromResolved(e[n]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{wi.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,n)=>e.indexOf(i)===n),e}get detections(){return this._detections}get preferWorkers(){return _o.config.preferWorkers}set preferWorkers(t){At("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 vo=new vA;ht.handleByList(Z.LoadParser,vo.loader.parsers).handleByList(Z.ResolveParser,vo.resolver.parsers).handleByList(Z.CacheParser,vo.cache.parsers).handleByList(Z.DetectionParser,vo.detections);const bA={extension:Z.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof ct),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((n,s)=>{e[i+(s===0?"":s+1)]=n})}),e}};ht.add(bA);async function zp(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 xA={extension:{type:Z.DetectionParser,priority:1},test:async()=>zp("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};ht.add(xA);const wA={extension:{type:Z.DetectionParser,priority:0},test:async()=>zp("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};ht.add(wA);const jp=["png","jpg","jpeg"],EA={extension:{type:Z.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...jp],remove:async r=>r.filter(t=>!jp.includes(t))};ht.add(EA);const TA="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function ph(r){return TA?!1:document.createElement("video").canPlayType(r)!==""}const AA={extension:{type:Z.DetectionParser,priority:0},test:async()=>ph("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};ht.add(AA);const SA={extension:{type:Z.DetectionParser,priority:0},test:async()=>ph("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};ht.add(SA);const CA={extension:{type:Z.DetectionParser,priority:0},test:async()=>ph("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};ht.add(CA);const IA={extension:Z.ResolveParser,test:_o.test,parse:r=>{var t;return{resolution:parseFloat(((t=tt.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:ue.extname(r).slice(1),src:r}}};ht.add(IA);var be=(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))(be||{});const bo={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 fr,hn;function Wp(){hn={bptc:fr.getExtension("EXT_texture_compression_bptc"),astc:fr.getExtension("WEBGL_compressed_texture_astc"),etc:fr.getExtension("WEBGL_compressed_texture_etc"),s3tc:fr.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:fr.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:fr.getExtension("WEBGL_compressed_texture_pvrtc")||fr.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:fr.getExtension("WEBGL_compressed_texture_etc1"),atc:fr.getExtension("WEBGL_compressed_texture_atc")}}const PA={extension:{type:Z.DetectionParser,priority:2},test:async()=>{const r=tt.ADAPTER.createCanvas().getContext("webgl");return r?(fr=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{hn||Wp();const t=[];for(const e in hn)hn[e]&&t.push(e);return[...t,...r]},remove:async r=>(hn||Wp(),r.filter(t=>!(t in hn)))};ht.add(PA);class RA extends Ws{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,n;typeof t=="string"?(i=t,n=new Uint8Array):(i=null,n=t),super(n,e),this.origin=i,this.buffer=n?new Bl(n):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 Bl(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Ei extends RA{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=Ei._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Ei._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const n=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;n.pixelStorei(n.UNPACK_ALIGNMENT,4);for(let s=0,o=this.levels;s<o;s++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:c}=this._levelBuffers[s];n.compressedTexImage2D(n.TEXTURE_2D,a,this.format,l,h,0,c)}return!0}onBlobLoaded(){this._levelBuffers=Ei._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,n,s,o,a){const l=new Array(i);let h=t.byteOffset,c=o,u=a,d=c+n-1&~(n-1),f=u+s-1&~(s-1),p=d*f*bo[e];for(let g=0;g<i;g++)l[g]={levelID:g,levelWidth:i>1?c:d,levelHeight:i>1?u:f,levelBuffer:new Uint8Array(t.buffer,h,p)},h+=p,c=c>>1||1,u=u>>1||1,d=c+n-1&~(n-1),f=u+s-1&~(s-1),p=d*f*bo[e];return l}}const mh=4,xo=124,MA=32,Yp=20,DA=542327876,wo={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},BA={FOURCC:2},Eo={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},OA=1,LA=2,NA=4,FA=64,kA=512,UA=131072,GA=827611204,$A=861165636,HA=894720068,XA=808540228,VA=4,zA={[GA]:be.COMPRESSED_RGBA_S3TC_DXT1_EXT,[$A]:be.COMPRESSED_RGBA_S3TC_DXT3_EXT,[HA]:be.COMPRESSED_RGBA_S3TC_DXT5_EXT},jA={70:be.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:be.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:be.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:be.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:be.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:be.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:be.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:be.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:be.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:be.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:be.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:be.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:be.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function WA(r){const t=new Uint32Array(r);if(t[0]!==DA)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,xo/Uint32Array.BYTES_PER_ELEMENT),i=e[wo.HEIGHT],n=e[wo.WIDTH],s=e[wo.MIPMAP_COUNT],o=new Uint32Array(r,wo.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,MA/Uint32Array.BYTES_PER_ELEMENT),a=o[OA];if(a&NA){const l=o[BA.FOURCC];if(l!==XA){const v=zA[l],m=mh+xo,b=new Uint8Array(r,m);return[new Ei(b,{format:v,width:n,height:i,levels:s})]}const h=mh+xo,c=new Uint32Array(t.buffer,h,Yp/Uint32Array.BYTES_PER_ELEMENT),u=c[Eo.DXGI_FORMAT],d=c[Eo.RESOURCE_DIMENSION],f=c[Eo.MISC_FLAG],p=c[Eo.ARRAY_SIZE],g=jA[u];if(g===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${u}`);if(f===VA)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,_=mh+xo+Yp;if(p===1)y.push(new Uint8Array(r,_));else{const v=bo[g];let m=0,b=n,S=i;for(let C=0;C<s;C++){const I=Math.max(1,b+3&-4),M=Math.max(1,S+3&-4),F=I*M*v;m+=F,b=b>>>1,S=S>>>1}let R=_;for(let C=0;C<p;C++)y.push(new Uint8Array(r,R,m)),R+=m}return y.map(v=>new Ei(v,{format:g,width:n,height:i,levels:s}))}throw a&FA?new Error("DDSParser does not support uncompressed texture data."):a&kA?new Error("DDSParser does not supported YUV uncompressed texture data."):a&UA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&LA?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 qp=[171,75,84,88,32,49,49,187,13,10,26,10],YA=67305985,Ze={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,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},gh=64,Kp={[pt.UNSIGNED_BYTE]:1,[pt.UNSIGNED_SHORT]:2,[pt.INT]:4,[pt.UNSIGNED_INT]:4,[pt.FLOAT]:4,[pt.HALF_FLOAT]:8},qA={[j.RGBA]:4,[j.RGB]:3,[j.RG]:2,[j.RED]:1,[j.LUMINANCE]:1,[j.LUMINANCE_ALPHA]:2,[j.ALPHA]:1},KA={[pt.UNSIGNED_SHORT_4_4_4_4]:2,[pt.UNSIGNED_SHORT_5_5_5_1]:2,[pt.UNSIGNED_SHORT_5_6_5]:2};function ZA(r,t,e=!1){const i=new DataView(t);if(!QA(r,i))return null;const n=i.getUint32(Ze.ENDIANNESS,!0)===YA,s=i.getUint32(Ze.GL_TYPE,n),o=i.getUint32(Ze.GL_FORMAT,n),a=i.getUint32(Ze.GL_INTERNAL_FORMAT,n),l=i.getUint32(Ze.PIXEL_WIDTH,n),h=i.getUint32(Ze.PIXEL_HEIGHT,n)||1,c=i.getUint32(Ze.PIXEL_DEPTH,n)||1,u=i.getUint32(Ze.NUMBER_OF_ARRAY_ELEMENTS,n)||1,d=i.getUint32(Ze.NUMBER_OF_FACES,n),f=i.getUint32(Ze.NUMBER_OF_MIPMAP_LEVELS,n),p=i.getUint32(Ze.BYTES_OF_KEY_VALUE_DATA,n);if(h===0||c!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==1)throw new Error("WebGL does not support array textures");const g=4,y=4,_=l+3&-4,v=h+3&-4,m=new Array(u);let b=l*h;s===0&&(b=_*v);let S;if(s!==0?Kp[s]?S=Kp[s]*qA[o]:S=KA[s]:S=bo[a],S===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const R=e?tS(i,p,n):null;let C=b*S,I=l,M=h,F=_,U=v,P=gh+p;for(let T=0;T<f;T++){const E=i.getUint32(P,n);let A=P+4;for(let L=0;L<u;L++){let D=m[L];D||(D=m[L]=new Array(f)),D[T]={levelID:T,levelWidth:f>1||s!==0?I:F,levelHeight:f>1||s!==0?M:U,levelBuffer:new Uint8Array(t,A,C)},A+=C}P+=E+4,P=P%4!==0?P+4-P%4:P,I=I>>1||1,M=M>>1||1,F=I+g-1&-4,U=M+y-1&-4,C=F*U*S}return s!==0?{uncompressed:m.map(T=>{let E=T[0].levelBuffer,A=!1;return s===pt.FLOAT?E=new Float32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4):s===pt.UNSIGNED_INT?(A=!0,E=new Uint32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4)):s===pt.INT&&(A=!0,E=new Int32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4)),{resource:new Ws(E,{width:T[0].levelWidth,height:T[0].levelHeight}),type:s,format:A?JA(o):o}}),kvData:R}:{compressed:m.map(T=>new Ei(null,{format:a,width:l,height:h,levels:f,levelBuffers:T})),kvData:R}}function QA(r,t){for(let e=0;e<qp.length;e++)if(t.getUint8(e)!==qp[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function JA(r){switch(r){case j.RGBA:return j.RGBA_INTEGER;case j.RGB:return j.RGB_INTEGER;case j.RG:return j.RG_INTEGER;case j.RED:return j.RED_INTEGER;default:return r}}function tS(r,t,e){const i=new Map;let n=0;for(;n<t;){const s=r.getUint32(gh+n,e),o=gh+n+4,a=3-(s+3)%4;if(s===0||s>t-n){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<s&&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)),c=new DataView(r.buffer,o+l+1,s-l-1);i.set(h,c),n+=4+s+a}return i}const eS={extension:{type:Z.LoadParser,priority:Ke.High},name:"loadDDS",test(r){return Vr(r,".dds")},async load(r,t,e){const i=await(await tt.ADAPTER.fetch(r)).arrayBuffer(),n=WA(i).map(s=>{const o=new bt(s,{mipmap:ir.OFF,alphaMode:Re.NO_PREMULTIPLIED_ALPHA,resolution:wr(r),...t.data});return Jn(o,e,r)});return n.length===1?n[0]:n},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};ht.add(eS);const rS={extension:{type:Z.LoadParser,priority:Ke.High},name:"loadKTX",test(r){return Vr(r,".ktx")},async load(r,t,e){const i=await(await tt.ADAPTER.fetch(r)).arrayBuffer(),{compressed:n,uncompressed:s,kvData:o}=ZA(r,i),a=n??s,l={mipmap:ir.OFF,alphaMode:Re.NO_PREMULTIPLIED_ALPHA,resolution:wr(r),...t.data},h=a.map(c=>{a===s&&Object.assign(l,{type:c.type,format:c.format});const u=c.resource??c,d=new bt(u,l);return d.ktxKeyValueData=o,Jn(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};ht.add(rS);const iS=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],nS={extension:Z.ResolveParser,test:r=>{const t=ue.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{var i,n;const t=r.split("."),e=t.pop();if(["ktx","dds"].includes(e)){const s=t.pop();if(iS.includes(s))return{resolution:parseFloat(((i=tt.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:s,src:r}}return{resolution:parseFloat(((n=tt.RETINA_PREFIX.exec(r))==null?void 0:n[1])??"1"),format:e,src:r}}};ht.add(nS);const To=new wt,sS=4,Zp=class ns{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,n){const s=new Image;return s.src=await this.base64(t,e,i,n),s}async base64(t,e,i,n){const s=this.canvas(t,n);if(s.toBlob!==void 0)return new Promise((o,a)=>{s.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(s.toDataURL!==void 0)return s.toDataURL(e,i);if(s.convertToBlob!==void 0){const o=await s.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:n,height:s,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);o&&ns._flipY(i,n,s),a&&ns._unpremultiplyAlpha(i);const l=new Uw(n,s,1),h=new ImageData(new Uint8ClampedArray(i.buffer),n,s);return l.context.putImageData(h,0,0),l.canvas}pixels(t,e){const{pixels:i,width:n,height:s,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&ns._flipY(i,n,s),a&&ns._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let n,s=!1,o=!1,a,l=!1;t&&(t instanceof _i?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(To.width=e.width,To.height=e.height,e=To)));const h=i.gl;if(a){if(n=a.baseTexture.resolution,e=e??a.frame,s=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===j.RGBA,!l){i.renderTexture.bind(a);const f=a.framebuffer.glFramebuffers[i.CONTEXT_UID];f.blitFramebuffer&&i.framebuffer.bind(f.blitFramebuffer)}}else n=i.resolution,e||(e=To,e.width=i.width/n,e.height=i.height/n),s=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const c=Math.max(Math.round(e.width*n),1),u=Math.max(Math.round(e.height*n),1),d=new Uint8Array(sS*c*u);return h.readPixels(Math.round(e.x*n),Math.round(e.y*n),c,u,h.RGBA,h.UNSIGNED_BYTE,d),l&&(a==null||a.destroy(!0)),{pixels:d,width:c,height:u,flipY:s,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(t,e,i){const n=e<<2,s=i>>1,o=new Uint8Array(n);for(let a=0;a<s;a++){const l=a*n,h=(i-a-1)*n;o.set(t.subarray(l,l+n)),t.copyWithin(l,h,h+n),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 n=t[i+3];if(n!==0){const s=255.001/n;t[i]=t[i]*s+.5,t[i+1]=t[i+1]*s+.5,t[i+2]=t[i+2]*s+.5}}}};Zp.extension={name:"extract",type:Z.RendererSystem};let oS=Zp;ht.add(oS);const Ao={build(r){const t=r.points;let e,i,n,s,o,a;if(r.type===ve.CIRC){const p=r.shape;e=p.x,i=p.y,o=a=p.radius,n=s=0}else if(r.type===ve.ELIP){const p=r.shape;e=p.x,i=p.y,o=p.width,a=p.height,n=s=0}else{const p=r.shape,g=p.width/2,y=p.height/2;e=p.x+g,i=p.y+y,o=a=Math.max(0,Math.min(p.radius,Math.min(g,y))),n=g-o,s=y-a}if(!(o>=0&&a>=0&&n>=0&&s>=0)){t.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(n?4:0)+(s?4:0);if(t.length=h,h===0)return;if(l===0){t.length=8,t[0]=t[6]=e+n,t[1]=t[3]=i+s,t[2]=t[4]=e-n,t[5]=t[7]=i-s;return}let c=0,u=l*4+(n?2:0)+2,d=u,f=h;{const p=n+o,g=s,y=e+p,_=e-p,v=i+g;if(t[c++]=y,t[c++]=v,t[--u]=v,t[--u]=_,s){const m=i-g;t[d++]=_,t[d++]=m,t[--f]=m,t[--f]=y}}for(let p=1;p<l;p++){const g=Math.PI/2*(p/l),y=n+Math.cos(g)*o,_=s+Math.sin(g)*a,v=e+y,m=e-y,b=i+_,S=i-_;t[c++]=v,t[c++]=b,t[--u]=b,t[--u]=m,t[d++]=m,t[d++]=S,t[--f]=S,t[--f]=v}{const p=n,g=s+a,y=e+p,_=e-p,v=i+g,m=i-g;t[c++]=y,t[c++]=v,t[--f]=m,t[--f]=y,n&&(t[c++]=_,t[c++]=v,t[--f]=m,t[--f]=_)}},triangulate(r,t){const e=r.points,i=t.points,n=t.indices;if(e.length===0)return;let s=i.length/2;const o=s;let a,l;if(r.type!==ve.RREC){const c=r.shape;a=c.x,l=c.y}else{const c=r.shape;a=c.x+c.width/2,l=c.y+c.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),s++,i.push(e[0],e[1]);for(let c=2;c<e.length;c+=2)i.push(e[c],e[c+1]),n.push(s++,o,s);n.push(o+1,o,s)}};function Qp(r,t=!1){const e=r.length;if(e<6)return;let i=0;for(let n=0,s=r[e-2],o=r[e-1];n<e;n+=2){const a=r[n],l=r[n+1];i+=(a-s)*(l+o),s=a,o=l}if(!t&&i>0||t&&i<=0){const n=e/2;for(let s=n+n%2;s<e;s+=2){const o=e-s-2,a=e-s-1,l=s,h=s+1;[r[o],r[l]]=[r[l],r[o]],[r[a],r[h]]=[r[h],r[a]]}}}const Jp={build(r){r.points=r.shape.points.slice()},triangulate(r,t){let e=r.points;const i=r.holes,n=t.points,s=t.indices;if(e.length>=6){Qp(e,!1);const o=[];for(let h=0;h<i.length;h++){const c=i[h];Qp(c.points,!0),o.push(e.length/2),e=e.concat(c.points)}const a=u1(e,o,2);if(!a)return;const l=n.length/2;for(let h=0;h<a.length;h+=3)s.push(a[h]+l),s.push(a[h+1]+l),s.push(a[h+2]+l);for(let h=0;h<e.length;h++)n.push(e[h])}}},aS={build(r){const t=r.shape,e=t.x,i=t.y,n=t.width,s=t.height,o=r.points;o.length=0,n>=0&&s>=0&&o.push(e,i,e+n,i,e+n,i+s,e,i+s)},triangulate(r,t){const e=r.points,i=t.points;if(e.length===0)return;const n=i.length/2;i.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(n,n+1,n+2,n+1,n+2,n+3)}},lS={build(r){Ao.build(r)},triangulate(r,t){Ao.triangulate(r,t)}};var Ge=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(Ge||{}),zr=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(zr||{});const cn={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 tm{static curveTo(t,e,i,n,s,o){const a=o[o.length-2],l=o[o.length-1]-e,h=a-t,c=n-e,u=i-t,d=Math.abs(l*u-h*c);if(d<1e-8||s===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const f=l*l+h*h,p=c*c+u*u,g=l*c+h*u,y=s*Math.sqrt(f)/d,_=s*Math.sqrt(p)/d,v=y*g/f,m=_*g/p,b=y*u+_*h,S=y*c+_*l,R=h*(_+v),C=l*(_+v),I=u*(y+m),M=c*(y+m),F=Math.atan2(C-S,R-b),U=Math.atan2(M-S,I-b);return{cx:b+t,cy:S+e,radius:s,startAngle:F,endAngle:U,anticlockwise:h*c>u*l}}static arc(t,e,i,n,s,o,a,l,h){const c=a-o,u=cn._segmentsCount(Math.abs(c)*s,Math.ceil(Math.abs(c)/qs)*40),d=c/(u*2),f=d*2,p=Math.cos(d),g=Math.sin(d),y=u-1,_=y%1/y;for(let v=0;v<=y;++v){const m=v+_*v,b=d+o+f*m,S=Math.cos(b),R=-Math.sin(b);h.push((p*S+g*R)*s+i,(p*-R+g*S)*s+n)}}}class hS{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 yh{static curveLength(t,e,i,n,s,o,a,l){let h=0,c=0,u=0,d=0,f=0,p=0,g=0,y=0,_=0,v=0,m=0,b=t,S=e;for(let R=1;R<=10;++R)c=R/10,u=c*c,d=u*c,f=1-c,p=f*f,g=p*f,y=g*t+3*p*c*i+3*f*u*s+d*a,_=g*e+3*p*c*n+3*f*u*o+d*l,v=b-y,m=S-_,b=y,S=_,h+=Math.sqrt(v*v+m*m);return h}static curveTo(t,e,i,n,s,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const c=cn._segmentsCount(yh.curveLength(l,h,t,e,i,n,s,o));let u=0,d=0,f=0,p=0,g=0;a.push(l,h);for(let y=1,_=0;y<=c;++y)_=y/c,u=1-_,d=u*u,f=d*u,p=_*_,g=p*_,a.push(f*l+3*d*_*t+3*u*p*i+g*s,f*h+3*d*_*e+3*u*p*n+g*o)}}function em(r,t,e,i,n,s,o,a){const l=r-e*n,h=t-i*n,c=r+e*s,u=t+i*s;let d,f;o?(d=i,f=-e):(d=-i,f=e);const p=l+d,g=h+f,y=c+d,_=u+f;return a.push(p,g,y,_),2}function Ti(r,t,e,i,n,s,o,a){const l=e-r,h=i-t;let c=Math.atan2(l,h),u=Math.atan2(n-r,s-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),g=Math.sqrt(l*l+h*h),y=(15*p*Math.sqrt(g)/Math.PI>>0)+1,_=f/y;if(d+=_,a){o.push(r,t,e,i);for(let v=1,m=d;v<y;v++,m+=_)o.push(r,t,r+Math.sin(m)*g,t+Math.cos(m)*g);o.push(r,t,n,s)}else{o.push(e,i,r,t);for(let v=1,m=d;v<y;v++,m+=_)o.push(r+Math.sin(m)*g,t+Math.cos(m)*g,r,t);o.push(n,s,r,t)}return y*2}function cS(r,t){const e=r.shape;let i=r.points||e.points.slice();const n=t.closePointEps;if(i.length===0)return;const s=r.lineStyle,o=new It(i[0],i[1]),a=new It(i[i.length-2],i[i.length-1]),l=e.type!==ve.POLY||e.closeStroke,h=Math.abs(o.x-a.x)<n&&Math.abs(o.y-a.y)<n;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const D=(o.x+a.x)*.5,N=(a.y+o.y)*.5;i.unshift(D,N),i.push(D,N)}const c=t.points,u=i.length/2;let d=i.length;const f=c.length/2,p=s.width/2,g=p*p,y=s.miterLimit*s.miterLimit;let _=i[0],v=i[1],m=i[2],b=i[3],S=0,R=0,C=-(v-b),I=_-m,M=0,F=0,U=Math.sqrt(C*C+I*I);C/=U,I/=U,C*=p,I*=p;const P=s.alignment,T=(1-P)*2,E=P*2;l||(s.cap===zr.ROUND?d+=Ti(_-C*(T-E)*.5,v-I*(T-E)*.5,_-C*T,v-I*T,_+C*E,v+I*E,c,!0)+2:s.cap===zr.SQUARE&&(d+=em(_,v,C,I,T,E,!0,c))),c.push(_-C*T,v-I*T,_+C*E,v+I*E);for(let D=1;D<u-1;++D){_=i[(D-1)*2],v=i[(D-1)*2+1],m=i[D*2],b=i[D*2+1],S=i[(D+1)*2],R=i[(D+1)*2+1],C=-(v-b),I=_-m,U=Math.sqrt(C*C+I*I),C/=U,I/=U,C*=p,I*=p,M=-(b-R),F=m-S,U=Math.sqrt(M*M+F*F),M/=U,F/=U,M*=p,F*=p;const N=m-_,$=v-b,O=m-S,B=R-b,k=N*O+$*B,V=$*O-B*N,z=V<0;if(Math.abs(V)<.001*Math.abs(k)){c.push(m-C*T,b-I*T,m+C*E,b+I*E),k>=0&&(s.join===Ge.ROUND?d+=Ti(m,b,m-C*T,b-I*T,m-M*T,b-F*T,c,!1)+4:d+=2,c.push(m-M*E,b-F*E,m+M*T,b+F*T));continue}const K=(-C+_)*(-I+b)-(-C+m)*(-I+v),X=(-M+S)*(-F+b)-(-M+m)*(-F+R),ft=(N*X-O*K)/V,H=(B*K-$*X)/V,mt=(ft-m)*(ft-m)+(H-b)*(H-b),Q=m+(ft-m)*T,ut=b+(H-b)*T,gt=m-(ft-m)*E,Et=b-(H-b)*E,Dt=Math.min(N*N+$*$,O*O+B*B),Yt=z?T:E,Vt=Dt+Yt*Yt*g,et=mt<=Vt;let $e=s.join;if($e===Ge.MITER&&mt/g>y&&($e=Ge.BEVEL),et)switch($e){case Ge.MITER:{c.push(Q,ut,gt,Et);break}case Ge.BEVEL:{z?c.push(Q,ut,m+C*E,b+I*E,Q,ut,m+M*E,b+F*E):c.push(m-C*T,b-I*T,gt,Et,m-M*T,b-F*T,gt,Et),d+=2;break}case Ge.ROUND:{z?(c.push(Q,ut,m+C*E,b+I*E),d+=Ti(m,b,m+C*E,b+I*E,m+M*E,b+F*E,c,!0)+4,c.push(Q,ut,m+M*E,b+F*E)):(c.push(m-C*T,b-I*T,gt,Et),d+=Ti(m,b,m-C*T,b-I*T,m-M*T,b-F*T,c,!1)+4,c.push(m-M*T,b-F*T,gt,Et));break}}else{switch(c.push(m-C*T,b-I*T,m+C*E,b+I*E),$e){case Ge.MITER:{z?c.push(gt,Et,gt,Et):c.push(Q,ut,Q,ut),d+=2;break}case Ge.ROUND:{z?d+=Ti(m,b,m+C*E,b+I*E,m+M*E,b+F*E,c,!0)+2:d+=Ti(m,b,m-C*T,b-I*T,m-M*T,b-F*T,c,!1)+2;break}}c.push(m-M*T,b-F*T,m+M*E,b+F*E),d+=2}}_=i[(u-2)*2],v=i[(u-2)*2+1],m=i[(u-1)*2],b=i[(u-1)*2+1],C=-(v-b),I=_-m,U=Math.sqrt(C*C+I*I),C/=U,I/=U,C*=p,I*=p,c.push(m-C*T,b-I*T,m+C*E,b+I*E),l||(s.cap===zr.ROUND?d+=Ti(m-C*(T-E)*.5,b-I*(T-E)*.5,m-C*T,b-I*T,m+C*E,b+I*E,c,!1)+2:s.cap===zr.SQUARE&&(d+=em(m,b,C,I,T,E,!1,c)));const A=t.indices,L=cn.epsilon*cn.epsilon;for(let D=f;D<d+f-2;++D)_=c[D*2],v=c[D*2+1],m=c[(D+1)*2],b=c[(D+1)*2+1],S=c[(D+2)*2],R=c[(D+2)*2+1],!(Math.abs(_*(b-R)+m*(R-v)+S*(v-b))<L)&&A.push(D,D+1,D+2)}function uS(r,t){let e=0;const i=r.shape,n=r.points||i.points,s=i.type!==ve.POLY||i.closeStroke;if(n.length===0)return;const o=t.points,a=t.indices,l=n.length/2,h=o.length/2;let c=h;for(o.push(n[0],n[1]),e=1;e<l;e++)o.push(n[e*2],n[e*2+1]),a.push(c,c+1),c++;s&&a.push(c,h)}function rm(r,t){r.lineStyle.native?uS(r,t):cS(r,t)}class _h{static curveLength(t,e,i,n,s,o){const a=t-2*i+s,l=e-2*n+o,h=2*i-2*t,c=2*n-2*e,u=4*(a*a+l*l),d=4*(a*h+l*c),f=h*h+c*c,p=2*Math.sqrt(u+d+f),g=Math.sqrt(u),y=2*u*g,_=2*Math.sqrt(f),v=d/g;return(y*p+g*d*(p-_)+(4*f*u-d*d)*Math.log((2*g+v+p)/(v+_)))/(4*y)}static curveTo(t,e,i,n,s){const o=s[s.length-2],a=s[s.length-1],l=cn._segmentsCount(_h.curveLength(o,a,t,e,i,n));let h=0,c=0;for(let u=1;u<=l;++u){const d=u/l;h=o+(t-o)*d,c=a+(e-a)*d,s.push(h+(t+(i-t)*d-h)*d,c+(e+(n-e)*d-c)*d)}}}const vh={[ve.POLY]:Jp,[ve.CIRC]:Ao,[ve.ELIP]:Ao,[ve.RECT]:aS,[ve.RREC]:lS},im=[],So=[];class Co{constructor(t,e=null,i=null,n=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=n,this.type=t.type}clone(){return new Co(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 un=new It,nm=class qm extends Nf{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 po,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(),So.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),im.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,n=null){const s=new Co(t,e,i,n);return this.graphicsData.push(s),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new Co(t,null,null,e),n=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=n.lineStyle,n.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 n=e[i];if(n.fillStyle.visible&&n.shape&&(n.matrix?n.matrix.applyInverse(t,un):un.copyFrom(t),n.shape.contains(un.x,un.y))){let s=!1;if(n.holes){for(let o=0;o<n.holes.length;o++)if(n.holes[o].shape.contains(un.x,un.y)){s=!0;break}}if(!s)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,n=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],n=i.style);for(let l=this.shapeIndex;l<e.length;l++){this.shapeIndex++;const h=e[l],c=h.fillStyle,u=h.lineStyle;vh[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(c.visible||u.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?c:u;if(!f.visible)continue;const p=f.texture.baseTexture,g=this.indices.length,y=this.points.length/2;p.wrapMode=Fr.REPEAT,d===0?this.processFill(h):this.processLine(h);const _=this.points.length/2-y;_!==0&&(i&&!this._compareStyles(n,f)&&(i.end(g,y),i=null),i||(i=im.pop()||new hS,i.begin(f,g,y),this.batches.push(i),n=f),this.addUvs(this.points,t,f.texture,y,_,f.matrix))}}const s=this.indices.length,o=this.points.length/2;if(i&&i.end(s,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],n=i.fillStyle,s=i.lineStyle;if(n&&!n.texture.baseTexture.valid||s&&!s.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 n=t[e];for(let s=0;s<n.size;s++){const o=n.start+s;this.indicesUint16[o]=this.indicesUint16[o]-n.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<qm.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++bt._globalBatch;for(let u=0;u<this.drawCalls.length;u++)this.drawCalls[u].texArray.clear(),So.push(this.drawCalls[u]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let n=So.pop();n||(n=new Hl,n.texArray=new Yl),n.texArray.count=0,n.start=0,n.size=0,n.type=rr.TRIANGLES;let s=0,o=null,a=0,l=!1,h=rr.TRIANGLES,c=0;this.drawCalls.push(n);for(let u=0;u<this.batches.length;u++){const d=this.batches[u],f=8,p=d.style,g=p.texture.baseTexture;l!==!!p.native&&(l=!!p.native,h=l?rr.LINES:rr.TRIANGLES,o=null,s=f,t++),o!==g&&(o=g,g._batchEnabled!==t&&(s===f&&(t++,s=0,n.size>0&&(n=So.pop(),n||(n=new Hl,n.texArray=new Yl),this.drawCalls.push(n)),n.start=c,n.size=0,n.texArray.count=0,n.type=h),g.touched=1,g._batchEnabled=t,g._batchLocation=s,g.wrapMode=Fr.REPEAT,n.texArray.elements[n.texArray.count++]=g,s++)),n.size+=d.size,c+=d.size,a=g._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}bt._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,n=this.textureIds,s=new ArrayBuffer(t.length*3*4),o=new Float32Array(s),a=new Uint32Array(s);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++]=n[h];this._buffer.update(s),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Jp.triangulate(t,this):vh[t.type].triangulate(t,this)}processLine(t){rm(t,this);for(let e=0;e<t.holes.length;e++)rm(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];vh[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 n=t[i*2],s=t[i*2+1];t[i*2]=e.a*n+e.c*s+e.tx,t[i*2+1]=e.b*n+e.d*s+e.ty}}addColors(t,e,i,n,s=0){const o=Mt.shared.setValue(e).toLittleEndianNumber(),a=Mt.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,s+n);for(let l=0;l<n;l++)t[s+l]=a}addTextureIds(t,e,i,n=0){t.length=Math.max(t.length,n+i);for(let s=0;s<i;s++)t[n+s]=e}addUvs(t,e,i,n,s,o=null){let a=0;const l=e.length,h=i.frame;for(;a<s;){let u=t[(n+a)*2],d=t[(n+a)*2+1];if(o){const f=o.a*u+o.c*d+o.tx;d=o.b*u+o.d*d+o.ty,u=f}a++,e.push(u/h.width,d/h.height)}const c=i.baseTexture;(h.width<c.width||h.height<c.height)&&this.adjustUvs(e,i,l,s)}adjustUvs(t,e,i,n){const s=e.baseTexture,o=1e-6,a=i+n*2,l=e.frame,h=l.width/s.width,c=l.height/s.height;let u=l.x/l.width,d=l.y/l.height,f=Math.floor(t[i]+o),p=Math.floor(t[i+1]+o);for(let g=i+2;g<a;g+=2)f=Math.min(f,Math.floor(t[g]+o)),p=Math.min(p,Math.floor(t[g+1]+o));u-=f,d-=p;for(let g=i;g<a;g+=2)t[g]=(t[g]+u)*h,t[g+1]=(t[g+1]+d)*c}};nm.BATCHABLE_SIZE=100;let dS=nm;class Io{constructor(){this.color=16777215,this.alpha=1,this.texture=ct.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Io;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=ct.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class bh extends Io{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=zr.BUTT,this.join=Ge.MITER,this.miterLimit=10}clone(){const t=new bh;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=zr.BUTT,this.join=Ge.MITER,this.miterLimit=10}}const xh={},wh=class Go extends We{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 Io,this._lineStyle=new bh,this._matrix=null,this._holeMode=!1,this.state=ur.for2d(),this._geometry=t||new dS,this._geometry.refCount++,this._transformID=-1,this._tintColor=new Mt(16777215),this.blendMode=vt.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new Go(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,n=.5,s=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:n,native:s}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:ct.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:zr.BUTT,join:Ge.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 di,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new di,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,n=i[i.length-2],s=i[i.length-1];return(n!==t||s!==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,n){this._initCurve();const s=this.currentPath.points;return s.length===0&&this.moveTo(0,0),_h.curveTo(t,e,i,n,s),this}bezierCurveTo(t,e,i,n,s,o){return this._initCurve(),yh.curveTo(t,e,i,n,s,o,this.currentPath.points),this}arcTo(t,e,i,n,s){this._initCurve(t,e);const o=this.currentPath.points,a=tm.curveTo(t,e,i,n,s,o);if(a){const{cx:l,cy:h,radius:c,startAngle:u,endAngle:d,anticlockwise:f}=a;this.arc(l,h,c,u,d,f)}return this}arc(t,e,i,n,s,o=!1){if(n===s)return this;if(!o&&s<=n?s+=qs:o&&n<=s&&(n+=qs),s-n===0)return this;const a=t+Math.cos(n)*i,l=e+Math.sin(n)*i,h=this._geometry.closePointEps;let c=this.currentPath?this.currentPath.points:null;if(c){const u=Math.abs(c[c.length-2]-a),d=Math.abs(c[c.length-1]-l);u<h&&d<h||c.push(a,l)}else this.moveTo(a,l),c=this.currentPath.points;return tm.arc(a,l,t,e,i,n,s,o,c),this}beginFill(t=0,e){return this.beginTextureFill({texture:ct.WHITE,color:t,alpha:e})}normalizeColor(t){const e=Mt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:ct.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,n){return this.drawShape(new wt(t,e,i,n))}drawRoundedRect(t,e,i,n,s){return this.drawShape(new Js(t,e,i,n,s))}drawCircle(t,e,i){return this.drawShape(new Zs(t,e,i))}drawEllipse(t,e,i,n){return this.drawShape(new Qs(t,e,i,n))}drawPolygon(...t){let e,i=!0;const n=t[0];n.points?(i=n.closeStroke,e=n.points):Array.isArray(t[0])?e=t[0]:e=t;const s=new di(e);return s.closeStroke=i,this.drawShape(s),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===ve.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 n=0;n<i;n++){const s=t.batches[n],o=s.style.color,a=new Float32Array(this.vertexData.buffer,s.attribStart*4*2,s.attribSize*2),l=new Float32Array(t.uvsFloat32.buffer,s.attribStart*4*2,s.attribSize*2),h=new Uint16Array(t.indicesUint16.buffer,s.start*2,s.size),c={vertexData:a,blendMode:e,indices:h,uvs:l,_batchRGB:Mt.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:s.style.texture,alpha:s.style.alpha,worldAlpha:1};this.batches[n]=c}}_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 n=this.batches[e];n.worldAlpha=this.worldAlpha*n.alpha,t.plugins[this.pluginName].render(n)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,n=this.worldAlpha,s=e.uniforms,o=i.drawCalls;s.translationMatrix=this.transform.worldTransform,Mt.shared.setValue(this._tintColor).premultiply(n).toArray(s.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:n,size:s,start:o}=e,a=i.count;for(let l=0;l<a;l++)t.texture.bind(i.elements[l],l);t.geometry.draw(n,s,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!xh[i]){const{maxTextures:n}=t.plugins[i],s=new Int32Array(n);for(let l=0;l<n;l++)s[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new kt,default:je.from({uSamplers:s},!0)},a=t.plugins[i]._shader.program;xh[i]=new dr(a,o)}e=xh[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:n,maxY:s}=t.bounds;this._bounds.addFrame(this.transform,e,i,n,s)}containsPoint(t){return this.worldTransform.applyInverse(t,Go._TEMP_POINT),this._geometry.containsPoint(Go._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=Mt.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,n=e.b,s=e.c,o=e.d,a=e.tx,l=e.ty,h=this._geometry.points,c=this.vertexData;let u=0;for(let d=0;d<h.length;d+=2){const f=h[d],p=h[d+1];c[u++]=i*f+s*p+a,c[u++]=o*p+n*f+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)}};wh.curves=cn,wh._TEMP_POINT=new It;let ts=wh;class fS{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 Eh=new It,sm=new di,om=class Km extends We{constructor(t,e,i,n=rr.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||ur.for2d(),this.drawMode=n,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=tt.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===rr.TRIANGLES&&e.length<Km.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 n=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[n]),t.plugins[n].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 n=this.transform.worldTransform,s=n.a,o=n.b,a=n.c,l=n.d,h=n.tx,c=n.ty,u=this.vertexData;for(let d=0;d<u.length/2;d++){const f=e[d*2],p=e[d*2+1];u[d*2]=s*f+a*p+h,u[d*2+1]=o*f+l*p+c}if(this._roundPixels){const d=tt.RESOLUTION;for(let f=0;f<u.length;++f)u[f]=Math.round(u[f]*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 fS(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,Eh);const e=this.geometry.getBuffer("aVertexPosition").data,i=sm.points,n=this.geometry.getIndex().data,s=n.length,o=this.drawMode===4?3:1;for(let a=0;a+2<s;a+=o){const l=n[a]*2,h=n[a+1]*2,c=n[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[c],i[5]=e[c+1],sm.contains(Eh.x,Eh.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}};om.BATCHABLE_SIZE=100;let am=om;class pS extends Hr{constructor(t,e,i){super();const n=new Qt(t),s=new Qt(e,!0),o=new Qt(i,!0,!0);this.addAttribute("aVertexPosition",n,2,!1,pt.FLOAT).addAttribute("aTextureCoord",s,2,!1,pt.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var mS=`varying vec2 vTextureCoord;
912
912
  uniform vec4 uColor;
913
913
 
914
914
  uniform sampler2D uSampler;
@@ -917,7 +917,7 @@ void main(void)
917
917
  {
918
918
  gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
919
919
  }
920
- `,mS=`attribute vec2 aVertexPosition;
920
+ `,gS=`attribute vec2 aVertexPosition;
921
921
  attribute vec2 aTextureCoord;
922
922
 
923
923
  uniform mat3 projectionMatrix;
@@ -932,7 +932,7 @@ void main(void)
932
932
 
933
933
  vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
934
934
  }
935
- `;class am extends ur{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:kt.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||Er.from(mS,pS),i),this._colorDirty=!1,this.uvMatrix=new rp(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new Mt(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;Mt.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class lm{constructor(t,e,i){this.geometry=new Gr,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let n=0;n<t.length;++n){let s=t[n];s={attributeName:s.attributeName,size:s.size,uploadFunction:s.uploadFunction,type:s.type||pt.FLOAT,offset:s.offset},e[n]?this.dynamicProperties.push(s):this.staticProperties.push(s)}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 Jt(Nw(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 Jt(this.dynamicData,!1,!1);let n=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=n,n+=a.size,this.staticStride+=a.size}const s=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(s),this.staticDataUint32=new Uint32Array(s),this.staticBuffer=new Jt(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===pt.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===pt.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(t,e,i){for(let n=0;n<this.dynamicProperties.length;n++){const s=this.dynamicProperties[n];s.uploadFunction(t,e,i,s.type===pt.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,s.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let n=0;n<this.staticProperties.length;n++){const s=this.staticProperties[n];s.uploadFunction(t,e,i,s.type===pt.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,s.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 gS=`varying vec2 vTextureCoord;
935
+ `;class lm extends dr{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:kt.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||Tr.from(gS,mS),i),this._colorDirty=!1,this.uvMatrix=new ip(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new Mt(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;Mt.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class hm{constructor(t,e,i){this.geometry=new Hr,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let n=0;n<t.length;++n){let s=t[n];s={attributeName:s.attributeName,size:s.size,uploadFunction:s.uploadFunction,type:s.type||pt.FLOAT,offset:s.offset},e[n]?this.dynamicProperties.push(s):this.staticProperties.push(s)}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 Qt(Fw(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 Qt(this.dynamicData,!1,!1);let n=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=n,n+=a.size,this.staticStride+=a.size}const s=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(s),this.staticDataUint32=new Uint32Array(s),this.staticBuffer=new Qt(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===pt.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===pt.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(t,e,i){for(let n=0;n<this.dynamicProperties.length;n++){const s=this.dynamicProperties[n];s.uploadFunction(t,e,i,s.type===pt.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,s.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let n=0;n<this.staticProperties.length;n++){const s=this.staticProperties[n];s.uploadFunction(t,e,i,s.type===pt.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,s.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 yS=`varying vec2 vTextureCoord;
936
936
  varying vec4 vColor;
937
937
 
938
938
  uniform sampler2D uSampler;
@@ -940,7 +940,7 @@ uniform sampler2D uSampler;
940
940
  void main(void){
941
941
  vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
942
942
  gl_FragColor = color;
943
- }`,yS=`attribute vec2 aVertexPosition;
943
+ }`,_S=`attribute vec2 aVertexPosition;
944
944
  attribute vec2 aTextureCoord;
945
945
  attribute vec4 aColor;
946
946
 
@@ -965,8 +965,8 @@ void main(void){
965
965
  vTextureCoord = aTextureCoord;
966
966
  vColor = aColor * uColor;
967
967
  }
968
- `;class hm extends io{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new kt,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:pt.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=ur.from(yS,gS,{}),this.state=cr.for2d()}render(t){const e=t.children,i=t._maxSize,n=t._batchSize,s=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=Tf(t.blendMode,h),s.state.set(this.state);const c=s.gl,u=t.worldTransform.copyTo(this.tempMatrix);u.prepend(s.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=u.toArray(!0),this.shader.uniforms.uColor=Mt.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 f=0,p=0;f<o;f+=n,p+=1){let g=o-f;g>n&&(g=n),p>=a.length&&a.push(this._generateOneMoreBuffer(t));const y=a[p];y.uploadDynamic(e,f,g);const _=t._bufferUpdateIDs[p]||0;d=d||y._updateID<_,d&&(y._updateID=t._updateID,y.uploadStatic(e,f,g)),s.geometry.bind(y.geometry),c.drawElements(c.TRIANGLES,g*6,c.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,n=t._batchSize,s=t._properties;for(let o=0;o<i;o+=n)e.push(new lm(this.properties,s,n));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new lm(this.properties,i,e)}uploadVertices(t,e,i,n,s,o){let a=0,l=0,h=0,c=0;for(let u=0;u<i;++u){const d=t[e+u],f=d._texture,p=d.scale.x,g=d.scale.y,y=f.trim,_=f.orig;y?(l=y.x-d.anchor.x*_.width,a=l+y.width,c=y.y-d.anchor.y*_.height,h=c+y.height):(a=_.width*(1-d.anchor.x),l=_.width*-d.anchor.x,h=_.height*(1-d.anchor.y),c=_.height*-d.anchor.y),n[o]=l*p,n[o+1]=c*g,n[o+s]=a*p,n[o+s+1]=c*g,n[o+s*2]=a*p,n[o+s*2+1]=h*g,n[o+s*3]=l*p,n[o+s*3+1]=h*g,o+=s*4}}uploadPosition(t,e,i,n,s,o){for(let a=0;a<i;a++){const l=t[e+a].position;n[o]=l.x,n[o+1]=l.y,n[o+s]=l.x,n[o+s+1]=l.y,n[o+s*2]=l.x,n[o+s*2+1]=l.y,n[o+s*3]=l.x,n[o+s*3+1]=l.y,o+=s*4}}uploadRotation(t,e,i,n,s,o){for(let a=0;a<i;a++){const l=t[e+a].rotation;n[o]=l,n[o+s]=l,n[o+s*2]=l,n[o+s*3]=l,o+=s*4}}uploadUvs(t,e,i,n,s,o){for(let a=0;a<i;++a){const l=t[e+a]._texture._uvs;l?(n[o]=l.x0,n[o+1]=l.y0,n[o+s]=l.x1,n[o+s+1]=l.y1,n[o+s*2]=l.x2,n[o+s*2+1]=l.y2,n[o+s*3]=l.x3,n[o+s*3+1]=l.y3,o+=s*4):(n[o]=0,n[o+1]=0,n[o+s]=0,n[o+s+1]=0,n[o+s*2]=0,n[o+s*2+1]=0,n[o+s*3]=0,n[o+s*3+1]=0,o+=s*4)}}uploadTint(t,e,i,n,s,o){for(let a=0;a<i;++a){const l=t[e+a],h=Mt.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);n[o]=h,n[o+s]=h,n[o+s*2]=h,n[o+s*3]=h,o+=s*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}hm.extension={name:"particle",type:Z.RendererPlugin},ht.add(hm);var Io=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(Io||{});const Po={willReadFrequently:!0},fr=class dt{static get experimentalLetterSpacingSupported(){let t=dt._experimentalLetterSpacingSupported;if(t!==void 0){const e=tt.ADAPTER.getCanvasRenderingContext2D().prototype;t=dt._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,n,s,o,a,l,h){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=s,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(t,e,i,n=dt._canvas){i=i??e.wordWrap;const s=e.toFontString(),o=dt.measureFont(s);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=n.getContext("2d",Po);a.font=s;const l=(i?dt.wordWrap(t,e,n):t).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let c=0;for(let p=0;p<l.length;p++){const g=dt._measureText(l[p],e.letterSpacing,a);h[p]=g,c=Math.max(c,g)}let u=c+e.strokeThickness;e.dropShadow&&(u+=e.dropShadowDistance);const d=e.lineHeight||o.fontSize+e.strokeThickness;let f=Math.max(d,o.fontSize+e.strokeThickness*2)+e.leading+(l.length-1)*(d+e.leading);return e.dropShadow&&(f+=e.dropShadowDistance),new dt(t,e,u,f,l,h,d+e.leading,c,o)}static _measureText(t,e,i){let n=!1;dt.experimentalLetterSpacingSupported&&(dt.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,n=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let s=i.measureText(t).width;return s>0&&(n?s-=e:s+=(dt.graphemeSegmenter(t).length-1)*e),s}static wordWrap(t,e,i=dt._canvas){const n=i.getContext("2d",Po);let s=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:c}=e,u=dt.collapseSpaces(c),d=dt.collapseNewlines(c);let f=!u;const p=e.wordWrapWidth+h,g=dt.tokenize(t);for(let y=0;y<g.length;y++){let _=g[y];if(dt.isNewline(_)){if(!d){a+=dt.addLine(o),f=!u,o="",s=0;continue}_=" "}if(u){const m=dt.isBreakingSpace(_),b=dt.isBreakingSpace(o[o.length-1]);if(m&&b)continue}const v=dt.getFromCache(_,h,l,n);if(v>p)if(o!==""&&(a+=dt.addLine(o),o="",s=0),dt.canBreakWords(_,e.breakWords)){const m=dt.wordWrapSplit(_);for(let b=0;b<m.length;b++){let S=m[b],R=S,C=1;for(;m[b+C];){const M=m[b+C];if(!dt.canBreakChars(R,M,_,b,e.breakWords))S+=M;else break;R=M,C++}b+=C-1;const I=dt.getFromCache(S,h,l,n);I+s>p&&(a+=dt.addLine(o),f=!1,o="",s=0),o+=S,s+=I}}else{o.length>0&&(a+=dt.addLine(o),o="",s=0);const m=y===g.length-1;a+=dt.addLine(_,!m),f=!1,o="",s=0}else v+s>p&&(f=!1,a+=dt.addLine(o),o="",s=0),(o.length>0||!dt.isBreakingSpace(_)||f)&&(o+=_,s+=v)}return a+=dt.addLine(o,!1),a}static addLine(t,e=!0){return t=dt.trimRight(t),t=e?`${t}
969
- `:t,t}static getFromCache(t,e,i,n){let s=i[t];return typeof s!="number"&&(s=dt._measureText(t,e,n)+e,i[t]=s),s}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!dt.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:dt._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:dt._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let n=0;n<t.length;n++){const s=t[n],o=t[n+1];if(dt.isBreakingSpace(s,o)||dt.isNewline(s)){i!==""&&(e.push(i),i=""),e.push(s);continue}i+=s}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,n,s){return!0}static wordWrapSplit(t){return dt.graphemeSegmenter(t)}static measureFont(t){if(dt._fonts[t])return dt._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=dt._canvas,n=dt._context;n.font=t;const s=dt.METRICS_STRING+dt.BASELINE_SYMBOL,o=Math.ceil(n.measureText(s).width);let a=Math.ceil(n.measureText(dt.BASELINE_SYMBOL).width);const l=Math.ceil(dt.HEIGHT_MULTIPLIER*a);if(a=a*dt.BASELINE_MULTIPLIER|0,o===0||l===0)return dt._fonts[t]=e,e;i.width=o,i.height=l,n.fillStyle="#f00",n.fillRect(0,0,o,l),n.font=t,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText(s,0,a);const h=n.getImageData(0,0,o,l).data,c=h.length,u=o*4;let d=0,f=0,p=!1;for(d=0;d<a;++d){for(let g=0;g<u;g+=4)if(h[f+g]!==255){p=!0;break}if(!p)f+=u;else break}for(e.ascent=a-d,f=c-u,p=!1,d=l;d>a;--d){for(let g=0;g<u;g+=4)if(h[f+g]!==255){p=!0;break}if(!p)f-=u;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,dt._fonts[t]=e,e}static clearMetrics(t=""){t?delete dt._fonts[t]:dt._fonts={}}static get _canvas(){var t;if(!dt.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",Po))!=null&&t.measureText)return dt.__canvas=i,i;e=tt.ADAPTER.createCanvas()}catch{e=tt.ADAPTER.createCanvas()}e.width=e.height=10,dt.__canvas=e}return dt.__canvas}static get _context(){return dt.__context||(dt.__context=dt._canvas.getContext("2d",Po)),dt.__context}};fr.METRICS_STRING="|ÉqÅ",fr.BASELINE_SYMBOL="M",fr.BASELINE_MULTIPLIER=1.4,fr.HEIGHT_MULTIPLIER=2,fr.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]})(),fr.experimentalLetterSpacing=!1,fr._fonts={},fr._newlines=[10,13],fr._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Vr=fr;const _S=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],cm=class ns{constructor(t){this.styleID=0,this.reset(),Th(this,t,t)}clone(){const t={};return Th(t,this,ns.defaultStyle),new ns(t)}reset(){Th(this,ns.defaultStyle,ns.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=Eh(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=Eh(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){vS(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=Eh(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 n=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!_S.includes(n)&&(n=`"${n}"`),e[i]=n}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};cm.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Io.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 zr=cm;function Eh(r){const t=Mt.shared,e=i=>{const n=t.setValue(i);return n.alpha===1?n.toHex():n.toRgbaString()};return Array.isArray(r)?r.map(e):e(r)}function vS(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 Th(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const bS={texture:!0,children:!1,baseTexture:!0},um=class Gh extends rn{constructor(t,e,i){let n=!1;i||(i=tt.ADAPTER.createCanvas(),n=!0),i.width=3,i.height=3;const s=ct.from(i);s.orig=new wt,s.trim=new wt,super(s),this._ownCanvas=n,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=Gh.defaultResolution??tt.RESOLUTION,this._autoResolution=Gh.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 Vr.experimentalLetterSpacing}static set experimentalLetterSpacing(t){At("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Vr.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,n=Vr.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),s=n.width,o=n.height,a=n.lines,l=n.lineHeight,h=n.lineWidths,c=n.maxLineWidth,u=n.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,s)+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,f;const p=e.dropShadow?2:1;for(let g=0;g<p;++g){const y=e.dropShadow&&g===0,_=y?Math.ceil(Math.max(1,o)+e.padding*2):0,v=_*this._resolution;if(y){i.fillStyle="black",i.strokeStyle="black";const b=e.dropShadowColor,S=e.dropShadowBlur*this._resolution,R=e.dropShadowDistance*this._resolution;i.shadowColor=Mt.shared.setValue(b).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=S,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*R,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*R+v}else i.fillStyle=this._generateFillStyle(e,a,n),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let m=(l-u.fontSize)/2;l-u.fontSize<0&&(m=0);for(let b=0;b<a.length;b++)d=e.strokeThickness/2,f=e.strokeThickness/2+b*l+u.ascent+m,e.align==="right"?d+=c-h[b]:e.align==="center"&&(d+=(c-h[b])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[b],d+e.padding,f+e.padding-_,!0),e.fill&&this.drawLetterSpacing(a[b],d+e.padding,f+e.padding-_)}this.updateTexture()}drawLetterSpacing(t,e,i,n=!1){const s=this._style.letterSpacing;let o=!1;if(Vr.experimentalLetterSpacingSupported&&(Vr.experimentalLetterSpacing?(this.context.letterSpacing=`${s}px`,this.context.textLetterSpacing=`${s}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),s===0||o){n?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let a=e;const l=Vr.graphemeSegmenter(t);let h=this.context.measureText(t).width,c=0;for(let u=0;u<l.length;++u){const d=l[u];n?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let f="";for(let p=u+1;p<l.length;++p)f+=l[p];c=this.context.measureText(f).width,a+=h-c+s,h=c}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=Gw(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,n=i.trim?0:i.padding,s=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=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),s.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 n=t.fill;if(Array.isArray(n)){if(n.length===1)return n[0]}else return n;let s;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,c=n.slice(),u=t.fillGradientStops.slice();if(!u.length){const d=c.length+1;for(let f=1;f<d;++f)u.push(f/d)}if(c.unshift(n[0]),u.unshift(0),c.push(n[n.length-1]),u.push(1),t.fillGradientType===Io.LINEAR_VERTICAL){s=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let f=0;f<e.length;f++){const p=i.lineHeight*(f-1)+d,g=i.lineHeight*f;let y=g;f>0&&p>g&&(y=(g+p)/2);const _=g+d,v=i.lineHeight*(f+1);let m=_;f+1<e.length&&v<_&&(m=(_+v)/2);const b=(m-y)/h;for(let S=0;S<c.length;S++){let R=0;typeof u[S]=="number"?R=u[S]:R=S/c.length;let C=Math.min(1,Math.max(0,y/h+R*b));C=Number(C.toFixed(5)),s.addColorStop(C,c[S])}}}else{s=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=c.length+1;let f=1;for(let p=0;p<c.length;p++){let g;typeof u[p]=="number"?g=u[p]:g=f/d,s.addColorStop(g,c[p]),f++}}return s}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},bS,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=kr(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=kr(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 zr?this._style=t:this._style=new zr(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)}};um.defaultAutoResolution=!0;let dm=um;class xS{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function wS(r,t){var i;let e=!1;if((i=r==null?void 0:r._textures)!=null&&i.length){for(let n=0;n<r._textures.length;n++)if(r._textures[n]instanceof ct){const s=r._textures[n].baseTexture;t.includes(s)||(t.push(s),e=!0)}}return e}function ES(r,t){if(r.baseTexture instanceof bt){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function TS(r,t){if(r._texture&&r._texture instanceof ct){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function AS(r,t){return t instanceof dm?(t.updateText(!0),!0):!1}function SS(r,t){if(t instanceof zr){const e=t.toFontString();return Vr.measureFont(e),!0}return!1}function CS(r,t){if(r instanceof dm){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 IS(r,t){return r instanceof zr?(t.includes(r)||t.push(r),!0):!1}const fm=class Km{constructor(t){this.limiter=new xS(Km.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(CS),this.registerFindHook(IS),this.registerFindHook(wS),this.registerFindHook(ES),this.registerFindHook(TS),this.registerUploadHook(AS),this.registerUploadHook(SS)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,Be.system.addOnce(this.tick,this,vi.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,n=this.uploadHooks.length;i<n;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)Be.system.addOnce(this.tick,this,vi.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 je)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&Be.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}};fm.uploadsPerFrame=4;let Ah=fm;Object.defineProperties(tt,{UPLOADS_PER_FRAME:{get(){return Ah.uploadsPerFrame},set(r){At("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Ah.uploadsPerFrame=r}}});function pm(r,t){return t instanceof bt?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function PS(r,t){if(!(t instanceof Qn))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let n=0;n<i.length;n++){const{texture:s}=i[n].style;s&&pm(r,s.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function RS(r,t){return r instanceof Qn?(t.push(r),!0):!1}class mm extends Ah{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(RS),this.registerUploadHook(pm),this.registerUploadHook(PS)}}mm.extension={name:"prepare",type:Z.RendererSystem},ht.add(mm);var MS=`#version 300 es
968
+ `;class cm extends no{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new kt,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:pt.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=dr.from(_S,yS,{}),this.state=ur.for2d()}render(t){const e=t.children,i=t._maxSize,n=t._batchSize,s=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=Af(t.blendMode,h),s.state.set(this.state);const c=s.gl,u=t.worldTransform.copyTo(this.tempMatrix);u.prepend(s.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=u.toArray(!0),this.shader.uniforms.uColor=Mt.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 f=0,p=0;f<o;f+=n,p+=1){let g=o-f;g>n&&(g=n),p>=a.length&&a.push(this._generateOneMoreBuffer(t));const y=a[p];y.uploadDynamic(e,f,g);const _=t._bufferUpdateIDs[p]||0;d=d||y._updateID<_,d&&(y._updateID=t._updateID,y.uploadStatic(e,f,g)),s.geometry.bind(y.geometry),c.drawElements(c.TRIANGLES,g*6,c.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,n=t._batchSize,s=t._properties;for(let o=0;o<i;o+=n)e.push(new hm(this.properties,s,n));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new hm(this.properties,i,e)}uploadVertices(t,e,i,n,s,o){let a=0,l=0,h=0,c=0;for(let u=0;u<i;++u){const d=t[e+u],f=d._texture,p=d.scale.x,g=d.scale.y,y=f.trim,_=f.orig;y?(l=y.x-d.anchor.x*_.width,a=l+y.width,c=y.y-d.anchor.y*_.height,h=c+y.height):(a=_.width*(1-d.anchor.x),l=_.width*-d.anchor.x,h=_.height*(1-d.anchor.y),c=_.height*-d.anchor.y),n[o]=l*p,n[o+1]=c*g,n[o+s]=a*p,n[o+s+1]=c*g,n[o+s*2]=a*p,n[o+s*2+1]=h*g,n[o+s*3]=l*p,n[o+s*3+1]=h*g,o+=s*4}}uploadPosition(t,e,i,n,s,o){for(let a=0;a<i;a++){const l=t[e+a].position;n[o]=l.x,n[o+1]=l.y,n[o+s]=l.x,n[o+s+1]=l.y,n[o+s*2]=l.x,n[o+s*2+1]=l.y,n[o+s*3]=l.x,n[o+s*3+1]=l.y,o+=s*4}}uploadRotation(t,e,i,n,s,o){for(let a=0;a<i;a++){const l=t[e+a].rotation;n[o]=l,n[o+s]=l,n[o+s*2]=l,n[o+s*3]=l,o+=s*4}}uploadUvs(t,e,i,n,s,o){for(let a=0;a<i;++a){const l=t[e+a]._texture._uvs;l?(n[o]=l.x0,n[o+1]=l.y0,n[o+s]=l.x1,n[o+s+1]=l.y1,n[o+s*2]=l.x2,n[o+s*2+1]=l.y2,n[o+s*3]=l.x3,n[o+s*3+1]=l.y3,o+=s*4):(n[o]=0,n[o+1]=0,n[o+s]=0,n[o+s+1]=0,n[o+s*2]=0,n[o+s*2+1]=0,n[o+s*3]=0,n[o+s*3+1]=0,o+=s*4)}}uploadTint(t,e,i,n,s,o){for(let a=0;a<i;++a){const l=t[e+a],h=Mt.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);n[o]=h,n[o+s]=h,n[o+s*2]=h,n[o+s*3]=h,o+=s*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}cm.extension={name:"particle",type:Z.RendererPlugin},ht.add(cm);var Po=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(Po||{});const Ro={willReadFrequently:!0},pr=class dt{static get experimentalLetterSpacingSupported(){let t=dt._experimentalLetterSpacingSupported;if(t!==void 0){const e=tt.ADAPTER.getCanvasRenderingContext2D().prototype;t=dt._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,n,s,o,a,l,h){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=s,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(t,e,i,n=dt._canvas){i=i??e.wordWrap;const s=e.toFontString(),o=dt.measureFont(s);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=n.getContext("2d",Ro);a.font=s;const l=(i?dt.wordWrap(t,e,n):t).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let c=0;for(let p=0;p<l.length;p++){const g=dt._measureText(l[p],e.letterSpacing,a);h[p]=g,c=Math.max(c,g)}let u=c+e.strokeThickness;e.dropShadow&&(u+=e.dropShadowDistance);const d=e.lineHeight||o.fontSize+e.strokeThickness;let f=Math.max(d,o.fontSize+e.strokeThickness*2)+e.leading+(l.length-1)*(d+e.leading);return e.dropShadow&&(f+=e.dropShadowDistance),new dt(t,e,u,f,l,h,d+e.leading,c,o)}static _measureText(t,e,i){let n=!1;dt.experimentalLetterSpacingSupported&&(dt.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,n=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let s=i.measureText(t).width;return s>0&&(n?s-=e:s+=(dt.graphemeSegmenter(t).length-1)*e),s}static wordWrap(t,e,i=dt._canvas){const n=i.getContext("2d",Ro);let s=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:c}=e,u=dt.collapseSpaces(c),d=dt.collapseNewlines(c);let f=!u;const p=e.wordWrapWidth+h,g=dt.tokenize(t);for(let y=0;y<g.length;y++){let _=g[y];if(dt.isNewline(_)){if(!d){a+=dt.addLine(o),f=!u,o="",s=0;continue}_=" "}if(u){const m=dt.isBreakingSpace(_),b=dt.isBreakingSpace(o[o.length-1]);if(m&&b)continue}const v=dt.getFromCache(_,h,l,n);if(v>p)if(o!==""&&(a+=dt.addLine(o),o="",s=0),dt.canBreakWords(_,e.breakWords)){const m=dt.wordWrapSplit(_);for(let b=0;b<m.length;b++){let S=m[b],R=S,C=1;for(;m[b+C];){const M=m[b+C];if(!dt.canBreakChars(R,M,_,b,e.breakWords))S+=M;else break;R=M,C++}b+=C-1;const I=dt.getFromCache(S,h,l,n);I+s>p&&(a+=dt.addLine(o),f=!1,o="",s=0),o+=S,s+=I}}else{o.length>0&&(a+=dt.addLine(o),o="",s=0);const m=y===g.length-1;a+=dt.addLine(_,!m),f=!1,o="",s=0}else v+s>p&&(f=!1,a+=dt.addLine(o),o="",s=0),(o.length>0||!dt.isBreakingSpace(_)||f)&&(o+=_,s+=v)}return a+=dt.addLine(o,!1),a}static addLine(t,e=!0){return t=dt.trimRight(t),t=e?`${t}
969
+ `:t,t}static getFromCache(t,e,i,n){let s=i[t];return typeof s!="number"&&(s=dt._measureText(t,e,n)+e,i[t]=s),s}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!dt.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:dt._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:dt._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let n=0;n<t.length;n++){const s=t[n],o=t[n+1];if(dt.isBreakingSpace(s,o)||dt.isNewline(s)){i!==""&&(e.push(i),i=""),e.push(s);continue}i+=s}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,n,s){return!0}static wordWrapSplit(t){return dt.graphemeSegmenter(t)}static measureFont(t){if(dt._fonts[t])return dt._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=dt._canvas,n=dt._context;n.font=t;const s=dt.METRICS_STRING+dt.BASELINE_SYMBOL,o=Math.ceil(n.measureText(s).width);let a=Math.ceil(n.measureText(dt.BASELINE_SYMBOL).width);const l=Math.ceil(dt.HEIGHT_MULTIPLIER*a);if(a=a*dt.BASELINE_MULTIPLIER|0,o===0||l===0)return dt._fonts[t]=e,e;i.width=o,i.height=l,n.fillStyle="#f00",n.fillRect(0,0,o,l),n.font=t,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText(s,0,a);const h=n.getImageData(0,0,o,l).data,c=h.length,u=o*4;let d=0,f=0,p=!1;for(d=0;d<a;++d){for(let g=0;g<u;g+=4)if(h[f+g]!==255){p=!0;break}if(!p)f+=u;else break}for(e.ascent=a-d,f=c-u,p=!1,d=l;d>a;--d){for(let g=0;g<u;g+=4)if(h[f+g]!==255){p=!0;break}if(!p)f-=u;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,dt._fonts[t]=e,e}static clearMetrics(t=""){t?delete dt._fonts[t]:dt._fonts={}}static get _canvas(){var t;if(!dt.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",Ro))!=null&&t.measureText)return dt.__canvas=i,i;e=tt.ADAPTER.createCanvas()}catch{e=tt.ADAPTER.createCanvas()}e.width=e.height=10,dt.__canvas=e}return dt.__canvas}static get _context(){return dt.__context||(dt.__context=dt._canvas.getContext("2d",Ro)),dt.__context}};pr.METRICS_STRING="|ÉqÅ",pr.BASELINE_SYMBOL="M",pr.BASELINE_MULTIPLIER=1.4,pr.HEIGHT_MULTIPLIER=2,pr.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]})(),pr.experimentalLetterSpacing=!1,pr._fonts={},pr._newlines=[10,13],pr._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let jr=pr;const vS=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],um=class ss{constructor(t){this.styleID=0,this.reset(),Ah(this,t,t)}clone(){const t={};return Ah(t,this,ss.defaultStyle),new ss(t)}reset(){Ah(this,ss.defaultStyle,ss.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=Th(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=Th(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){bS(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=Th(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 n=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!vS.includes(n)&&(n=`"${n}"`),e[i]=n}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};um.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Po.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 Wr=um;function Th(r){const t=Mt.shared,e=i=>{const n=t.setValue(i);return n.alpha===1?n.toHex():n.toRgbaString()};return Array.isArray(r)?r.map(e):e(r)}function bS(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 Ah(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const xS={texture:!0,children:!1,baseTexture:!0},dm=class $h extends nn{constructor(t,e,i){let n=!1;i||(i=tt.ADAPTER.createCanvas(),n=!0),i.width=3,i.height=3;const s=ct.from(i);s.orig=new wt,s.trim=new wt,super(s),this._ownCanvas=n,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=$h.defaultResolution??tt.RESOLUTION,this._autoResolution=$h.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 jr.experimentalLetterSpacing}static set experimentalLetterSpacing(t){At("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),jr.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,n=jr.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),s=n.width,o=n.height,a=n.lines,l=n.lineHeight,h=n.lineWidths,c=n.maxLineWidth,u=n.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,s)+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,f;const p=e.dropShadow?2:1;for(let g=0;g<p;++g){const y=e.dropShadow&&g===0,_=y?Math.ceil(Math.max(1,o)+e.padding*2):0,v=_*this._resolution;if(y){i.fillStyle="black",i.strokeStyle="black";const b=e.dropShadowColor,S=e.dropShadowBlur*this._resolution,R=e.dropShadowDistance*this._resolution;i.shadowColor=Mt.shared.setValue(b).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=S,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*R,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*R+v}else i.fillStyle=this._generateFillStyle(e,a,n),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let m=(l-u.fontSize)/2;l-u.fontSize<0&&(m=0);for(let b=0;b<a.length;b++)d=e.strokeThickness/2,f=e.strokeThickness/2+b*l+u.ascent+m,e.align==="right"?d+=c-h[b]:e.align==="center"&&(d+=(c-h[b])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[b],d+e.padding,f+e.padding-_,!0),e.fill&&this.drawLetterSpacing(a[b],d+e.padding,f+e.padding-_)}this.updateTexture()}drawLetterSpacing(t,e,i,n=!1){const s=this._style.letterSpacing;let o=!1;if(jr.experimentalLetterSpacingSupported&&(jr.experimentalLetterSpacing?(this.context.letterSpacing=`${s}px`,this.context.textLetterSpacing=`${s}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),s===0||o){n?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let a=e;const l=jr.graphemeSegmenter(t);let h=this.context.measureText(t).width,c=0;for(let u=0;u<l.length;++u){const d=l[u];n?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let f="";for(let p=u+1;p<l.length;++p)f+=l[p];c=this.context.measureText(f).width,a+=h-c+s,h=c}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=$w(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,n=i.trim?0:i.padding,s=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=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),s.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 n=t.fill;if(Array.isArray(n)){if(n.length===1)return n[0]}else return n;let s;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,c=n.slice(),u=t.fillGradientStops.slice();if(!u.length){const d=c.length+1;for(let f=1;f<d;++f)u.push(f/d)}if(c.unshift(n[0]),u.unshift(0),c.push(n[n.length-1]),u.push(1),t.fillGradientType===Po.LINEAR_VERTICAL){s=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let f=0;f<e.length;f++){const p=i.lineHeight*(f-1)+d,g=i.lineHeight*f;let y=g;f>0&&p>g&&(y=(g+p)/2);const _=g+d,v=i.lineHeight*(f+1);let m=_;f+1<e.length&&v<_&&(m=(_+v)/2);const b=(m-y)/h;for(let S=0;S<c.length;S++){let R=0;typeof u[S]=="number"?R=u[S]:R=S/c.length;let C=Math.min(1,Math.max(0,y/h+R*b));C=Number(C.toFixed(5)),s.addColorStop(C,c[S])}}}else{s=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=c.length+1;let f=1;for(let p=0;p<c.length;p++){let g;typeof u[p]=="number"?g=u[p]:g=f/d,s.addColorStop(g,c[p]),f++}}return s}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},xS,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=Gr(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=Gr(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 Wr?this._style=t:this._style=new Wr(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)}};dm.defaultAutoResolution=!0;let fm=dm;class wS{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function ES(r,t){var i;let e=!1;if((i=r==null?void 0:r._textures)!=null&&i.length){for(let n=0;n<r._textures.length;n++)if(r._textures[n]instanceof ct){const s=r._textures[n].baseTexture;t.includes(s)||(t.push(s),e=!0)}}return e}function TS(r,t){if(r.baseTexture instanceof bt){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function AS(r,t){if(r._texture&&r._texture instanceof ct){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function SS(r,t){return t instanceof fm?(t.updateText(!0),!0):!1}function CS(r,t){if(t instanceof Wr){const e=t.toFontString();return jr.measureFont(e),!0}return!1}function IS(r,t){if(r instanceof fm){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 PS(r,t){return r instanceof Wr?(t.includes(r)||t.push(r),!0):!1}const pm=class Zm{constructor(t){this.limiter=new wS(Zm.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(IS),this.registerFindHook(PS),this.registerFindHook(ES),this.registerFindHook(TS),this.registerFindHook(AS),this.registerUploadHook(SS),this.registerUploadHook(CS)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,Be.system.addOnce(this.tick,this,xi.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,n=this.uploadHooks.length;i<n;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)Be.system.addOnce(this.tick,this,xi.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 We)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&Be.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}};pm.uploadsPerFrame=4;let Sh=pm;Object.defineProperties(tt,{UPLOADS_PER_FRAME:{get(){return Sh.uploadsPerFrame},set(r){At("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Sh.uploadsPerFrame=r}}});function mm(r,t){return t instanceof bt?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function RS(r,t){if(!(t instanceof ts))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let n=0;n<i.length;n++){const{texture:s}=i[n].style;s&&mm(r,s.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function MS(r,t){return r instanceof ts?(t.push(r),!0):!1}class gm extends Sh{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(MS),this.registerUploadHook(mm),this.registerUploadHook(RS)}}gm.extension={name:"prepare",type:Z.RendererSystem},ht.add(gm);var DS=`#version 300 es
970
970
  #define SHADER_NAME Tiling-Sprite-100
971
971
 
972
972
  precision lowp float;
@@ -992,7 +992,7 @@ void main(void)
992
992
 
993
993
  fragmentColor = texSample * uColor;
994
994
  }
995
- `,DS=`#version 300 es
995
+ `,BS=`#version 300 es
996
996
  #define SHADER_NAME Tiling-Sprite-300
997
997
 
998
998
  precision lowp float;
@@ -1012,7 +1012,7 @@ void main(void)
1012
1012
 
1013
1013
  vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1014
1014
  }
1015
- `,BS=`#version 100
1015
+ `,OS=`#version 100
1016
1016
  #ifdef GL_EXT_shader_texture_lod
1017
1017
  #extension GL_EXT_shader_texture_lod : enable
1018
1018
  #endif
@@ -1045,7 +1045,7 @@ void main(void)
1045
1045
 
1046
1046
  gl_FragColor = texSample * uColor;
1047
1047
  }
1048
- `,gm=`#version 100
1048
+ `,ym=`#version 100
1049
1049
  #define SHADER_NAME Tiling-Sprite-100
1050
1050
 
1051
1051
  precision lowp float;
@@ -1065,7 +1065,7 @@ void main(void)
1065
1065
 
1066
1066
  vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1067
1067
  }
1068
- `,OS=`#version 100
1068
+ `,LS=`#version 100
1069
1069
  #define SHADER_NAME Tiling-Sprite-Simple-100
1070
1070
 
1071
1071
  precision lowp float;
@@ -1080,7 +1080,7 @@ void main(void)
1080
1080
  vec4 texSample = texture2D(uSampler, vTextureCoord);
1081
1081
  gl_FragColor = texSample * uColor;
1082
1082
  }
1083
- `;const Ro=new kt;class ym extends io{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new Zf,this.state=cr.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=ur.from(gm,OS,e),this.shader=t.context.webGLVersion>1?ur.from(DS,MS,e):ur.from(gm,BS,e)}render(t){const e=this.renderer,i=this.quad;let n=i.vertices;n[0]=n[6]=t._width*-t.anchor.x,n[1]=n[3]=t._height*-t.anchor.y,n[2]=n[4]=t._width*(1-t.anchor.x),n[5]=n[7]=t._height*(1-t.anchor.y);const s=t.uvRespectAnchor?t.anchor.x:0,o=t.uvRespectAnchor?t.anchor.y:0;n=i.uvs,n[0]=n[6]=-s,n[1]=n[3]=-o,n[2]=n[4]=1-s,n[5]=n[7]=1-o,i.invalidate();const a=t._texture,l=a.baseTexture,h=l.alphaMode>0,c=t.tileTransform.localTransform,u=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!==Lr.CLAMP:l.wrapMode===Lr.CLAMP&&(l.wrapMode=Lr.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,g=a.height,y=t._width,_=t._height;Ro.set(c.a*p/y,c.b*p/_,c.c*g/y,c.d*g/_,c.tx/y,c.ty/_),Ro.invert(),d?Ro.prepend(u.mapCoord):(f.uniforms.uMapCoord=u.mapCoord.toArray(!0),f.uniforms.uClampFrame=u.uClampFrame,f.uniforms.uClampOffset=u.uClampOffset),f.uniforms.uTransform=Ro.toArray(!0),f.uniforms.uColor=Mt.shared.setValue(t.tint).premultiply(t.worldAlpha,h).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=a,e.shader.bind(f),e.geometry.bind(i),this.state.blendMode=Tf(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}ym.extension={name:"tilingSprite",type:Z.RendererPlugin},ht.add(ym);const _m=class ss{constructor(t,e,i){this.linkedSheets=[],(t instanceof bt||t instanceof ct)&&(t={texture:t,data:e,resolutionFilename:i});const{texture:n,data:s,resolutionFilename:o=null,cachePrefix:a=""}=t;this.cachePrefix=a,this._texture=n instanceof ct?n:null,this.baseTexture=n instanceof bt?n:this._texture.baseTexture,this.textures={},this.animations={},this.data=s;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=xr(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 n=this._frameKeys[e],s=this._frames[n],o=s.frame;if(o){let a=null,l=null;const h=s.trimmed!==!1&&s.sourceSize?s.sourceSize:s.frame,c=new wt(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);s.rotated?a=new wt(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 wt(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),s.trimmed!==!1&&s.spriteSourceSize&&(l=new wt(Math.floor(s.spriteSourceSize.x)/this.resolution,Math.floor(s.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[n]=new ct(this.baseTexture,a,c,l,s.rotated?2:0,s.anchor,s.borders),ct.addToCache(this.textures[n],this.cachePrefix+n.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 n=t[e][i];this.animations[e].push(this.textures[n])}}}_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=[]}};_m.BATCH_SIZE=1e3;let vm=_m;const LS=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function bm(r,t,e){const i={};if(r.forEach(n=>{i[n]=t}),Object.keys(t.textures).forEach(n=>{i[`${t.cachePrefix}${n}`]=t.textures[n]}),!e){const n=ue.dirname(r[0]);t.linkedSheets.forEach((s,o)=>{Object.assign(i,bm([`${n}/${t.data.meta.related_multi_packs[o]}`],s,!0))})}return i}const NS={extension:Z.Asset,cache:{test:r=>r instanceof vm,getCacheableAssets:(r,t)=>bm(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&LS.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=tt.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:Z.LoadParser,priority:qe.Normal},async testParse(r,t){return ue.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var c,u;const{texture:i,imageFilename:n,cachePrefix:s}=(t==null?void 0:t.data)??{};let o=ue.dirname(t.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i&&i.baseTexture)a=i;else{const d=ch(o+(n??r.meta.image),t.src);a=(await e.load([d]))[d]}const l=new vm({texture:a.baseTexture,data:r,resolutionFilename:t.src,cachePrefix:s});await l.parse();const h=(c=r==null?void 0:r.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const d=[];for(const p of h){if(typeof p!="string")continue;let g=o+p;(u=t.data)!=null&&u.ignoreMultiPack||(g=ch(g,t.src),d.push(e.load({src:g,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);l.linkedSheets=f,f.forEach(p=>{p.linkedSheets=[l].concat(l.linkedSheets.filter(g=>g!==p))})}return l},unload(r){r.destroy(!0)}}};ht.add(NS);class Mo{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Do{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 s in e){const o=e[s].match(/^[a-z]+/gm)[0],a=e[s].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const h in a){const c=a[h].split("="),u=c[0],d=c[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;l[u]=p}i[o].push(l)}const n=new Mo;return i.info.forEach(s=>n.info.push({face:s.face,size:parseInt(s.size,10)})),i.common.forEach(s=>n.common.push({lineHeight:parseInt(s.lineHeight,10)})),i.page.forEach(s=>n.page.push({id:parseInt(s.id,10),file:s.file})),i.char.forEach(s=>n.char.push({id:parseInt(s.id,10),page:parseInt(s.page,10),x:parseInt(s.x,10),y:parseInt(s.y,10),width:parseInt(s.width,10),height:parseInt(s.height,10),xoffset:parseInt(s.xoffset,10),yoffset:parseInt(s.yoffset,10),xadvance:parseInt(s.xadvance,10)})),i.kerning.forEach(s=>n.kerning.push({first:parseInt(s.first,10),second:parseInt(s.second,10),amount:parseInt(s.amount,10)})),i.distanceField.forEach(s=>n.distanceField.push({distanceRange:parseInt(s.distanceRange,10),fieldType:s.fieldType})),n}}class Sh{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 Mo,i=t.getElementsByTagName("info"),n=t.getElementsByTagName("common"),s=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<n.length;h++)e.common.push({lineHeight:parseInt(n[h].getAttribute("lineHeight"),10)});for(let h=0;h<s.length;h++)e.page.push({id:parseInt(s[h].getAttribute("id"),10)||0,file:s[h].getAttribute("file")});for(let h=0;h<o.length;h++){const c=o[h];e.char.push({id:parseInt(c.getAttribute("id"),10),page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xoffset:parseInt(c.getAttribute("xoffset"),10),yoffset:parseInt(c.getAttribute("yoffset"),10),xadvance:parseInt(c.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>")?Sh.test(tt.ADAPTER.parseXML(t)):!1}static parse(t){return Sh.parse(tt.ADAPTER.parseXML(t))}}const Ih=[Do,Sh,Ch];function FS(r){for(let t=0;t<Ih.length;t++)if(Ih[t].test(r))return Ih[t];return null}function kS(r,t,e,i,n,s){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,c=r.width/i-l-h*2,u=r.height/i-l-h*2,d=o.slice(),f=e.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let g=1;g<p;++g)f.push(g/p)}if(d.unshift(o[0]),f.unshift(0),d.push(o[o.length-1]),f.push(1),e.fillGradientType===Io.LINEAR_VERTICAL){a=t.createLinearGradient(c/2,h,c/2,u+h);let p=0;const g=(s.fontProperties.fontSize+e.strokeThickness)/u;for(let y=0;y<n.length;y++){const _=s.lineHeight*y;for(let v=0;v<d.length;v++){let m=0;typeof f[v]=="number"?m=f[v]:m=v/d.length;const b=_/u+m*g;let S=Math.max(p,b);S=Math.min(S,1),a.addColorStop(S,d[v]),p=S}}}else{a=t.createLinearGradient(h,u/2,c+h,u/2);const p=d.length+1;let g=1;for(let y=0;y<d.length;y++){let _;typeof f[y]=="number"?_=f[y]:_=g/p,a.addColorStop(_,d[y]),g++}}return a}function US(r,t,e,i,n,s,o){const a=e.text,l=e.fontProperties;t.translate(i,n),t.scale(s,s);const h=o.strokeThickness/2,c=-(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=kS(r,t,o,s,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const u=o.dropShadowColor,d=o.dropShadowBlur*s,f=o.dropShadowDistance*s;t.shadowColor=Mt.shared.setValue(u).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*f,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*f}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,h,c+e.lineHeight-l.descent),o.fill&&t.fillText(a,h,c+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Bo(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function xm(r){return Array.from?Array.from(r):r.split("")}function GS(r){typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const n=r[e];if(Array.isArray(n)){if(n.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);const s=n[0].charCodeAt(0),o=n[1].charCodeAt(0);if(o<s)throw new Error("[BitmapFont]: Invalid character range.");for(let a=s,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...xm(n))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const jr=class pr{constructor(t,e,i){var c;const[n]=t.info,[s]=t.common,[o]=t.page,[a]=t.distanceField,l=xr(o.file),h={};this._ownsTextures=i,this.font=n.face,this.size=n.size,this.lineHeight=s.lineHeight/l,this.chars={},this.pageTextures=h;for(let u=0;u<t.page.length;u++){const{id:d,file:f}=t.page[u];h[d]=e instanceof Array?e[u]:e[f],a!=null&&a.fieldType&&a.fieldType!=="none"&&(h[d].baseTexture.alphaMode=Re.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=rr.OFF)}for(let u=0;u<t.char.length;u++){const{id:d,page:f}=t.char[u];let{x:p,y:g,width:y,height:_,xoffset:v,yoffset:m,xadvance:b}=t.char[u];p/=l,g/=l,y/=l,_/=l,v/=l,m/=l,b/=l;const S=new wt(p+h[f].frame.x/l,g+h[f].frame.y/l,y,_);this.chars[d]={xOffset:v,yOffset:m,xAdvance:b,kerning:{},texture:new ct(h[f].baseTexture,S),page:f}}for(let u=0;u<t.kerning.length;u++){let{first:d,second:f,amount:p}=t.kerning[u];d/=l,f/=l,p/=l,this.chars[f]&&(this.chars[f].kerning[d]=p)}this.distanceFieldRange=a==null?void 0:a.distanceRange,this.distanceFieldType=((c=a==null?void 0:a.fieldType)==null?void 0:c.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 n;if(t instanceof Mo)n=t;else{const o=FS(t);if(!o)throw new Error("Unrecognized data format for font.");n=o.parse(t)}e instanceof ct&&(e=[e]);const s=new pr(n,e,i);return pr.available[s.font]=s,s}static uninstall(t){const e=pr.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete pr.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:n,padding:s,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},pr.defaultOptions,i),c=GS(n),u=e instanceof zr?e:new zr(e),d=a,f=new Mo;f.info[0]={face:u.fontFamily,size:u.fontSize},f.common[0]={lineHeight:u.fontSize};let p=0,g=0,y,_,v,m=0;const b=[];for(let R=0;R<c.length;R++){y||(y=tt.ADAPTER.createCanvas(),y.width=a,y.height=l,_=y.getContext("2d"),v=new bt(y,{resolution:o,...h}),b.push(new ct(v)),f.page.push({id:b.length-1,file:""}));const C=c[R],I=Vr.measureText(C,u,!1,y),M=I.width,F=Math.ceil(I.height),U=Math.ceil((u.fontStyle==="italic"?2:1)*M);if(g>=l-F*o){if(g===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${C}')`);--R,y=null,_=null,v=null,g=0,p=0,m=0;continue}if(m=Math.max(F+I.fontProperties.descent,m),U*o+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${C}')`);--R,g+=m*o,g=Math.ceil(g),p=0,m=0;continue}US(y,_,I,p,g,o,u);const P=Bo(I.text);f.char.push({id:P,page:b.length-1,x:p/o,y:g/o,width:U,height:F,xoffset:0,yoffset:0,xadvance:M-(u.dropShadow?u.dropShadowDistance:0)-(u.stroke?u.strokeThickness:0)}),p+=(U+2*s)*o,p=Math.ceil(p)}if(!(i!=null&&i.skipKerning))for(let R=0,C=c.length;R<C;R++){const I=c[R];for(let M=0;M<C;M++){const F=c[M],U=_.measureText(I).width,P=_.measureText(F).width,T=_.measureText(I+F).width-(U+P);T&&f.kerning.push({first:Bo(I),second:Bo(F),amount:T})}}const S=new pr(f,b,!0);return pr.available[t]!==void 0&&pr.uninstall(t),pr.available[t]=S,S}};jr.ALPHA=[["a","z"],["A","Z"]," "],jr.NUMERIC=[["0","9"]],jr.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],jr.ASCII=[[" ","~"]],jr.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:jr.ALPHANUMERIC},jr.available={};let Wr=jr;var $S=`// Pixi texture info\r
1083
+ `;const Mo=new kt;class _m extends no{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new Qf,this.state=ur.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=dr.from(ym,LS,e),this.shader=t.context.webGLVersion>1?dr.from(BS,DS,e):dr.from(ym,OS,e)}render(t){const e=this.renderer,i=this.quad;let n=i.vertices;n[0]=n[6]=t._width*-t.anchor.x,n[1]=n[3]=t._height*-t.anchor.y,n[2]=n[4]=t._width*(1-t.anchor.x),n[5]=n[7]=t._height*(1-t.anchor.y);const s=t.uvRespectAnchor?t.anchor.x:0,o=t.uvRespectAnchor?t.anchor.y:0;n=i.uvs,n[0]=n[6]=-s,n[1]=n[3]=-o,n[2]=n[4]=1-s,n[5]=n[7]=1-o,i.invalidate();const a=t._texture,l=a.baseTexture,h=l.alphaMode>0,c=t.tileTransform.localTransform,u=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!==Fr.CLAMP:l.wrapMode===Fr.CLAMP&&(l.wrapMode=Fr.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,g=a.height,y=t._width,_=t._height;Mo.set(c.a*p/y,c.b*p/_,c.c*g/y,c.d*g/_,c.tx/y,c.ty/_),Mo.invert(),d?Mo.prepend(u.mapCoord):(f.uniforms.uMapCoord=u.mapCoord.toArray(!0),f.uniforms.uClampFrame=u.uClampFrame,f.uniforms.uClampOffset=u.uClampOffset),f.uniforms.uTransform=Mo.toArray(!0),f.uniforms.uColor=Mt.shared.setValue(t.tint).premultiply(t.worldAlpha,h).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=a,e.shader.bind(f),e.geometry.bind(i),this.state.blendMode=Af(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}_m.extension={name:"tilingSprite",type:Z.RendererPlugin},ht.add(_m);const vm=class os{constructor(t,e,i){this.linkedSheets=[],(t instanceof bt||t instanceof ct)&&(t={texture:t,data:e,resolutionFilename:i});const{texture:n,data:s,resolutionFilename:o=null,cachePrefix:a=""}=t;this.cachePrefix=a,this._texture=n instanceof ct?n:null,this.baseTexture=n instanceof bt?n:this._texture.baseTexture,this.textures={},this.animations={},this.data=s;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=wr(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<=os.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=os.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const n=this._frameKeys[e],s=this._frames[n],o=s.frame;if(o){let a=null,l=null;const h=s.trimmed!==!1&&s.sourceSize?s.sourceSize:s.frame,c=new wt(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);s.rotated?a=new wt(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 wt(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),s.trimmed!==!1&&s.spriteSourceSize&&(l=new wt(Math.floor(s.spriteSourceSize.x)/this.resolution,Math.floor(s.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[n]=new ct(this.baseTexture,a,c,l,s.rotated?2:0,s.anchor,s.borders),ct.addToCache(this.textures[n],this.cachePrefix+n.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 n=t[e][i];this.animations[e].push(this.textures[n])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*os.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*os.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=[]}};vm.BATCH_SIZE=1e3;let bm=vm;const NS=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function xm(r,t,e){const i={};if(r.forEach(n=>{i[n]=t}),Object.keys(t.textures).forEach(n=>{i[`${t.cachePrefix}${n}`]=t.textures[n]}),!e){const n=ue.dirname(r[0]);t.linkedSheets.forEach((s,o)=>{Object.assign(i,xm([`${n}/${t.data.meta.related_multi_packs[o]}`],s,!0))})}return i}const FS={extension:Z.Asset,cache:{test:r=>r instanceof bm,getCacheableAssets:(r,t)=>xm(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&NS.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=tt.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:Z.LoadParser,priority:Ke.Normal},async testParse(r,t){return ue.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var c,u;const{texture:i,imageFilename:n,cachePrefix:s}=(t==null?void 0:t.data)??{};let o=ue.dirname(t.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i&&i.baseTexture)a=i;else{const d=uh(o+(n??r.meta.image),t.src);a=(await e.load([d]))[d]}const l=new bm({texture:a.baseTexture,data:r,resolutionFilename:t.src,cachePrefix:s});await l.parse();const h=(c=r==null?void 0:r.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const d=[];for(const p of h){if(typeof p!="string")continue;let g=o+p;(u=t.data)!=null&&u.ignoreMultiPack||(g=uh(g,t.src),d.push(e.load({src:g,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);l.linkedSheets=f,f.forEach(p=>{p.linkedSheets=[l].concat(l.linkedSheets.filter(g=>g!==p))})}return l},unload(r){r.destroy(!0)}}};ht.add(FS);class Do{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 s in e){const o=e[s].match(/^[a-z]+/gm)[0],a=e[s].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const h in a){const c=a[h].split("="),u=c[0],d=c[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;l[u]=p}i[o].push(l)}const n=new Do;return i.info.forEach(s=>n.info.push({face:s.face,size:parseInt(s.size,10)})),i.common.forEach(s=>n.common.push({lineHeight:parseInt(s.lineHeight,10)})),i.page.forEach(s=>n.page.push({id:parseInt(s.id,10),file:s.file})),i.char.forEach(s=>n.char.push({id:parseInt(s.id,10),page:parseInt(s.page,10),x:parseInt(s.x,10),y:parseInt(s.y,10),width:parseInt(s.width,10),height:parseInt(s.height,10),xoffset:parseInt(s.xoffset,10),yoffset:parseInt(s.yoffset,10),xadvance:parseInt(s.xadvance,10)})),i.kerning.forEach(s=>n.kerning.push({first:parseInt(s.first,10),second:parseInt(s.second,10),amount:parseInt(s.amount,10)})),i.distanceField.forEach(s=>n.distanceField.push({distanceRange:parseInt(s.distanceRange,10),fieldType:s.fieldType})),n}}class Ch{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 Do,i=t.getElementsByTagName("info"),n=t.getElementsByTagName("common"),s=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<n.length;h++)e.common.push({lineHeight:parseInt(n[h].getAttribute("lineHeight"),10)});for(let h=0;h<s.length;h++)e.page.push({id:parseInt(s[h].getAttribute("id"),10)||0,file:s[h].getAttribute("file")});for(let h=0;h<o.length;h++){const c=o[h];e.char.push({id:parseInt(c.getAttribute("id"),10),page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xoffset:parseInt(c.getAttribute("xoffset"),10),yoffset:parseInt(c.getAttribute("yoffset"),10),xadvance:parseInt(c.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 Ih{static test(t){return typeof t=="string"&&t.includes("<font>")?Ch.test(tt.ADAPTER.parseXML(t)):!1}static parse(t){return Ch.parse(tt.ADAPTER.parseXML(t))}}const Ph=[Bo,Ch,Ih];function kS(r){for(let t=0;t<Ph.length;t++)if(Ph[t].test(r))return Ph[t];return null}function US(r,t,e,i,n,s){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,c=r.width/i-l-h*2,u=r.height/i-l-h*2,d=o.slice(),f=e.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let g=1;g<p;++g)f.push(g/p)}if(d.unshift(o[0]),f.unshift(0),d.push(o[o.length-1]),f.push(1),e.fillGradientType===Po.LINEAR_VERTICAL){a=t.createLinearGradient(c/2,h,c/2,u+h);let p=0;const g=(s.fontProperties.fontSize+e.strokeThickness)/u;for(let y=0;y<n.length;y++){const _=s.lineHeight*y;for(let v=0;v<d.length;v++){let m=0;typeof f[v]=="number"?m=f[v]:m=v/d.length;const b=_/u+m*g;let S=Math.max(p,b);S=Math.min(S,1),a.addColorStop(S,d[v]),p=S}}}else{a=t.createLinearGradient(h,u/2,c+h,u/2);const p=d.length+1;let g=1;for(let y=0;y<d.length;y++){let _;typeof f[y]=="number"?_=f[y]:_=g/p,a.addColorStop(_,d[y]),g++}}return a}function GS(r,t,e,i,n,s,o){const a=e.text,l=e.fontProperties;t.translate(i,n),t.scale(s,s);const h=o.strokeThickness/2,c=-(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=US(r,t,o,s,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const u=o.dropShadowColor,d=o.dropShadowBlur*s,f=o.dropShadowDistance*s;t.shadowColor=Mt.shared.setValue(u).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*f,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*f}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,h,c+e.lineHeight-l.descent),o.fill&&t.fillText(a,h,c+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Oo(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function wm(r){return Array.from?Array.from(r):r.split("")}function $S(r){typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const n=r[e];if(Array.isArray(n)){if(n.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);const s=n[0].charCodeAt(0),o=n[1].charCodeAt(0);if(o<s)throw new Error("[BitmapFont]: Invalid character range.");for(let a=s,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...wm(n))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Yr=class mr{constructor(t,e,i){var c;const[n]=t.info,[s]=t.common,[o]=t.page,[a]=t.distanceField,l=wr(o.file),h={};this._ownsTextures=i,this.font=n.face,this.size=n.size,this.lineHeight=s.lineHeight/l,this.chars={},this.pageTextures=h;for(let u=0;u<t.page.length;u++){const{id:d,file:f}=t.page[u];h[d]=e instanceof Array?e[u]:e[f],a!=null&&a.fieldType&&a.fieldType!=="none"&&(h[d].baseTexture.alphaMode=Re.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=ir.OFF)}for(let u=0;u<t.char.length;u++){const{id:d,page:f}=t.char[u];let{x:p,y:g,width:y,height:_,xoffset:v,yoffset:m,xadvance:b}=t.char[u];p/=l,g/=l,y/=l,_/=l,v/=l,m/=l,b/=l;const S=new wt(p+h[f].frame.x/l,g+h[f].frame.y/l,y,_);this.chars[d]={xOffset:v,yOffset:m,xAdvance:b,kerning:{},texture:new ct(h[f].baseTexture,S),page:f}}for(let u=0;u<t.kerning.length;u++){let{first:d,second:f,amount:p}=t.kerning[u];d/=l,f/=l,p/=l,this.chars[f]&&(this.chars[f].kerning[d]=p)}this.distanceFieldRange=a==null?void 0:a.distanceRange,this.distanceFieldType=((c=a==null?void 0:a.fieldType)==null?void 0:c.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 n;if(t instanceof Do)n=t;else{const o=kS(t);if(!o)throw new Error("Unrecognized data format for font.");n=o.parse(t)}e instanceof ct&&(e=[e]);const s=new mr(n,e,i);return mr.available[s.font]=s,s}static uninstall(t){const e=mr.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete mr.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:n,padding:s,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},mr.defaultOptions,i),c=$S(n),u=e instanceof Wr?e:new Wr(e),d=a,f=new Do;f.info[0]={face:u.fontFamily,size:u.fontSize},f.common[0]={lineHeight:u.fontSize};let p=0,g=0,y,_,v,m=0;const b=[];for(let R=0;R<c.length;R++){y||(y=tt.ADAPTER.createCanvas(),y.width=a,y.height=l,_=y.getContext("2d"),v=new bt(y,{resolution:o,...h}),b.push(new ct(v)),f.page.push({id:b.length-1,file:""}));const C=c[R],I=jr.measureText(C,u,!1,y),M=I.width,F=Math.ceil(I.height),U=Math.ceil((u.fontStyle==="italic"?2:1)*M);if(g>=l-F*o){if(g===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${C}')`);--R,y=null,_=null,v=null,g=0,p=0,m=0;continue}if(m=Math.max(F+I.fontProperties.descent,m),U*o+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${C}')`);--R,g+=m*o,g=Math.ceil(g),p=0,m=0;continue}GS(y,_,I,p,g,o,u);const P=Oo(I.text);f.char.push({id:P,page:b.length-1,x:p/o,y:g/o,width:U,height:F,xoffset:0,yoffset:0,xadvance:M-(u.dropShadow?u.dropShadowDistance:0)-(u.stroke?u.strokeThickness:0)}),p+=(U+2*s)*o,p=Math.ceil(p)}if(!(i!=null&&i.skipKerning))for(let R=0,C=c.length;R<C;R++){const I=c[R];for(let M=0;M<C;M++){const F=c[M],U=_.measureText(I).width,P=_.measureText(F).width,T=_.measureText(I+F).width-(U+P);T&&f.kerning.push({first:Oo(I),second:Oo(F),amount:T})}}const S=new mr(f,b,!0);return mr.available[t]!==void 0&&mr.uninstall(t),mr.available[t]=S,S}};Yr.ALPHA=[["a","z"],["A","Z"]," "],Yr.NUMERIC=[["0","9"]],Yr.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Yr.ASCII=[[" ","~"]],Yr.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Yr.ALPHANUMERIC},Yr.available={};let qr=Yr;var HS=`// 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
- `,HS=`// Mesh material default fragment\r
1121
+ `,XS=`// 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 wm=[],Em=[],Tm=[],XS=class Zm extends je{constructor(t,e={}){super();const{align:i,tint:n,maxWidth:s,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},Zm.styleDefaults,e);if(!Wr.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new Mt(n),this._font=void 0,this._fontName=a,this._fontSize=l,this.text=t,this._maxWidth=s,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new wr(()=>{this.dirty=!0},this,0,0),this._roundPixels=tt.ROUND_PIXELS,this.dirty=!0,this._resolution=tt.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var U;const t=Wr.available[this._fontName],e=this.fontSize,i=e/t.size,n=new It,s=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,`
1138
- `)||" ",h=xm(l),c=this._maxWidth*t.size/e,u=t.distanceFieldType==="none"?wm:Em;let d=null,f=0,p=0,g=0,y=-1,_=0,v=0,m=0,b=0;for(let P=0;P<h.length;P++){const T=h[P],E=Bo(T);if(/(?:\s)/.test(T)&&(y=P,_=f,b++),T==="\r"||T===`
1139
- `){o.push(f),a.push(-1),p=Math.max(p,f),++g,++v,n.x=0,n.y+=t.lineHeight,d=null,b=0;continue}const A=t.chars[E];if(!A)continue;d&&A.kerning[d]&&(n.x+=A.kerning[d]);const L=Tm.pop()||{texture:ct.EMPTY,line:0,charCode:0,prevSpaces:0,position:new It};L.texture=A.texture,L.line=g,L.charCode=E,L.position.x=Math.round(n.x+A.xOffset+this._letterSpacing/2),L.position.y=Math.round(n.y+A.yOffset),L.prevSpaces=b,s.push(L),f=L.position.x+Math.max(A.xAdvance-A.xOffset,A.texture.orig.width),n.x+=A.xAdvance+this._letterSpacing,m=Math.max(m,A.yOffset+A.texture.height),d=E,y!==-1&&c>0&&n.x>c&&(++v,Ji(s,1+y-v,1+P-y),P=y,y=-1,o.push(_),a.push(s.length>0?s[s.length-1].prevSpaces:0),p=Math.max(p,_),g++,n.x=0,n.y+=t.lineHeight,d=null,b=0)}const S=h[h.length-1];S!=="\r"&&S!==`
1140
- `&&(/(?:\s)/.test(S)&&(f=_),o.push(f),p=Math.max(p,f),a.push(-1));const R=[];for(let P=0;P<=g;P++){let T=0;this._align==="right"?T=p-o[P]:this._align==="center"?T=(p-o[P])/2:this._align==="justify"&&(T=a[P]<0?0:(p-o[P])/a[P]),R.push(T)}const C=s.length,I={},M=[],F=this._activePagesMeshData;u.push(...F);for(let P=0;P<C;P++){const T=s[P].texture,E=T.baseTexture.uid;if(!I[E]){let A=u.pop();if(!A){const D=new fS;let N,$;t.distanceFieldType==="none"?(N=new am(ct.EMPTY),$=vt.NORMAL):(N=new am(ct.EMPTY,{program:Er.from(HS,$S),uniforms:{uFWidth:0}}),$=vt.NORMAL_NPM);const O=new om(D,N);O.blendMode=$,A={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:O,vertices:null,uvs:null,indices:null}}A.index=0,A.indexCount=0,A.vertexCount=0,A.uvsCount=0,A.total=0;const{_textureCache:L}=this;L[E]=L[E]||new ct(T.baseTexture),A.mesh.texture=L[E],A.mesh.tint=this._tintColor.value,M.push(A),I[E]=A}I[E].total++}for(let P=0;P<F.length;P++)M.includes(F[P])||this.removeChild(F[P].mesh);for(let P=0;P<M.length;P++)M[P].mesh.parent!==this&&this.addChild(M[P].mesh);this._activePagesMeshData=M;for(const P in I){const T=I[P],E=T.total;if(!(((U=T.indices)==null?void 0:U.length)>6*E)||T.vertices.length<om.BATCHABLE_SIZE*2)T.vertices=new Float32Array(4*2*E),T.uvs=new Float32Array(4*2*E),T.indices=new Uint16Array(6*E);else{const A=T.total,L=T.vertices;for(let D=A*4*2;D<L.length;D++)L[D]=0}T.mesh.size=6*E}for(let P=0;P<C;P++){const T=s[P];let E=T.position.x+R[T.line]*(this._align==="justify"?T.prevSpaces:1);this._roundPixels&&(E=Math.round(E));const A=E*i,L=T.position.y*i,D=T.texture,N=I[D.baseTexture.uid],$=D.frame,O=D._uvs,B=N.index++;N.indices[B*6+0]=0+B*4,N.indices[B*6+1]=1+B*4,N.indices[B*6+2]=2+B*4,N.indices[B*6+3]=0+B*4,N.indices[B*6+4]=2+B*4,N.indices[B*6+5]=3+B*4,N.vertices[B*8+0]=A,N.vertices[B*8+1]=L,N.vertices[B*8+2]=A+$.width*i,N.vertices[B*8+3]=L,N.vertices[B*8+4]=A+$.width*i,N.vertices[B*8+5]=L+$.height*i,N.vertices[B*8+6]=A,N.vertices[B*8+7]=L+$.height*i,N.uvs[B*8+0]=O.x0,N.uvs[B*8+1]=O.y0,N.uvs[B*8+2]=O.x1,N.uvs[B*8+3]=O.y1,N.uvs[B*8+4]=O.x2,N.uvs[B*8+5]=O.y2,N.uvs[B*8+6]=O.x3,N.uvs[B*8+7]=O.y3}this._textWidth=p*i,this._textHeight=(n.y+t.lineHeight)*i;for(const P in I){const T=I[P];if(this.anchor.x!==0||this.anchor.y!==0){let D=0;const N=this._textWidth*this.anchor.x,$=this._textHeight*this.anchor.y;for(let O=0;O<T.total;O++)T.vertices[D++]-=N,T.vertices[D++]-=$,T.vertices[D++]-=N,T.vertices[D++]-=$,T.vertices[D++]-=N,T.vertices[D++]-=$,T.vertices[D++]-=N,T.vertices[D++]-=$}this._maxLineHeight=m*i;const E=T.mesh.geometry.getBuffer("aVertexPosition"),A=T.mesh.geometry.getBuffer("aTextureCoord"),L=T.mesh.geometry.getIndex();E.data=T.vertices,A.data=T.uvs,L.data=T.indices,E.update(),A.update(),L.update()}for(let P=0;P<s.length;P++)Tm.push(s[P]);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:n}=Wr.available[this._fontName];if(i!=="none"){const{a:s,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(s*s+o*o),c=Math.sqrt(a*a+l*l),u=(Math.abs(h)+Math.abs(c))/2,d=this.fontSize/n,f=t._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=u*e*d*f}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=Wr.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(!Wr.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??Wr.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=Wr.available[this._fontName].distanceFieldType==="none"?wm:Em;i.push(...this._activePagesMeshData);for(const n of this._activePagesMeshData)this.removeChild(n.mesh);this._activePagesMeshData=[],i.filter(n=>e[n.mesh.texture.baseTexture.uid]).forEach(n=>{n.mesh.texture=ct.EMPTY});for(const n in e)e[n].destroy(),delete e[n];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};XS.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const VS=[".xml",".fnt"],zS={extension:{type:Z.LoadParser,priority:qe.Normal},name:"loadBitmapFont",test(r){return VS.includes(ue.extname(r).toLowerCase())},async testParse(r){return Do.test(r)||Ch.test(r)},async parse(r,t,e){const i=Do.test(r)?Do.parse(r):Ch.parse(r),{src:n}=t,{page:s}=i,o=[];for(let h=0;h<s.length;++h){const c=s[h].file;let u=ue.join(ue.dirname(n),c);u=ch(u,n),o.push(u)}const a=await e.load(o),l=o.map(h=>a[h]);return Wr.install(i,l,!0)},async load(r,t){return(await tt.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};ht.add(zS);const Ph=class mn extends zr{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new mn(Object.keys(mn.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 mn.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=mn;if(i[t]){const n=i[t];return this._fonts.push(n),n.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return tt.ADAPTER.fetch(t).then(n=>n.blob()).then(async n=>new Promise((s,o)=>{const a=URL.createObjectURL(n),l=new FileReader;l.onload=()=>s([a,l.result]),l.onerror=o,l.readAsDataURL(n)})).then(async([n,s])=>{const o=Object.assign({family:ue.basename(t,ue.extname(t)),weight:"normal",style:"normal",display:"auto",src:n,dataSrc:s,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 Em=[],Tm=[],Am=[],VS=class Qm extends We{constructor(t,e={}){super();const{align:i,tint:n,maxWidth:s,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},Qm.styleDefaults,e);if(!qr.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new Mt(n),this._font=void 0,this._fontName=a,this._fontSize=l,this.text=t,this._maxWidth=s,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new Er(()=>{this.dirty=!0},this,0,0),this._roundPixels=tt.ROUND_PIXELS,this.dirty=!0,this._resolution=tt.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var U;const t=qr.available[this._fontName],e=this.fontSize,i=e/t.size,n=new It,s=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,`
1138
+ `)||" ",h=wm(l),c=this._maxWidth*t.size/e,u=t.distanceFieldType==="none"?Em:Tm;let d=null,f=0,p=0,g=0,y=-1,_=0,v=0,m=0,b=0;for(let P=0;P<h.length;P++){const T=h[P],E=Oo(T);if(/(?:\s)/.test(T)&&(y=P,_=f,b++),T==="\r"||T===`
1139
+ `){o.push(f),a.push(-1),p=Math.max(p,f),++g,++v,n.x=0,n.y+=t.lineHeight,d=null,b=0;continue}const A=t.chars[E];if(!A)continue;d&&A.kerning[d]&&(n.x+=A.kerning[d]);const L=Am.pop()||{texture:ct.EMPTY,line:0,charCode:0,prevSpaces:0,position:new It};L.texture=A.texture,L.line=g,L.charCode=E,L.position.x=Math.round(n.x+A.xOffset+this._letterSpacing/2),L.position.y=Math.round(n.y+A.yOffset),L.prevSpaces=b,s.push(L),f=L.position.x+Math.max(A.xAdvance-A.xOffset,A.texture.orig.width),n.x+=A.xAdvance+this._letterSpacing,m=Math.max(m,A.yOffset+A.texture.height),d=E,y!==-1&&c>0&&n.x>c&&(++v,Ji(s,1+y-v,1+P-y),P=y,y=-1,o.push(_),a.push(s.length>0?s[s.length-1].prevSpaces:0),p=Math.max(p,_),g++,n.x=0,n.y+=t.lineHeight,d=null,b=0)}const S=h[h.length-1];S!=="\r"&&S!==`
1140
+ `&&(/(?:\s)/.test(S)&&(f=_),o.push(f),p=Math.max(p,f),a.push(-1));const R=[];for(let P=0;P<=g;P++){let T=0;this._align==="right"?T=p-o[P]:this._align==="center"?T=(p-o[P])/2:this._align==="justify"&&(T=a[P]<0?0:(p-o[P])/a[P]),R.push(T)}const C=s.length,I={},M=[],F=this._activePagesMeshData;u.push(...F);for(let P=0;P<C;P++){const T=s[P].texture,E=T.baseTexture.uid;if(!I[E]){let A=u.pop();if(!A){const D=new pS;let N,$;t.distanceFieldType==="none"?(N=new lm(ct.EMPTY),$=vt.NORMAL):(N=new lm(ct.EMPTY,{program:Tr.from(XS,HS),uniforms:{uFWidth:0}}),$=vt.NORMAL_NPM);const O=new am(D,N);O.blendMode=$,A={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:O,vertices:null,uvs:null,indices:null}}A.index=0,A.indexCount=0,A.vertexCount=0,A.uvsCount=0,A.total=0;const{_textureCache:L}=this;L[E]=L[E]||new ct(T.baseTexture),A.mesh.texture=L[E],A.mesh.tint=this._tintColor.value,M.push(A),I[E]=A}I[E].total++}for(let P=0;P<F.length;P++)M.includes(F[P])||this.removeChild(F[P].mesh);for(let P=0;P<M.length;P++)M[P].mesh.parent!==this&&this.addChild(M[P].mesh);this._activePagesMeshData=M;for(const P in I){const T=I[P],E=T.total;if(!(((U=T.indices)==null?void 0:U.length)>6*E)||T.vertices.length<am.BATCHABLE_SIZE*2)T.vertices=new Float32Array(4*2*E),T.uvs=new Float32Array(4*2*E),T.indices=new Uint16Array(6*E);else{const A=T.total,L=T.vertices;for(let D=A*4*2;D<L.length;D++)L[D]=0}T.mesh.size=6*E}for(let P=0;P<C;P++){const T=s[P];let E=T.position.x+R[T.line]*(this._align==="justify"?T.prevSpaces:1);this._roundPixels&&(E=Math.round(E));const A=E*i,L=T.position.y*i,D=T.texture,N=I[D.baseTexture.uid],$=D.frame,O=D._uvs,B=N.index++;N.indices[B*6+0]=0+B*4,N.indices[B*6+1]=1+B*4,N.indices[B*6+2]=2+B*4,N.indices[B*6+3]=0+B*4,N.indices[B*6+4]=2+B*4,N.indices[B*6+5]=3+B*4,N.vertices[B*8+0]=A,N.vertices[B*8+1]=L,N.vertices[B*8+2]=A+$.width*i,N.vertices[B*8+3]=L,N.vertices[B*8+4]=A+$.width*i,N.vertices[B*8+5]=L+$.height*i,N.vertices[B*8+6]=A,N.vertices[B*8+7]=L+$.height*i,N.uvs[B*8+0]=O.x0,N.uvs[B*8+1]=O.y0,N.uvs[B*8+2]=O.x1,N.uvs[B*8+3]=O.y1,N.uvs[B*8+4]=O.x2,N.uvs[B*8+5]=O.y2,N.uvs[B*8+6]=O.x3,N.uvs[B*8+7]=O.y3}this._textWidth=p*i,this._textHeight=(n.y+t.lineHeight)*i;for(const P in I){const T=I[P];if(this.anchor.x!==0||this.anchor.y!==0){let D=0;const N=this._textWidth*this.anchor.x,$=this._textHeight*this.anchor.y;for(let O=0;O<T.total;O++)T.vertices[D++]-=N,T.vertices[D++]-=$,T.vertices[D++]-=N,T.vertices[D++]-=$,T.vertices[D++]-=N,T.vertices[D++]-=$,T.vertices[D++]-=N,T.vertices[D++]-=$}this._maxLineHeight=m*i;const E=T.mesh.geometry.getBuffer("aVertexPosition"),A=T.mesh.geometry.getBuffer("aTextureCoord"),L=T.mesh.geometry.getIndex();E.data=T.vertices,A.data=T.uvs,L.data=T.indices,E.update(),A.update(),L.update()}for(let P=0;P<s.length;P++)Am.push(s[P]);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:n}=qr.available[this._fontName];if(i!=="none"){const{a:s,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(s*s+o*o),c=Math.sqrt(a*a+l*l),u=(Math.abs(h)+Math.abs(c))/2,d=this.fontSize/n,f=t._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=u*e*d*f}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=qr.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(!qr.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??qr.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=qr.available[this._fontName].distanceFieldType==="none"?Em:Tm;i.push(...this._activePagesMeshData);for(const n of this._activePagesMeshData)this.removeChild(n.mesh);this._activePagesMeshData=[],i.filter(n=>e[n.mesh.texture.baseTexture.uid]).forEach(n=>{n.mesh.texture=ct.EMPTY});for(const n in e)e[n].destroy(),delete e[n];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};VS.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const zS=[".xml",".fnt"],jS={extension:{type:Z.LoadParser,priority:Ke.Normal},name:"loadBitmapFont",test(r){return zS.includes(ue.extname(r).toLowerCase())},async testParse(r){return Bo.test(r)||Ih.test(r)},async parse(r,t,e){const i=Bo.test(r)?Bo.parse(r):Ih.parse(r),{src:n}=t,{page:s}=i,o=[];for(let h=0;h<s.length;++h){const c=s[h].file;let u=ue.join(ue.dirname(n),c);u=uh(u,n),o.push(u)}const a=await e.load(o),l=o.map(h=>a[h]);return qr.install(i,l,!0)},async load(r,t){return(await tt.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};ht.add(jS);const Rh=class gn extends Wr{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new gn(Object.keys(gn.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 gn.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=gn;if(i[t]){const n=i[t];return this._fonts.push(n),n.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return tt.ADAPTER.fetch(t).then(n=>n.blob()).then(async n=>new Promise((s,o)=>{const a=URL.createObjectURL(n),l=new FileReader;l.onload=()=>s([a,l.result]),l.onerror=o,l.readAsDataURL(n)})).then(async([n,s])=>{const o=Object.assign({family:ue.basename(t,ue.extname(t)),weight:"normal",style:"normal",display:"auto",src:n,dataSrc:s,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}
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=Ow(t)),typeof t=="number"?Bw(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),n=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const s=`${i}px ${n}px`;return this.dropShadowBlur>0?`text-shadow: ${s} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${s} ${t}`}reset(){Object.assign(this,mn.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}=tt.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}};Ph.availableFonts={},Ph.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 Rh=Ph;const Oo=class gn extends rn{constructor(t="",e={}){super(ct.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,n=ct.from(i,{scaleMode:tt.SCALE_MODE,resourceOptions:{autoLoad:!1}});n.orig=new wt,n.trim=new wt,this.texture=n;const s="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(s,"svg"),l=document.createElementNS(s,"foreignObject"),h=document.createElementNS(o,"div"),c=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=gn.defaultMaxWidth,this.maxHeight=gn.defaultMaxHeight,this._domElement=h,this._styleElement=c,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(c),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=gn.defaultAutoResolution,this._resolution=gn.defaultResolution??tt.RESOLUTION,this.text=t,this.style=e}measureText(t){var c,u;const{text:e,style:i,resolution:n}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(n)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const s=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=s;(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:(c=this._style)==null?void 0:c.toCSS(n)}),this._styleElement.textContent=(u=this._style)==null?void 0:u.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:n}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:s,height:o}=this.measureText();i.width=n.width=Math.ceil(Math.max(1,s)),i.height=n.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{n.onload=async()=>{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.src=n.src,n.onload=null,n.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);n.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:n}=this,{padding:s}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/n,e.trim.height=e._frame.height=i.height/n,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(),o.setRealSize(i.width,i.height,n),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,n,s,o,a;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},gn.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(n=this._svgRoot)==null||n.remove(),this._svgRoot=e,(s=this._domElement)==null||s.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=kr(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=kr(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 Rh?(this.ownsStyle=!1,this._style=t):t instanceof zr?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Rh.from(t)):(this.ownsStyle=!0,this._style=new Rh(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;")}};Oo.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Oo.defaultMaxWidth=2024,Oo.defaultMaxHeight=2024,Oo.defaultAutoResolution=!0;const jS=16777215,WS=.25,YS=16777215,qS=1,KS=1.5;let Yr=!1,un;const Mh=r=>{const t={tint:r!=null&&r.fill?new Mt(r.fill).toNumber():jS,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 Mt(r==null?void 0:r.fill).alpha:WS},e={tint:r!=null&&r.stroke?new Mt(r.stroke).toNumber():YS,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 Mt(r==null?void 0:r.stroke).alpha:qS,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?KS:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},dn=r=>(t,e,i,n={})=>{const{fillStyle:s,strokeStyle:o}=Mh(i),a=new Qn;n.strokeOnly||(a.beginFill(16777215),r(e,a),a.endFill(),a.tint=s.tint,a.alpha=s.alpha),t.addChild(a);const l=new Qn,h=o.lineWidth===1?1:o.lineWidth/un;return l.lineStyle(h,16777215,1,.5,o.lineWidth===1),r(e,l),l.tint=o.tint||16777215,l.alpha=o.alpha,t.addChild(l),{fill:a,stroke:l,strokeWidth:o.lineWidth}},ZS=dn((r,t)=>{const{x:e,y:i,w:n,h:s}=r.geometry;t.drawRect(e,i,n,s)}),JS=dn((r,t)=>{const{cx:e,cy:i,rx:n,ry:s}=r.geometry;t.drawEllipse(e,i,n,s)}),QS=dn((r,t)=>{const[[e,i],[n,s]]=r.geometry.points;t.moveTo(e,i),t.lineTo(n,s),t.closePath()}),t2=dn((r,t)=>{const e=r.geometry.points.reduce((i,n)=>[...i,...n],[]);t.drawPolygon(e)}),e2=dn((r,t)=>{const{points:e,closed:i}=r.geometry;if(e.length===0)return;i||t.beginFill(0,0);const n=(o,a)=>{const[l,h]=o.point,[c,u]=a.point;if(o.type==="CURVE"||a.type==="CURVE"){const d=o.type==="CURVE"&&o.outHandle?o.outHandle[0]:l,f=o.type==="CURVE"&&o.outHandle?o.outHandle[1]:h,p=a.type==="CURVE"&&a.inHandle?a.inHandle[0]:c,g=a.type==="CURVE"&&a.inHandle?a.inHandle[1]:u;t.bezierCurveTo(d,f,p,g,c,u)}else t.lineTo(c,u)},s=e[0];t.moveTo(s.point[0],s.point[1]);for(let o=1;o<e.length;o++){const a=e[o-1],l=e[o];n(a,l)}if(i&&e.length>2){const o=e[e.length-1],a=e[0];n(o,a),t.closePath()}else t.endFill()}),r2=dn((r,t)=>{const e=i=>i.points.reduce((n,s)=>[...n,...s],[]);r.geometry.polygons.forEach(i=>{const[n,...s]=i.rings;t.drawPolygon(e(n)),s.forEach(o=>{t.beginHole(),t.drawPolygon(e(o)),t.endHole()})})}),Am=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},Sm=(r,t,e,i)=>()=>{const n=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),s=Am(r);(s!==un||!Yr)&&(Yr=!0,e.forEach(({stroke:d,strokeWidth:f})=>{const{lineStyle:p}=d.geometry.graphicsData[0];f>1?(Yr=s===un,p.width=f/s,p.native=!1,d.geometry.invalidate()):f===1&&!p.native&&(p.width=1,p.native=!0,d.geometry.invalidate())})),un=s;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+n.x*s:-n.x*s,h=-n.y*s;let c,u;a>0&&a<=Math.PI/2?(c=n.height*s,u=0):a>Math.PI/2&&a<=Math.PI?(c=n.width*s,u=n.height*s):a>Math.PI&&a<=Math.PI*1.5?(c=0,u=n.width*s):(c=0,u=0),t.position.x=c+l*Math.cos(a)-h*Math.sin(a),t.position.y=u+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-s:s,s),t.rotation=a,i.render(t)},i2=(r,t)=>{const e=new Qn,i=wp({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),n=new Map;let s=new Set,o,a;un=Am(r);const l=(m,b)=>{Yr=!1;const S=n.get(m.id);S&&(S.fill.destroy(),S.stroke.destroy());const{selector:R}=m.target,C=typeof a=="function"?a(m,b):a;let I;if(R.type===_t.RECTANGLE)I=ZS(e,R,C);else if(R.type===_t.POLYGON)I=t2(e,R,C);else if(R.type===_t.ELLIPSE)I=JS(e,R,C);else if(R.type===_t.MULTIPOLYGON)I=r2(e,R,C);else if(R.type===_t.POLYLINE){const M=R;I=e2(e,M,C,{strokeOnly:!M.geometry.closed})}else R.type===_t.LINE?I=QS(e,R,C):console.warn(`Unsupported shape type: ${R.type}`);I&&n.set(m.id,{annotation:m,...I})},h=m=>{const b=n.get(m.id);b&&(n.delete(m.id),b.fill.destroy(),b.stroke.destroy())},c=(m,b,S)=>{Yr=!1;const R=n.get(m.id);if(R&&(n.delete(m.id),R.fill.destroy(),R.stroke.destroy(),l(b,S),s.has(b.id))){const{fill:C,stroke:I}=n.get(b.id);e.removeChild(C),e.removeChild(I)}},u=(m,b)=>{const S=n.get(m);S&&(n.delete(m),S.fill.destroy(),S.stroke.destroy(),l(S.annotation,b))},d=(m,b)=>{i.resize(m,b),i.render(e)},f=m=>{Yr=!1;const{children:b}=e;n.forEach(({fill:S,stroke:R,annotation:C})=>{const I=m?s.has(C.id)||m(C):!0;I&&!b.includes(S)?(e.addChild(S),e.addChild(R)):!I&&b.includes(S)&&(e.removeChild(S),e.removeChild(R))}),i.render(e)},p=m=>{const b=new Set(m.selected.map(C=>C.id)),S=m.selected.filter(({id:C})=>!s.has(C)),R=[...s].filter(C=>!b.has(C));S.forEach(({id:C,editable:I})=>{if(I){const M=n.get(C);M&&da(M.annotation.target.selector)&&(e.removeChild(M.fill),e.removeChild(M.stroke))}else u(C,{selected:!0,hovered:C===o})}),R.forEach(C=>u(C,{hovered:C===o})),s=b,i.render(e)},g=m=>{o!==m&&(m&&s.has(m)||(o&&!s.has(o)&&u(o,{selected:s.has(o)}),m&&u(m,{selected:s.has(m),hovered:!0}),o=m,i.render(e)))},y=m=>{if(typeof m=="function")n.forEach(({annotation:b,fill:S,stroke:R,strokeWidth:C},I)=>{C>1&&(Yr=!1);const M={selected:s.has(b.id),hovered:o===b.id},{fillStyle:F,strokeStyle:U}=Mh(m(b,M));S.tint=F.tint,S.alpha=F.alpha,R.tint=U.tint||16777215,R.alpha=U.alpha,n.set(b.id,{annotation:b,fill:S,stroke:R,strokeWidth:U.lineWidth})});else{const{fillStyle:b,strokeStyle:S}=Mh(m);S.lineWidth>1&&(Yr=!1),n.forEach(({annotation:R,fill:C,stroke:I,strokeWidth:M},F)=>{C.tint=b.tint,C.alpha=b.alpha,I.tint=S.tint||16777215,I.alpha=S.alpha,n.set(R.id,{annotation:R,fill:C,stroke:I,strokeWidth:S.lineWidth})})}a=m,i.render(e),Sm(r,e,n,i)()},_=m=>{m?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),getScale:()=>un,redraw:Sm(r,e,n,i),removeAnnotation:h,resize:d,setFilter:f,setHovered:g,setSelected:p,setStyle:y,setVisible:_,updateAnnotation:c}};function n2(r,t,e){let i,n,{filter:s}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:c,hover:u,selection:d,viewport:f}=o;Tn(r,u,I=>e(11,i=I)),Tn(r,d,I=>e(8,n=I));const p=Bi(),g=Ne?10:2;let y,_;const v=I=>{const M=new se.Point(I.x,I.y),{x:F,y:U}=l.viewport.pointFromPixel(M);return l.viewport.viewportToImageCoordinates(F,U)},m=()=>g/y.getScale(),b=I=>{const{x:M,y:F}=I.position;_={x:M,y:F}},S=I=>M=>{const{x:F,y:U}=v(new se.Point(M.offsetX,M.offsetY)),P=m(),T=c.getAt(F,U,s,P);T?(I.classList.add("hover"),i!==T.id&&(u.set(T.id),y.setHovered(T.id))):(I.classList.remove("hover"),i&&(u.set(void 0),y.setHovered(void 0)))},R=I=>{if(!_)return;const M=I.originalEvent,{x:F,y:U}=I.position,P=F-_.x,T=U-_.y;if(Math.sqrt(P*P+T*T)<5){const{x:A,y:L}=v(I.position),D=m(),N=c.getAt(A,L,s,D);N?p("click",{originalEvent:M,annotation:N}):p("click",{originalEvent:M})}_=void 0};let C;return ei(()=>{var N;const{offsetWidth:I,offsetHeight:M}=l.canvas,F=document.createElement("canvas");F.width=I,F.height=M,F.className="a9s-gl-canvas",(N=l.element.querySelector(".openseadragon-canvas"))==null||N.appendChild(F),e(7,y=i2(l,F));const U=S(F);F.addEventListener("pointermove",U);const P=new ResizeObserver($=>{try{const{width:O,height:B}=$[0].contentRect;F.width=O,F.height=B,y.resize(O,B)}catch{console.warn("WebGL canvas already disposed")}});P.observe(F);const T=()=>{const $=l.viewport.getBounds();C=l.viewport.viewportToImageRectangle($);const{x:O,y:B,width:k,height:V}=C,z=c.getIntersecting(O,B,k,V);f.set(z.map(K=>K.id))};l.addHandler("canvas-press",b),l.addHandler("canvas-release",R),l.addHandler("update-viewport",y.redraw),l.addHandler("animation-finish",T);const E=$=>$.filter(O=>Le(O)),A=$=>Le($.oldValue)&&Le($.newValue),L=$=>{const{selector:O}=$.target;if(O.type===_t.POLYGON){const B=iv(O);return{...$,target:{...$.target,selector:{...B}}}}else if(O.type===_t.MULTIPOLYGON){const B=ev(O);return{...$,target:{...$.target,selector:{...B}}}}else return $},D=$=>{const{created:O,updated:B,deleted:k}=$.changes,V=(O||[]).filter(z=>Le(z)).map(L);if(E(k||[]).forEach(z=>y.removeAnnotation(z)),V.forEach(z=>y.addAnnotation(z)),(B||[]).filter(z=>A(z)).map(({oldValue:z,newValue:K})=>({oldValue:z,newValue:L(K)})).forEach(({oldValue:z,newValue:K})=>y.updateAnnotation(z,K)),C){const{x:z,y:K,width:X,height:ft}=C,H=c.getIntersecting(z,K,X,ft);f.set(H.map(mt=>mt.id))}else f.set(c.all().map(z=>z.id));y.redraw()};return c.observe(D),()=>{var $;F.removeEventListener("pointermove",U),P.disconnect(),l.removeHandler("canvas-press",b),l.removeHandler("canvas-release",R),l.removeHandler("update-viewport",y.redraw),l.removeHandler("animation-finish",T),c.unobserve(D),y.destroy(),($=F.parentNode)==null||$.removeChild(F)}}),r.$$set=I=>{"filter"in I&&e(2,s=I.filter),"state"in I&&e(3,o=I.state),"style"in I&&e(4,a=I.style),"viewer"in I&&e(5,l=I.viewer),"visible"in I&&e(6,h=I.visible)},r.$$.update=()=>{r.$$.dirty&132&&(y==null||y.setFilter(s)),r.$$.dirty&384&&(y==null||y.setSelected(n)),r.$$.dirty&144&&(y==null||y.setStyle(a)),r.$$.dirty&192&&(y==null||y.setVisible(h))},[u,d,s,o,a,l,h,y,n]}class s2 extends jt{constructor(t){super(),zt(this,t,n2,null,Ut,{filter:2,state:3,style:4,viewer:5,visible:6})}}const Cm=(r,t,e,i)=>{if(!i)return r;if(t.shiftKey||t.ctrlKey||t.metaKey){const s=(e.selected||[]).map(o=>o.id);return s.includes(r)?s.filter(o=>o!==r):[...s,r]}else return r},o2=r=>({transform:r&2,scale:r&1}),Im=r=>({transform:r[1],scale:r[0]});function a2(r){let t;const e=r[4].default,i=lu(e,r,r[3],Im);return{c(){i&&i.c()},m(n,s){i&&i.m(n,s),t=!0},p(n,[s]){i&&i.p&&(!t||s&11)&&uu(i,e,n,n[3],t?cu(e,n[3],s,o2):du(n[3]),Im)},i(n){t||(q(i,n),t=!0)},o(n){at(i,n),t=!1},d(n){i&&i.d(n)}}}function l2(r,t,e){let{$$slots:i={},$$scope:n}=t,{viewer:s}=t,o=1,a;const l=()=>{const h=s.viewport.getContainerSize().x,c=s.viewport.getZoom(!0),u=s.viewport.getFlip(),d=s.viewport.pixelFromPoint(new se.Point(0,0),!0);u&&(d.x=h-d.x);const f=c*h/s.world.getContentFactor(),p=u?-f:f,g=s.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${p}, ${f}) rotate(${g})`),e(0,o=c*h/s.world.getContentFactor())};return ei(()=>(s.addHandler("update-viewport",l),()=>{s.removeHandler("update-viewport",l)})),r.$$set=h=>{"viewer"in h&&e(2,s=h.viewer),"$$scope"in h&&e(3,n=h.$$scope)},[o,a,s,n,i]}class Dh extends jt{constructor(t){super(),zt(this,t,l2,a2,Ut,{viewer:2})}}function h2(r,t,e){const i=Bi();let{drawingMode:n}=t,{opts:s}=t,{target:o}=t,{tool:a}=t,{transform:l}=t,{viewer:h}=t,{viewportScale:c}=t,u;return ei(()=>{const d=o.closest("svg"),f=[],p=(g,y,_)=>{if(d==null||d.addEventListener(g,y,_),f.push(()=>d==null?void 0:d.removeEventListener(g,y,_)),g==="pointerup"||g==="dblclick"){const v=b=>{const{originalEvent:S}=b;y(S)},m=g==="pointerup"?"canvas-click":"canvas-double-click";h.addHandler(m,v),f.push(()=>h.removeHandler(m,v))}else if(g==="pointermove"){const v=m=>{const{originalEvent:b}=m;y(b)};h.addHandler("canvas-drag",v),f.push(()=>h.removeHandler("canvas-drag",v))}};return e(7,u=new a({target:o,props:{addEventListener:p,drawingMode:n,opts:s,transform:l,viewportScale:c,svgEl:d}})),u.$on("create",g=>i("create",g.detail)),()=>{f.forEach(g=>g()),u.$destroy()}}),r.$$set=d=>{"drawingMode"in d&&e(0,n=d.drawingMode),"opts"in d&&e(1,s=d.opts),"target"in d&&e(2,o=d.target),"tool"in d&&e(3,a=d.tool),"transform"in d&&e(4,l=d.transform),"viewer"in d&&e(5,h=d.viewer),"viewportScale"in d&&e(6,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&144&&u&&u.$set({transform:l}),r.$$.dirty&192&&u&&u.$set({viewportScale:c})},[n,s,o,a,l,h,c,u]}class c2 extends jt{constructor(t){super(),zt(this,t,h2,null,Ut,{drawingMode:0,opts:1,target:2,tool:3,transform:4,viewer:5,viewportScale:6})}}const{Boolean:u2}=va;function Pm(r,t,e){const i=r.slice();i[41]=t[e];const n=i[19](i[41].target.selector);return i[42]=n,i}function d2(r){let t=`${r[2]}-${r[7]}`,e,i,n=Rm(r);return{c(){n.c(),e=Pe()},m(s,o){n.m(s,o),ot(s,e,o),i=!0},p(s,o){o[0]&132&&Ut(t,t=`${s[2]}-${s[7]}`)?(le(),at(n,1,1,Ft),he(),n=Rm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(q(n),i=!0)},o(s){at(n),i=!1},d(s){s&&st(e),n.d(s)}}}function f2(r){let t,e,i=xe(r[9].filter(r[29])),n=[];for(let o=0;o<i.length;o+=1)n[o]=Bm(Pm(r,i,o));const s=o=>at(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=Pe()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);ot(o,t,a),e=!0},p(o,a){if(a[0]&713474|a[1]&512){i=xe(o[9].filter(o[29]));let l;for(l=0;l<i.length;l+=1){const h=Pm(o,i,l);n[l]?(n[l].p(h,a),q(n[l],1)):(n[l]=Bm(h),n[l].c(),q(n[l],1),n[l].m(t.parentNode,t))}for(le(),l=i.length;l<n.length;l+=1)s(l);he()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(n[a]);e=!0}},o(o){n=n.filter(u2);for(let a=0;a<n.length;a+=1)at(n[a]);e=!1},d(o){o&&st(t),Dr(n,o)}}}function Rm(r){let t,e;return t=new c2({props:{target:r[8],tool:r[10],drawingMode:r[4],transform:{elementToImage:r[13]},viewer:r[3],viewportScale:r[40],opts:r[5]}}),t.$on("create",r[18]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n[0]&256&&(s.target=i[8]),n[0]&1024&&(s.tool=i[10]),n[0]&16&&(s.drawingMode=i[4]),n[0]&8&&(s.viewer=i[3]),n[1]&512&&(s.viewportScale=i[40]),n[0]&32&&(s.opts=i[5]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Mm(r){let t=r[41].id,e,i,n=Dm(r);return{c(){n.c(),e=Pe()},m(s,o){n.m(s,o),ot(s,e,o),i=!0},p(s,o){o[0]&512&&Ut(t,t=s[41].id)?(le(),at(n,1,1,Ft),he(),n=Dm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(q(n),i=!0)},o(s){at(n),i=!1},d(s){s&&st(e),n.d(s)}}}function Dm(r){let t,e;return t=new Vv({props:{target:r[8],editor:r[19](r[41].target.selector),annotation:r[41],style:r[1],transform:{elementToImage:r[13]},viewportScale:r[40]}}),t.$on("grab",r[14]),t.$on("change",function(){Zt(r[17](r[41]))&&r[17](r[41]).apply(this,arguments)}),t.$on("release",r[15]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&256&&(s.target=r[8]),n[0]&512&&(s.editor=r[19](r[41].target.selector)),n[0]&512&&(s.annotation=r[41]),n[0]&2&&(s.style=r[1]),n[1]&512&&(s.viewportScale=r[40]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Bm(r){let t,e,i=r[42]&&Mm(r);return{c(){i&&i.c(),t=Pe()},m(n,s){i&&i.m(n,s),ot(n,t,s),e=!0},p(n,s){n[42]?i?(i.p(n,s),s[0]&512&&q(i,1)):(i=Mm(n),i.c(),q(i,1),i.m(t.parentNode,t)):i&&(le(),at(i,1,1,()=>{i=null}),he())},i(n){e||(q(i),e=!0)},o(n){at(i),e=!1},d(n){n&&st(t),i&&i.d(n)}}}function p2(r){let t,e,i,n,s,o,a,l;const h=[f2,d2],c=[];function u(d,f){var p;return d[8]&&((p=d[9])==null?void 0:p.length)===1?0:d[8]&&d[10]&&d[0]?1:-1}return~(i=u(r))&&(n=c[i]=h[i](r)),{c(){t=it("svg"),e=it("g"),n&&n.c(),w(e,"transform",s=r[39]),w(e,"class","svelte-g4ws1v"),w(t,"tabindex",0),w(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-g4ws1v"),Br(t,"drawing",r[0]),Br(t,"editing",r[9]),Br(t,"hover",r[6])},m(d,f){ot(d,t,f),Ct(t,e),~i&&c[i].m(e,null),r[30](e),o=!0,a||(l=Pt(t,"pointermove",r[16]),a=!0)},p(d,f){let p=i;i=u(d),i===p?~i&&c[i].p(d,f):(n&&(le(),at(c[p],1,1,()=>{c[p]=null}),he()),~i?(n=c[i],n?n.p(d,f):(n=c[i]=h[i](d),n.c()),q(n,1),n.m(e,null)):n=null),(!o||f[1]&256&&s!==(s=d[39]))&&w(e,"transform",s),(!o||f[0]&1)&&Br(t,"drawing",d[0]),(!o||f[0]&512)&&Br(t,"editing",d[9]),(!o||f[0]&64)&&Br(t,"hover",d[6])},i(d){o||(q(n),o=!0)},o(d){at(n),o=!1},d(d){d&&st(t),~i&&c[i].d(),r[30](null),a=!1,l()}}}function m2(r){let t,e;return t=new Dh({props:{viewer:r[3],$$slots:{default:[p2,({transform:i,scale:n})=>({39:i,40:n}),({transform:i,scale:n})=>[0,(i?256:0)|(n?512:0)]]},$$scope:{ctx:r}}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n[0]&8&&(s.viewer=i[3]),n[0]&2047|n[1]&17152&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function g2(r,t,e){let i,n,s,o,a,{drawingEnabled:l}=t,{filter:h}=t,{multiSelect:c}=t,{preferredDrawingMode:u}=t,{state:d}=t,{style:f=void 0}=t,{toolName:p=gs()[0]}=t,{user:g}=t,{viewer:y}=t;const _=Ne?10:2;let v=!1,m=0;const b=()=>e(7,m+=1),S=()=>p,R=()=>l;let C;const{store:I,selection:M,hover:F}=d;Tn(r,M,X=>e(28,o=X)),Tn(r,F,X=>e(33,a=X));let U,P,T;const E=X=>{I.unobserve(U);const ft=X.filter(({editable:H})=>H).map(({id:H})=>H);ft.length>0?(e(9,P=ft.map(H=>I.getAnnotation(H))),U=H=>{const{updated:mt}=H.changes;e(9,P=(mt||[]).map(J=>J.newValue))},I.observe(U,{annotations:ft}),y.forceRedraw()):e(9,P=void 0)},A=(X,ft)=>{const{x:H,y:mt}=y.viewport.viewerElementToImageCoordinates(new se.Point(X,ft));return[H,mt]},L=()=>{const X=y.viewport.getContainerSize().x;return y.viewport.getZoom(!0)*X/y.world.getContentFactor()},D=()=>_/L(),N=X=>{y.setMouseNavEnabled(!1),T=X.timeStamp},$=X=>{if(y.setMouseNavEnabled(!0),performance.now()-(T||0)<300){const{offsetX:H,offsetY:mt}=X.detail,[J,ut]=A(H,mt),gt=D(),Et=I.getAt(J,ut,void 0,gt);if(Et&&(!h||h(Et))&&!P.find(Yt=>Yt.id===Et.id)){F.set(Et.id);const Yt=Cm(Et.id,X.detail,M,c);M.userSelect(Yt)}}},O=X=>{const ft=new se.Point(X.offsetX,X.offsetY),H=y.viewport.pointFromPixel(ft),{x:mt,y:J}=y.viewport.viewportToImageCoordinates(H.x,H.y),ut=D(),gt=I.getAt(mt,J,h,ut);gt?a!==gt.id&&F.set(gt.id):a&&F.set(void 0)},B=X=>ft=>{var ut;const{target:H}=X,mt=10*60*1e3,J=((ut=H.creator)==null?void 0:ut.id)!==g.id||!H.created||new Date().getTime()-H.created.getTime()>mt;I.updateTarget({...H,selector:ft.detail,created:J?H.created:new Date,updated:J?new Date:void 0,updatedBy:J?g:void 0})},k=X=>{const ft=uv(),H={id:ft,bodies:[],target:{annotation:ft,selector:X.detail,creator:g,created:new Date}};I.addAnnotation(H),M.setSelected(H.id),y.setMouseNavEnabled(!0)},V=X=>da(X);ei(()=>{const X=ft=>{if(o.selected.length===0)return;const{offsetX:H,offsetY:mt}=ft,J=y.viewport.pointFromPixel(new se.Point(H,mt)),{x:ut,y:gt}=y.viewport.viewportToImageCoordinates(J.x,J.y),Et=D();e(6,v=!!I.getAt(ut,gt,h,Et))};return y.element.addEventListener("pointermove",X),()=>{var ft;(ft=y.element)==null||ft.removeEventListener("pointermove",X)}});const z=X=>Le(X);function K(X){bs[X?"unshift":"push"](()=>{C=X,e(8,C)})}return r.$$set=X=>{"drawingEnabled"in X&&e(0,l=X.drawingEnabled),"filter"in X&&e(20,h=X.filter),"multiSelect"in X&&e(21,c=X.multiSelect),"preferredDrawingMode"in X&&e(22,u=X.preferredDrawingMode),"state"in X&&e(23,d=X.state),"style"in X&&e(1,f=X.style),"toolName"in X&&e(2,p=X.toolName),"user"in X&&e(24,g=X.user),"viewer"in X&&e(3,y=X.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(10,{tool:i,opts:n}=ys(p)||{tool:void 0,opts:void 0},i,(e(5,n),e(2,p))),r.$$.dirty[0]&4194336&&e(4,s=(n==null?void 0:n.drawingMode)||u),r.$$.dirty[0]&25&&(l&&s==="drag"?y.setMouseNavEnabled(!1):y.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&l&&M.clear(),r.$$.dirty[0]&268435481&&o.selected.length===0&&s==="drag"&&l&&y.setMouseNavEnabled(!1),r.$$.dirty[0]&268435456&&E(o.selected)},[l,f,p,y,s,n,v,m,C,P,i,M,F,A,N,$,O,B,k,V,h,c,u,d,g,b,S,R,o,z,K]}class y2 extends jt{constructor(t){super(),zt(this,t,g2,m2,Ut,{drawingEnabled:0,filter:20,multiSelect:21,preferredDrawingMode:22,state:23,style:1,toolName:2,user:24,viewer:3,cancelDrawing:25,getDrawingTool:26,isDrawingEnabled:27},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[25]}get getDrawingTool(){return this.$$.ctx[26]}get isDrawingEnabled(){return this.$$.ctx[27]}}function _2(r){let t,e,i,n,s,o,a,l=r[2].appearance.label+"",h,c,u,d;return{c(){t=it("g"),e=it("rect"),a=it("text"),h=ba(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",n=18/r[3]),w(e,"fill",s=r[2].appearance.color),w(e,"stroke",o=r[2].appearance.color),w(a,"font-size",c=12/r[3]),w(a,"x",u=r[0]+Math.round(5/r[3])),w(a,"y",d=r[1]-5/r[3]),w(a,"class","svelte-1rehw2p"),w(t,"class","a9s-presence-label")},m(f,p){ot(f,t,p),Ct(t,e),Ct(t,a),Ct(a,h),r[6](t)},p(f,[p]){p&1&&w(e,"x",f[0]),p&10&&i!==(i=f[1]-18/f[3])&&w(e,"y",i),p&8&&n!==(n=18/f[3])&&w(e,"height",n),p&4&&s!==(s=f[2].appearance.color)&&w(e,"fill",s),p&4&&o!==(o=f[2].appearance.color)&&w(e,"stroke",o),p&4&&l!==(l=f[2].appearance.label+"")&&U_(h,l),p&8&&c!==(c=12/f[3])&&w(a,"font-size",c),p&9&&u!==(u=f[0]+Math.round(5/f[3]))&&w(a,"x",u),p&10&&d!==(d=f[1]-5/f[3])&&w(a,"y",d)},i:Ft,o:Ft,d(f){f&&st(t),r[6](null)}}}function v2(r,t,e){let{x:i}=t,{y:n}=t,{user:s}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=u=>{const d=l.querySelector("text"),f=l.querySelector("rect"),p=d.getBBox().width+10/u;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${p/2}px)`),f.setAttribute("width",`${p}`)};function c(u){bs[u?"unshift":"push"](()=>{l=u,e(4,l)})}return r.$$set=u=>{"x"in u&&e(0,i=u.x),"y"in u&&e(1,n=u.y),"user"in u&&e(2,s=u.user),"scale"in u&&e(3,o=u.scale),"hAlign"in u&&e(5,a=u.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,n,s,o,l,a,c]}class Om extends jt{constructor(t){super(),zt(this,t,v2,_2,Ut,{x:0,y:1,user:2,scale:3,hAlign:5})}}function b2(r){let t,e,i,n,s,o;return e=new Om({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=it("g"),Lt(e.$$.fragment),i=it("polygon"),w(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),w(i,"stroke",n=r[0].appearance.color),w(i,"fill","transparent"),w(i,"points",s=r[2].points.map(Lm).join(" ")),w(t,"class","a9s-presence-overlay")},m(a,l){ot(a,t,l),Bt(e,t,null),Ct(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&&n!==(n=a[0].appearance.color))&&w(i,"stroke",n),(!o||l&4&&s!==(s=a[2].points.map(Lm).join(" ")))&&w(i,"points",s)},i(a){o||(q(e.$$.fragment,a),o=!0)},o(a){at(e.$$.fragment,a),o=!1},d(a){a&&st(t),Ot(e)}}}const Lm=r=>r.join(",");function x2(r,t,e){let i,n,{annotation:s}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[c,...u]=h.points;return u.forEach(([d,f])=>{f<c[1]&&(c=[d,f])}),c};return r.$$set=h=>{"annotation"in h&&e(4,s=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=s.target.selector.geometry),r.$$.dirty&4&&e(3,n=l(i))},[o,a,i,n,s]}class w2 extends jt{constructor(t){super(),zt(this,t,x2,b2,Ut,{annotation:4,user:0,scale:1})}}function E2(r){let t,e,i,n,s,o,a,l,h;return e=new Om({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=it("g"),Lt(e.$$.fragment),i=it("rect"),w(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),w(i,"stroke",n=r[0].appearance.color),w(i,"fill","transparent"),w(i,"x",s=r[2].x),w(i,"y",o=r[2].y),w(i,"width",a=r[2].w),w(i,"height",l=r[2].h),w(t,"class","a9s-presence-overlay")},m(c,u){ot(c,t,u),Bt(e,t,null),Ct(t,i),h=!0},p(c,[u]){const d={};u&2&&(d.scale=c[1]),u&1&&(d.user=c[0]),u&4&&(d.x=c[2].x),u&4&&(d.y=c[2].y),e.$set(d),(!h||u&1&&n!==(n=c[0].appearance.color))&&w(i,"stroke",n),(!h||u&4&&s!==(s=c[2].x))&&w(i,"x",s),(!h||u&4&&o!==(o=c[2].y))&&w(i,"y",o),(!h||u&4&&a!==(a=c[2].w))&&w(i,"width",a),(!h||u&4&&l!==(l=c[2].h))&&w(i,"height",l)},i(c){h||(q(e.$$.fragment,c),h=!0)},o(c){at(e.$$.fragment,c),h=!1},d(c){c&&st(t),Ot(e)}}}function T2(r,t,e){let i,{annotation:n}=t,{user:s}=t,{scale:o}=t;return r.$$set=a=>{"annotation"in a&&e(3,n=a.annotation),"user"in a&&e(0,s=a.user),"scale"in a&&e(1,o=a.scale)},r.$$.update=()=>{r.$$.dirty&8&&e(2,i=n.target.selector.geometry)},[s,o,i,n]}class A2 extends jt{constructor(t){super(),zt(this,t,T2,E2,Ut,{annotation:3,user:0,scale:1})}}const{Boolean:S2}=va;function Nm(r,t,e){const i=r.slice();return i[8]=t[e],i}function Fm(r){let t,e;return t=new Dh({props:{viewer:r[0],$$slots:{default:[P2,({transform:i,scale:n})=>({6:i,7:n}),({transform:i,scale:n})=>(i?64:0)|(n?128:0)]},$$scope:{ctx:r}}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&1&&(s.viewer=i[0]),n&2244&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function km(r){let t,e,i=xe(r[2]),n=[];for(let o=0;o<i.length;o+=1)n[o]=Um(Nm(r,i,o));const s=o=>at(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=Pe()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);ot(o,t,a),e=!0},p(o,a){if(a&132){i=xe(o[2]);let l;for(l=0;l<i.length;l+=1){const h=Nm(o,i,l);n[l]?(n[l].p(h,a),q(n[l],1)):(n[l]=Um(h),n[l].c(),q(n[l],1),n[l].m(t.parentNode,t))}for(le(),l=i.length;l<n.length;l+=1)s(l);he()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(n[a]);e=!0}},o(o){n=n.filter(S2);for(let a=0;a<n.length;a+=1)at(n[a]);e=!1},d(o){o&&st(t),Dr(n,o)}}}function C2(r){let t,e;return t=new w2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&4&&(s.annotation=i[8].annotation),n&4&&(s.user=i[8].selectedBy),n&128&&(s.scale=i[7]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function I2(r){let t,e;return t=new A2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&4&&(s.annotation=i[8].annotation),n&4&&(s.user=i[8].selectedBy),n&128&&(s.scale=i[7]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Um(r){let t,e,i,n;const s=[I2,C2],o=[];function a(l,h){return l[8].annotation.target.selector.type===_t.RECTANGLE?0:l[8].annotation.target.selector.type===_t.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=s[t](r)),{c(){e&&e.c(),i=Pe()},m(l,h){~t&&o[t].m(l,h),ot(l,i,h),n=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(le(),at(o[c],1,1,()=>{o[c]=null}),he()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=s[t](l),e.c()),q(e,1),e.m(i.parentNode,i)):e=null)},i(l){n||(q(e),n=!0)},o(l){at(e),n=!1},d(l){l&&st(i),~t&&o[t].d(l)}}}function P2(r){let t,e,i,n,s=r[2].length>0&&km(r);return{c(){t=it("svg"),e=it("g"),s&&s.c(),w(e,"transform",i=r[6]),w(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){ot(o,t,a),Ct(t,e),s&&s.m(e,null),n=!0},p(o,a){o[2].length>0?s?(s.p(o,a),a&4&&q(s,1)):(s=km(o),s.c(),q(s,1),s.m(e,null)):s&&(le(),at(s,1,1,()=>{s=null}),he()),(!n||a&64&&i!==(i=o[6]))&&w(e,"transform",i)},i(o){n||(q(s),n=!0)},o(o){at(s),n=!1},d(o){o&&st(t),s&&s.d()}}}function R2(r){let t=!!r[1],e,i,n=t&&Fm(r);return{c(){n&&n.c(),e=Pe()},m(s,o){n&&n.m(s,o),ot(s,e,o),i=!0},p(s,[o]){o&2&&(t=!!s[1]),t?n?(n.p(s,o),o&2&&q(n,1)):(n=Fm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n&&(le(),at(n,1,1,()=>{n=null}),he())},i(s){i||(q(n),i=!0)},o(s){at(n),i=!1},d(s){s&&st(e),n&&n.d(s)}}}function M2(r,t,e){let{store:i}=t,{viewer:n}=t,{provider:s}=t,o=[],a;const l=(h,c)=>{e(2,o=[...o.filter(({selectedBy:u})=>u.presenceKey!==h.presenceKey),...(c||[]).map(u=>({annotation:i.getAnnotation(u),selectedBy:h}))].filter(({annotation:u})=>(u||console.warn("Selection event on unknown annotation"),!!u))),a&&i.unobserve(a),a=u=>{const{deleted:d,updated:f}=u.changes,p=new Set((d||[]).map(y=>y.id)),g=o.filter(({annotation:y})=>!p.has(y.id)).map(y=>{const _=(f||[]).find(v=>v.oldValue.id===y.annotation.id);return _?{selectedBy:y.selectedBy,annotation:_.newValue}:y});e(2,o=g)},i.observe(a,{annotations:o.map(u=>u.annotation.id)})};return $_(()=>{a&&i.unobserve(a)}),r.$$set=h=>{"store"in h&&e(3,i=h.store),"viewer"in h&&e(0,n=h.viewer),"provider"in h&&e(1,s=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&s&&s.on("selectionChange",l)},[n,s,o,i]}class D2 extends jt{constructor(t){super(),zt(this,t,M2,R2,Ut,{store:3,viewer:0,provider:1})}}function B2(r){let t,e,i,n,s;return{c(){t=it("ellipse"),w(t,"cx",e=r[0].cx),w(t,"cy",i=r[0].cy),w(t,"rx",n=r[0].rx),w(t,"ry",s=r[0].ry)},m(o,a){ot(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].cx)&&w(t,"cx",e),a&1&&i!==(i=o[0].cy)&&w(t,"cy",i),a&1&&n!==(n=o[0].rx)&&w(t,"rx",n),a&1&&s!==(s=o[0].ry)&&w(t,"ry",s)},i:Ft,o:Ft,d(o){o&&st(t)}}}function O2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class L2 extends jt{constructor(t){super(),zt(this,t,O2,B2,Ut,{annotation:1})}}function N2(r){let t,e,i,n,s;return{c(){t=it("line"),w(t,"x1",e=r[0].points[0][0]),w(t,"y1",i=r[0].points[0][1]),w(t,"x2",n=r[0].points[1][0]),w(t,"y2",s=r[0].points[1][1])},m(o,a){ot(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].points[0][0])&&w(t,"x1",e),a&1&&i!==(i=o[0].points[0][1])&&w(t,"y1",i),a&1&&n!==(n=o[0].points[1][0])&&w(t,"x2",n),a&1&&s!==(s=o[0].points[1][1])&&w(t,"y2",s)},i:Ft,o:Ft,d(o){o&&st(t)}}}function F2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class k2 extends jt{constructor(t){super(),zt(this,t,F2,N2,Ut,{annotation:1})}}function Gm(r,t,e){const i=r.slice();return i[2]=t[e],i}function $m(r){let t,e;return{c(){t=it("path"),e=it("path"),w(t,"fill-rule","evenodd"),w(t,"d",He(r[2])),w(e,"class","a9s-inner"),w(e,"fill-rule","evenodd"),w(e,"d",He(r[2]))},m(i,n){ot(i,t,n),ot(i,e,n)},p:Ft,d(i){i&&(st(t),st(e))}}}function U2(r){let t,e=xe(r[0]),i=[];for(let n=0;n<e.length;n+=1)i[n]=$m(Gm(r,e,n));return{c(){t=it("g");for(let n=0;n<i.length;n+=1)i[n].c()},m(n,s){ot(n,t,s);for(let o=0;o<i.length;o+=1)i[o]&&i[o].m(t,null)},p(n,[s]){if(s&1){e=xe(n[0]);let o;for(o=0;o<e.length;o+=1){const a=Gm(n,e,o);i[o]?i[o].p(a,s):(i[o]=$m(a),i[o].c(),i[o].m(t,null))}for(;o<i.length;o+=1)i[o].d(1);i.length=e.length}},i:Ft,o:Ft,d(n){n&&st(t),Dr(i,n)}}}function G2(r,t,e){let{annotation:i}=t;const{polygons:n}=i.target.selector.geometry;return r.$$set=s=>{"annotation"in s&&e(1,i=s.annotation)},[n,i]}class $2 extends jt{constructor(t){super(),zt(this,t,G2,U2,Ut,{annotation:1})}}function H2(r){let t,e;return{c(){t=it("polygon"),w(t,"points",e=r[0].points.map(Hm).join(" "))},m(i,n){ot(i,t,n)},p(i,[n]){n&1&&e!==(e=i[0].points.map(Hm).join(" "))&&w(t,"points",e)},i:Ft,o:Ft,d(i){i&&st(t)}}}const Hm=r=>r.join(",");function X2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class V2 extends jt{constructor(t){super(),zt(this,t,X2,H2,Ut,{annotation:1})}}function z2(r){let t;return{c(){t=it("path"),w(t,"d",r[0])},m(e,i){ot(e,t,i)},p(e,[i]){i&1&&w(t,"d",e[0])},i:Ft,o:Ft,d(e){e&&st(t)}}}function j2(r,t,e){let i,n,{annotation:s}=t;return r.$$set=o=>{"annotation"in o&&e(1,s=o.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(2,i=s.target.selector.geometry),r.$$.dirty&4&&e(0,n=Jo(i))},[n,s,i]}class W2 extends jt{constructor(t){super(),zt(this,t,j2,z2,Ut,{annotation:1})}}function Y2(r){let t,e,i,n,s;return{c(){t=it("rect"),w(t,"x",e=r[0].x),w(t,"y",i=r[0].y),w(t,"width",n=r[0].w),w(t,"height",s=r[0].h)},m(o,a){ot(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].x)&&w(t,"x",e),a&1&&i!==(i=o[0].y)&&w(t,"y",i),a&1&&n!==(n=o[0].w)&&w(t,"width",n),a&1&&s!==(s=o[0].h)&&w(t,"height",s)},i:Ft,o:Ft,d(o){o&&st(t)}}}function q2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class K2 extends jt{constructor(t){super(),zt(this,t,q2,Y2,Ut,{annotation:1})}}const{Boolean:Z2}=va;function Xm(r,t,e){const i=r.slice();return i[10]=t[e],i}function Vm(r){let t,e;return t=new Dh({props:{viewer:r[0],$$slots:{default:[nC,({transform:i})=>({9:i}),({transform:i})=>i?512:0]},$$scope:{ctx:r}}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&1&&(s.viewer=i[0]),n&8710&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function J2(r){let t,e;return t=new k2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Q2(r){let t,e;return t=new L2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function tC(r){let t,e;return t=new W2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function eC(r){let t,e;return t=new $2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function rC(r){let t,e;return t=new V2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function iC(r){let t,e;return t=new K2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function zm(r){let t,e,i,n;const s=[iC,rC,eC,tC,Q2,J2],o=[];function a(l,h){return l[10].target.selector.type===_t.RECTANGLE?0:l[10].target.selector.type===_t.POLYGON?1:l[10].target.selector.type===_t.MULTIPOLYGON?2:l[10].target.selector.type===_t.POLYLINE?3:l[10].target.selector.type===_t.ELLIPSE?4:l[10].target.selector.type===_t.LINE?5:-1}return~(t=a(r))&&(e=o[t]=s[t](r)),{c(){e&&e.c(),i=Pe()},m(l,h){~t&&o[t].m(l,h),ot(l,i,h),n=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(le(),at(o[c],1,1,()=>{o[c]=null}),he()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=s[t](l),e.c()),q(e,1),e.m(i.parentNode,i)):e=null)},i(l){n||(q(e),n=!0)},o(l){at(e),n=!1},d(l){l&&st(i),~t&&o[t].d(l)}}}function nC(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g=xe(r[1].filter(r[6])),y=[];for(let v=0;v<g.length;v+=1)y[v]=zm(Xm(r,g,v));const _=v=>at(y[v],1,1,()=>{y[v]=null});return{c(){var v,m,b,S;t=it("svg"),e=it("g"),i=it("rect"),l=it("rect");for(let R=0;R<y.length;R+=1)y[R].c();w(i,"class","a9s-union-bg svelte-jwrce3"),w(i,"x",n=(v=r[2])==null?void 0:v.minX),w(i,"y",s=(m=r[2])==null?void 0:m.minY),w(i,"width",o=r[2]?r[2].maxX-r[2].minX:0),w(i,"height",a=r[2]?r[2].maxY-r[2].minY:0),w(l,"class","a9s-union-fg svelte-jwrce3"),w(l,"x",h=(b=r[2])==null?void 0:b.minX),w(l,"y",c=(S=r[2])==null?void 0:S.minY),w(l,"width",u=r[2]?r[2].maxX-r[2].minX:0),w(l,"height",d=r[2]?r[2].maxY-r[2].minY:0),w(e,"transform",f=r[9]),w(t,"class","a9s-osd-selectionlayer svelte-jwrce3")},m(v,m){ot(v,t,m),Ct(t,e),Ct(e,i),Ct(e,l);for(let b=0;b<y.length;b+=1)y[b]&&y[b].m(e,null);p=!0},p(v,m){var b,S,R,C;if((!p||m&4&&n!==(n=(b=v[2])==null?void 0:b.minX))&&w(i,"x",n),(!p||m&4&&s!==(s=(S=v[2])==null?void 0:S.minY))&&w(i,"y",s),(!p||m&4&&o!==(o=v[2]?v[2].maxX-v[2].minX:0))&&w(i,"width",o),(!p||m&4&&a!==(a=v[2]?v[2].maxY-v[2].minY:0))&&w(i,"height",a),(!p||m&4&&h!==(h=(R=v[2])==null?void 0:R.minX))&&w(l,"x",h),(!p||m&4&&c!==(c=(C=v[2])==null?void 0:C.minY))&&w(l,"y",c),(!p||m&4&&u!==(u=v[2]?v[2].maxX-v[2].minX:0))&&w(l,"width",u),(!p||m&4&&d!==(d=v[2]?v[2].maxY-v[2].minY:0))&&w(l,"height",d),m&2){g=xe(v[1].filter(v[6]));let I;for(I=0;I<g.length;I+=1){const M=Xm(v,g,I);y[I]?(y[I].p(M,m),q(y[I],1)):(y[I]=zm(M),y[I].c(),q(y[I],1),y[I].m(e,null))}for(le(),I=g.length;I<y.length;I+=1)_(I);he()}(!p||m&512&&f!==(f=v[9]))&&w(e,"transform",f)},i(v){if(!p){for(let m=0;m<g.length;m+=1)q(y[m]);p=!0}},o(v){y=y.filter(Z2);for(let m=0;m<y.length;m+=1)at(y[m]);p=!1},d(v){v&&st(t),Dr(y,v)}}}function sC(r){let t=!!r[2],e,i,n=t&&Vm(r);return{c(){n&&n.c(),e=Pe()},m(s,o){n&&n.m(s,o),ot(s,e,o),i=!0},p(s,[o]){o&4&&(t=!!s[2]),t?n?(n.p(s,o),o&4&&q(n,1)):(n=Vm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n&&(le(),at(n,1,1,()=>{n=null}),he())},i(s){i||(q(n),i=!0)},o(s){at(n),i=!1},d(s){s&&st(e),n&&n.d(s)}}}function oC(r,t,e){let i,n,s,{state:o}=t,{viewer:a}=t;const{store:l}=o,{selection:h}=o;Tn(r,h,d=>e(5,s=d));const c=d=>{let f=-1/0,p=-1/0,g=1/0,y=1/0;for(let _ of d.filter(v=>Le(v))){const{bounds:v}=_.target.selector.geometry;v.maxX>f&&(f=v.maxX),v.maxY>p&&(p=v.maxY),v.minX<g&&(g=v.minX),v.minY<y&&(y=v.minY)}return a.forceRedraw(),{maxX:f,maxY:p,minX:g,minY:y}},u=d=>Le(d);return r.$$set=d=>{"state"in d&&e(4,o=d.state),"viewer"in d&&e(0,a=d.viewer)},r.$$.update=()=>{r.$$.dirty&32&&e(1,i=s.selected.map(({id:d})=>l.getAnnotation(d))),r.$$.dirty&2&&e(2,n=i.length>1?c(i):void 0)},[a,i,n,h,o,s,u]}class aC extends jt{constructor(t){super(),zt(this,t,oC,sC,Ut,{state:4,viewer:0})}}const jm=(r,t)=>{t==="auto"?r.addHandler("open",e=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",s=>{const{fullyLoaded:o}=s;if(o){const a=r.canvas.querySelector("canvas"),l=eu(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},Wm=(r,t,e)=>(i,n={})=>{const s=typeof i=="string"?i:i.id,o=t.getAnnotation(s);if(!o||!Le(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=n;let[h,c,u,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,c=c/a.width,u=u/a.height,d=d/a.width;const{minX:f,minY:p,maxX:g,maxY:y}=o.target.selector.geometry.bounds,_=g-f,v=y-p,m=f-d*_,b=p-h*v,S=_+(c+d)*_,R=v+(h+u)*v,C=r.viewport.imageToViewportRectangle(m,b,S,R);r.viewport[e](C,n.immediately)},lC=(r,t)=>Wm(r,t,"fitBounds"),hC=(r,t)=>Wm(r,t,"fitBoundsWithConstraints"),cC=(r,t={})=>{const e=iu(t,{drawingEnabled:!1,drawingMode:Ne?"drag":"click",userSelectAction:Go.EDIT,theme:"light"}),i=tu(e),{hover:n,selection:s,store:o}=i,a=fg(o,e.initialHistory),l=pg(i,a,e.adapter,e.autoSave);let h=wg(),c=e.drawingEnabled,u=e.drawingMode,d=e.modalSelect;const f=su(a,r.element),p=new s2({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),g=new D2({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),y=new y2({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!c,filter:void 0,multiSelect:e.multiSelect,preferredDrawingMode:u,state:i,style:e.style,user:h,viewer:r}}),_=new aC({target:r.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:r}});p.$on("click",B=>{const{originalEvent:k,annotation:V}=B.detail,z=K=>Cm(K.id,k,s,e.multiSelect);d?s.isEmpty()&&V&&s.userSelect(z(V),k):V&&!(u==="click"&&c)?s.userSelect(z(V),k):s.isEmpty()||(e.multiSelect?k.metaKey||k.shiftKey||k.ctrlKey||s.userSelect([],k):s.userSelect([],k))}),r.element.addEventListener("pointerdown",B=>{if(n.current){const k=o.getAnnotation(n.current);l.emit("clickAnnotation",k,B)}}),jm(r,e.theme);const v=gg(i,a,e.adapter),m=()=>y.cancelDrawing(),b=()=>{p.$destroy(),g.$destroy(),y.$destroy(),_.$destroy(),f.destroy(),a.destroy()},S=lC(r,o),R=hC(r,o),C=()=>y.getDrawingTool(),I=()=>h,M=()=>y.isDrawingEnabled(),F=(B,k,V)=>Uc(B,k,V),U=(B,k)=>Lc(B,k),P=B=>{if(!ys(B))throw`No drawing tool named ${B}`;y.$set({toolName:B})},T=B=>{c=B,y.$set({drawingEnabled:B})},E=B=>{p.$set({filter:B}),y.$set({filter:B})},A=B=>d=B,L=B=>{p.$set({style:B}),y.$set({style:B})},D=B=>g.$set({provider:B}),N=B=>jm(r,B),$=B=>{h=B,y.$set({user:B})},O=B=>p.$set({visible:B});return{...v,cancelDrawing:m,destroy:b,fitBounds:S,fitBoundsWithConstraints:R,getDrawingTool:C,getUser:I,isDrawingEnabled:M,listDrawingTools:gs,on:l.on,off:l.off,registerDrawingTool:F,registerShapeEditor:U,setDrawingEnabled:T,setDrawingTool:P,setFilter:E,setModalSelect:A,setPresenceProvider:D,setStyle:L,setTheme:N,setUser:$,setVisible:O,state:i,viewer:r}};qt.ShapeType=_t,qt.UserSelectAction=Go,qt.W3CImageFormat=Zy,qt.chainStyles=$y,qt.computeStyle=Gy,qt.createBody=ng,qt.createImageAnnotator=L_,qt.createOSDAnnotator=cC,qt.defaultColorProvider=Tg,Object.defineProperty(qt,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=Lw(t)),typeof t=="number"?Ow(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),n=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const s=`${i}px ${n}px`;return this.dropShadowBlur>0?`text-shadow: ${s} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${s} ${t}`}reset(){Object.assign(this,gn.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}=tt.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}};Rh.availableFonts={},Rh.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 Mh=Rh;const Lo=class yn extends nn{constructor(t="",e={}){super(ct.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,n=ct.from(i,{scaleMode:tt.SCALE_MODE,resourceOptions:{autoLoad:!1}});n.orig=new wt,n.trim=new wt,this.texture=n;const s="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(s,"svg"),l=document.createElementNS(s,"foreignObject"),h=document.createElementNS(o,"div"),c=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=yn.defaultMaxWidth,this.maxHeight=yn.defaultMaxHeight,this._domElement=h,this._styleElement=c,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(c),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=yn.defaultAutoResolution,this._resolution=yn.defaultResolution??tt.RESOLUTION,this.text=t,this.style=e}measureText(t){var c,u;const{text:e,style:i,resolution:n}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(n)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const s=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=s;(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:(c=this._style)==null?void 0:c.toCSS(n)}),this._styleElement.textContent=(u=this._style)==null?void 0:u.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:n}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:s,height:o}=this.measureText();i.width=n.width=Math.ceil(Math.max(1,s)),i.height=n.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{n.onload=async()=>{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.src=n.src,n.onload=null,n.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);n.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:n}=this,{padding:s}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/n,e.trim.height=e._frame.height=i.height/n,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(),o.setRealSize(i.width,i.height,n),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,n,s,o,a;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},yn.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(n=this._svgRoot)==null||n.remove(),this._svgRoot=e,(s=this._domElement)==null||s.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=Gr(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=Gr(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 Mh?(this.ownsStyle=!1,this._style=t):t instanceof Wr?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Mh.from(t)):(this.ownsStyle=!0,this._style=new Mh(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;")}};Lo.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Lo.defaultMaxWidth=2024,Lo.defaultMaxHeight=2024,Lo.defaultAutoResolution=!0;const WS=16777215,YS=.25,qS=16777215,KS=1,ZS=1.5;let Kr=!1,dn;const Dh=r=>{const t={tint:r!=null&&r.fill?new Mt(r.fill).toNumber():WS,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 Mt(r==null?void 0:r.fill).alpha:YS},e={tint:r!=null&&r.stroke?new Mt(r.stroke).toNumber():qS,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 Mt(r==null?void 0:r.stroke).alpha:KS,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?ZS:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},fn=r=>(t,e,i,n={})=>{const{fillStyle:s,strokeStyle:o}=Dh(i),a=new ts;n.strokeOnly||(a.beginFill(16777215),r(e,a),a.endFill(),a.tint=s.tint,a.alpha=s.alpha),t.addChild(a);const l=new ts,h=o.lineWidth===1?1:o.lineWidth/dn;return l.lineStyle(h,16777215,1,.5,o.lineWidth===1),r(e,l),l.tint=o.tint||16777215,l.alpha=o.alpha,t.addChild(l),{fill:a,stroke:l,strokeWidth:o.lineWidth}},QS=fn((r,t)=>{const{x:e,y:i,w:n,h:s}=r.geometry;t.drawRect(e,i,n,s)}),JS=fn((r,t)=>{const{cx:e,cy:i,rx:n,ry:s}=r.geometry;t.drawEllipse(e,i,n,s)}),t2=fn((r,t)=>{const[[e,i],[n,s]]=r.geometry.points;t.moveTo(e,i),t.lineTo(n,s),t.closePath()}),e2=fn((r,t)=>{const e=r.geometry.points.reduce((i,n)=>[...i,...n],[]);t.drawPolygon(e)}),r2=fn((r,t)=>{const{points:e,closed:i}=r.geometry;if(e.length===0)return;i||t.beginFill(0,0);const n=(o,a)=>{const[l,h]=o.point,[c,u]=a.point;if(o.type==="CURVE"||a.type==="CURVE"){const d=o.type==="CURVE"&&o.outHandle?o.outHandle[0]:l,f=o.type==="CURVE"&&o.outHandle?o.outHandle[1]:h,p=a.type==="CURVE"&&a.inHandle?a.inHandle[0]:c,g=a.type==="CURVE"&&a.inHandle?a.inHandle[1]:u;t.bezierCurveTo(d,f,p,g,c,u)}else t.lineTo(c,u)},s=e[0];t.moveTo(s.point[0],s.point[1]);for(let o=1;o<e.length;o++){const a=e[o-1],l=e[o];n(a,l)}if(i&&e.length>2){const o=e[e.length-1],a=e[0];n(o,a),t.closePath()}else t.endFill()}),i2=fn((r,t)=>{const e=i=>i.points.reduce((n,s)=>[...n,...s],[]);r.geometry.polygons.forEach(i=>{const[n,...s]=i.rings;t.drawPolygon(e(n)),s.forEach(o=>{t.beginHole(),t.drawPolygon(e(o)),t.endHole()})})}),Sm=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},Cm=(r,t,e,i)=>()=>{const n=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),s=Sm(r);(s!==dn||!Kr)&&(Kr=!0,e.forEach(({stroke:d,strokeWidth:f})=>{const{lineStyle:p}=d.geometry.graphicsData[0];f>1?(Kr=s===dn,p.width=f/s,p.native=!1,d.geometry.invalidate()):f===1&&!p.native&&(p.width=1,p.native=!0,d.geometry.invalidate())})),dn=s;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+n.x*s:-n.x*s,h=-n.y*s;let c,u;a>0&&a<=Math.PI/2?(c=n.height*s,u=0):a>Math.PI/2&&a<=Math.PI?(c=n.width*s,u=n.height*s):a>Math.PI&&a<=Math.PI*1.5?(c=0,u=n.width*s):(c=0,u=0),t.position.x=c+l*Math.cos(a)-h*Math.sin(a),t.position.y=u+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-s:s,s),t.rotation=a,i.render(t)},n2=(r,t)=>{const e=new ts,i=Ep({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),n=new Map;let s=new Set,o,a;dn=Sm(r);const l=(m,b)=>{Kr=!1;const S=n.get(m.id);S&&(S.fill.destroy(),S.stroke.destroy());const{selector:R}=m.target,C=typeof a=="function"?a(m,b):a;let I;if(R.type===_t.RECTANGLE)I=QS(e,R,C);else if(R.type===_t.POLYGON)I=e2(e,R,C);else if(R.type===_t.ELLIPSE)I=JS(e,R,C);else if(R.type===_t.MULTIPOLYGON)I=i2(e,R,C);else if(R.type===_t.POLYLINE){const M=R;I=r2(e,M,C,{strokeOnly:!M.geometry.closed})}else R.type===_t.LINE?I=t2(e,R,C):console.warn(`Unsupported shape type: ${R.type}`);I&&n.set(m.id,{annotation:m,...I})},h=m=>{const b=n.get(m.id);b&&(n.delete(m.id),b.fill.destroy(),b.stroke.destroy())},c=(m,b,S)=>{Kr=!1;const R=n.get(m.id);if(R&&(n.delete(m.id),R.fill.destroy(),R.stroke.destroy(),l(b,S),s.has(b.id))){const{fill:C,stroke:I}=n.get(b.id);e.removeChild(C),e.removeChild(I)}},u=(m,b)=>{const S=n.get(m);S&&(n.delete(m),S.fill.destroy(),S.stroke.destroy(),l(S.annotation,b))},d=(m,b)=>{i.resize(m,b),i.render(e)},f=m=>{Kr=!1;const{children:b}=e;n.forEach(({fill:S,stroke:R,annotation:C})=>{const I=m?s.has(C.id)||m(C):!0;I&&!b.includes(S)?(e.addChild(S),e.addChild(R)):!I&&b.includes(S)&&(e.removeChild(S),e.removeChild(R))}),i.render(e)},p=m=>{const b=new Set(m.selected.map(C=>C.id)),S=m.selected.filter(({id:C})=>!s.has(C)),R=[...s].filter(C=>!b.has(C));S.forEach(({id:C,editable:I})=>{if(I){const M=n.get(C);M&&fa(M.annotation.target.selector)&&(e.removeChild(M.fill),e.removeChild(M.stroke))}else u(C,{selected:!0,hovered:C===o})}),R.forEach(C=>u(C,{hovered:C===o})),s=b,i.render(e)},g=m=>{o!==m&&(m&&s.has(m)||(o&&!s.has(o)&&u(o,{selected:s.has(o)}),m&&u(m,{selected:s.has(m),hovered:!0}),o=m,i.render(e)))},y=m=>{if(typeof m=="function")n.forEach(({annotation:b,fill:S,stroke:R,strokeWidth:C},I)=>{C>1&&(Kr=!1);const M={selected:s.has(b.id),hovered:o===b.id},{fillStyle:F,strokeStyle:U}=Dh(m(b,M));S.tint=F.tint,S.alpha=F.alpha,R.tint=U.tint||16777215,R.alpha=U.alpha,n.set(b.id,{annotation:b,fill:S,stroke:R,strokeWidth:U.lineWidth})});else{const{fillStyle:b,strokeStyle:S}=Dh(m);S.lineWidth>1&&(Kr=!1),n.forEach(({annotation:R,fill:C,stroke:I,strokeWidth:M},F)=>{C.tint=b.tint,C.alpha=b.alpha,I.tint=S.tint||16777215,I.alpha=S.alpha,n.set(R.id,{annotation:R,fill:C,stroke:I,strokeWidth:S.lineWidth})})}a=m,i.render(e),Cm(r,e,n,i)()},_=m=>{m?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),getScale:()=>dn,redraw:Cm(r,e,n,i),removeAnnotation:h,resize:d,setFilter:f,setHovered:g,setSelected:p,setStyle:y,setVisible:_,updateAnnotation:c}};function s2(r,t,e){let i,n,{filter:s}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:c,hover:u,selection:d,viewport:f}=o;An(r,u,I=>e(11,i=I)),An(r,d,I=>e(8,n=I));const p=Oi(),g=Ne?10:2;let y,_;const v=I=>{const M=new se.Point(I.x,I.y),{x:F,y:U}=l.viewport.pointFromPixel(M);return l.viewport.viewportToImageCoordinates(F,U)},m=()=>g/y.getScale(),b=I=>{const{x:M,y:F}=I.position;_={x:M,y:F}},S=I=>M=>{const{x:F,y:U}=v(new se.Point(M.offsetX,M.offsetY)),P=m(),T=c.getAt(F,U,s,P);T?(I.classList.add("hover"),i!==T.id&&(u.set(T.id),y.setHovered(T.id))):(I.classList.remove("hover"),i&&(u.set(void 0),y.setHovered(void 0)))},R=I=>{if(!_)return;const M=I.originalEvent,{x:F,y:U}=I.position,P=F-_.x,T=U-_.y;if(Math.sqrt(P*P+T*T)<5){const{x:A,y:L}=v(I.position),D=m(),N=c.getAt(A,L,s,D);N?p("click",{originalEvent:M,annotation:N}):p("click",{originalEvent:M})}_=void 0};let C;return ii(()=>{var N;const{offsetWidth:I,offsetHeight:M}=l.canvas,F=document.createElement("canvas");F.width=I,F.height=M,F.className="a9s-gl-canvas",(N=l.element.querySelector(".openseadragon-canvas"))==null||N.appendChild(F),e(7,y=n2(l,F));const U=S(F);F.addEventListener("pointermove",U);const P=new ResizeObserver($=>{try{const{width:O,height:B}=$[0].contentRect;F.width=O,F.height=B,y.resize(O,B)}catch{console.warn("WebGL canvas already disposed")}});P.observe(F);const T=()=>{const $=l.viewport.getBounds();C=l.viewport.viewportToImageRectangle($);const{x:O,y:B,width:k,height:V}=C,z=c.getIntersecting(O,B,k,V);f.set(z.map(K=>K.id))};l.addHandler("canvas-press",b),l.addHandler("canvas-release",R),l.addHandler("update-viewport",y.redraw),l.addHandler("animation-finish",T);const E=$=>$.filter(O=>Le(O)),A=$=>Le($.oldValue)&&Le($.newValue),L=$=>{const{selector:O}=$.target;if(O.type===_t.POLYGON){const B=nv(O);return{...$,target:{...$.target,selector:{...B}}}}else if(O.type===_t.MULTIPOLYGON){const B=rv(O);return{...$,target:{...$.target,selector:{...B}}}}else return $},D=$=>{const{created:O,updated:B,deleted:k}=$.changes,V=(O||[]).filter(z=>Le(z)).map(L);if(E(k||[]).forEach(z=>y.removeAnnotation(z)),V.forEach(z=>y.addAnnotation(z)),(B||[]).filter(z=>A(z)).map(({oldValue:z,newValue:K})=>({oldValue:z,newValue:L(K)})).forEach(({oldValue:z,newValue:K})=>y.updateAnnotation(z,K)),C){const{x:z,y:K,width:X,height:ft}=C,H=c.getIntersecting(z,K,X,ft);f.set(H.map(mt=>mt.id))}else f.set(c.all().map(z=>z.id));y.redraw()};return c.observe(D),()=>{var $;F.removeEventListener("pointermove",U),P.disconnect(),l.removeHandler("canvas-press",b),l.removeHandler("canvas-release",R),l.removeHandler("update-viewport",y.redraw),l.removeHandler("animation-finish",T),c.unobserve(D),y.destroy(),($=F.parentNode)==null||$.removeChild(F)}}),r.$$set=I=>{"filter"in I&&e(2,s=I.filter),"state"in I&&e(3,o=I.state),"style"in I&&e(4,a=I.style),"viewer"in I&&e(5,l=I.viewer),"visible"in I&&e(6,h=I.visible)},r.$$.update=()=>{r.$$.dirty&132&&(y==null||y.setFilter(s)),r.$$.dirty&384&&(y==null||y.setSelected(n)),r.$$.dirty&144&&(y==null||y.setStyle(a)),r.$$.dirty&192&&(y==null||y.setVisible(h))},[u,d,s,o,a,l,h,y,n]}class o2 extends jt{constructor(t){super(),zt(this,t,s2,null,Ut,{filter:2,state:3,style:4,viewer:5,visible:6})}}const Im=(r,t,e,i)=>{if(!i)return r;if(t.shiftKey||t.ctrlKey||t.metaKey){const s=(e.selected||[]).map(o=>o.id);return s.includes(r)?s.filter(o=>o!==r):[...s,r]}else return r},a2=r=>({transform:r&2,scale:r&1}),Pm=r=>({transform:r[1],scale:r[0]});function l2(r){let t;const e=r[4].default,i=hu(e,r,r[3],Pm);return{c(){i&&i.c()},m(n,s){i&&i.m(n,s),t=!0},p(n,[s]){i&&i.p&&(!t||s&11)&&du(i,e,n,n[3],t?uu(e,n[3],s,a2):fu(n[3]),Pm)},i(n){t||(q(i,n),t=!0)},o(n){at(i,n),t=!1},d(n){i&&i.d(n)}}}function h2(r,t,e){let{$$slots:i={},$$scope:n}=t,{viewer:s}=t,o=1,a;const l=()=>{const h=s.viewport.getContainerSize().x,c=s.viewport.getZoom(!0),u=s.viewport.getFlip(),d=s.viewport.pixelFromPoint(new se.Point(0,0),!0);u&&(d.x=h-d.x);const f=c*h/s.world.getContentFactor(),p=u?-f:f,g=s.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${p}, ${f}) rotate(${g})`),e(0,o=c*h/s.world.getContentFactor())};return ii(()=>(s.addHandler("update-viewport",l),()=>{s.removeHandler("update-viewport",l)})),r.$$set=h=>{"viewer"in h&&e(2,s=h.viewer),"$$scope"in h&&e(3,n=h.$$scope)},[o,a,s,n,i]}class Bh extends jt{constructor(t){super(),zt(this,t,h2,l2,Ut,{viewer:2})}}function c2(r,t,e){const i=Oi();let{drawingMode:n}=t,{opts:s}=t,{target:o}=t,{tool:a}=t,{transform:l}=t,{viewer:h}=t,{viewportScale:c}=t,u;return ii(()=>{const d=o.closest("svg"),f=[],p=(g,y,_)=>{if(d==null||d.addEventListener(g,y,_),f.push(()=>d==null?void 0:d.removeEventListener(g,y,_)),g==="pointerup"||g==="dblclick"){const v=b=>{const{originalEvent:S}=b;y(S)},m=g==="pointerup"?"canvas-click":"canvas-double-click";h.addHandler(m,v),f.push(()=>h.removeHandler(m,v))}else if(g==="pointermove"){const v=m=>{const{originalEvent:b}=m;y(b)};h.addHandler("canvas-drag",v),f.push(()=>h.removeHandler("canvas-drag",v))}};return e(7,u=new a({target:o,props:{addEventListener:p,drawingMode:n,opts:s,transform:l,viewportScale:c,svgEl:d}})),u.$on("create",g=>i("create",g.detail)),()=>{f.forEach(g=>g()),u.$destroy()}}),r.$$set=d=>{"drawingMode"in d&&e(0,n=d.drawingMode),"opts"in d&&e(1,s=d.opts),"target"in d&&e(2,o=d.target),"tool"in d&&e(3,a=d.tool),"transform"in d&&e(4,l=d.transform),"viewer"in d&&e(5,h=d.viewer),"viewportScale"in d&&e(6,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&144&&u&&u.$set({transform:l}),r.$$.dirty&192&&u&&u.$set({viewportScale:c})},[n,s,o,a,l,h,c,u]}class u2 extends jt{constructor(t){super(),zt(this,t,c2,null,Ut,{drawingMode:0,opts:1,target:2,tool:3,transform:4,viewer:5,viewportScale:6})}}const{Boolean:d2}=ba;function Rm(r,t,e){const i=r.slice();i[41]=t[e];const n=i[19](i[41].target.selector);return i[42]=n,i}function f2(r){let t=`${r[2]}-${r[7]}`,e,i,n=Mm(r);return{c(){n.c(),e=Pe()},m(s,o){n.m(s,o),ot(s,e,o),i=!0},p(s,o){o[0]&132&&Ut(t,t=`${s[2]}-${s[7]}`)?(le(),at(n,1,1,Ft),he(),n=Mm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(q(n),i=!0)},o(s){at(n),i=!1},d(s){s&&st(e),n.d(s)}}}function p2(r){let t,e,i=xe(r[9].filter(r[29])),n=[];for(let o=0;o<i.length;o+=1)n[o]=Om(Rm(r,i,o));const s=o=>at(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=Pe()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);ot(o,t,a),e=!0},p(o,a){if(a[0]&713474|a[1]&512){i=xe(o[9].filter(o[29]));let l;for(l=0;l<i.length;l+=1){const h=Rm(o,i,l);n[l]?(n[l].p(h,a),q(n[l],1)):(n[l]=Om(h),n[l].c(),q(n[l],1),n[l].m(t.parentNode,t))}for(le(),l=i.length;l<n.length;l+=1)s(l);he()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(n[a]);e=!0}},o(o){n=n.filter(d2);for(let a=0;a<n.length;a+=1)at(n[a]);e=!1},d(o){o&&st(t),Or(n,o)}}}function Mm(r){let t,e;return t=new u2({props:{target:r[8],tool:r[10],drawingMode:r[4],transform:{elementToImage:r[13]},viewer:r[3],viewportScale:r[40],opts:r[5]}}),t.$on("create",r[18]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n[0]&256&&(s.target=i[8]),n[0]&1024&&(s.tool=i[10]),n[0]&16&&(s.drawingMode=i[4]),n[0]&8&&(s.viewer=i[3]),n[1]&512&&(s.viewportScale=i[40]),n[0]&32&&(s.opts=i[5]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Dm(r){let t=r[41].id,e,i,n=Bm(r);return{c(){n.c(),e=Pe()},m(s,o){n.m(s,o),ot(s,e,o),i=!0},p(s,o){o[0]&512&&Ut(t,t=s[41].id)?(le(),at(n,1,1,Ft),he(),n=Bm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n.p(s,o)},i(s){i||(q(n),i=!0)},o(s){at(n),i=!1},d(s){s&&st(e),n.d(s)}}}function Bm(r){let t,e;return t=new zv({props:{target:r[8],editor:r[19](r[41].target.selector),annotation:r[41],style:r[1],transform:{elementToImage:r[13]},viewportScale:r[40]}}),t.$on("grab",r[14]),t.$on("change",function(){Zt(r[17](r[41]))&&r[17](r[41]).apply(this,arguments)}),t.$on("release",r[15]),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){r=i;const s={};n[0]&256&&(s.target=r[8]),n[0]&512&&(s.editor=r[19](r[41].target.selector)),n[0]&512&&(s.annotation=r[41]),n[0]&2&&(s.style=r[1]),n[1]&512&&(s.viewportScale=r[40]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Om(r){let t,e,i=r[42]&&Dm(r);return{c(){i&&i.c(),t=Pe()},m(n,s){i&&i.m(n,s),ot(n,t,s),e=!0},p(n,s){n[42]?i?(i.p(n,s),s[0]&512&&q(i,1)):(i=Dm(n),i.c(),q(i,1),i.m(t.parentNode,t)):i&&(le(),at(i,1,1,()=>{i=null}),he())},i(n){e||(q(i),e=!0)},o(n){at(i),e=!1},d(n){n&&st(t),i&&i.d(n)}}}function m2(r){let t,e,i,n,s,o,a,l;const h=[p2,f2],c=[];function u(d,f){var p;return d[8]&&((p=d[9])==null?void 0:p.length)===1?0:d[8]&&d[10]&&d[0]?1:-1}return~(i=u(r))&&(n=c[i]=h[i](r)),{c(){t=it("svg"),e=it("g"),n&&n.c(),w(e,"transform",s=r[39]),w(e,"class","svelte-g4ws1v"),w(t,"tabindex",0),w(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-g4ws1v"),Lr(t,"drawing",r[0]),Lr(t,"editing",r[9]),Lr(t,"hover",r[6])},m(d,f){ot(d,t,f),Ct(t,e),~i&&c[i].m(e,null),r[30](e),o=!0,a||(l=Pt(t,"pointermove",r[16]),a=!0)},p(d,f){let p=i;i=u(d),i===p?~i&&c[i].p(d,f):(n&&(le(),at(c[p],1,1,()=>{c[p]=null}),he()),~i?(n=c[i],n?n.p(d,f):(n=c[i]=h[i](d),n.c()),q(n,1),n.m(e,null)):n=null),(!o||f[1]&256&&s!==(s=d[39]))&&w(e,"transform",s),(!o||f[0]&1)&&Lr(t,"drawing",d[0]),(!o||f[0]&512)&&Lr(t,"editing",d[9]),(!o||f[0]&64)&&Lr(t,"hover",d[6])},i(d){o||(q(n),o=!0)},o(d){at(n),o=!1},d(d){d&&st(t),~i&&c[i].d(),r[30](null),a=!1,l()}}}function g2(r){let t,e;return t=new Bh({props:{viewer:r[3],$$slots:{default:[m2,({transform:i,scale:n})=>({39:i,40:n}),({transform:i,scale:n})=>[0,(i?256:0)|(n?512:0)]]},$$scope:{ctx:r}}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n[0]&8&&(s.viewer=i[3]),n[0]&2047|n[1]&17152&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function y2(r,t,e){let i,n,s,o,a,{drawingEnabled:l}=t,{filter:h}=t,{multiSelect:c}=t,{preferredDrawingMode:u}=t,{state:d}=t,{style:f=void 0}=t,{toolName:p=ys()[0]}=t,{user:g}=t,{viewer:y}=t;const _=Ne?10:2;let v=!1,m=0;const b=()=>e(7,m+=1),S=()=>p,R=()=>l;let C;const{store:I,selection:M,hover:F}=d;An(r,M,X=>e(28,o=X)),An(r,F,X=>e(33,a=X));let U,P,T;const E=X=>{I.unobserve(U);const ft=X.filter(({editable:H})=>H).map(({id:H})=>H);ft.length>0?(e(9,P=ft.map(H=>I.getAnnotation(H))),U=H=>{const{updated:mt}=H.changes;e(9,P=(mt||[]).map(Q=>Q.newValue))},I.observe(U,{annotations:ft}),y.forceRedraw()):e(9,P=void 0)},A=(X,ft)=>{const{x:H,y:mt}=y.viewport.viewerElementToImageCoordinates(new se.Point(X,ft));return[H,mt]},L=()=>{const X=y.viewport.getContainerSize().x;return y.viewport.getZoom(!0)*X/y.world.getContentFactor()},D=()=>_/L(),N=X=>{y.setMouseNavEnabled(!1),T=X.timeStamp},$=X=>{if(y.setMouseNavEnabled(!0),performance.now()-(T||0)<300){const{offsetX:H,offsetY:mt}=X.detail,[Q,ut]=A(H,mt),gt=D(),Et=I.getAt(Q,ut,void 0,gt);if(Et&&(!h||h(Et))&&!P.find(Yt=>Yt.id===Et.id)){F.set(Et.id);const Yt=Im(Et.id,X.detail,M,c);M.userSelect(Yt)}}},O=X=>{const ft=new se.Point(X.offsetX,X.offsetY),H=y.viewport.pointFromPixel(ft),{x:mt,y:Q}=y.viewport.viewportToImageCoordinates(H.x,H.y),ut=D(),gt=I.getAt(mt,Q,h,ut);gt?a!==gt.id&&F.set(gt.id):a&&F.set(void 0)},B=X=>ft=>{var ut;const{target:H}=X,mt=10*60*1e3,Q=((ut=H.creator)==null?void 0:ut.id)!==g.id||!H.created||new Date().getTime()-H.created.getTime()>mt;I.updateTarget({...H,selector:ft.detail,created:Q?H.created:new Date,updated:Q?new Date:void 0,updatedBy:Q?g:void 0})},k=X=>{const ft=dv(),H={id:ft,bodies:[],target:{annotation:ft,selector:X.detail,creator:g,created:new Date}};I.addAnnotation(H),M.setSelected(H.id),y.setMouseNavEnabled(!0)},V=X=>fa(X);ii(()=>{const X=ft=>{if(o.selected.length===0)return;const{offsetX:H,offsetY:mt}=ft,Q=y.viewport.pointFromPixel(new se.Point(H,mt)),{x:ut,y:gt}=y.viewport.viewportToImageCoordinates(Q.x,Q.y),Et=D();e(6,v=!!I.getAt(ut,gt,h,Et))};return y.element.addEventListener("pointermove",X),()=>{var ft;(ft=y.element)==null||ft.removeEventListener("pointermove",X)}});const z=X=>Le(X);function K(X){xs[X?"unshift":"push"](()=>{C=X,e(8,C)})}return r.$$set=X=>{"drawingEnabled"in X&&e(0,l=X.drawingEnabled),"filter"in X&&e(20,h=X.filter),"multiSelect"in X&&e(21,c=X.multiSelect),"preferredDrawingMode"in X&&e(22,u=X.preferredDrawingMode),"state"in X&&e(23,d=X.state),"style"in X&&e(1,f=X.style),"toolName"in X&&e(2,p=X.toolName),"user"in X&&e(24,g=X.user),"viewer"in X&&e(3,y=X.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(10,{tool:i,opts:n}=_s(p)||{tool:void 0,opts:void 0},i,(e(5,n),e(2,p))),r.$$.dirty[0]&4194336&&e(4,s=(n==null?void 0:n.drawingMode)||u),r.$$.dirty[0]&25&&(l&&s==="drag"?y.setMouseNavEnabled(!1):y.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&l&&M.clear(),r.$$.dirty[0]&268435481&&o.selected.length===0&&s==="drag"&&l&&y.setMouseNavEnabled(!1),r.$$.dirty[0]&268435456&&E(o.selected)},[l,f,p,y,s,n,v,m,C,P,i,M,F,A,N,$,O,B,k,V,h,c,u,d,g,b,S,R,o,z,K]}class _2 extends jt{constructor(t){super(),zt(this,t,y2,g2,Ut,{drawingEnabled:0,filter:20,multiSelect:21,preferredDrawingMode:22,state:23,style:1,toolName:2,user:24,viewer:3,cancelDrawing:25,getDrawingTool:26,isDrawingEnabled:27},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[25]}get getDrawingTool(){return this.$$.ctx[26]}get isDrawingEnabled(){return this.$$.ctx[27]}}function v2(r){let t,e,i,n,s,o,a,l=r[2].appearance.label+"",h,c,u,d;return{c(){t=it("g"),e=it("rect"),a=it("text"),h=xa(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",n=18/r[3]),w(e,"fill",s=r[2].appearance.color),w(e,"stroke",o=r[2].appearance.color),w(a,"font-size",c=12/r[3]),w(a,"x",u=r[0]+Math.round(5/r[3])),w(a,"y",d=r[1]-5/r[3]),w(a,"class","svelte-1rehw2p"),w(t,"class","a9s-presence-label")},m(f,p){ot(f,t,p),Ct(t,e),Ct(t,a),Ct(a,h),r[6](t)},p(f,[p]){p&1&&w(e,"x",f[0]),p&10&&i!==(i=f[1]-18/f[3])&&w(e,"y",i),p&8&&n!==(n=18/f[3])&&w(e,"height",n),p&4&&s!==(s=f[2].appearance.color)&&w(e,"fill",s),p&4&&o!==(o=f[2].appearance.color)&&w(e,"stroke",o),p&4&&l!==(l=f[2].appearance.label+"")&&G_(h,l),p&8&&c!==(c=12/f[3])&&w(a,"font-size",c),p&9&&u!==(u=f[0]+Math.round(5/f[3]))&&w(a,"x",u),p&10&&d!==(d=f[1]-5/f[3])&&w(a,"y",d)},i:Ft,o:Ft,d(f){f&&st(t),r[6](null)}}}function b2(r,t,e){let{x:i}=t,{y:n}=t,{user:s}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=u=>{const d=l.querySelector("text"),f=l.querySelector("rect"),p=d.getBBox().width+10/u;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${p/2}px)`),f.setAttribute("width",`${p}`)};function c(u){xs[u?"unshift":"push"](()=>{l=u,e(4,l)})}return r.$$set=u=>{"x"in u&&e(0,i=u.x),"y"in u&&e(1,n=u.y),"user"in u&&e(2,s=u.user),"scale"in u&&e(3,o=u.scale),"hAlign"in u&&e(5,a=u.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,n,s,o,l,a,c]}class Lm extends jt{constructor(t){super(),zt(this,t,b2,v2,Ut,{x:0,y:1,user:2,scale:3,hAlign:5})}}function x2(r){let t,e,i,n,s,o;return e=new Lm({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=it("g"),Lt(e.$$.fragment),i=it("polygon"),w(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),w(i,"stroke",n=r[0].appearance.color),w(i,"fill","transparent"),w(i,"points",s=r[2].points.map(Nm).join(" ")),w(t,"class","a9s-presence-overlay")},m(a,l){ot(a,t,l),Bt(e,t,null),Ct(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&&n!==(n=a[0].appearance.color))&&w(i,"stroke",n),(!o||l&4&&s!==(s=a[2].points.map(Nm).join(" ")))&&w(i,"points",s)},i(a){o||(q(e.$$.fragment,a),o=!0)},o(a){at(e.$$.fragment,a),o=!1},d(a){a&&st(t),Ot(e)}}}const Nm=r=>r.join(",");function w2(r,t,e){let i,n,{annotation:s}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[c,...u]=h.points;return u.forEach(([d,f])=>{f<c[1]&&(c=[d,f])}),c};return r.$$set=h=>{"annotation"in h&&e(4,s=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=s.target.selector.geometry),r.$$.dirty&4&&e(3,n=l(i))},[o,a,i,n,s]}class E2 extends jt{constructor(t){super(),zt(this,t,w2,x2,Ut,{annotation:4,user:0,scale:1})}}function T2(r){let t,e,i,n,s,o,a,l,h;return e=new Lm({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=it("g"),Lt(e.$$.fragment),i=it("rect"),w(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),w(i,"stroke",n=r[0].appearance.color),w(i,"fill","transparent"),w(i,"x",s=r[2].x),w(i,"y",o=r[2].y),w(i,"width",a=r[2].w),w(i,"height",l=r[2].h),w(t,"class","a9s-presence-overlay")},m(c,u){ot(c,t,u),Bt(e,t,null),Ct(t,i),h=!0},p(c,[u]){const d={};u&2&&(d.scale=c[1]),u&1&&(d.user=c[0]),u&4&&(d.x=c[2].x),u&4&&(d.y=c[2].y),e.$set(d),(!h||u&1&&n!==(n=c[0].appearance.color))&&w(i,"stroke",n),(!h||u&4&&s!==(s=c[2].x))&&w(i,"x",s),(!h||u&4&&o!==(o=c[2].y))&&w(i,"y",o),(!h||u&4&&a!==(a=c[2].w))&&w(i,"width",a),(!h||u&4&&l!==(l=c[2].h))&&w(i,"height",l)},i(c){h||(q(e.$$.fragment,c),h=!0)},o(c){at(e.$$.fragment,c),h=!1},d(c){c&&st(t),Ot(e)}}}function A2(r,t,e){let i,{annotation:n}=t,{user:s}=t,{scale:o}=t;return r.$$set=a=>{"annotation"in a&&e(3,n=a.annotation),"user"in a&&e(0,s=a.user),"scale"in a&&e(1,o=a.scale)},r.$$.update=()=>{r.$$.dirty&8&&e(2,i=n.target.selector.geometry)},[s,o,i,n]}class S2 extends jt{constructor(t){super(),zt(this,t,A2,T2,Ut,{annotation:3,user:0,scale:1})}}const{Boolean:C2}=ba;function Fm(r,t,e){const i=r.slice();return i[8]=t[e],i}function km(r){let t,e;return t=new Bh({props:{viewer:r[0],$$slots:{default:[R2,({transform:i,scale:n})=>({6:i,7:n}),({transform:i,scale:n})=>(i?64:0)|(n?128:0)]},$$scope:{ctx:r}}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&1&&(s.viewer=i[0]),n&2244&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Um(r){let t,e,i=xe(r[2]),n=[];for(let o=0;o<i.length;o+=1)n[o]=Gm(Fm(r,i,o));const s=o=>at(n[o],1,1,()=>{n[o]=null});return{c(){for(let o=0;o<n.length;o+=1)n[o].c();t=Pe()},m(o,a){for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(o,a);ot(o,t,a),e=!0},p(o,a){if(a&132){i=xe(o[2]);let l;for(l=0;l<i.length;l+=1){const h=Fm(o,i,l);n[l]?(n[l].p(h,a),q(n[l],1)):(n[l]=Gm(h),n[l].c(),q(n[l],1),n[l].m(t.parentNode,t))}for(le(),l=i.length;l<n.length;l+=1)s(l);he()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(n[a]);e=!0}},o(o){n=n.filter(C2);for(let a=0;a<n.length;a+=1)at(n[a]);e=!1},d(o){o&&st(t),Or(n,o)}}}function I2(r){let t,e;return t=new E2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&4&&(s.annotation=i[8].annotation),n&4&&(s.user=i[8].selectedBy),n&128&&(s.scale=i[7]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function P2(r){let t,e;return t=new S2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&4&&(s.annotation=i[8].annotation),n&4&&(s.user=i[8].selectedBy),n&128&&(s.scale=i[7]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function Gm(r){let t,e,i,n;const s=[P2,I2],o=[];function a(l,h){return l[8].annotation.target.selector.type===_t.RECTANGLE?0:l[8].annotation.target.selector.type===_t.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=s[t](r)),{c(){e&&e.c(),i=Pe()},m(l,h){~t&&o[t].m(l,h),ot(l,i,h),n=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(le(),at(o[c],1,1,()=>{o[c]=null}),he()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=s[t](l),e.c()),q(e,1),e.m(i.parentNode,i)):e=null)},i(l){n||(q(e),n=!0)},o(l){at(e),n=!1},d(l){l&&st(i),~t&&o[t].d(l)}}}function R2(r){let t,e,i,n,s=r[2].length>0&&Um(r);return{c(){t=it("svg"),e=it("g"),s&&s.c(),w(e,"transform",i=r[6]),w(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){ot(o,t,a),Ct(t,e),s&&s.m(e,null),n=!0},p(o,a){o[2].length>0?s?(s.p(o,a),a&4&&q(s,1)):(s=Um(o),s.c(),q(s,1),s.m(e,null)):s&&(le(),at(s,1,1,()=>{s=null}),he()),(!n||a&64&&i!==(i=o[6]))&&w(e,"transform",i)},i(o){n||(q(s),n=!0)},o(o){at(s),n=!1},d(o){o&&st(t),s&&s.d()}}}function M2(r){let t=!!r[1],e,i,n=t&&km(r);return{c(){n&&n.c(),e=Pe()},m(s,o){n&&n.m(s,o),ot(s,e,o),i=!0},p(s,[o]){o&2&&(t=!!s[1]),t?n?(n.p(s,o),o&2&&q(n,1)):(n=km(s),n.c(),q(n,1),n.m(e.parentNode,e)):n&&(le(),at(n,1,1,()=>{n=null}),he())},i(s){i||(q(n),i=!0)},o(s){at(n),i=!1},d(s){s&&st(e),n&&n.d(s)}}}function D2(r,t,e){let{store:i}=t,{viewer:n}=t,{provider:s}=t,o=[],a;const l=(h,c)=>{e(2,o=[...o.filter(({selectedBy:u})=>u.presenceKey!==h.presenceKey),...(c||[]).map(u=>({annotation:i.getAnnotation(u),selectedBy:h}))].filter(({annotation:u})=>(u||console.warn("Selection event on unknown annotation"),!!u))),a&&i.unobserve(a),a=u=>{const{deleted:d,updated:f}=u.changes,p=new Set((d||[]).map(y=>y.id)),g=o.filter(({annotation:y})=>!p.has(y.id)).map(y=>{const _=(f||[]).find(v=>v.oldValue.id===y.annotation.id);return _?{selectedBy:y.selectedBy,annotation:_.newValue}:y});e(2,o=g)},i.observe(a,{annotations:o.map(u=>u.annotation.id)})};return H_(()=>{a&&i.unobserve(a)}),r.$$set=h=>{"store"in h&&e(3,i=h.store),"viewer"in h&&e(0,n=h.viewer),"provider"in h&&e(1,s=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&s&&s.on("selectionChange",l)},[n,s,o,i]}class B2 extends jt{constructor(t){super(),zt(this,t,D2,M2,Ut,{store:3,viewer:0,provider:1})}}function O2(r){let t,e,i,n,s;return{c(){t=it("ellipse"),w(t,"cx",e=r[0].cx),w(t,"cy",i=r[0].cy),w(t,"rx",n=r[0].rx),w(t,"ry",s=r[0].ry)},m(o,a){ot(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].cx)&&w(t,"cx",e),a&1&&i!==(i=o[0].cy)&&w(t,"cy",i),a&1&&n!==(n=o[0].rx)&&w(t,"rx",n),a&1&&s!==(s=o[0].ry)&&w(t,"ry",s)},i:Ft,o:Ft,d(o){o&&st(t)}}}function L2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class N2 extends jt{constructor(t){super(),zt(this,t,L2,O2,Ut,{annotation:1})}}function F2(r){let t,e,i,n,s;return{c(){t=it("line"),w(t,"x1",e=r[0].points[0][0]),w(t,"y1",i=r[0].points[0][1]),w(t,"x2",n=r[0].points[1][0]),w(t,"y2",s=r[0].points[1][1])},m(o,a){ot(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].points[0][0])&&w(t,"x1",e),a&1&&i!==(i=o[0].points[0][1])&&w(t,"y1",i),a&1&&n!==(n=o[0].points[1][0])&&w(t,"x2",n),a&1&&s!==(s=o[0].points[1][1])&&w(t,"y2",s)},i:Ft,o:Ft,d(o){o&&st(t)}}}function k2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class U2 extends jt{constructor(t){super(),zt(this,t,k2,F2,Ut,{annotation:1})}}function $m(r,t,e){const i=r.slice();return i[2]=t[e],i}function Hm(r){let t,e;return{c(){t=it("path"),e=it("path"),w(t,"fill-rule","evenodd"),w(t,"d",He(r[2])),w(e,"class","a9s-inner"),w(e,"fill-rule","evenodd"),w(e,"d",He(r[2]))},m(i,n){ot(i,t,n),ot(i,e,n)},p:Ft,d(i){i&&(st(t),st(e))}}}function G2(r){let t,e=xe(r[0]),i=[];for(let n=0;n<e.length;n+=1)i[n]=Hm($m(r,e,n));return{c(){t=it("g");for(let n=0;n<i.length;n+=1)i[n].c()},m(n,s){ot(n,t,s);for(let o=0;o<i.length;o+=1)i[o]&&i[o].m(t,null)},p(n,[s]){if(s&1){e=xe(n[0]);let o;for(o=0;o<e.length;o+=1){const a=$m(n,e,o);i[o]?i[o].p(a,s):(i[o]=Hm(a),i[o].c(),i[o].m(t,null))}for(;o<i.length;o+=1)i[o].d(1);i.length=e.length}},i:Ft,o:Ft,d(n){n&&st(t),Or(i,n)}}}function $2(r,t,e){let{annotation:i}=t;const{polygons:n}=i.target.selector.geometry;return r.$$set=s=>{"annotation"in s&&e(1,i=s.annotation)},[n,i]}class H2 extends jt{constructor(t){super(),zt(this,t,$2,G2,Ut,{annotation:1})}}function X2(r){let t,e;return{c(){t=it("polygon"),w(t,"points",e=r[0].points.map(Xm).join(" "))},m(i,n){ot(i,t,n)},p(i,[n]){n&1&&e!==(e=i[0].points.map(Xm).join(" "))&&w(t,"points",e)},i:Ft,o:Ft,d(i){i&&st(t)}}}const Xm=r=>r.join(",");function V2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class z2 extends jt{constructor(t){super(),zt(this,t,V2,X2,Ut,{annotation:1})}}function j2(r){let t;return{c(){t=it("path"),w(t,"d",r[0])},m(e,i){ot(e,t,i)},p(e,[i]){i&1&&w(t,"d",e[0])},i:Ft,o:Ft,d(e){e&&st(t)}}}function W2(r,t,e){let i,n,{annotation:s}=t;return r.$$set=o=>{"annotation"in o&&e(1,s=o.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(2,i=s.target.selector.geometry),r.$$.dirty&4&&e(0,n=Jo(i))},[n,s,i]}class Y2 extends jt{constructor(t){super(),zt(this,t,W2,j2,Ut,{annotation:1})}}function q2(r){let t,e,i,n,s;return{c(){t=it("rect"),w(t,"x",e=r[0].x),w(t,"y",i=r[0].y),w(t,"width",n=r[0].w),w(t,"height",s=r[0].h)},m(o,a){ot(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].x)&&w(t,"x",e),a&1&&i!==(i=o[0].y)&&w(t,"y",i),a&1&&n!==(n=o[0].w)&&w(t,"width",n),a&1&&s!==(s=o[0].h)&&w(t,"height",s)},i:Ft,o:Ft,d(o){o&&st(t)}}}function K2(r,t,e){let i,{annotation:n}=t;return r.$$set=s=>{"annotation"in s&&e(1,n=s.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=n.target.selector.geometry)},[i,n]}class Z2 extends jt{constructor(t){super(),zt(this,t,K2,q2,Ut,{annotation:1})}}const{Boolean:Q2}=ba;function Vm(r,t,e){const i=r.slice();return i[10]=t[e],i}function zm(r){let t,e;return t=new Bh({props:{viewer:r[0],$$slots:{default:[sC,({transform:i})=>({9:i}),({transform:i})=>i?512:0]},$$scope:{ctx:r}}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&1&&(s.viewer=i[0]),n&8710&&(s.$$scope={dirty:n,ctx:i}),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function J2(r){let t,e;return t=new U2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function tC(r){let t,e;return t=new N2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function eC(r){let t,e;return t=new Y2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function rC(r){let t,e;return t=new H2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function iC(r){let t,e;return t=new z2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function nC(r){let t,e;return t=new Z2({props:{annotation:r[10]}}),{c(){Lt(t.$$.fragment)},m(i,n){Bt(t,i,n),e=!0},p(i,n){const s={};n&2&&(s.annotation=i[10]),t.$set(s)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){at(t.$$.fragment,i),e=!1},d(i){Ot(t,i)}}}function jm(r){let t,e,i,n;const s=[nC,iC,rC,eC,tC,J2],o=[];function a(l,h){return l[10].target.selector.type===_t.RECTANGLE?0:l[10].target.selector.type===_t.POLYGON?1:l[10].target.selector.type===_t.MULTIPOLYGON?2:l[10].target.selector.type===_t.POLYLINE?3:l[10].target.selector.type===_t.ELLIPSE?4:l[10].target.selector.type===_t.LINE?5:-1}return~(t=a(r))&&(e=o[t]=s[t](r)),{c(){e&&e.c(),i=Pe()},m(l,h){~t&&o[t].m(l,h),ot(l,i,h),n=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(le(),at(o[c],1,1,()=>{o[c]=null}),he()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=s[t](l),e.c()),q(e,1),e.m(i.parentNode,i)):e=null)},i(l){n||(q(e),n=!0)},o(l){at(e),n=!1},d(l){l&&st(i),~t&&o[t].d(l)}}}function sC(r){let t,e,i,n,s,o,a,l,h,c,u,d,f,p,g=xe(r[1].filter(r[6])),y=[];for(let v=0;v<g.length;v+=1)y[v]=jm(Vm(r,g,v));const _=v=>at(y[v],1,1,()=>{y[v]=null});return{c(){var v,m,b,S;t=it("svg"),e=it("g"),i=it("rect"),l=it("rect");for(let R=0;R<y.length;R+=1)y[R].c();w(i,"class","a9s-union-bg svelte-jwrce3"),w(i,"x",n=(v=r[2])==null?void 0:v.minX),w(i,"y",s=(m=r[2])==null?void 0:m.minY),w(i,"width",o=r[2]?r[2].maxX-r[2].minX:0),w(i,"height",a=r[2]?r[2].maxY-r[2].minY:0),w(l,"class","a9s-union-fg svelte-jwrce3"),w(l,"x",h=(b=r[2])==null?void 0:b.minX),w(l,"y",c=(S=r[2])==null?void 0:S.minY),w(l,"width",u=r[2]?r[2].maxX-r[2].minX:0),w(l,"height",d=r[2]?r[2].maxY-r[2].minY:0),w(e,"transform",f=r[9]),w(t,"class","a9s-osd-selectionlayer svelte-jwrce3")},m(v,m){ot(v,t,m),Ct(t,e),Ct(e,i),Ct(e,l);for(let b=0;b<y.length;b+=1)y[b]&&y[b].m(e,null);p=!0},p(v,m){var b,S,R,C;if((!p||m&4&&n!==(n=(b=v[2])==null?void 0:b.minX))&&w(i,"x",n),(!p||m&4&&s!==(s=(S=v[2])==null?void 0:S.minY))&&w(i,"y",s),(!p||m&4&&o!==(o=v[2]?v[2].maxX-v[2].minX:0))&&w(i,"width",o),(!p||m&4&&a!==(a=v[2]?v[2].maxY-v[2].minY:0))&&w(i,"height",a),(!p||m&4&&h!==(h=(R=v[2])==null?void 0:R.minX))&&w(l,"x",h),(!p||m&4&&c!==(c=(C=v[2])==null?void 0:C.minY))&&w(l,"y",c),(!p||m&4&&u!==(u=v[2]?v[2].maxX-v[2].minX:0))&&w(l,"width",u),(!p||m&4&&d!==(d=v[2]?v[2].maxY-v[2].minY:0))&&w(l,"height",d),m&2){g=xe(v[1].filter(v[6]));let I;for(I=0;I<g.length;I+=1){const M=Vm(v,g,I);y[I]?(y[I].p(M,m),q(y[I],1)):(y[I]=jm(M),y[I].c(),q(y[I],1),y[I].m(e,null))}for(le(),I=g.length;I<y.length;I+=1)_(I);he()}(!p||m&512&&f!==(f=v[9]))&&w(e,"transform",f)},i(v){if(!p){for(let m=0;m<g.length;m+=1)q(y[m]);p=!0}},o(v){y=y.filter(Q2);for(let m=0;m<y.length;m+=1)at(y[m]);p=!1},d(v){v&&st(t),Or(y,v)}}}function oC(r){let t=!!r[2],e,i,n=t&&zm(r);return{c(){n&&n.c(),e=Pe()},m(s,o){n&&n.m(s,o),ot(s,e,o),i=!0},p(s,[o]){o&4&&(t=!!s[2]),t?n?(n.p(s,o),o&4&&q(n,1)):(n=zm(s),n.c(),q(n,1),n.m(e.parentNode,e)):n&&(le(),at(n,1,1,()=>{n=null}),he())},i(s){i||(q(n),i=!0)},o(s){at(n),i=!1},d(s){s&&st(e),n&&n.d(s)}}}function aC(r,t,e){let i,n,s,{state:o}=t,{viewer:a}=t;const{store:l}=o,{selection:h}=o;An(r,h,d=>e(5,s=d));const c=d=>{let f=-1/0,p=-1/0,g=1/0,y=1/0;for(let _ of d.filter(v=>Le(v))){const{bounds:v}=_.target.selector.geometry;v.maxX>f&&(f=v.maxX),v.maxY>p&&(p=v.maxY),v.minX<g&&(g=v.minX),v.minY<y&&(y=v.minY)}return a.forceRedraw(),{maxX:f,maxY:p,minX:g,minY:y}},u=d=>Le(d);return r.$$set=d=>{"state"in d&&e(4,o=d.state),"viewer"in d&&e(0,a=d.viewer)},r.$$.update=()=>{r.$$.dirty&32&&e(1,i=s.selected.map(({id:d})=>l.getAnnotation(d))),r.$$.dirty&2&&e(2,n=i.length>1?c(i):void 0)},[a,i,n,h,o,s,u]}class lC extends jt{constructor(t){super(),zt(this,t,aC,oC,Ut,{state:4,viewer:0})}}const Wm=(r,t)=>{t==="auto"?r.addHandler("open",e=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",s=>{const{fullyLoaded:o}=s;if(o){const a=r.canvas.querySelector("canvas"),l=ru(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},Ym=(r,t,e)=>(i,n={})=>{const s=typeof i=="string"?i:i.id,o=t.getAnnotation(s);if(!o||!Le(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=n;let[h,c,u,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,c=c/a.width,u=u/a.height,d=d/a.width;const{minX:f,minY:p,maxX:g,maxY:y}=o.target.selector.geometry.bounds,_=g-f,v=y-p,m=f-d*_,b=p-h*v,S=_+(c+d)*_,R=v+(h+u)*v,C=r.viewport.imageToViewportRectangle(m,b,S,R);r.viewport[e](C,n.immediately)},hC=(r,t)=>Ym(r,t,"fitBounds"),cC=(r,t)=>Ym(r,t,"fitBoundsWithConstraints"),uC=(r,t={})=>{const e=nu(t,{drawingEnabled:!1,drawingMode:Ne?"drag":"click",userSelectAction:$o.EDIT,theme:"light"}),i=eu(e),{hover:n,selection:s,store:o}=i,a=pg(o,e.initialHistory),l=mg(i,a,e.adapter,e.autoSave);let h=Eg(),c=e.drawingEnabled,u=e.drawingMode,d=e.modalSelect;const f=ou(a,r.element),p=new o2({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),g=new B2({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),y=new _2({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!c,filter:void 0,multiSelect:e.multiSelect,preferredDrawingMode:u,state:i,style:e.style,user:h,viewer:r}}),_=new lC({target:r.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:r}});p.$on("click",B=>{const{originalEvent:k,annotation:V}=B.detail,z=K=>Im(K.id,k,s,e.multiSelect);d?s.isEmpty()&&V&&s.userSelect(z(V),k):V&&!(u==="click"&&c)?s.userSelect(z(V),k):s.isEmpty()||(e.multiSelect?k.metaKey||k.shiftKey||k.ctrlKey||s.userSelect([],k):s.userSelect([],k))}),r.element.addEventListener("pointerdown",B=>{if(n.current){const k=o.getAnnotation(n.current);l.emit("clickAnnotation",k,B)}}),Wm(r,e.theme);const v=yg(i,a,e.adapter),m=()=>y.cancelDrawing(),b=()=>{p.$destroy(),g.$destroy(),y.$destroy(),_.$destroy(),f.destroy(),a.destroy()},S=hC(r,o),R=cC(r,o),C=()=>y.getDrawingTool(),I=()=>h,M=()=>y.isDrawingEnabled(),F=(B,k,V)=>Gc(B,k,V),U=(B,k)=>Nc(B,k),P=B=>{if(!_s(B))throw`No drawing tool named ${B}`;y.$set({toolName:B})},T=B=>{c=B,y.$set({drawingEnabled:B})},E=B=>{p.$set({filter:B}),y.$set({filter:B})},A=B=>d=B,L=B=>{p.$set({style:B}),y.$set({style:B})},D=B=>g.$set({provider:B}),N=B=>Wm(r,B),$=B=>{h=B,y.$set({user:B})},O=B=>p.$set({visible:B});return{...v,cancelDrawing:m,destroy:b,fitBounds:S,fitBoundsWithConstraints:R,getDrawingTool:C,getUser:I,isDrawingEnabled:M,listDrawingTools:ys,on:l.on,off:l.off,registerDrawingTool:F,registerShapeEditor:U,setDrawingEnabled:T,setDrawingTool:P,setFilter:E,setModalSelect:A,setPresenceProvider:D,setStyle:L,setTheme:N,setUser:$,setVisible:O,state:i,viewer:r}};qt.ShapeType=_t,qt.UserSelectAction=$o,qt.W3CImageFormat=Zy,qt.chainStyles=$y,qt.computeStyle=Gy,qt.createBody=sg,qt.createImageAnnotator=N_,qt.createOSDAnnotator=uC,qt.defaultColorProvider=Ag,Object.defineProperty(qt,Symbol.toStringTag,{value:"Module"})});
1148
1148
  //# sourceMappingURL=annotorious-openseadragon.js.map